Django.fun

Questions & Answers about Django, page 2007

error is comming while sending list and fetch value on sended list data

plz explain why this is happening in detail and solution also. thanks in advance. list is coming in views but when i fetch the value against them then it prints 'none' and also when i use to send js list …

How to process the practice answers directly on the server and the results are immediately updated on the practice data using Django

I want to process the practice answers directly on the server and the results are immediately updated on the practice data, so when the user opens the practice data, the practice data value is already available. models.py class PracticeAnswer(models.Model): practice_answer_id …

Django: NOT NULL constraint failed: account_tutorvalidator.user_id

I am new to django and I created this "apply now form" exclusively for tutors that when they submit the form it will appear to the admin site, and I will manually check it if they are a valid tutor. …

FBV Delete to CBV Delete

I am new to django ,how can i convert this FBV delete to CBV delete ? def delete_hotel(request, pk): hotel = Hotel.objects.get(pk=pk) owner = MyUser.objects.get(pk=pk) hotel.delete() owner.delete() return redirect('/admin/')

any django app that can store sessions ip,browser ..etc and not delete it after the user logout?

i want to store the session history for users in my application , any app can be used ? if not how some thing like that can be made ? i want to have complete history for IPS , browsers …

I can't see chatmessage_thread in my serializer result

I'm working on a small project using Django Rest Framework, I would like to access chatmessage_thread. I don't see chatmessage_thread in my result, should I add something in my serializer ? this is my queryset class ThreadViewSet(viewsets.GenericViewSet): queryset = Thread.objects.all() …

Apache/2.4.46 (Ubuntu) Server at Port 80 Error

I have uploaded 2 django projects before and worked perfectly fine to the server, but now for some reason I am receiving this error. I have revisited a tutorial word by word and revised it several times, I am not …

ManyToMany vs. Intermediary Model for Follower-Following Relationship for Django Rest Framework

I'm working on a blog application with Django Rest Framework (very original I know) and I'm trying to add a followers/following relationship between Users. Currently my UserProfile is implemented as follows: from django.db import models from django.contrib.auth import get_user_model from …

Handling File Upload Errors in Django with DO/S3

I'm using django-storages with DO/S3 to upload a file from curl (later to be a Java client): curl -F some_file=@some_file.txt -F name=some_file --referer https://localhost:8000 -k -i https://localhost:8000/file/request Storage backend configured: storages.backends.s3boto3.S3Boto3Storage My model field: some_file = models.FileField('Some file', blank=True, …

Django - Would I be able to use template tags for rendering HTML given URL path conditionals?

I have a blog page with the path /articles/. I would like to use conditional statements to reflect HTML renders. For example, my blog uses a paginator for blog posts. The paginator uses a URL query to retrieve the next …

how can i get chatmessage_thread ( i'm using Django Rest Framework )

I'm working on a small project (chat) using Django Rest Framework / Channels I have a small issue, I can't get chatmessage_thread i'm getting this error message : 'QuerySet' object has no attribute 'chatmessage_thread' this is my serialize : …

How to entering to URLs in Django?

Well I just started today working with the Django app but when I follow his tutorial https://www.youtube.com/watch?v=_uQrJ0TkZlc&t=18317s at 5:20:20 The machine won't let me go to the URL of 127.0.0.1:8000/products/ pyshop\urls.py from django.contrib import admin from …

Django how to show user profile picture publicly?

right now authenticated user can only see his own profile pic. I want every user can see each others profile picture. how to visible profile picture publicly: here is my code: models.py: class UserProfile(models.Model): user = models.ForeignKey(settings.AUTH_USER_MODEL,on_delete=models.CASCADE,related_name="userprofile") slug = models.SlugField(max_length=2000,unique=True,blank=True,null=True) …

Django simple app causes a circular import error, followed by a definition error

I'm having a seemingly simple definition error whereby the class Automation is not defined. I've created a very simple app called automations which seems to have caused a problem despite barely changing it. Note that there's also another app called …

Defining the initial values of a ModelForm in Django admin using the contents of the request

I'm trying to pre-fill a ModelForm for the admin interface of my Django application. I'm storing some values in request.session and I'd like to use them to define the initial parameter of my ModelForm. I'm able to retrieve these values …

Django Channels: Saving logged in user to session

According to the docs: If you are in a WebSocket consumer, or logging-in after the first response has been sent in a http consumer, the session is populated but will not be saved automatically - you …

Fetch auto-populated data from a ForeignKey model and use in the form

I am facing one Issue in Django: Below are my codes, In create_support I have created a form, to submit a ticket, I want the Profile to be auto populated post user login and should not display in the drop …

can you send a subExpand in django?

As you can see, I am making a request to get to viewset ServicioRealizadosOrdenTrabajoTipoViewSet. if you look at the serializer "Servicioserializer", There are 3 expandable_fields that I am using in the frontend endpint sefl._list.... ".....&expand=tecnico&expand=orden_trabajo". lor what I want is …

Django Rest Framework can't identify serializer field name

This is the problem: I have a serializer field pointing to another serializer. I sending an allright request to server and I get this response: { "purchase_header": [ "This field is required." ] } But the field was sended …

Django Lambda with Microservices, Breaking Django Project in Lambda functions

I've just started to implement serverless architecture using Django and AWS lambda and It's working perfectly fine now. My project consist of two apps user_onboarding and user_training and structure is as follows : MainApp - user_onboarding - models.py - urls.py …

Tutorials

Константы Python: Улучшение управляемости вашего кода

Современный Python: начинаем проект с pyenv и poetry

Настройка проекта Python — виртуальные среды и управление пакетами

Использование requests в Python — тайм-ауты, повторы, хуки

Понимание декораторов в Python

ProcessPoolExecutor в Python: полное руководство

map() против submit() с ProcessPoolExecutor в Python

Понимание атрибутов, словарей и слотов в Python

Полное руководство по slice в Python

Выпуск Django 4.0

Безопасное развертывание приложения Django с помощью Gunicorn, Nginx и HTTPS

Автоматический повтор невыполненных задач Celery

Django REST Framework и Elasticsearch

Докеризация Django с помощью Postgres, Gunicorn и Nginx

Асинхронные задачи с Django и Celery

Релизы безопасности Django: 3.2.4, 3.1.12 и 2.2.24

Выпуски исправлений ошибок Django: 3.2.3, 3.1.11 и 2.2.23

Эффективное использование сериализаторов Django REST Framework

Выпуски безопасности Django: 3.2.2, 3.1.10 и 2.2.22

Выпущенные релизы безопасности Django: 3.2.1, 3.1.9 и 2.2.21

View all tutorials →