new model and admin view
This commit is contained in:
parent
7eb7941b06
commit
103d4a0358
2 changed files with 34 additions and 2 deletions
13
fbf/admin.py
13
fbf/admin.py
|
@ -1,3 +1,14 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
from .models import Bird, FallenBird
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(FallenBird)
|
||||||
|
class ContractAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ["bird", "date_found", "place", "created", "updated", "user"]
|
||||||
|
list_filter = ("bird", "created", "user")
|
||||||
|
|
||||||
|
|
||||||
|
@admin.register(Bird)
|
||||||
|
class ContractAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ["name"]
|
||||||
|
|
|
@ -1,3 +1,24 @@
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
from django.conf import settings
|
||||||
|
from uuid import uuid4
|
||||||
|
|
||||||
# Create your models here.
|
|
||||||
|
class FallenBird(models.Model):
|
||||||
|
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
|
||||||
|
bird = models.ForeignKey("Bird", on_delete=models.CASCADE)
|
||||||
|
date_found = models.DateTimeField()
|
||||||
|
place = models.CharField(max_length=256)
|
||||||
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
|
updated = models.DateTimeField(auto_now=True)
|
||||||
|
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.place
|
||||||
|
|
||||||
|
|
||||||
|
class Bird(models.Model):
|
||||||
|
id = models.UUIDField(primary_key=True, default=uuid4, editable=False)
|
||||||
|
name = models.CharField(max_length=256)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue