I try to populate a many-to-many field. The Relationship exists between the Menus and Course Model. I added some custom fields to the M2M Table, so I can store the order of the courses and their type (i.e. Starter, Appetizer, etc.). To get a dynamic webform, I use modelformset_factory with the python-formset-js-improved pip package (https://pypi.org/project/django-formset-js-improved/). following the logic in my
Tag: django
Python Django Rest – Return extra field with lowest, highest and average values of some other field
I’m new to Django and APIs in general and I want to create a Django based API using Django Rest Framework. Here’s what I want to do: Endpoint to age range report: Response: Endpoint to salary range report: Response: I have two apps, employees and reports. Here’s employees/models.py: Here’s employees/serializers.py: I’m not sure how to create my views and serializers
How can i implement Notifications system in django
I created an app where user’s can post a question and get answers from others users. Now I want to implement a notification system, so that when a user answer a question, the author of that question will receive notification. Like social media notifications. The home templates: the models: The views: the home page view: the urls Answer Here is
How to send JSON format data in postman to django models that have a foreign key to another model?
I have tried to send a POST request to django views.py file using postman. It was working when I sent a POST and GET request to django models that haven’t ForeignKey field. However, when I tried to send a POST request to a django model that have a ForeignKey field, it wasn’t working. My question is how to send a
Django – accessing a count of a queryset filtered by specific value in my template
I had problems even formulating the title to this question :) I am very much a beginner in everything coding but am enjoying learning through a Django project. Usually I can go bit by bit solving my problems by searching around, but I have failed in the below and am stuck although I am certain there is an easy solution…
django-rest-framework – How to create seperate profiles for users based on is_staff
I am working on a job portal project. I am using custom user model And I have 2 separate models one for job seekers and other for employers. My doubt is how to restrict one user from creating a profile on other type of user based on is_staff field in User model. I am new to django, please help me.
Object is not subscriptable python error django
I have this function where i am using models ‘Start’ and ‘End’ that contain fields latitude and longitude.. and I am trying to match them with a field called elements that I am using subscript to extract the start_id and end_id and match them with ‘Start’ and ‘End’ The function in question that is giving me a subscript error is:
Django: Horizontal scaling with a single database
I have a single django instance about to hit its limits in terms of throughput. Id like to make a second instance and start scaling horizontally. I understand when dealing with database read replicas there is some minimal django configuration necessary, but in the instance of only using a single database: is there anything I need to do, or anything
Need to have the correct url path in Django
I am trying to get my Django app to point to the correct URL in my chatserver/urls.py file. I am getting this error when I start my django app: Using the URLconf defined in chatserver.urls, Django tried these URL patterns, in this order: admin/ join [name=’join’] The empty path didn’t match any of these. This is my chatserver/urls.py file: And
Django: Create a superuser in a data migration
Goal: automatically creating a superuser I’m trying to create a default user, specifically a superuser, in an early data migration, so whenever my Django application is run in my Docker container, it already has a superuser with which I can access the admin site. I had already tried different options for creating said superuser, and although I have some functioning