Category "django"

does filtering queryset in django query database every time?

Imagine I have the following code: qs = Users.objects.all() list = [] for i in range(10): list.append(qs.filter(age=i)) here the filter is called 10 times

Why do I get [INFO] Worker Exiting (pid: 2) when deploying cloud run service with docker? (On VSCode with cloud code extension)

I'm really new to this stuff, I'm a 16 year old currently doing a research project/internship, and I've just started 2 weeks ago. So I'm extremely confused. I'v

Configuring PostgreSQL schema for default Django DB working with PgBouncer connection pool

I need to set the default DB schema for a Django project, so that all tables of all apps (including 3rd party apps) store their tables in the configured Postgre

Why are the error reporting emails not being sent (Django)?

Python version: 3.6.3 Django version: 3.0.8 I am trying to use enable Django's error reporting via email, but nothing seems to happen when I encounter a 500 err

How to print multiple object from table def __str__(self):return self.title

I created a article models below models.py class Article(models.Model): user = models.ForeignKey(User, on_delete=models.CASCADE, blank=True) is_deleted

Django: how to count the ratings and reviews of a post using django?

i have a model course and i also have a model review and rating that allows users rate a particular course. now i want to count all the ratings on each course w

DRF-simple-JWT: New user registered but not able to login

I am able to create a New User using the "register" endpoint. I can the user being created on the admin page as well. When I try to get an access token for the

Detect when user register/Login on Context Proccessor Django

I have to do some checks all the time with the context proccessor.The value must be 'True' as soon as the user logs in.But when navigating the site after loggin

understanding try except python/django

I need your help with understanding try-except python/Django. so I have this function: def submit_dept_head_application(request, application_id): cv = request.F

How can we add more than 3 authors field for a single magzine? in Django models

I created a magzine model in django. But their are more than three authors of a magzine. I have written below code for three authors. If I write the code of two

DRF --405 Method not allowed for update operation

I have done this before and may be it did work properly that time but now suddenly it's not working as it's expected to be. The viewset.py: class ProfileView

Images are not rendering on Django template from a multi-model view

Problem: I cannot get images to appear on my template plant_detail.html. I think I'm calling on variables incorrectly, but not sure what to change. Context: I c

Creating Custom Join in Django

I am struggling to create the correct prefetch behavior in Django. Here is the outline of the problem: Each Account has DailyQuotes, updated daily at different

Django. How to get URL by its name?

I want to get url by name specified in urls.py. Like {% url 'some_name' %} in template, but in Python. My urls.py: urlpatterns = [ ... path('admin_secti

How to change HTMX behavior to replace the full web page if form is invalid

If this form submits as invalid, I want to override the htmx and do a HttpRedirectResponse that refreshes the full page instead of just changing the div, #super

Vercel CLI Pyhon version issue when deploying Django project

When running the vercel command in Ubuntu terminal: Error! Command failed: python3.6 /tmp/2de7da56/get-pip.py --user ERROR: This script does not work on Pyth

Adding search bar function into a django project

I'm trying to add search bar in my application but I don't know how to query a database to gives the things that user's search for. I want when user search for

How to upload and use images on heroku django

so i make this app in which you can make products. And those products have an image that was saved in a file while i was using this app localy. I deployed my ap

ImportError: cannot import name 'url' from 'django.conf.urls'

ImportError: cannot import name 'url' from 'django.conf.urls' (/home/chams/pfe_project/CarApp/venv/lib/python3.8/site-packages/django/conf/urls/_init_.py) I can

In Django, how to restrict access to a template to users based on their department_name. Each user belongs to certain department

I have the below model. Departments, users. Users are assigned to a department. How can I restrict the access of templates based on the department_name of a use