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
|
2017-01-27 03:58:33 +08:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2005-11-11 12:45:05 +08:00
|
|
|
|
2013-11-03 04:12:09 +08:00
|
|
|
|
2006-05-02 09:31:56 +08:00
|
|
|
class Redirect(models.Model):
|
2015-07-22 22:43:21 +08:00
|
|
|
site = models.ForeignKey(Site, models.CASCADE, verbose_name=_('site'))
|
2016-03-29 06:33:29 +08:00
|
|
|
old_path = models.CharField(
|
|
|
|
_('redirect from'),
|
|
|
|
max_length=200,
|
|
|
|
db_index=True,
|
|
|
|
help_text=_("This should be an absolute path, excluding the domain name. Example: '/events/search/'."),
|
|
|
|
)
|
|
|
|
new_path = models.CharField(
|
|
|
|
_('redirect to'),
|
|
|
|
max_length=200,
|
|
|
|
blank=True,
|
|
|
|
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)
|