Changes between Version 7 and Version 8 of ReplacingGetAbsoluteUrl


Ignore:
Timestamp:
Sep 10, 2008, 6:47:45 PM (16 years ago)
Author:
simon
Comment:

Added example usage of the prototype mixin

Legend:

Unmodified
Added
Removed
Modified
  • ReplacingGetAbsoluteUrl

    v7 v8  
    127127    get_url_path.dont_recurse = True
    128128}}}
     129And you use it like this:
     130{{{
     131#!python
     132from django.db import models
     133from django_urls.base import UrlMixin
     134
     135class ArticleWithPathDefined(models.Model, UrlMixin):
     136    slug = models.SlugField()
     137   
     138    def get_url_path(self):
     139        return '/articles/%s/' % self.slug
     140
     141class AssetWithUrlDefined(models.Model, UrlMixin):
     142    domain = models.CharField(max_length=30)
     143    filename = models.CharField(max_length = 30)
     144   
     145    def get_url(self):
     146        return 'http://%s/assets/%s' % (self.domain, self.filename)
     147}}}
Back to Top