Skip to content

Commit

Permalink
Added created_at and updated_at fields. #4
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiocaccamo committed Jul 6, 2022
1 parent 1300f90 commit 22727d2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions redirects/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def test_display(self, obj):
"counter",
"status_code",
"test_display",
"created_at",
"updated_at",
)
list_display_links = ("redirect_display",)
list_editable = (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("redirects", "0002_add_priority"),
]

operations = [
migrations.AddField(
model_name="redirect",
name="created_at",
field=models.DateTimeField(
auto_now_add=True, null=True, verbose_name="Created at"
),
),
migrations.AddField(
model_name="redirect",
name="updated_at",
field=models.DateTimeField(
auto_now=True, null=True, verbose_name="Updated at"
),
),
]
14 changes: 14 additions & 0 deletions redirects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ class Redirect(models.Model):
verbose_name=_("Status code"),
)

created_at = models.DateTimeField(
auto_now_add=True,
editable=False,
null=True,
verbose_name=_("Created at"),
)

updated_at = models.DateTimeField(
auto_now=True,
editable=False,
null=True,
verbose_name=_("Updated at"),
)

def _get_response_path_with_match_exact(self, path):
if self.old_path.lower() == path.lower():
return self.new_path
Expand Down

0 comments on commit 22727d2

Please sign in to comment.