-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added url admin page * added new fields * updated admin ui
- Loading branch information
1 parent
c1c0508
commit c089f33
Showing
4 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,15 @@ | ||
from django.contrib import admin | ||
|
||
from shortener.models import URL | ||
|
||
|
||
# Register your models here. | ||
# Register the model with the admin site | ||
@admin.register(URL) | ||
class ShortenedURLAdmin(admin.ModelAdmin): | ||
# Display the new fields in the admin list view | ||
list_display = ('original_url', 'short_code', 'created_at', 'clicks', 'last_accessed') | ||
search_fields = ('original_url', 'short_code') | ||
list_filter = ('created_at', 'last_accessed') | ||
|
||
readonly_fields = ('clicks', 'last_accessed') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Generated by Django 5.1.3 on 2024-11-22 15:26 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('shortener', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='url', | ||
name='clicks', | ||
field=models.PositiveIntegerField(default=0), | ||
), | ||
migrations.AddField( | ||
model_name='url', | ||
name='last_accessed', | ||
field=models.DateTimeField(blank=True, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters