from django.db import models
from .models import Shipment
from django.utils import timezone
# Create your models here.
# A specie can belong to many shipments
class Specie(models.Model):
shipment = models.ManyToManyField(Shipment)
name = models.CharField(max_length=120, null=True)
image = models.ImageField(upload_to="species", default="no_picture.png")
created = models.DateTimeField(default=timezone.now)
def __str__(self):
return self.name
===================
from django.db import models
from .models import Supplier
# Create your models here.
# A shipment can have many species
class Shipment(models.Model):
supplier = models.ForeignKey(Supplier, on_delete=models.CASCADE)
slabel = models.CharField(max_length=10)
received = models.PositiveIntegerField(default=0)
bad = models.PositiveIntegerField(default=0)
non = models.PositiveIntegerField(default=0)
doa = models.PositiveIntegerField(default=0)
para = models.PositiveIntegerField(default=0)
released = models.PositiveIntegerField(default=0)
entered = models.BooleanField(default=False)
created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return f"{self.slabel}"
======================
from django.db import models
# Create your models here.
# Supplier can have many shipments
class Supplier(models.Model):
name = models.CharField(max_length=120, null=True)
phone = models.CharField(max_length=15, null=True)
email = models.CharField(max_length=120, null=True)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
def __str__(self):
return self.name
the error I can't resolve is:
ImportError: cannot import name 'Supplier' from partially initialized module 'shipment.models' (most likely due to a circular import) (/Users/frankd/django_projects/tryit/src/shipment/models.py)
thanks again.
On Thursday, June 3, 2021 at 10:47:07 PM UTC-5 Mike Dewhirst wrote:
On 4/06/2021 1:39 pm, Mike Dewhirst wrote:
> On 4/06/2021 11:34 am, frank dilorenzo wrote:
>> I have the following conditions.
>> A supplier can have many shipments.
>> A shipment can have many species.
>> A shipment can have only one supplier.
>> Species can belong to many shipments.
>
> supplier 1:n shipment
> shipment n:m species
shipment has FK to supplier
species has m2m field with shipment
The latter implements a connecting table between species and shipment
which can be expanded to carry additional information if you need to
include anything related to a particular shipment + species
In all this I refer to the word species in its singular sense. E.g., we
are members of the human species.
>
>>
>> No matter how I try I can't seem to configure the models correctly.
>> I was hoping someone could help me on this.
>>
>> Thank you.
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users...@googlegroups.com
>> <mailto:django-users...@googlegroups.com>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/5ea61c33-9f24-470d-8191-177c2e73adf1n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/5ea61c33-9f24-470d-8191-177c2e73adf1n%40googlegroups.com?utm_medium=email&utm_source=footer>.
>>
>
>
--
Signed email is an absolute defence against phishing. This email has
been signed with my private key. If you import my public key you can
automatically decrypt my signature and be sure it came from me. Just
ask and I'll send it to you. Your email software can handle signing.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/ae4089fd-3499-41e4-8409-1b3a7f83d96dn%40googlegroups.com.
No comments:
Post a Comment