I want to add an attribute to a django model as much as the user wants to. For example I want to add a few academic degrees with this code We can just add one degree and if a person has more, he or she can’t add them. I need a way to add as much degrees as i want
Tag: django
TypeError: test_admin_login() missing 1 required positional argument: ‘self’
I’m writing test cases for my Django-based rest APIs. The problem is in the method of testcase class. I want to use test_admin_login method in the setuptestdata method. And I’m unable to do that. I’m getting error that I mentioned in the title. Answer if any function needs the self this means you need to create an instance of it
How to sum with condition in a Django queryset
I am trying to sum Django query with a condition. Suppose I have got some data like this: And these types are string and they have values, like x = 1, y = 25, z = -3 How can I sum up all the values without a loop? Currently using a loop. Answer To perform the calculation inside the database
Access Django M2M values in queryset without looping
I receive some data through Ajax that allows me to do some filtering on a model that has some m2m relations (say Model). I get a queryset, say “content” that I then need to send back using json. Here are simplified lines of code: It was working fine but the project changed and I now need to include the values
Saving related model objects in single view
I am beginner and I am working on Django project – risk assessment application. I have a trouble to achieve saving on related objects for my application risk record. I am using MultiModelForm to achieve the following. I am successfully creating Whatif instance and connecting it with GuideWordi instance on save, however, I am not able to connect my RiskRecordi
Django-axes Errors: ‘Settings’ object has no attribute . .
I’ve run into a lot of attribute errors when using django-axes. Whenever I fix one of them by setting the default attributes, more start showing up. I followed the documentation for installation. Here is my code… settings.py At the bottom I tried to set some of the default attributes that were causing errors. Right now, the code above results in
How can I add the following JSON to a new URL based on its “category”: 2?
I have a JSON array in my server in Django rest framework, but I want to filter them by category , for example some of them have ‘category’:1 and some of them have ‘category’:2 like this: How can I add the following JSON to a new URL based on its “category”: 2? views: urls: Answer Assuming that this thingy you
Notification in django rest API
I want to make a notification system in django so that, when you add a new entry to the database I get notified. As admin I do everything in the Django Rest API Answer using signals.py, I sent a message to the bot via json
How to append value to the ArrayField in Django with PostgreSQL?
I have created a model with the ArrayField in Django Model. I am using PostgreSQL for the database. I want to create new rows in the database or update the existing rows. But I can not insert or append data to the ArrayField. Model View The time field does not being created or updated with the new value. How can
No module named ‘fusioncharts’
I am trying to plot fusion chart in django after adding fusioncharts,I am getting an error. Answer Normally when you get such an error it is because you forgot to install the module, did a bit of research and came to the conclusion that you can install using pip: open the command prompt use the command pip install twFusionCharts.If this