Disclaimer: I can wipe out the database anytime. So while answering this, please don’t care about migrations and stuff. Imagine me having a model with multiple values: Now I want to add a comment to be stored for every value of that model. For example I want to add a comment “measured in winter” to the temperature model field. What
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
I would like to limit the borrowing objects in my Django app
I have an app that displays games and users can borrow them. I want to limit the amount of borrowed games for each user to max 3 games. I created two models borrow and games. The methods work well except for the max borrowing. Answer You can check whether he has borrowed more than 3 games in form.is_valid() if like
how to select more options in “ManyToManyField()”?
i wanted to create a tag option for a a music model , well mainly musics accept more than one tag and there are amny kind of genres and tags ,so i wanted to make a ManyToManyField() that you can set more than 1 value ,also if you tag is not in add it in. to do that i thought
How can I delete all user data when deleting profile on Django using signals.py
how can I delete all user data when deleting a user profile on Django using signals.py? I am trying to delete a custom user model using Django and when the profile is deleted I want to delete all data of that user using signals.py how can I create it? I want to delete blogs of the user-written when the profile
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
Why is model._meta.get_fields() returning unexpected relationship column names, and can this be prevented?
Imagine I have some models as below: Now I have a function to return all column names to generate some overview in my HTML as such: Why does this return uptake_medium? As this is a ForeignKey relation set within the Uptake model, it should only be present within the Uptake model right? When I review the admin models this column
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
Django IntegrityError (1048, “Column ‘item_id_id’ cannot be null”)
Here is my models.py Items model from different App: My views.py Forms.py My template And the form when i run the server is this: Answer In you model the field is named item_id but in your ModelForm the field is named itemID. The field names should be the same. Rename the fields in your ModelForm so they match the Model.