Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
__str__ returned non-string (type ManyRelatedManager)
I'm getting this error after adding the get_cliente to my serializer: TypeError at /pedido __str__ returned non-string (type ManyRelatedManager) What can I do to fix it? This is the serializer: class PedidoSerializer(serializers.ModelSerializer): cliente = serializers.SerializerMethodField() class Meta: model = Pedido fields = ('fecha','pizzas','telefono','email', 'cliente') def validate(self, data): email = data.get('email') telefono = data.get('telefono') if not email and not telefono: raise serializers.ValidationError("Se requiere email o telefono") return data def get_cliente(self, data): try: if Cliente.objects.filter(email=data).exists() or Cliente.objects.filter(telefono=data).exists(): selected_cliente = Cliente.objects.all() return ClienteSerializer(selected_cliente, many=True).data except Cliente.DoesNotExist: return None -
Access items from within a list of objects
I am trying to retrieve all of the userstories from a list of sprints which have a particular group that the user logged in is a part of. I have been able to get all of the sprints using a for loop: {% for sprint in user.groups.all.0.sprints.all %} I want to be able to get the items from within each sprint that I have retrieved using the above loop. How would I go about this? Thanks! -
Django: how to pass a table id in a button to delete view
So some context: I have for example a specific car with it's description on : http://localhost:8000/vehicle/1 (not the pk of the vehicle here. On this page you can apart from changing data and so on you can also add all types of documents and there is a table showing your uploaded documents: Document table HTML <h4>Overview Documents</h4> <div class="row"> <div class="col"> <div class="table-responsive"> <table class="table table-striped table-sm"> <thead> <tr> <th>#</th> <th>PDF Name</th> <th></th> <th></th> </tr> </thead> <tbody> {% for item in all_docs %} <tr> <td>{{ forloop.counter }}</td> <td> {{ item.pdf.namepdf|default_if_none:'' }} </td> <td><button class="btn btn-sm btn-secondary" type="button" name="delete_vehdoc">Delete</button> </td> This is my views.PY def updatevehicle(request, pk): ... all_docs = DOC_PDF_Vehicles.objects.filter(vehicle=pk, user=request.user) context = {"all_docs": all_docs} if request.method == "POST" and 'delete_vehdoc' in request.POST: vehdoc = DOC_PDF_Vehicles.objects.get(id=id, user=request.user) vehdoc.delete() return redirect('update_vehicle', pk=pk) Now the issue is as you can see here. I use a lot of ID's and PK's In my delete view you can see i use an id to retrieve the correct db record but I have atm no idea how to give that ID from my template to the view. Please also note that I basically refresh the original page (which also has an pk) to update the … -
How to push postgresql to docker hub
I'm trying to upload my project to docker hub. I followed this tutorial https://docs.docker.com/compose/django/. I use docker-compose and it works great for me, but I cannot upload it to the docker hub. I am using docker-compose push and it only pushes a project image without a base. I would like the base to also go to the dockhub docker-compose.yml version: "3.9" services: db: image: postgres volumes: - ./data/db:/var/lib/postgresql/data environment: - POSTGRES_DB=postgres - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres web: build: . command: python manage.py runserver 0.0.0.0:8000 volumes: - .:/code ports: - "8000:8000" depends_on: - db dockerfile FROM python:3 ENV PYTHONUNBUFFERED=1 WORKDIR /code COPY requirements.txt /code/ RUN pip install -r requirements.txt COPY . /code/ -
DRF serializer with dynamic model
I have more than 10 serializers like this one, and in each of them I just change the model name. It sounds like code repetition. serializers.py class xSerializer(serializers.ModelSerializer): class Meta: model = x fields = '__all__' read_only_fields = ['a', 'b', 'c', 'd'] class ySerializer(serializers.ModelSerializer): class Meta: model = y fields = '__all__' read_only_fields = ['a', 'b', 'c', 'd'] views.py class xViewSet(viewsets.ModelViewSet): serializer_class = xSerializer Can I dynamically make a serializer structure similar to this in "DRF"? (Also, if such a thing is possible, can I do it for "fields"? If I want to send which "field" will be in "viewset") class xViewSet(viewsets.ModelViewSet): serializer_class = GeneralSerializer(model_name,fields) -
Deploy App on Heroku give error - Could not build wheels for twisted-iocpsupport which use PEP 517 and cannot be installed directly
I am trying to deploy a django app on heroku from GitHub. When I try to deploy, I am getting the following error- Failed to build twisted-iocpsupport ERROR: Could not build wheels for twisted-iocpsupport which use PEP 517 and cannot be installed directly ! Push rejected, failed to compile Python app. ! Push failed All of my python packages are up to data. Version info: python - 3.8.7, pip - 21.0.1, django - 3.2, wheel - 0.36.2, pyinstaller - 4.3, twisted-iocpsupport - 1.0.1 How to fix the problem? -
AttribueError with Django and mysql connector python
I was using SQLite for my django database and i want to use a MariaDb on my Synology NAS. I use Django 3.2 on Python 3.9.0+ and MariaDB 10.3.24 I use pip package mysql-connector-python==8.0.23 as mysql connector. DATABASES = { 'default': { 'ENGINE': 'mysql.connector.django', 'NAME': 'energyHomeWeb_django', 'USER': 'energyHomeWeb', 'PASSWORD': 'password', 'HOST': '192.168.1.123', 'PORT': '3307', 'OPTIONS': { 'autocommit': True, }, } } When i want to start or migrate my server I have this error : Exception in thread django-main-thread: Traceback (most recent call last): File "/usr/lib/python3.9/threading.py", line 950, in _bootstrap_inner self.run() File "/usr/lib/python3.9/threading.py", line 888, in run self._target(*self._args, **self._kwargs) File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run self.check_migrations() File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/core/management/base.py", line 486, in check_migrations executor = MigrationExecutor(connections[DEFAULT_DB_ALIAS]) File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/db/migrations/executor.py", line 18, in __init__ self.loader = MigrationLoader(self.connection) File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/db/migrations/loader.py", line 53, in __init__ self.build_graph() File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/db/migrations/loader.py", line 220, in build_graph self.applied_migrations = recorder.applied_migrations() File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 77, in applied_migrations if self.has_table(): File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/db/migrations/recorder.py", line 55, in has_table with self.connection.cursor() as cursor: File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner return func(*args, **kwargs) File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/db/backends/base/base.py", line 259, in cursor return self._cursor() File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/db/backends/base/base.py", line 235, in _cursor self.ensure_connection() File "/home/iomys/.virtualenvs/energyHomeWeb/lib/python3.9/site-packages/django/utils/asyncio.py", line 26, in inner return func(*args, **kwargs) File … -
Why do I keep getting AttributeError after updating my code and deleting the function that's giving me the error?
so I keep getting AttributeError because of a function that I added and then deleted, as if there was some trace of it still in my code somehow. How can I fix it? This is the serializer giving me the error: class PedidoSerializer(serializers.ModelSerializer): cliente = serializers.SerializerMethodField() class Meta: model = Pedido fields = ('fecha','pizzas','telefono','email', 'cliente') def validate(self, data): email = data.get('email') telefono = data.get('telefono') if not email and not telefono: raise serializers.ValidationError("Se requiere email o telefono") elif email or telefono: try: selected_cliente = Cliente.objects.all() return ClienteSerializer(selected_cliente, many=True).data except Cliente.DoesNotExist: return None else: return data I had originally added a def get_cliente but then I just added its functions to the def validate. The error says: 'PedidoSerializer' object has no attribute 'get_cliente' -
I trial get all comments for Post and add user in NotfFaId ,
I trial get all comments for Post and add user in NotfFaId I don't understand how fix it. , The QuerySet value for an exact lookup must be limited to one result using slicing. def topic_single(request, post): post = get_object_or_404(Topic, slug=post, status='published') postcat = Topic.objects.filter(category=post.category) # print(post.comments.all()) fav = bool random_items = Topic.newmanager.all().order_by('?')[0:9] if post.favourites.filter(id=request.user.id).exists(): fav = True session_key = 'view_post_{}'.format(post) if not request.session.get(session_key,False): post.views +=1 post.save() request.session[session_key] = True allcomments = post.comments.filter(status=True) CommentT.objects.get(id=allcomments).NotfFaId.add(request.user) comment_form = NewCommentTForm() return render(request, 'forum/detail.html', {'post': post, 'comment_form': comment_form, 'allcomments': allcomments, 'random_items': random_items, 'Category': Category.objects.all(),'Category2': postcat, 'fav': fav}) model class CommentT(MPTTModel): Topic = models.ForeignKey(Topic, on_delete=models.CASCADE, related_name='comments') author = models.ForeignKey( User, on_delete=models.CASCADE, related_name='author') parent = TreeForeignKey('self', on_delete=models.CASCADE, null=True, blank=True, related_name='children') NotfFaId = models.ManyToManyField( User, related_name='NotfFaVId', default=None, blank=True) content = models.TextField() publish = models.DateTimeField(auto_now_add=True) status = models.BooleanField(default=True) class MPTTMeta: order_insertion_by = ['publish'] -
How to query a JSONField comprising a list of values in DJANGO
I am using JSONField to store the configuration parameter(user_types) as a list as follows: ["user_type1", "user_type2", "user_type3"] How to query to filter elements of type "user_type1"? The following query is not working: rows=ConfigUserTable.objects.filter(user_types__in=["user_type1"]) Thanks -
Django multiplechoicefield always renders None
I made a multiplechoicefield form (to ask what category user wants to select), but i can't get the answer back...it always renders "None". I added some 'print' in the code to be sure that it was the problem and it is. I don't understand why. forms.py: class Category(forms.ModelForm): class Meta: model = Auctions fields = ("category",) #fields = ('category',) #widgets = {'category' : forms.RadioSelect()} catform = forms.MultipleChoiceField(choices=fields, widget=forms.CheckboxSelectMultiple()) models.py ''' class Auctions(models.Model): Category = [('FASHION', 'Fashion'),('TOYS','Toys'),('ELECTRONICS','Electronics'),('HOME','Home')] ID_auction = models.AutoField(primary_key = True) title = models.CharField(max_length = 80) description = models.TextField() startingbid = models.IntegerField() image = models.URLField(blank = True) category = models.CharField(max_length = 80, choices = Category) author_id = models.ForeignKey(User,on_delete = models.CASCADE, related_name = "auteur") highest_bid = models.IntegerField("Bid", blank = True, null = True) buyer = models.ForeignKey(User, on_delete = models.CASCADE, related_name = "acheteur") active = models.BooleanField(default=True) ''' views.py ''' def filter_cat(request): if request.method == "POST": form = Category(request.POST) print(form) if form.is_valid(): cat = form.cleaned_data.get("catform") print(cat) auctions = Auctions.objects.filter(category = cat) return render(request, "auctions/index.html",{ 'active_listing' : auctions, 'cat' : cat }) else : form = Category() return render(request, "auctions/filter_cat.html",{'form' : form}) ''' when I select FASHION for example i get this on the terminal : for print(form): Category: --------- Fashion Toys Electronics Home … -
File name repeating in nginx
I'm trying to setup django project to work with gunicorn and nginx server. With DEBUG=FALSE. I see in nginx log that static word is repeated twice thus changing the path. # settings.py """ Django settings for cognizance project. Generated by 'django-admin startproject' using Django 3.2. For more information on this file, see https://docs.djangoproject.com/en/3.2/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/3.2/ref/settings/ """ import os from pathlib import Path import sys # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = '<SECRET>' # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ALLOWED_HOSTS = ['127.0.0.1'] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'pages' ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'cognizance.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'cognizance.wsgi.application' # Database # https://docs.djangoproject.com/en/3.2/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # … -
Build an API, Without using inbuilt User Class
Create APIs for the mentioned points in a complete flow: Sign up user by taking email address, unique username and password Password should be saved in database in encrypted form Once user register, sign in user by their username and password Implement forget password by taking their email address and username. Mail their unique system generated random password on their registered email address. Reset password functionality by taking their username, current password and new password in the request. Logout user Use JWT Token after signing in and fetch their username from token in all the request after sign in. -
'function' object has no attribute 'order_by'
i am creating a simple blog website in django and have a model which contains time at which the blog will be published when in views i am trying to sort the post according to time it is giving error 'function' object has no attribute 'order_by' my views.py: class AboutView(TemplateView): template_name = 'blog/about.html' class Postlistview(ListView): model = Post def get_queryset(self): return Post.objects.filter(published_date__lte=timezone.now.order_by('-published_date')) my models.py : class Post(models.Model): author = models.ForeignKey('auth.User', on_delete=models.CASCADE) title = models.CharField(max_length=100) text = models.TextField(max_length=200) created_date = models.DateTimeField(default=timezone.now) published_date = models.DateTimeField(blank=True, null=True) def publish(self): self.published_date = models.DateTimeField(default=timezone.now) self.save() def get_absolute_url(self): return reverse('post_detail', kwargs={'pk': self.pk}) def approve_comments(self): return self.comments.filter(approved_comments=True) def __str__(self): return self.title class Comment(models.Model): post = models.ForeignKey('blog.Post', related_name='comments', on_delete=models.CASCADE) text = models.CharField(max_length=200) author = models.CharField(max_length=20) create_date = models.DurationField(default=timezone.now) approved_comments = models.BooleanField(default=False) def approve(self): self.approved_comments = True self.save() def get_absolute_url(self): return reverse('post_list') def __str__(self): return self.text -
DJANGO RESET PASSWORD THROUGH EMAIL
Iam getting this error whenever I try to run the script to reset django password through mail this is my code EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' EMAIL_HOST = 'smtp.gmail.com' EMAIL_HOST_USER = 'sellme.onchuru@gmail.com' EMAIL_HOST_PASSWORD = '#######' EMAIL_PORT = 587 EMAIL_USE_TLS = True and in urls path('reset_password', auth_views.PasswordResetView.as_view(), name='reset_password'), path('reset_password_sent', auth_views.PasswordResetDoneView.as_view(), name='password_reset_done'), path('reset/<uidb64>/<token>', auth_views.PasswordResetConfirmView.as_view(), name='password_reset_confirm'), path('reset_password', auth_views.PasswordResetCompleteView.as_view(), name='password_reset_complete'), path('logout',views.logout_request, name='logout'), Iam not getting it where am I going wrong even after turning on allow less secure apps? -
Django admin update a value automatically when some value is updated
In my model below, I want to automatically update the value of previous_location when the value of location is updated inside django administration. How do I implement this? Thank you in advance. class Finder(models.Model): name = models.CharField(max_length=50, default="") location = models.CharField(max_length=50, default="") previous_location = models.CharField(max_length=50, default="") -
Django POST request always return 400 even the method is successful
I am working on a Django project and I am making a simple API for creating users. The problem is, the post request can be performed successfully as I check the backends. However, it always returns the 400 error code as the last line shown. My views.py code is as following: class createUserView(APIView): serializer_class = CreateUserSerializer def post(self, request, format=None): serializer = self.serializer_class(data = request.data) if serializer.is_valid(): name = serializer.data.get('name') age = serializer.data.get('age') queryset = user.objects.filter(name=name) if queryset.exists(): print("already exists") new_user = user(name=name, age=age) # new_user.save() return Response(userSerializer(new_user).data, status=status.HTTP_200) else: new_user = user(name = name,age=age) new_user.save() return Response(userSerializer(new_user).data, status=status.HTTP_201_CREATED) return Response({'Bad Request': 'Invalid data...'}, status=status.HTTP_400_BAD_REQUEST) my models.py code is as following: from django.db import models # Create your models here. class user(models.Model): name = models.CharField(max_length=20, unique=True,null=False, default=None) age = models.IntegerField(null=False, default=1) created_at = models.DateTimeField(auto_now_add=True) I think the problem is in the views.py. Whenever the code enters the user.save() block, the return statement does not work so the code keep running until the last line. -
Django - Multiple permissions in a view
I want to create a permission for a view that would verify that the user is either the owner of a shop or an admin. I have already created two permissions which work well when called separately which checks for one that the user is admin and for the other that the user is the owner of the shop. I would now like to make a global condition verifying that one of the two conditions is met. Here are my departure conditions : utils.py class IsOwner(BasePermission): """ Check if the user who made the request is owner. Use like that : permission_classes = [IsOwner] """ def has_permission(self, request, view): return request.user and request.user.is_authenticated def has_object_permission(self, request, view, obj): try: user_shop = UserShop.objects.get(user=request.user, shop=obj) return True except: return False class IsAdmin(BasePermission): """ Check if the user who made the request is admin. Use like that : permission_classes = [IsAdmin] """ def has_permission(self, request, view): if not 'Authorization' in request.headers: return False else: return request.user.is_admin class OwnerView(GenericAPIView): """ Check if a user is owner """ permission_classes = (IsOwner,) class AdminView(APIView): """ Check if a user is admin """ permission_classes = (IsAdmin,) Here is the function I am trying to do : class … -
django uses wrong django version, although I installed a specific version with pipenv
I created a django project and installed django version 3.1.0 using: pipenv install django~=3.1.0 then I activated the shell using: pipenv shell everything worked fine. No errors. However, when I run the server, it says I'm running django version 3.1.8, which I installed globally earlier but uninstalled afterwards. -
Database structure and django models
How would you create your Django models to have the following structure: 1. A table of inventory items (ok, easy). 2. A table to store report templates (WeeklyReport, MonthlyReport) with some of the inventory items from the table 1 (ok, easy) 3. A table with all instances of the generated reports. For example: Weekly Report, Monthly report, but each report can have only the items from the template. (how to enforce this kind of relationship?) I hope the image attached could explain my needs. Tables -
Deploying django + mysql + images
I'm a complete beginner and I need to deploy a django project with mySql database. It also has a lot of static files(images). It is for a personal project. There are a lot of options like AWS, heroku, python anywhere gcp etc and I'm really confused. How should I go about this? -
Django: aggregate(sum()) repeating the sum in template
I want my data to be displayed like this: Date installment month amount total January 1, 2021 January 30000 30000 February 1, 2021 February 40000 70000 (i.e sum of 30000 and 40000) March 1, 2021 March 30000 100000 (i.e sum of 30000, 40000 and 30000) . . and so on.. For this purpose I am using aggregate() in my InstallmentListView as given below: views.py class InstallmentListView(ListView): model = Installment template_name = 'client_management_system/installment_detail.html' context_object_name = 'installments' # This function is to show the installments of the client, the details of which we are seeing currently, and # pk=self.kwargs['pk'] is to get the client id/pk from URL def get_queryset(self): user = get_object_or_404(Client, pk=self.kwargs['pk']) return Installment.objects.filter(client=user) def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) user = get_object_or_404(Client, pk=self.kwargs['pk']) context['total'] = Installment.objects.filter(client=user).aggregate(Sum('installment_amount')) @register.filter def get_item(total, key): return total.get(key) return context and my template file is given below: template.html <!DOCTYPE html> {% extends "client_management_system/base.html" %} {% block content %} <body> <legend class="border-bottom mb-4"><h5>Installment History</h5></legend> <article class="media content-section"> <div> <table id="installmentTable" style="width:100%"> <tr> <th style="width:150px">Date</th> <th style="width:250px">Installment Month</th> <th style="width:170px">Amount</th> <th style="width:100px">Balance</th> </tr> {% for installment in installments %} <fieldset> <tr> <td>{{ installment.installment_date|date:"F d, Y" }}</td> <td>{{ installment.installment_month }}</td> <td>{{ installment.installment_amount }}</td> <td>{{ total|get_item:'installment_amount__sum' }}</td> </tr> </fieldset> {% … -
How does a search engine discover/crawl a website loaded by a DB?
I am creating a new blog website in Django. All the posts and their details are stored inside an sqlite database (one that comes default with Django). Once a post's URL is requested, the server returns the webpage which contains the post loaded from the database. My question is, since the webpages do not exist until someone types in the URL, how will a search engine such as Google crawl the website and make it show up in the search results if it is relevant to the search? Is it necessary to provide a sitemap for this to happen? -
pillow cant save cropped image in Django
i have forms py with save def which taking float numbers by script when its cropped , i am missing something but in outside cannt find problem , it selects image cropes by visual and when i click save croped it doesnt saves thanks so much forms.py class PhotoForm(forms.ModelForm): x = forms.FloatField(widget=forms.HiddenInput()) y = forms.FloatField(widget=forms.HiddenInput()) width = forms.FloatField(widget=forms.HiddenInput()) height = forms.FloatField(widget=forms.HiddenInput()) class Meta: model = Profile fields = ('name', 'profile_info','picture', 'x', 'y', 'width', 'height',) def save(self): photo = super(PhotoForm, self).save() x = self.cleaned_data.get('x') y = self.cleaned_data.get('y') w = self.cleaned_data.get('width') h = self.cleaned_data.get('height') image = Image.open(photo.picture) cropped_image = image.crop((x, y, w+x, h+y)) resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS) resized_image.save(photo.picture.path) return photo model.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='profile') name = models.CharField(max_length=50, null=True, blank=True , default='') profile_info = models.TextField(max_length=150, null=True, blank=True, default='') created = models.DateField(auto_now_add=True) favorites = models.ManyToManyField(Post) picture = models.ImageField() def __str__(self): return self.user.username views.py @login_required def EditProfile(request): user = request.user.id profile = Profile.objects.get(user__id=user) BASE_WIDTH = 400 if request.method == 'POST': form = PhotoForm(request.POST, request.FILES) if form.is_valid(): profile.name = form.cleaned_data.get('name') profile.profile_info = form.cleaned_data.get('profile_info') profile.save() return redirect('index') else: form = PhotoForm() context = { 'form':form, 'profile': profile } return render(request, 'edit_profile.html', context) and html edit profile whichhave modal to crop image i … -
Django app exited with code 252 on Docker
I am new to Docker, currently I am trying to deploy my app in a container. I have made 2 containers one for the DB and one for the app. But when I am trying to run my docker-compose file the app container exists with exit code 252. Here are the logs - web_1 | Watching for file changes with StatReloader web_1 | Performing system checks... web_1 | mushroomxpert_web_1 exited with code 252 This is my docker-compose file version: '3.7' services: web: image: mushroomxpert build: context: ./web # command: 'gunicorn MushroomXpert.wsgi --log-file -' command: python manage.py runserver 0.0.0.0:8000 ports: - '8000:8000' environment: - ALLOWED_HOSTS=localhost - DEBUF=False - DB_NAME=mushroomxpert_db - DB_USER=mushroom_admin - DB_PASSWORD=chikchik1 - DB_HOST=db - DB_PORT=5432 depends_on: - db db: image: postgres environment: - POSTGRES_PASSWORD=chikchik1 - POSTGRES_USER=mushroom_admin - POSTGRES_DB=mushroomxpert_db