As of May 31, 2023, we have updated our Code of Conduct.

Questions tagged [django-views]

Django views are MVC views; they control rendering (typically through templates), and the data displayed.

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

How to parse value from key in django template

First i want to explain what i want to achieve. at first this my query at view invoices = vendor.invoices.order_by('-due_date') this is the relevant model : class Booking(model.Models): ... ...
Andi Fathul Mukminin's user avatar
1 vote
1 answer
26 views

How do I calculate the total number of likes for all of a user's posts in Django?

I'm working on a Django project and I'm trying to calculate the total number of likes for a user based on their posts (i.e if a user has post with 10 likes and another with 5, the total likes must ...
Karmin Mahmood's user avatar
-1 votes
0 answers
14 views

Problem with Django Forms to filter by models' field with many to many relationship

If you have any other ideas on how to solve this, I'd love to hear it. The main idea is that the user can enter a list of products and then he will be returned a list of Dish model objects that has at ...
Kacper Włodarczyk's user avatar
1 vote
2 answers
35 views

Django checkboxes not saving to database: What am I doing wrong?

Value of checkbox when clicked is not saved in database Django. I am creating a website to track the progress of printing a book. The data is not being saved in the database and i don't know why. I ...
Ahmad Nasr's user avatar
0 votes
1 answer
32 views

How to update post with multiple images in django templates

i have two models 1-post 2-postimage so the post can have multiple images so I'm having a trouble to update the post and its images in my templates i did like upload multiple images when i create a ...
7mood's user avatar
  • 5
0 votes
0 answers
15 views

Django/HTMX - How to stop resetting selected option when search form is submitted?

I want to implement a search form that has a Product ID field and a and Product locations select field in which the list of locations should be populated based on the Product ID entered. For the ...
DEV's user avatar
  • 65
-1 votes
1 answer
16 views

How to update a post in Django using the same manual-written form for creating it?

I have a form in which I can create a new post, which works perfectly. Now I want the same form to be filled when clicking on a link in order to update the post. I've found lots of tutorials, but all ...
unix nexo's user avatar
0 votes
1 answer
22 views

"detail": "Authentication credentials were not provided." Django DRF

Im trying to create an api for my django project to get some data from database and show it as restframework Response everytime I try to get the data it shows me this error this is my views.py code ...
Shervin.bdn's user avatar
0 votes
2 answers
19 views

Issue with dictionary values not appending in Django session

I'm encountering an issue with updating dictionary values in Django session. Initially, I was using a list to store data in the session, and it worked perfectly fine. However, when I switched to using ...
Virtual's user avatar
1 vote
2 answers
22 views

Nested for loop - model.id in parent for loop does not match model.id in nested for loop (django)

I am trying to access data from a parent to a child via a foreign key. WHAT WORKS - the views The data in the child is not "ready to be used" and need to be processed, to be represented in a ...
PhilM's user avatar
  • 235
0 votes
1 answer
25 views

Django - problem re-adding goods to the basket

I am creating an online store on Djnago. The project has a basket in which you can place goods, as well as remove them. Goods are placed and removed without problems. But, after the product has been ...
Yevhen's user avatar
  • 1
-1 votes
1 answer
16 views

Do I need a default authentication system even I know pretty much [closed]

I can create user table and use it as a default login activity. I don't have hands on experiance of django's conf.auth. I am using my own login system. I can create session object, can manage session ...
Nugget's user avatar
  • 11
0 votes
0 answers
9 views

How to prevent auto-filling of other Django forms when updating a specific form and how to make them not required to fill?

I have some Django forms each one with an update button that I'm rendering on a template. When I try to submit something through the button I can't because It says I have to fill every form. I also ...
ffe6e66e6eff's user avatar
5 votes
0 answers
242 views

Implementing Name Synchronization and Money Transfers in Transactions Model with Account Number Input

I have the following models in my Django application: class Transaction (models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE) account_number = models.IntegerField() name ...
Adamu_Dee_Azare's user avatar
0 votes
0 answers
17 views

How to specify quantity of multiple model objects by form

So, im making my first pet project with django and im struggling with cart in my store. Many guides are doing quantity in cart by buttons, but i want to enter a value by number form like this: enter ...
Librin's user avatar
  • 3
-2 votes
0 answers
26 views

how to add product in cart in Django

i am trying to add product to cart by getting its id this is the path urls.py this is views.py productdetail.html how to get product by their id and to add them in cart?
Swagat Kothawale's user avatar
0 votes
1 answer
27 views

Linking a custom HTML form with a django model form

I want to connect my model forms to Html forms with horizontal fields. How do I manually render each field. I have tried to implement with no success. With the following method, I have manually render ...
Jaks's user avatar
  • 45
0 votes
2 answers
31 views

request.user returns AnonymousUser in a project with react, django and rest framework

I have a web project what back-end is coded with django and front-end is coded with react. In my project, i want to create an order to a special user so this part of project needs to know the user but ...
PicoDev's user avatar
  • 55
0 votes
0 answers
14 views

Access json field's dict value which is inside list using queryset

I have django model named Blog with fields title, data class Blog(models.Model): title = models.CharField(max_length=100) data = models.JSONField(default=...
Venessa's user avatar
0 votes
1 answer
28 views

How do I add the project title to the project_details url's (slug) on this django project

I've been stuck trying to add the project title to the project_details urls (slug). The issue is, I would rather achieve this without changing the models.py as this would create complications with the ...
Daniel Marsh's user avatar
0 votes
2 answers
51 views

User can't create objects in the page

I made a program where users can keep track of their expenses by entering them into the system after creating their own account. The system requires users to fill in four fields: customer, category, ...
Francisco's user avatar
3 votes
3 answers
51 views

How to assign an order to field in a many to many field

This is my first django project so I'm still learning. I Django project of Formula One Races and Racers. The Race model looks like this, class Race(models.Model): name = models.CharField(...
Tasnia's user avatar
  • 31
1 vote
1 answer
12 views

django duplicate SQL queries stemming from model method get_absolute_url that accesses ForeignKey relationship

Problem Summary I have a class-based list view that just displays links for each object along with some data from some of the object fields. The href for the links is generated using a ...
shadowplumber's user avatar
0 votes
1 answer
28 views

Django optimize waiting for a response

I'm trying to speed up my Django server which is running let's say 4 processes and for some view, it is making a request to another server which is performing some computation and sending a request to ...
Jakub Swistak's user avatar
1 vote
1 answer
10 views

Django Generic detail view 'class' must be called with either an object pk or a slug in the URLconf while trying to delete an object

In my Django app, I'm trying to delete a Comment which is associated with a post, but I keep getting this error message. The expected output is for the Comment to be deleted from the site and the ...
Ldnsky's user avatar
  • 13
0 votes
1 answer
18 views

Access Foreign Key's Queryset

I have these models: class Source(models.Model): name = models.CharField(max_length=255, blank=True, null=True) feed_url = models.CharField(max_length=512) .... class Post(...
haduki's user avatar
  • 1,102
1 vote
0 answers
27 views

Why does clicking on a brand checkbox in Django and Ajax result in displaying another HTML page?

I am trying to filter products by brand name through checkboxes using django, ajax jquery, but while clicking on the checkbox I am having another products html page within the running html page ...
Md. Sajib Mahmud's user avatar
1 vote
1 answer
7 views

i cant append the form to a list

why wont this code append the task to tasks i'v been taking CS50 course, and after i apply this code i didn't see the expected result i tried everything but still the form wont append to the list of ...
Youssefwolf's user avatar
1 vote
2 answers
29 views

Field 'id' expected a number but got <QueryDict

This is a common error on stack overflow but I cannot draw similarities with their errors and mine. A number is expected in the id column of the database(automatically made by django) but a query dict ...
Muffin's user avatar
  • 81
0 votes
1 answer
26 views

how to filter dropdown values based on the value of other dropdown in django

I have 2 models main_category and sub_category, in the sub_category model, it has a name and Foreign key of the main_category it belongs to. and I have 3rd model which is 'record' and it has ...
Mohammed Ahmed Mohammed's user avatar
0 votes
0 answers
19 views

Trouble passing Django request.POST.get() variables to context after AJAX

I am in a quite strange situation. I have this form: <form method="post" id="preventivo-form"> {% csrf_token %} <input type="hidden" name="...
Andrea's user avatar
  • 51
0 votes
0 answers
13 views

In Django, when connecting two DB Postgres tables through 1to1 relation they don't connect with each other automatically but only through admin panel

In Django project, when connecting two DB Postgres tables through One to One relation they don't connect with each other automatically but only through admin panel manually I'm a rookee in Djanog and ...
David's user avatar
  • 1
0 votes
1 answer
35 views

User.objects.create_user() in django does not works

I have been trying to create objects using 'User' class in Django for entering my user details to database but it does not works. no records where created during the process. I also tried by creating ...
AthulRajagopal's user avatar
0 votes
0 answers
49 views

How to display a 3D object (*.stl file) using Django

I have a website developed using Django. Several 3D object files (*.stl files) are loaded from the administration. I would like to add the following two functionalities. 1- Being able to view 3D ...
ldiaz997's user avatar
  • 128
0 votes
0 answers
20 views

Why is my Django CreateView not adding new recipes to the database?

My Django CreateView doesn't submit data to the database. I am an absolute beginner when it comes to Django and creating websites and I feel like there's something that i haven't quite understood yet. ...
chiara's user avatar
  • 1
0 votes
0 answers
7 views

I need hlp with urls.py in creating dynamic url, and integrate my feedback model in my existing pg

[enter image description here](https://i.stack.imgur.com/YGUXY.jpg) I have create my models successfully when i call it on new path its working good but not in existing path any suggestion please? ...
shoaib's user avatar
  • 1
0 votes
0 answers
6 views

Is it possible to force users to go through OTP before accessing the password reset form in Django?

path('PassChangeForm/',views.PassChangeForm, name="PassChangeForm" ), i don't want user type PassChangeForm in the URL bar of the browser, and they got PassChangeForm page, They must ...
Sanket Chudasama's user avatar
0 votes
0 answers
14 views

What could be causing 'Schedule matching query does not exist' error in Django and how to solve it?

I am having a problem with my code. It returns error log Traceback (most recent call last): File "/mnt/c/Users/davep/Desktop/a/Water_management/newenv/lib/python3.10/site-packages/django/core/...
Palarion Dave's user avatar
-1 votes
1 answer
46 views

How to fix this error AttributeError: 'NoneType' object has no attribute 'extraBottles'?

I am having a problem with my code. It returns error log of "AttributeError: 'NoneType' object has no attribute 'extraBottles'" Internal Server Error: /employee/order/79/ Traceback (most ...
Palarion Dave's user avatar
-1 votes
0 answers
28 views

Template does not exist error been trying to solve for two hours

TemplateDoesNotExist at /login/ users/login.html Request Method: GET Request URL: http://127.0.0.1:8000/login/ Django Version: 4.2.1 Exception Type: TemplateDoesNotExist Exception Value: users/...
anirudh pandey's user avatar
0 votes
0 answers
7 views

Django form submission error: 'GameArticleComment matching query does not exist' - any solutions?

am getting an error when trying to submit an form for blog comments please anyone to help me and direct me where l went wrong. The error is GameArticleComment matching query does not exist. even l ...
Byansi 's user avatar
0 votes
1 answer
36 views

How can I specify OneToMany relationship in Django models?

I am using Django for fetching data from the join of three tables. Table1, Table2, and Table3 all have a column name cols. I want to join all three tables and have to define the models for that. I can ...
Nishant Bharat's user avatar
0 votes
0 answers
22 views

How to create dynamic views

I was wondering if anyone could provide some insight into dynamic views in Django / Python? I thought it would be useful to have a drop down menu and then depending on the chosen result, determines ...
Neil Faulkner's user avatar
1 vote
1 answer
23 views

Check if an id is in another model's field, and get the connected values

Given these two models: class Event(models.Model): title = models.CharField(max_length=200) class dateEvent(models.Model): venue = models.ForeignKey(Venue, on_delete=models.CASCADE,null=True, ...
HBMCS's user avatar
  • 668
0 votes
0 answers
15 views

Issue with Displaying invoice Data in Table Format in PDF Generated from Djnago Database

Facing difficulty in displaying data in table format within a PDF generated from a database using Python. Seeking assistance to resolve the issue and ensure proper representation of data. Any ...
AIENA JAVED's user avatar
-3 votes
0 answers
33 views

How to integrate a code that performs facial detection and recognition in this views.py code for Django and changes in urls.py if needed [closed]

This is the code for the view as of now, which captures an image of the student at signup and opens up a screen of live video capture when the student starts taking the exam. I wish to integrate ...
Vaishnavi Gupta's user avatar
0 votes
1 answer
22 views

Why am I getting a TypeError when passing HTTP method dictionaries to Django REST Framework's as_view() method in ViewSets?

I created a ViewSet, in which I need to use in two URL Patterns, one is for getting the list of items and other is for getting the detail of single item. The problem is, when I pass {"get": &...
Khubaib Khawar's user avatar
2 votes
2 answers
51 views

Django date range filtering from url parameters returns empty queryset

I'm currently trying to do date range filtering from url parameters with get_queryset on a generics class based view, however I am receiving an empty array after doing date range filtering. It's a bit ...
jackied3's user avatar
0 votes
0 answers
26 views

Django Google reCAPTCHA not working - form data submits but page redirects to 404 page, how to solve?

I build a contact page with a django where is two forms. When I submit contact page form with google reCaptcha verification form data is submitting to the backend or admin panel but it redirecting my ...
Estieque Alam's user avatar
0 votes
1 answer
16 views

Why am I getting Error 405 - Method not allowed when trying to save data from Django custom form?

Error 405 - Method not allowed when trying to save a data to a custom form using Django. Method Not Allowed (POST): /create-establishment/ Method Not Allowed: /create-establishment/ I created a class,...
Aquaknight's user avatar

1
2 3 4 5
477