use_for_related_fields = True
def create_cabinet(self, name, number_of_shelfs):
cabinet = self.create(name=name, number_of_shelfs=number_of_shelfs)
created_shelfs = 0
while created_shelfs < number_of_shelfs:
cabinet.shelfs.create()
created_shelfs += 1
return place
name = models.CharField(max_length=50, unique=True)
number_of_shelfs = models.IntegerField
class Shelfs(models.Model):shelfs = ShelfManager()
and i want shelf to hold either model Box, Filter or Barrelplace = models.ForeignKey(Cabinet, on_delete=models.CASCADE, null=True, blank=True, related_name='shelfs')...
--
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.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPLZMbPTNJ8OavQiaUpdELVH4wo9V9p94zkFWDwZS4sXdZtS8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.