Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Got this error when i used the command manager server
I am building a dashboard project currently using Django so that I can learn it as well. I am following a tutorial and did as they did it but I am getting this error right now. I am not sure where I went wrong so please anything helps!! Error Message C:\Users\Vignesh\.vscode\Interview Dashboard\dashboard> python manage.py runserver Watching for file changes with StatReloader Performing system checks... System check identified no issues (0 silenced). You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. October 15, 2022 - 15:01:34 Django version 4.1.2, using settings 'dashboard.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CTRL-BREAK. [15/Oct/2022 15:01:55] "GET / HTTP/1.1" 200 10681 [15/Oct/2022 15:01:55] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423 [15/Oct/2022 15:01:55] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 85876 [15/Oct/2022 15:01:55] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 85692 [15/Oct/2022 15:01:55] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 86184 C:\Users\Vignesh\.vscode\Interview Dashboard\dashboard\dashboard\urls.py changed, reloading. Watching for file changes with StatReloader Performing system checks... Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Users\Vignesh\anaconda3\lib\site-packages\django\urls\resolvers.py", line 717, in url_patterns iter(patterns) TypeError: 'module' object is not iterable The above exception was the direct cause of the … -
How do I enforce that child classes have all fields in the database
I have defined a Person class. Than Teacher inherits from person. Is there a way to force Django to generate the table teacher with all the fields from the model, rather then having a foreign key to Person table, and 1 column: about? Also I would like to skip creation of person table, as it's abstract. class Person(models.Model): class meta: abstract = True name = models.CharField(max_length=60) surname = models.CharField(max_length=60) age = models.IntegerField() def __str__(self): return f'{self.surname}, {self.name}' class Teacher(Person): about = models.TextField(null=True, blank=True) -
Django REST Framework - Struggling with nested serializer - This Field is Required
I've been trying all night to get a nested serializer to work, and I'm so deep in it now that I'm struggling to keep track of the changes I've made. This is for a group project for a uni assignment, and I'm still quite new to Django. What I'm trying to accomplish is a CreateAPIView that uses a serializer to create a Composer, get/create a Nationality for it, and then add a row to a lookup table named ComposerNationality. I've gotten close a few times. But right now the I'm getting the following error when trying to POSt via Postman: "nationality_serializer": [ "This field is required." ] Here is what I have so far: models.py class Composer(models.Model): id = models.AutoField(primary_key=True) firstName = models.CharField(max_length=100) lastName = models.CharField(max_length=100) birth = models.IntegerField(blank=True, null=True) death = models.IntegerField(null=True, blank=True) biography = models.TextField(blank=True, null=True, default = 'No Information Available, Check Back Later') bio_source = models.CharField(max_length=200, blank=True, null=True, default = "") featured = models.BooleanField(default=False) composer_website = models.CharField(max_length=300, blank=True, null=True, default = "") image = models.CharField(max_length=300, default = "https://i.picsum.photos/id/634/200/200.jpg?hmac=3WUmj9wMd1h3UZICk1C5iydU5fixjx0px9jw-LBezgg") def __str__(self): return self.firstName class Nationality(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=100) def __str__(self): return self.name class ComposerNationality(models.Model): composer = models.ForeignKey(Composer, on_delete=models.CASCADE) nationality = models.ForeignKey(Nationality, on_delete=models.CASCADE) def __str__(self): return … -
How to perform inner join of 3 tables in Django?
I have this Django model example class Users(models.Model): first_name = models.CharField(max_length=255, blank=True, null=True,unique=True) last_name = models.CharField(max_length=255, blank=True, null=True) class TableA(models.Model): user= models.ForeignKey(Users, on_delete=models.CASCADE) atrribute_a_1 = models.CharField(max_length=255, blank=True, null=True,unique=True) atrribute_a_2 = models.CharField(max_length=255, blank=True, null=True) class TableB(models.Model): user= models.ForeignKey(Users, on_delete=models.CASCADE) table_a_id= models.ForeignKey(TableA, on_delete=models.CASCADE) atrribute_b_1 = models.DecimalField(max_digits = 100, decimal_places = 8, default=0) atrribute_b_2 = models.DecimalField(max_digits = 100, decimal_places = 8, default=0) atrribute_b_3 = models.DecimalField(max_digits = 100, decimal_places = 8, default=0) class TableC(models.Model): user= models.ForeignKey(Users, on_delete=models.CASCADE) table_a_id= models.ForeignKey(TableA, on_delete=models.CASCADE) atrribute_c_1 = models.DecimalField(max_digits = 100, decimal_places = 8, default=0) atrribute_c_2 = models.DecimalField(max_digits = 100, decimal_places = 8, default=0) class TableASerializer(serializers.ModelSerializer): class Meta: model = TableA fields = '__all__' class TableBSerializer(serializers.ModelSerializer): class Meta: model = TableB fields = '__all__' class TableCSerializer(serializers.ModelSerializer): class Meta: model = TableC fields = '__all__' I want to perform this action: select * from TableA inner join TableB on TableA.id=TableB.table_a_id inner join TableC on TableA.id=TableC.table_a_id where TableA.id=3 How am I supposed to do that? as I tried filter and select_related and it didn't work as I checked in the internet or even documentation examamples they start the selection from TableC or TableB , but in my case I want to start from TableA Like: my_query=TableA.Objects.filter(id=3)....something serializer=TableASerializer(my_query,many=False).data In results I want [All … -
DRF nested serializers returns empty dictionary
I have two modals designation and UserModal class DesignationModal(models.Model): designation=models.CharField(max_length=100) def __str__(self): return self.designation class UserModal(AbstractUser): username=models.CharField(max_length=300,unique=True) password=models.CharField(max_length=300) email=models.EmailField(max_length=300) designation=models.ForeignKey(DesignationModal,on_delete=models.CASCADE, related_name="desig",null=True) def __str__(self): return self.username every user only have one designation. I wrote serializer for that. class DesignationSerializer(serializers.Serializer): class Meta: model=DesignationModal fields=['designation','id'] class UserSerializer(serializers.ModelSerializer): designation=DesignationSerializer(read_only=True,many=False) class Meta: model=UserModal fields=['id', 'username','designation'] I'm getting a JSON response like this { "status": true, "data": [ { "id": 3, "username": "akhil", "designation": {} } ] } no values in the dictionary, when I used to rewrite the serializer code like this. class UserSerializer(serializers.ModelSerializer): designation=serializers.StringRelatedField() class Meta: model=UserModal fields=['id', 'username','designation'] im getting designation values as string { "status": true, "data": [ { "id": 3, "username": "akhil", "designation": "agent" } ] } why im not getting values in previous way ? -
source parameter in django serializer not working
I am trying to serialize a nested request body data (just the part of it) body - { "context": { "timestamp": "2022-10-13T09:48:47.905Z", }, "message": { "intent": { "item": { "descriptor": { "name": "apple" } }, }}} serializer class SearchSerilizer(serializers.Serializer): timestamp = serializers.CharField(source="context.timestamp", max_length=35) Caller snippet serializer = SearchSerilizer(data=request.data) if serializer.is_valid(): print(serializer.data) return Response(serializer.data) else: print(serializer.errors) return Response(serializer.errors) And it prints {'timestamp': [ErrorDetail(string='This field is required.', code='required')]} -
installation of Virtual Environment for Django
Is it necessary every time after shutdown I need to create virtual environment for the Django project I'm doing. correct me in Some ways possible . -
for loop in Django for custom n number of times
I want to run for loop based on the number of each individual model entry, I have a testimonial model and one of its field is ratings(and integer field) I want to run a for-loop for n times, where n=ratings value for that particular entry. for ex: here ratings = 4 I want to run for-loop for 4 times so that I can show 4 stars in the testimonial section. I tried doing this:(which of course is the wrong method, displayed just for sake demonstration of what I want) the models.py looks something like this: -
How to modify the display of a validation error in Django?
I wanted to create simple datepicker that does not accept back dates. Within my models.py I have defined MealDay class and standalone functionvalidate_pub_date. The logic behin works just fine, but I do not understand the way Django is showing up the ValidationError("Date can't be past!"). Why this is where it is, and why it seems to be within <li> tag? Is there any possibilty to handle the error within the HTML template or any other way to add some html/css to it? There is how the error looks now: models.py: def validate_pub_date(value): if value < timezone.now() - datetime.timedelta(days=1): raise ValidationError("Date can't be past!") return value class MealDay(models.Model): day = models.DateTimeField(default=timezone.now().day, validators = [validate_pub_date]) breakfast = models.TextField(max_length=100, blank=True) lunch = models.TextField(max_length=100) dinner = models.TextField(max_length=100, blank=True) views.py class MealdayCreateView(CreateView): model = MealDay template_name = "mealplanner/mealday_new.html" form_class = CreateMealdayForm forms.py class CreateMealdayForm(ModelForm): class Meta: model = MealDay fields = '__all__' widgets = { 'day': forms.DateInput(attrs={'type':'date'}), } mealday_new.html {% extends "mealplanner/base.html" %} {% block content %} <h1>Plan your meals!</h1> <form action="" method="post"> {% csrf_token %} {{ form.as_p }} <input type="submit" value="Save"> </form> {% endblock content %} {% endblock content %} -
How to structure the user model for todo list Django
So my boss wants me to learn django in one week i have no experience at all im stuck in a tutorial hell so to escape hell, im going to make a simple api for a todo list app. As of right now , i have developed endpoints for GET and POST but i want every list for a new user so, { users:[ { user_1: Tasks: [ { 'task1':abc, } ] } ] } Please help -
How to resolve this issue when building a docker image of a Django app
I'm trying to dockerize my django app but I'm having an issue where the CMD isn't recognizing the "python3" command. I created the requirements.txt, Dockerfile and .dockerignore file in the root directory and the Dockerfile contains the follow: FROM python:3.8-slim-buster WORKDIR /app COPY requirements.txt requirements.txt RUN pip install -r requirements.txt COPY . . CMD [ "python3", "manage.py", "runserver", "0.0.0.0:8000" ] I'm using VS Code and the intellisense is highlighting all the items in the CMD list as an error. When I try to build the image, I'm getting the following error: Error response from daemon: dockerfile parse error line 12: unknown instruction: "PYTHON3", Can anyone provide any possible solutions to the problem? -
Limit scope of external css to only a specific page?
I am creating a django project using HTML5, and CSS,. while extending the base.html to other files ,when I load in a new css file, it (obviously) overrides the one I'm using to style the page, and therefore most of the elements are affected like a tag and others. so is there Limit scope of external css to only a specific file.? Please tell me some solution i am a beginner and i am frustrated by this -
How to make dropdown menu for year at top side for orders statics page at Django?
I have 3 years of customer order information. I created a order statics page with Django. But years section not dynamic. This stats page getting datas with this_year = datetime.now().year. That's why displaying only in this years (2022) stats. I want to selectable a dropdown menu. When select previous year 2021, this year will be this_year = 2021. And will be display previous year's stats. How can make a menu for previous years? this_year = datetime.now().year - 1 ? Thank you. Some codes from views.py total_payment = ( orders.filter( date_created__month=this_month, date_created__year=this_year, status="Completed", ) .aggregate(Sum("payment")) .get("payment__sum") or 0 ) -
pyehon - TypeError: unhashable type: 'dict' [duplicate]
This piece of code is giving me an error unhashable type: dict can anyone explain to me what the solution is? cls.url_index = {'/': 'index.html'} cls.url_profile = {f'/profile/{cls.user.username}/': 'profile.html'} cls.url_group_list = {f'/group/{cls.group.slug}/': 'group_list.html'} cls.url_create = {'/create/': 'posts/post_create.html'}, cls.url_edit = {f'/posts/{cls.post.id}/edit/': 'posts/post_edit.html'} cls.url_post_detail = {f'posts/{cls.post.id}/': 'posts/post_detail.html'} cls.redirect_edit = {f'/auth/login/?next=/posts/{cls.post.id}/edit/'} cls.redirect_create = {'/auth/login/?next=/create/'} cls.url_fake = '/fake_page/' cls.ok = HTTPStatus.OK cls.not_found = HTTPStatus.NOT_FOUND ` def test_list_url_exists_at_desired_location(self): urls_posts = { self.url_index: self.ok, self.url_group_list: self.ok, self.url_profile: self.ok, self.url_post_detail: self.ok, self.url_fake: self.not_found, }` -
why authenticate is not working for user objects despite having objects saved in admin panel in Django
here is my loginHtml code <form method="post" action="handleLogin_url" enctype="multipart/form-data"> {{ tryAgain }} <br> {% csrf_token %} <label for="username">Enter Username</label><input id="username" name="username" type="text"> <label for="password">Enter password</label><input id='password' name="password" type="password"> <input type="submit" value="Lets Go"> views.py def handleLogin(HttpRequest): if HttpRequest.method=='POST': enteredname = HttpRequest.POST['username'] # user = User.objects.get(username=enteredname) enteredpassword = HttpRequest.POST['password'] user = authenticate( HttpRequest, username=enteredname,password=enteredpassword) # return render(HttpRequest, 'seeData.html', # {'User': user, 'enteredname': enteredname, 'enteredpassword': enteredpassword}) if user is not None: return render(HttpRequest, 'seeData.html', {'Users':user, 'enteredname':enteredname, 'enteredpassword':enteredpassword}) else : tryAgain = "Invalid username or password try again" return render(HttpRequest, 'LoginHtml.html', {'tryAgain':tryAgain}) else: return render(HttpRequest,'LoginHtml.html') seeDataHtml code {{ User.username }},{{ User.password }}||{{ enteredname }} {{ enteredpassword }} when I try using superuser credentials a superuser object is returned but when I use a user credential no object is returned but when I log into admin site I can see user objects -
How do i initialize value of a form using django sessions
class StudentAnswerForm(ModelForm): questionid = forms.ModelChoiceField(widget=forms.Select(), queryset=Quiz.objects.only('questionid')) studentanswer = forms.CharField(widget=forms.TextInput()) quizid = forms.ModelChoiceField(widget=forms.Select(), queryset=Quiz.objects.only('quizid')) username = forms.CharField(widget=forms.TextInput(),initial=request.session['username']) class Meta: model = StudentAnswer fields = ['quizid','questionid','studentanswer'] #fields = ['student_answer'] my views class AnswerQuiz(View): template = 'ansQuiz.html' def get(self, request): form = StudentAnswerForm() request.session['visits'] = int(request.session.get('visits', 0)) + 1 quiz = Quiz.objects.all() #get data from all objects on Quiz model return render(request, self.template,{'quiz':quiz, 'form':form}) def post(self,request): form = StudentAnswerForm(request.POST) if form.is_valid(): form.save() return render(request, self.template, {'form':form}) -
Many to Many relationship - Returning "main.ModelName.None"
I am trying to return a few values from other models via a ManyToManyField. It's returning main.ModelName.None in the template. The data is visible through the admin panel. As a result, I am assuming the problem is linked to the views or the way I render the data in HTML. I found a few post on the topic with the same problem but it seems there were dealing with an error message that I am not getting. In my case, I just cant render the data. Here is the code: models.py class Project(models.Model): name = models.CharField(verbose_name="Name",max_length=100, blank=True) def __str__(self): return str(self.name) if self.name else '' class Product(models.Model): project = models.ManyToManyField(Project, blank=True, related_name="available_products") class Meta: db_table='Product' def __str__(self): return str(self.name) views.py def show_product(request, product_id): products = Product.objects.get(pk=product_id) return render(request, 'main/show_product.html',{'products':products}) template <h6>Project Name</h6> {{ products.project }} This returns main.Project.None -
I want to know about using required=False in a DRF Serializer
I have a Serializer (not a model serializer) class DummySerializer(serializers.Serializer): clas = serializers.CharField() section = serializers.CharField(required=False) Now, when I give blank input ("") to "section" while PUT, then I receieve error (though I have given required=False) as { "section": [ "This field may not be blank." ] } I want something like this, If I give both "clas" and "section" as input then my request.data should give {"clas": "my_input", "section": "my_input"} and when I give only "clas" then request.data should give {"clas": "my_input" } NOT {"clas": "my_input", "section": ""} Then in my view, I want to give a default value to a variable based on field "section" is there or not as var = request.data.get("section", "default_val") can someone pls help here, how to achieve this behaviour. -
how to set model.field equal to a foreignkey,s model.field value django if no value is provided in the form?
class Album(TimeStampedModel): name = models.CharField(default='New Album' , max_length = 80) release_datetime = models.DateTimeField(blank = False) cost = models.DecimalField(blank = False, decimal_places = 2,max_digits = 15) artist = models.ForeignKey(Artist, on_delete=models.CASCADE) is_approved = models.BooleanField(default=False) def __str__(self): return (f"id: {self.id} \n name: {self.name} cost: {self.cost} \n approved : {self.is_approved}") class Song(models.Model): album = models.ForeignKey(Album, on_delete=models.CASCADE) name = models.CharField(blank = True , max_length = 80) image = models.ImageField(blank = False) thumbnail = ImageSpecField(format='JPEG') I want to make Song.name = album.name if supplied name from form is = "" (empty) how can I do this thanks in advance class Song(models.Model): # album = models.ForeignKey(Album, on_delete=models.CASCADE) name = models.CharField(blank?album.name) # image = models.ImageField(blank = False) # thumbnail = ImageSpecField(format='JPEG') something like that -
Django Custom Model Class,AttributeError has no attributes
From the online examples, this piece of code should create a model class that I can migrate. However, when ever I try to migrate, it keeps on telling me "AttributeError: type object 'Foo' has no attribute 'REQUIRED_FIELDS', or "USERNAME_FIELD" , and then keep on going. I don't understand why it makes me create these fields but in tutorials the code works without them. from django.db import models class Foo(models.Model): pass -
Exception Type: KeyError when registering a new user using a custom made register model
Whenever I try to register a new user when i receive an Exception Type: KeyError error. There seem to be something wrong with the submitted password but I don't understand the issue in depth. Can someone please explain this error to me? And perhaps how to solve it as well. The user is created, I can see that in the admin page. I also want the user to sign in when the account is created. I appreciate all inputs! <3 My model: from django.db import models from django.contrib.auth.models import AbstractBaseUser, User, PermissionsMixin from django.utils import timezone from django.utils.translation import gettext_lazy as _ from generalpage.managers import CustomUserRegisterManager from django.conf import settings from generalpage.managers import CustomUserRegisterManager class UserRegister(AbstractBaseUser, PermissionsMixin): user = models.OneToOneField(settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE) username = models.CharField(_("Användarnamn"), max_length=100, null=True, unique=True) age = models.IntegerField(_("Ålder"),null=True, blank=False) email = models.EmailField(_("E-mail"), unique=True, null=False) country = models.CharField(_("Land"),max_length=50, null=True, blank=True) county = models.CharField(_("Län"),max_length=50, null=True, blank=True) city = models.CharField(_("Stad"),max_length=50, null=True, blank=True) profile_picture = models.ImageField(_("Profilbild"),null=True, blank=True, default="avatar.svg", upload_to = "static/images/user_profile_pics/") is_staff = models.BooleanField(default=False) is_active = models.BooleanField(default=False) date_joined = models.DateTimeField(default=timezone.now) USERNAME_FIELD = 'email' # defines the unique identifier for the User model REQUIRED_FIELDS = ["username"] # A list of the field names that will be prompted for when creating a user … -
nginx django project nginx.conf
I have a django project. I'm trying to get my project on the server. I have my project on the server, but I'm having a problem with nginx. In connection with this, my css is not visible. Error: nginx: [emerg] unknown directive "etc/nginx/nginx.conf" in /etc/nginx/nginx.conf:7 nginx: configuration file /etc/nginx/nginx.conf test failed etc/nginx/nginx.conf enter code here etc/nginx/nginx.conf -# For more information on configuration, see: -# * Official English Documentation: http://nginx.org/en/docs/ -# * Official Russian Documentation: http://nginx.org/ru/docs/ user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; -# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 4096; include /etc/nginx/mime.types; default_type application/octet-stream; -# Load modular configuration files from the /etc/nginx/conf.d directory. -# See http://nginx.org/en/docs/ngx_core_module.html#include -# for more information. include /etc/nginx/conf.d/*.conf; server { listen 81; listen [::]:81; server_name __; root /usr/share/nginx/html; # Load configuration files for the default server block. include /etc/nginx/default.d/*.conf; error_page 404 /404.html; location = /404.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } location /static/ { root /home/username/public_html/; expires 1d; } } -# Settings for a … -
multiple file upload with reactjs form and Django backend not working
I created backend to upload multiple images with some text and multiple documents using django rest framework. I tested the backend with postman and upload works fine! when i upload files with react form, backend throws error with request.FILES empty. I am using React 17.0.2 version and next 12.0.4 Django version is 3.2.14 and rest-framework version is 3.13.1 Below is the code of react submit form. i am able to see the files in the console is submit form handler. const submitForm = async e => { const formData = new FormData() formData.append('name', e.formData.name) formData.append('city', e.formData.city) formData.append('email', e.formData.city) formData.append('images', e.formData.images) formData.append('email', e.formData.email) formData.append('mobile', e.formData.mobile) formData.append('docs', e.formData.req_doc) formData.append('description', e.formData.description) let url = 'http://localhost:3000/requirement/requirements/' fetch(url, { method: 'POST', headers: { Accept: '*/*', 'Accept-Encoding': 'gzip, deflate, br', content_type: 'multipart/form-data; boundary=<calculated when request is sent>' }, body: formData }).then(function (response) { console.log(response) }) i am also attaching the screenshot of request from browser which shows the images and files being sent in request. https://i.imgur.com/Ni5pm84.png The Django backend code where error occurs is below. class RequirementSerializer(serializers.ModelSerializer): images = RequirementImageSerializer(many=True, required=False) requirement_files = RequirementDocSerializer(many=True, required=False) class Meta: model = Requirement fields = ['id', 'name','description', 'email', 'mobile', 'city', 'created_at', 'updated_at','images','requirement_files'] # def validate_name(self,value): # if(value == "sumit"): … -
Is django storage sftp reliable method for uploading multiple small files uploaded by user to server?
Due to s3 unpredictable requests count on file upload and get, I want to use my own file server. The best method I have found so far is Sftp django storage but I am curious if it is reliable or not. I will use it for uploading images by multiple users say 10000 images per day by 1000 users. My application server and file server will be diferrent. So I am asking if it is a good approach or not? If it is not what method do you advise me to use? -
django + nginx on Docker (400) Bad Request
Although I tried every method raised in StackOverFlow, I cannot solve the problem. When I want to login my site, the error shows up. What I tried ALLOWED_HOSTS = ['*'] Removing underscore from the name of hosts Putting the name of upstream in nginx.conf Putting some stuff for nginx.conf as the following nginx.conf file settings.py ALLOWED_HOSTS = os.environ.get("DJANGO_ALLOWED_HOSTS").split(" ") env.prod DEBUG=Fault DJANGO_ALLOWED_HOSTS=localhost 127.0.0.1 [::1] ecap nginx.conf upstream ecap { server web:8000; } server { listen 80; location / { proxy_pass http://ecap; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; proxy_redirect off; } location /staticfiles/ { alias /home/app/web/staticfiles/; } location /mediafiles/ { alias /home/app/web/mediafiles/; } } docker-compose.prod.yml version: '3.8' services: web: build: context: ./app dockerfile: Dockerfile.prod command: gunicorn ecap.wsgi:application --bind 0.0.0.0:8000 volumes: - static_volume:/home/app/web/staticfiles - media_volume:/home/app/web/mediafiles expose: - 8000 env_file: - ./.env.prod depends_on: - db db: image: postgres:13.0-alpine volumes: - postgres_data:/var/lib/postgresql/data/ env_file: - ./.env.prod.db nginx: build: ./nginx volumes: - ./static_volume:/home/app/web/staticfiles - ./media_volume:/home/app/web/mediafiles ports: - 1337:80 depends_on: - web volumes: postgres_data: static_volume: media_volume: log ecap5-nginx-1 | 192.168.192.1 - - [15/Oct/2022:10:17:30 +0000] "POST /login/%7Burl%20'Login'%20%%7D HTTP/1.1" 400 157 "-" "-" "-" I appreciate your cooperation.