Introduction I am currently working on a small piece of the project to understand more about the Django ORM and to display individual objects. Using Generic views to keep the code clean. (I am somewhat new to Django Framework) Goal The goal of this piece is to show how many users have written an article. For example, I have total
Tag: django-models
Other user’s profile is not showing, It is showing only current user name . How to display other user’s profile?
I am creating a web app and I want this to display other user’s profile through the user’s post. I mean when a user click on other user’s profile for see the other user’s information then it will show the other user’s profile. I’ve tried everything but it is showing the name of the current user information after click on
Serialize a M-2-M relation with grouping in Django REST framework
I have two models, linked through a separate model as follow: Serialized is pretty straight forward: A viewset returns the total number of houses assigned to each employee for different projects, summed over dates: In the output we have multiple records for each employee: I want to convert it to a nested list so that the booked hours show up
module ‘qrcode’ has no attribute ‘make’
While integrating python library qrcode==6.1 with django==3.1.2. I have been trying to generate a qrcode which will contain the URL links for my other websites. Models.py But It always display an error saying that module ‘qrcode’ doesnot contain any attribute named ‘make()’. I want to know how to resolve this? Answer Make sure there are not any files named qrcode.py
Django Query Multi Table
I’m trying to do a form query on a field and the goal is to get all the kids enrolled in all the teachers classes in this drop down menu. The query I have right now is getting all the classes a teacher is enrolled in . However how do I retrieve the kids within those classes. I attached a
Django rest framework’s StringRelatedField is throwing KeyError
I have the following model classes. and I have imported these classes as following as they are located in a separate package and this is my serializer class and views is and url has the following I am getting the following error I looked into the DRF example and this seems to be a simple thing to achieve. https://www.django-rest-framework.org/api-guide/relations/#api-reference But
Django ModelForm has no model class specified, Although model in Meta class is set to a model
Error is “ModelForm has no model class specified.” forms.py code models.py code views.py code The error is occurs when I’m trying to create a new user form (user_form = UserForm()). Although in my meta class I set models to the User model imported from django.contrib.auth.models. Error Info Picture Answer I think your spellings in your forms are wrong could you
Django: def save() in models.py
I’m trying to add the save-function inside my models.py, but it seems I’m doing something wrong. The user has to type the first- and last-name. Without him or her entering any more data, another field inside my models.py should be filled with a combination from these fields. models.py: Is this even possible? Thanks for all your help. Have a nice
TypeError: Post() got an unexpected keyword argument ‘body’ in command line while working on query set
I am working on creating a blog app in Django and while I was making the Query set in cmd I got the following error, CODE IN CMD: ERROR : admin.py :- models.py:- ERROR in models.py :- I am new to Django and don’t know how to resolve the user model, and while creating the query set another error came
How to fix TemplatesDoesNotExist error even after BASE_DIR has been Joined with templates in settings.py?
Image 1- Error I notice Exception Value: registration/login.html , I don’t even have that in the templates, instead, i have sign-in.html, I have no idea why it mentioned login.html. Please see my templates folder below as image 3-Templates. I’m trying to fix the above error. My project path looks like Image 2- project path Image 3- Templates The image 2