This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

Django-model-url helps you to show correctly links to all objects even if page`s url was changed.

Usage case

For example, you have news page on your web site. You add a lot of links to the news page from other pages. At some time you had to change url for the news page. This action lead to the problem: all old links are broken now. Of course, you can add redirect from old address to new. This can application solve problem more elegantly.

How it works?

Before you save content with hyperlink to your database django-model-url tries to replace it with something like this {@ myapp.models.MyModel id @}. Module will search for controller (view) that presents specified url. If controller will be found module calls it and looks for object in context that passed to template.

When ever such “macro-url” will appear in response it will be replaced with actual url.

Installation:

In settings.py:

  1. Add 'modelurl' to your INSTALLED_APPS.

  2. Add 'modelurl.middleware.ModelUrlMiddleware' to the end of MIDDLEWARE_CLASSES.

  3. Configure the list of available models to be used by django-model-url

    MODELURL_MODELS = [
        {
            'model': 'myapp.models.MyModel',
        },
        ...
    ]
    

4. Configure the list of views that return objects of specified models. You must also specify the name of your context variable that represents your object

MODELURL_VIEWS = [
    {
        'view': 'myapp.views.get',
        'context': 'object',
    },
]

You can disable view if you don`t want to work with it:

MODELURL_VIEWS = [
    {
        'view': 'django.contrib.admin.site.root',
        'disable': True,
    },
]

Usage:

In your models:

  1. You can check single url by hands before saving

    from modelurl.utils import ReplaceByView
    
    class MyModel(models.Model):
        url = models.CharField(max_length=200)
        def save(self, *args, **kwargs):
            self.url = ReplaceByView().url(self.url)
            super(MyModel, self).save(*args, **kwargs)
    
  2. You can check html before saving

    from modelurl.utils import ReplaceByView
    
    class MyModel(models.Model):
        html = models.TextField()
        def save(self, *args, **kwargs):
            self.html = ReplaceByView().html(self.html)
            super(MyModel, self).save(*args, **kwargs)
    
  3. You can use django-model-url together with django-trusted-html to make your html correct, pretty and safe.

Classifiers:

Utilities

Release History

Release History

0.1.0

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
redsolutioncms.django-model-url-0.1.0.tar.gz (31.8 kB) Copy SHA256 Checksum SHA256 Source Oct 21, 2010

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting