I am trying to make an e-commerce website where “AnonymousUser” or Guest user can order and check out products by providing their name, email, and address. But after clicking the “Make Payment” button, my terminal was having an error that says “store.models.Customer.MultipleObjectsReturned: get() returned more than one Customer — it returned 2!” When I try to login and do the
Tag: django-views
‘QuerySet’ object has no attribute ‘x’
I want to go to a users page and see the their photos, so I was trying to get the objects assigned to a foreign key, but I keep getting the error above AttributeError at /user/30/ ‘QuerySet’ object has no attribute ‘file’. I feel like the problem is in my syntax, but I really have no clue why it can’t
Extracting data from Django Queryset and inserting into a Python list
I am trying to get one column of data from a Django model into a python list for further processing the in Django view. I have successfully created a simple Django model and populated the data. The fields are: “id”, “x_coord”, “y_coord”. I have run a few commands to extract data from the model. I want to get the values
Associating user id to courses that the user create
My django project basically allows users to create its own courses. So, I am trying to associate a user id to the courses that the user created so that it will display only the courses that the user has created when the user wanted to view all the courses that he/she has created. However, it returns an error saying “Cannot
I have updated my code– I want to pass an object in “for loop” with employee_id and his specific donation amount, How can I do this?
I am working on a donation app. In this app, There was a feature that sends an equal amount of donation money to every employee of the organization now they want to change this feature by sending a customized amount of donation to all or some of the employees. I have worked on it: Now I am using a for
How to solve local variable error with forloop in django?
Info: I want to get data from context. The context data is coming from for loop function. Problem: I am getting this UnboundLocalError local variable ‘context’ referenced before assignment Answer You should do something like this :
How to stop Getting 405 error Method not allowed?
I am trying to make my django project to work but somehow I always come to get this error Method Not Allowed (POST): / I have tried using decorators like @csrf_exempt like in the django documentation as to not encounter csrf errors and yet I came to this error.Please tell me what’s the problem with my code… urls.py views.py app.js
get more than two foreign keys from another django table and perform calculations on them
In the Django app, I have created two tables. Product Invoice I have one table called Product which contains product name and product price columns are given. Then, I have a second table named Invoice which contains a product name(foreign key), product price(foreign key), discount, and total. My concern is how can I import both the values from the Product
I am trying to add a new field to the default Django Form and am getting an error when I’m trying to import a class from a forms.py file I made
The error is occurring in views.py file in which when I try to import the form class I made from my forms .py file I get an error of… Here is what my views.py file looks like: And here is my forms.py file Why am I getting that error/what am I missing? Answer You problem comes from importing “from django.contrib.auth
Page not found (404) The current path, register/register, didn’t match any of these
on running server browser show I am trying to save the the data into database on submitting the form the browser show page not found error and and some wrong address. http://127.0.0.1:8000/register/register while i am rendering the homepage on submitting the form. views.py file urls.py file Answer try path(‘register/register’,views.register),