|
Revision 2111, 1.0 kB
(checked in by adrian, 3 years ago)
|
magic-removal: Fixed #1259 -- This is VERY backwards-incompatible! Normalized all table names to be singular. Added 'django_' prefix to core tables that didn't have it. Thanks, Tom Tobin.
|
| Line | |
|---|
| 1 |
from django.db import models |
|---|
| 2 |
from django.contrib.sites.models import Site |
|---|
| 3 |
from django.utils.translation import gettext_lazy as _ |
|---|
| 4 |
|
|---|
| 5 |
class Redirect(models.Model): |
|---|
| 6 |
site = models.ForeignKey(Site, radio_admin=models.VERTICAL) |
|---|
| 7 |
old_path = models.CharField(_('redirect from'), maxlength=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'), maxlength=200, blank=True, |
|---|
| 10 |
help_text=_("This can be either an absolute path (as above) or a full URL starting with 'http://'.")) |
|---|
| 11 |
class Meta: |
|---|
| 12 |
verbose_name = _('redirect') |
|---|
| 13 |
verbose_name_plural = _('redirects') |
|---|
| 14 |
db_table = 'django_redirect' |
|---|
| 15 |
unique_together=(('site', 'old_path'),) |
|---|
| 16 |
ordering = ('old_path',) |
|---|
| 17 |
class Admin: |
|---|
| 18 |
list_filter = ('site',) |
|---|
| 19 |
search_fields = ('old_path', 'new_path') |
|---|
| 20 |
|
|---|
| 21 |
def __repr__(self): |
|---|
| 22 |
return "%s ---> %s" % (self.old_path, self.new_path) |
|---|