Category "django"

Calling FileField objects in template renders incorrect path

I've implemented a FileField model in my project. I can successfully upload svg files and they save to the desired location. Within my project, I make heavy use

Python Django error "Select a valid choice. That choice is not one of the available choices."

I am relatively new to Django so I am likely doing something obviously wrong but I cant seem to figure out what exactly. I have a model called Report and this h

Django for loop in Carousel

I'm trying to add a title to each slide in a dynamic carousel in Django. I have the images functioning properly and working as expected. The title is stacking o

get_object_or_404 and .get(id=pk) is not working when i try to access my model in to some view

i'm trying to access my model using both method but one of them is not working in my view. i want when a user click on {{question.title}} in my home page to be

Django pymongo search, sort, limit on inner array and count them

I am learning Django with MongoDb and have a collection to search into. Here is a sample document in the collection: { "_id": { "$oid": "62615907568ddfc

How to assign a database model to a user

from django.db import models from datetime import datetime from django.contrib.auth.models import User class News(models.Model): user

Django - profile creation based on is_staff

I am currently working on a job portal project, where I need to create 2 profiles based on is_staff field of default user model of django. one for job seekers a

Not Implemented Error in Django Channels Layers

I was following the Django channels tutorial to create a simple chat application. But while trying to check if the channel layer can connect to Redis, I get thi

django removes "is_staff" permission if I try to login

I have a pretty strange situation within my django project. I have a LoginForm where a user can log into the website. I am using django 3.2.12 with some other l

Extra operation button in django admin panel

I want to add some buttons to do a lot of database operations at once, and I want to place those button(s) at (1) place. How to do that? Extra explains: What I

Implementing a search query inside a filter

I've been trying to implement a search bar inside my application, but I don't know how to query for similar names inside my db. Here is my view.py queryprms

Debug Toolbar not showing

I installed: pip install django-debug-toolbar I have DEBUG=True in my settings I have django.contrib.staticfiles and debug_toolbar in INSTALLED_APPS i have STAT

Graph not being displayed on django framework

I want to display a graph using C3 Javascript library which displays future prices of textile raw materials on django framework. When I run the code it does not

Flask Unique SQLAlchemy with Flask-LImiter

I want to make a project with flask where you sign up and sign in and then you can make new posts. I use flask-limiter to prevent users from making new posts. A

Upload file from html when block public access is true

I am using django-s3direct to file upload https://github.com/bradleyg/django-s3direct Using IAM role setting because I upload the file from the server on ECS co

Filtering in Django which depends on first field

Suppose I have 3 fields of a Car Shop. those are Condition, Brand, Model . class Car(models.Model): ConditionType=(('1','New'),('2','Used'),('3','Reco

Django Form processing files

So I have the following code: # the view class UpdateDateView(LoginRequiredMixin, UpdateView): model = Date form_class = DateForm template_name = '

Test a decorated function in Python

I have a Python function which is decorated. @retry_if_access_token_expired(app_id) def add_something( self, *, argument1,

Add Django Rest Framework Login Button to Browsable API when Using Third Party Auth Library (django-rest-knox)

The login button is missing from my browsable API. I am using django-rest-knox for token authentication. My urls.py contains: urlpatterns = [ path('admin/',

How to implement only client to graphql subscriptions in a website with only front code?

I am coding a only front end site using Django. to query data to a DataBase I use AJAX to my Django and Django requests a third party GraphQL. so far all works