link serial number field from the list given in django

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

To do the entry the way you describe, you would add a textarea field on the form. Once you’ve got the input, then you need to parse and validate the data entered.
If the intent of this is to link it through the many-to-many reference in AllSerial, then you’ll need to iterate over the entries in the entered data and add the references.

tnx for your answer
but for simplicity let’s say in product class I have this field :
serial = models.IntegerField(default=0)
and in the admin area in the field i entered (2312312312323 <= this is one serial number)
now my problem is here :
I don’t know how to view that serial in AllSerial class?
I want to view each serial that entered in the product class.
and it must add that serial in the product class, automatically for that specific product

These are rather broad questions you’re asking, and, I’m not entirely clear on exactly what you’re trying to achieve.
I can say that the docs are all rather comprehensive on these issues. For some specific starting points:

  • The Django tutorial and the Django Girls tutorial: They show in practice how to reference related fields through foreign key relationships. If you haven’t worked through either one of them, they’re worth your time. If you have, reviewing them may refresh your memory.
  • The Many-to-many and Many-to-one documentation pages.
    In particular, the examples in those last two references demonstrate how you can add and remove references between models using either of the two relationship types.

There’s another factor here that I just realized as well - it’s not clear to me at this point whether you’re building your own views and forms for this or if you’re trying to do this through the admin facility. If the latter, then you need to review the admin docs for customizing the ModelAdmin form used for your class.