2006-05-02 09:31:56 +08:00
|
|
|
from django.db import models
|
|
|
|
from django.contrib.sites.models import Site
|
Merged Unicode branch into trunk (r4952:5608). This should be fully
backwards compatible for all practical purposes.
Fixed #2391, #2489, #2996, #3322, #3344, #3370, #3406, #3432, #3454, #3492, #3582, #3690, #3878, #3891, #3937, #4039, #4141, #4227, #4286, #4291, #4300, #4452, #4702
git-svn-id: http://code.djangoproject.com/svn/django/trunk@5609 bcc190cf-cafb-0310-a4f2-bffc1f526a37
2007-07-04 20:11:04 +08:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2005-11-11 12:45:05 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2012-08-12 18:32:08 +08:00
|
|
|
@python_2_unicode_compatible
|
2006-05-02 09:31:56 +08:00
|
|
|
class Redirect(models.Model):
|
2008-07-19 07:54:34 +08:00
|
|
|
site = models.ForeignKey(Site)
|
2007-08-05 13:14:46 +08:00
|
|
|
old_path = models.CharField(_('redirect from'), max_length=200, db_index=True,
|
2005-11-11 12:45:05 +08:00
|
|
|
help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'."))
|
2007-08-05 13:14:46 +08:00
|
|
|
new_path = models.CharField(_('redirect to'), max_length=200, blank=True,
|
2005-11-11 12:45:05 +08:00
|
|
|
help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'."))
|
2006-06-13 00:20:05 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
class Meta:
|
2005-11-11 12:45:05 +08:00
|
|
|
verbose_name = _('redirect')
|
|
|
|
verbose_name_plural = _('redirects')
|
2006-05-02 09:31:56 +08:00
|
|
|
db_table = 'django_redirect'
|
2013-10-23 18:09:29 +08:00
|
|
|
unique_together = (('site', 'old_path'),)
|
2005-11-11 12:45:05 +08:00
|
|
|
ordering = ('old_path',)
|
2012-08-12 18:32:08 +08:00
|
|
|
|
|
|
|
def __str__(self):
|
2008-07-19 07:54:34 +08:00
|
|
|
return "%s ---> %s" % (self.old_path, self.new_path)
|