Skip to content
Advertisement

Tag: django-models

Trying to add a field to Django many-to-many relation

Right now I’m working on a Django project responsible for the warehouse management system. I got products, customers, warehouse branches, product types, orders, etc… products can be [Milk 1L bottle, cheese 500g pack, ….] The problem I have been facing is that I’m trying to make a many-to-many relationship between orders and products so I can track the products sold

Direct assignment to the forward side of a many-to-many set is prohibited. Use coolbox_id.set() instead. helpme

I am getting this error when i use many to many field help me plsssssss views.py I’ve been stuck here for 3 days now. At first I used it as a CharField so I could add it, but when I added another ID it couldn’t add it. It says there is a problem in this part ship_id_max = shipping.objects.aggregate(Max(‘shipping_id’))[‘ship_id__max’] models.py

django getting all objects from select

I also need the field (commentGroupDesc) from the foreign keys objects. models.py views.py Here I get the commentGroup fine but I also need commentGroupDesc to put into my form. Answer At first, it’s not a good thing to name same your model field as model name which is commentGroup kindly change field name, and run migration commands. You can simply

ImportError: cannot import name ‘RightsMaster’ from partially initialized module ‘DATABASE.models’ (most likely due to a circular import)

from DATABASE.models import ModuleMaster, PageMaster, RightsMaster ImportError: cannot import name ‘RightsMaster’ from partially initialized module ‘DATABASE.models’ (most likely due to a circular import) (C:UsersADMINDesktoppython serverDATABASEmodels_init_.py) module_page.py rights_master.py user_rights.py init.py Answer I fixed it I was trying to import ModuleMaster in user_rights.py But it is already connected with Foreign_key in PageMaster

Advertisement