I wrote a Django app that has 3 classes in model.py:
from django.db import models
from multiselectfield import MultiSelectField
from django.core.files.storage import FileSystemStorage
fs = FileSystemStorage(location='~/Desktop/django_project/register/static/register/textfiles')
class Product(models.Model):
productId = models.AutoField(primary_key=True)
product_name = models.CharField(max_length=20)
created_at = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
price = models.CharField(max_length=30)
serial = models.FileField(upload_to='uploads/%Y/%m/%d/',storage=fs,default="",blank=True,null=True)
def __str__(self):
return self.product_name
class AllSerial(models.Model):
serial_id = models.AutoField(primary_key=True)
product_name_serial = models.ManyToManyField(Product)
all_serial = models.IntegerField(default=0)
used_serial = models.IntegerField(default=0)
def __str__(self):
return self.product_name_serial
class Client(models.Model):
clientId = models.AutoField(primary_key=True)
name = models.CharField(max_length=50)
city = models.CharField(max_length=50)
phone_number = models.CharField(max_length=20)
product_name = models.ManyToManyField(Product)
DOWNLOADABLE = 'DL'
SHIPINGPOST = 'POST'
shippmentWayChoices = [
(DOWNLOADABLE, 'DOWNLOADI'),
(SHIPINGPOST, 'POSTI'),
]
shippmentWay = MultiSelectField(
choices=shippmentWayChoices,
default=DOWNLOADABLE,
)
serialNumber = models.TextField()
trackingItemPost = models.TextField()
description = models.TextField()
shoppingTime = models.DateTimeField(auto_now_add=True)
updated_at = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
but now in the product section, from the serial field, I want to add serial numbers (for example 1000000 serial). something like this:
image four
after that
whenever I go to all_serials and then click on the product_name , I want to see all serials that previously added in the product section. like this:
image five
please help me
even a single clue to how can I do this