python - Adding a field to a ManyToManyField -


so im working on django app. in admin can create shop packs people order.

so i've created model different items pack can include. after little research, found out needed manytomanyfield this.

so created model manytomanyfield connects shop items model. aka itemsincluded = models.manytomanyfield(shopitems) works can items , that.

my problem can add items want how many pcs u in each item. should integerfield.

i have tried option though in manytomanyfield. didn't work.

and im stuck here because can't find things how it. ideas?

just reference here model , admin model (all imports correct done)

models.py

class shoppakker(models.model):     navn = models.charfield(max_length=255, null=false)     description = models.textfield(null=false)     pris = models.integerfield(null=false)     item_include = models.manytomanyfield(kioskitem)     def __str__(self):         return self.navn 

admin.py

admin.site.register(shoppakker) 

though method

item_include = models.manytomanyfield(kioskitem, through='pakkeitem')  class pakkeitem(models.model):     vare = models.foreignkey(kioskitem)     antal = models.integerfield(null=false)     def __str__(self):         return self.navn 


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -