Category "django-views"

serving media files in Django for Production

I want to serve all types of media files in my Django Project I used Whitenoise to server static files and static files are working well but I'm having issues w

Django : local variable 'date' referenced before assignment but I import it

I am building a script that use the datetime module : def workspace_detail(request, token): yesterday = date.today() - timedelta(days=1) tomorrow = date.today

nothing happens when submitting django form

I have a problem with django forms, when submitting a form nothing seems to happen, even the server didn't get any response except GET request to view the form

Displaying child records based on parent id from URL

I have one model Dataset and another one called DatasetReview, where DatasetReview has a foreign key connection to Dataset. I would like to display all of the D

ValueError: Missing staticfiles manifest entry for 'favicon.ico'

I'm getting a ValueError when running python manage.py test. My project is named fellow_go, and I'm currently working on an App called pickup. Please note that

What is the correct way to implement Django password history?

I have implemented a solution for checking a new password against the last 5 passwords like so: Created 5 fields in a user profile table to store the encrypted

"Local variable referenced before assignment" Django error

I have no idea what may cause this issue. The only change I've made was add the loginquiredmixins to my class-based views. Once I started stylising the login pa

django: return string from view

I know this is a simple question, sorry. I just want to return a simple string, no templates. I have my view: def myview(request): return "return this st

Add extra context to admin index page

In my admin.py of my admin dashboard app I added this following code: class MyAdminSite(admin.AdminSite): def index(self, request, extra_context=None):

In Django, how can we stop losing the details filled in the form, if it fails validation?

I am using the UserCreationForm for user registration in my Django web app. When the user fills in the detail (username, password, confirm_password) and submits

Django Nested Inline Formsets to Populate Multilevel Nested Form

I'm trying to solve a problem. I have a model hierarchy like this: class Task(models.Model): name = models.CharField(max_length=255) number_of_steps = m

If statement on a Model.field

hopefully this is clear. I am trying to put together a view that takes care of what happens when a user places a bid on an active listing on the auction site I

How to change the validation error color and position in Django?

I am new to Django. I am trying to make a simple form to match the password. However, when I enter different passwords and press the Save button I get a black v

How to add custom views or overide views for Django Admin index?

urls.py -> ''''from django.contrib import admin from django.urls import path from Administrator import views admin.site.index_template = 'admi

Display last page of paginated results instead of 404 using ListView

The Django docs show how to return the last page of a paginated queryset using a function-based view by catching the EmptyPage exception. What's the easiest wa

Fetch Data from DB in base template Django Python

I am developing an application (simple online store) with Python Django I have created a base.html file in templates and then all other html files extends from

How to get the objects from child model to a django template?

I have created child ('Bid') model related to a parent(Post) model in my Django project. I also created a BidForm which I have added in my B_Bid.view so that ty

ValueError The QuerySet value for an exact lookup must be limited to one result using slicing on django views

am Getting this error i cant figure a way to solve it here are the views.py class SellerTransactionListView(ListView): model = Transaction template_na