2006-05-02 09:31:56 +08:00
|
|
|
from django.contrib.sites.models import Site
|
2015-01-28 20:35:27 +08:00
|
|
|
from django.db import models
|
2012-08-12 18:32:08 +08:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2015-01-28 20:35:27 +08:00
|
|
|
from django.utils.translation import ugettext_lazy as _
|
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)
|