Wyodrebnienie zdjec do innej tabeli
This commit is contained in:
parent
2e0103781a
commit
4969d0a6cd
Binary file not shown.
Binary file not shown.
@ -1,6 +1,8 @@
|
||||
from django.contrib import admin
|
||||
from .models import Car
|
||||
from .models import Zdjecie
|
||||
|
||||
# Register your models here.
|
||||
|
||||
admin.site.register(Car)
|
||||
admin.site.register(Zdjecie)
|
||||
|
||||
@ -2,15 +2,20 @@ from email.policy import default
|
||||
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
class Car(models.Model):
|
||||
marka = models.CharField(max_length=39)
|
||||
nr_rej = models.CharField(max_length=29)
|
||||
vin = models.CharField(max_length=29)
|
||||
data_przegladu = models.DateField()
|
||||
informacje = models.TextField(default="")
|
||||
zdjiecia = models.ImageField(upload_to='zdjiecia', null=True, blank=True)
|
||||
informacje = models.TextField(default="", blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.nr_rej
|
||||
|
||||
|
||||
class Zdjecie(models.Model):
|
||||
car = models.ForeignKey(Car, on_delete=models.CASCADE, related_name="zdjecia")
|
||||
obraz = models.ImageField(upload_to='zdjecia/', null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"Zdjęcie dla: {self.car.nr_rej}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user