Django

Code

root/django/branches/newforms-admin/django/contrib/redirects/models.py

Revision 7669, 1.3 kB (checked in by brosner, 6 months ago)

newforms-admin: Merged from trunk up to [7668].

  • Property svn:eol-style set to native
Line 
1 from django.db import models
2 from django.contrib.sites.models import Site
3 from django.utils.translation import ugettext_lazy as _
4
5 class Redirect(models.Model):
6     site = models.ForeignKey(Site)
7     old_path = models.CharField(_('redirect from'), max_length=200, db_index=True,
8         help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'."))
9     new_path = models.CharField(_('redirect to'), max_length=200, blank=True,
10         help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'."))
11
12     class Meta:
13         verbose_name = _('redirect')
14         verbose_name_plural = _('redirects')
15         db_table = 'django_redirect'
16         unique_together=(('site', 'old_path'),)
17         ordering = ('old_path',)
18    
19     def __unicode__(self):
20         return "%s ---> %s" % (self.old_path, self.new_path)
21
22 # Register the admin options for these models.
23 # TODO: Maybe this should live in a separate module admin.py, but how would we
24 # ensure that module was loaded?
25
26 from django.contrib import admin
27
28 class RedirectAdmin(admin.ModelAdmin):
29     list_display = ('old_path', 'new_path')
30     list_filter = ('site',)
31     search_fields = ('old_path', 'new_path')
32     radio_fields = {'site': admin.VERTICAL}
33
34 admin.site.register(Redirect, RedirectAdmin)
Note: See TracBrowser for help on using the browser.