Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Python Multii User Auth
I want to create a project in Python, Django. So I will be the admin. I will allow employer to create their system that allows their employee to login. How would I do so? I cant find any documentation on it. Employer will have to create employee account. -
Using Falcon with Django ORM
I'm trying to compare a few web frameworks (Falcon/FastAPI, etc...), with a single requirement, using Django's ORM as our method to interact with our DB (the reason at the moment isn't relevant). At the moment I'm focusing on Falcon, but I've already encountered a roadblock. I've set up a Django App, for the ORM portion, but every time I'm trying to access a model from the within the Falcon app, I get a OperationalError('no such table: db_customer') error. The table (db_customer) is there, and I can access it via dbshell or from python code that references to my django settings file directly via DJANGO_SETTINGS_MODULE. ** Please ignore logical code errors, this is just a quick and dirty to check viability and performance ** This is my directory tree: enter link description here app - api/ - customer_resource.py - db/ - dal/ - customer_actions.py - migrations/ - apps.py - manage.py - models.py - settings.py - sqlite.db - main.py Here are my files: models.py import json import django django.setup() from django.db.models import Model, BooleanField, CharField, URLField, DateTimeField class Customer(Model): name = CharField(max_length=100, db_index=True) domain = URLField(max_length=255, null=True) join_date = DateTimeField(auto_created=True, auto_now_add=True, null=True) is_active = BooleanField(default=True) def to_dict(self): return { 'id': self.id, 'name': … -
Python Django URL linking problems
I am working on an online school project, so there is classes in the classes there are subjects in the subjects the is a playlist of lessons. I created tow different playlist one for math lessons and one for English lessons, when I am entering the English Playlist I am seeing English and Math lessons in the same playlist, so Django Is showing me all the lessons I created in the tow playlists, thus I made some, OnetoOne, ManytoMany, ForignKeys relations in the database. How to add math lesson to math playlist and English Lesson to English Playlist?? CODE views.py: def playlist(request, classes_id, list_id): theMaterial=get_object_or_404(Material, pk=list_id) classid=get_object_or_404(Class, pk=classes_id) thePlaylist=get_object_or_404(Playlist, pk=list_id) theList=Playlist.objects thelesson=Lesson.objects context={ 'list':thePlaylist, 'Material': theMaterial, 'playlist':theList, 'class':classid, 'lesson':thelesson } return render(request, 'classes/list.html', context) def lesson(request, classes_id, list_id, lesson_id): playlist=get_object_or_404(Lesson, pk=lesson_id) material=get_object_or_404(Playlist, pk=list_id) theClass=get_object_or_404(Class, pk=classes_id) context={ 'material':material, 'list':playlist, 'class':theClass } return render(request, 'classes/lesson.html', context) models.py: class Playlist(models.Model): title=models.CharField(max_length=200, default="") Material= models.OneToOneField(Material, default=1, on_delete=models.SET_DEFAULT) def __str__(self): return self.title class Lesson(models.Model): video=models.FileField(upload_to="videos", default="") title=models.CharField(max_length=200, default="") description=models.TextField( default="" ) thumbnail=models.ImageField(upload_to="images", default="") Playlist=models.ManyToManyField(Playlist) Material=models.ManyToManyField(Material) classes=models.ManyToManyField(Class) def __str__(self): return self.title webpage: <html> <body> {% for lesson in lesson.all %} <li style="margin-left: 20px;"> <a style="font-family: Arial; font-size: 25px;" href="{% url 'lessons' class.id list.id lesson.id %}">{{lesson.title}} </a></li> … -
I got error ModuleNotFound when I try to import a class from another app
I have a django project named 'LibraryManagement' and there are two apps named book and authors. When I try to import the class from 'authors' models.py I got error ModuleNotFoundError: No module named 'LibraryManagement.authors' Code of models.py of 'authors' app from django.db import models class Authors(models.Model): author_name = models.CharField(max_length=100) description = models.TextField(max_length=300) Code of models.py of 'book' app from django.db import models from LibraryManagement.authors.models import Authors class Book(models.Model): book_name = models.CharField(max_length=100) author = models.ForeignKey(Authors) remarks = models.TextField(max_length=300) -
Filter lookup ignores default custom manager
I'm trying to filter entries of a certain model by doing a lookup in a field of it's one-to-many relationship. The problem is that I have a default custom manager overriding the default queryset which is not taken into account when I do the lookup. If I build a query explicitly using that manager, it does use the default queryset and I get the expected results. But when I do a field lookup from another model it does not. It will be easier to understand by checking the example below: class Ingredient(models.Model): name = CharField() gtin = CharField() def __unicode__(self): return self.name class Package(models.Model): ingredient = ForeignKey(Ingredient, related_manager='packages') size = CharField() active = BooleanField() objects = PackageManager() def __unicode__(self): return self.size class PackageManager(models.Manager): def get_queryset(self): return super(PackageManager, self).get_queryset().filter(active=True) and I have the following entries: ingredient = Ingredient.objects.create(name='Egg', gtin='2344234') package_1 = Package.objects.create(ingredient=ingredient, size='1 unit', active=True) package_2 = Package.objects.create(ingredient=ingredient, size='12 units', active=False) If I retrieve the packages through the related manager, I get only the active ones: ingredient.packages.all() <Package: '1 unit'> But if then I do a filter lookup: Ingredient.objects.filter(packages__size='12 units') <Ingredient: 'egg'> So the Package entry that was not active was not excluded from the lookup. I know I could build … -
DRF - how to 'update' the pk after deleting an object?
a beginner here! here's how im using url path (from the DRF tutorials): path('articles/', views.ArticleList.as_view()), path('articles/<int:pk>/', views.ArticleDetail.as_view()) and i noticed that after deleting an 'Article' (this is my model), the pk stays the same. an Example: 1st Article pk = 1, 2nd Article pk = 2, 3rd Acrticle pk = 3 after deleting the 2n Arctile im expecting -- 1st Article pk = 1, 3rd Artcile pk = 2 yet it remains 3rd Artile pk = 3. is there a better way to impleten the url, maybe the pk is not the variable im looking for? or i should update the list somehow? thnkx -
How to add remote debugger with docker in pycharm where there is some custom parameters after docker compose command
i was trying to add remote debugger to python based Geo Spatial Information CMS . They made a docs to run their system properly in debug mode in docker. But there was no clear instruction to add them in a ide's debugger like pycharm. the three commands that deploys and run their system are: docker-compose -f docker-compose.async.yml -f docker-compose.development.yml up docker-compose stop django docker-compose run \ -e DOCKER_ENV=development \ -e IS_CELERY=False \ -e DEBUG=True \ -e GEONODE_LB_HOST_IP=localhost \ -e GEONODE_LB_PORT=80 \ -e SITEURL=http://localhost/ \ -e ALLOWED_HOSTS="['localhost', ]" \ -e GEOSERVER_PUBLIC_LOCATION=http://localhost/geoserver/ \ -e GEOSERVER_WEB_UI_LOCATION=http://localhost/geoserver/ \ --rm --service-ports django python manage.py runserver --settings=geonode.settings 0.0.0.0:8000 This works on command line and successfully run the project. But i was trying to attach a debugger to the container. So i create a configuration in pycharm like this Docker-compose config and another django server configuration with that remote interpreter: django server with remote debugger of docker container But when i want to debug with django server configuration the ide says that Connection to Python debugger failed: Connection to the debugger script at localhost:52662 timed out you can find their docs here: On the top how can i add --rm --service-ports django python manage.py runserver --settings=geonode.settings 0.0.0.0:8000 … -
How to make Django select box option not selectable?
I have made a Django Form using Django Crispy Forms. I used the Foreign Key concept to display dropdowns in my page. I would like the first option of the dropdown ('Choose..') to be shown to the user but he/she must not be able to select it. It is very easy to do with JavaScript but I'm not sure how to do it with Django. My page with the dropdowns I am also attaching the code for my forms.py and models.py. models.py from django.db import models from django import forms class Organization(models.Model): orgname = models.CharField(max_length = 100, blank=True) def __str__(self): return str(self.orgname) class Team(models.Model): teamID = models.AutoField(primary_key=True) teamName = models.CharField(max_length = 100, blank=True) org = models.ForeignKey(Organization, on_delete=models.CASCADE) def __str__(self): return str(self.teamName) class AgileTeam(models.Model): agileTeamID = models.AutoField(primary_key=True) agileTeamName = models.CharField(max_length = 100, blank=True) org = models.ForeignKey(Organization, on_delete=models.CASCADE) team = models.ForeignKey(Team, on_delete=models.CASCADE) def __str__(self): return str(self.agileTeamName) class Employee(models.Model): name = models.CharField(max_length=100) assoc_id = models.CharField(max_length=10) username = models.CharField(max_length=50, blank=True) password = models.CharField(max_length=50, blank=True) organization = models.ForeignKey(Organization, on_delete=models.CASCADE) team = models.ForeignKey(Team, on_delete=models.CASCADE) agile_team = models.ForeignKey(AgileTeam, on_delete=models.CASCADE) forms.py from django import forms from django.forms import ModelForm from .models import Organization, Team, AgileTeam, Employee class EmployeeForm(forms.ModelForm): password = forms.CharField(widget=forms.PasswordInput(render_value = True)) class Meta: model = Employee … -
Downloading UTF-8-sig csv file to user
I set both content_type and to_csv encoding as utf_8_sig response = HttpResponse(content_type='text/csv;charset=utf_8_sig') response['Content-Disposition'] = 'attachment; filename=somefilename.csv' df.to_csv(path_or_buf=response,sep=',',float_format='%.2f',index=False,decimal=",",encoding='utf_8_sig') and then , send csv to user in javascript //ajax response DownlodCsv(response); const DownloadCsv = (function() { const a = document.createElement("a"); document.body.appendChild(a); a.style = "display: none"; return function(data, fileName) { const blob = new Blob([data], {type: "octet/stream"}), url = window.URL.createObjectURL(blob); a.href = url; a.download = fileName; a.click(); window.URL.revokeObjectURL(url); }; }()); However it still utf-8 not utf-8-sig (because I can't open this by excel) Is there any place I should to check????? -
How to write proper code for Integrity Testing in Django?
I started testing my code and there I wrote a piece of code that will test that if any duplicate name trying to save in database it will rises Integrity Error. First I want to see you my Model: class Company(models.Model): name = models.CharField(max_length=30, primary_key=True,unique=True, validators=[check_valid_characters, check_digit, check_whitespaces]) working_languages = models.ManyToManyField(ProgrammingLanguage, verbose_name='preferred languages') employees = models.IntegerField(blank=False, null=True, verbose_name='number of employees') address = models.CharField(max_length=100, validators=[check_whitespaces]) contact_number = models.CharField(max_length=11, verbose_name='Contact Number', validators=[MinLengthValidator(11),check_valid_mobile_number]) company_website = models.URLField(max_length=200, null=False) def __str__(self): return self.name And Test Case You can see below: def test__when_company_name_duplicate__should_raise_an_error(self): ob1 = Company(name='XYZ',employees='12',address='XYz',contact_number='01784009080',company_website='https://stackoverflow.com/') ob2 = Company(name='XYZ',employees='13',address='XcYz',contact_number='01784009081',company_website='https://stackoverflow.com/new') with self.assertRaises(IntegrityError): ob1.save() ob2.save() After I ran my Testcase the error I am getting is: >>FAIL: test__when_company_name_duplicate__should_raise_an_error (testapp.tests.MyTest) Traceback (most recent call last): File "/home/anik/Works/assignment/task/testapp/tests.py", line 73, in test__when_company_name_duplicate__should_raise_an_error ob2.save() AssertionError: IntegrityError not raised -
Django - Custom default value of a custom dropdown menu
I build a dropdown category selection menu myself to make the search function of my django site more preceise and filterd. This is working pretty fine so far but I was not able to figure out how I can change the default value of my dropdown menu as it's currently showing "--------" and not something like "All" as default selected value. base.html: <div class="my-custom-dropdown"> <a>{{ categorysearch_form.category }}</a> </div> search_context_processor.py: def categorysearch_form(request): form = SearchForm() return {'categorysearch_form': form} does smb. has any idea how this can be accomplished? using the content: parameter at my css only has a very limited bennefit as the lable "All" always gets placed outside of the actual selection box. thanks for reading :) -
Cannot get url from models.py for menu item
I create menu items fro my navigation but I can get everything from models, DB images(icons), name, but when I want to get URL nothing happening. My views for menu def index(request): Post_list = BlogPost.objects.all()[:5] Slider_item = HomePageSlider.objects.all() menu_item = Menu.objects.all() template_name = 'front/index.html' return render(request, template_name, {"Post_list":Post_list, "data_item":Slider_item, "menu_item":menu_item, }) My template HTML {% for menu in menu_item %} <li class="mobile-menu-item"> <a href="{{menu.0.Menu_url}}" class="mobile-menu-item-link">{{menu.Menu_name}}</a> </li> {% endfor %} my models.py for Menu from django.db import models class Menu(models.Model): Menu_name = models.CharField(max_length=100,blank=True) Menu_slug = models.SlugField(name="სლაგი",blank=True) Menu_image = models.ImageField(upload_to="menuimages") Menu_url = models.CharField(name="url",max_length=100,blank=True,null=True) class Meta: verbose_name = "მენიუ" def __str__(self): return self.Menu_name -
django how to get list with foreign key using primary key
i have this scenario where each company have more then one car , i have linked the two models : models.py class Company(models.Model): company_name = models.CharField(max_length=100, primary_key=True, null=False) created_at = models.DateTimeField(auto_created=True, null=True) def __str__(self): return self.company_name class car(models.Model): company = models.ForeignKey(Company, null=True, related_name='companyname', on_delete=models.CASCADE) car_reg = models.CharField(max_length=8, null=True) mot6due = models.CharField(max_length=100, null=True) cut_off = models.CharField(max_length=10, null=True) notes = models.TextField(null=True) updated_at = models.DateTimeField(auto_now_add=True) def __str__(self): return self.car_reg now i have list of companies listed , but now need to access each company to list separate cars belongs to each company views.py def dashboard(request): cars = car.objects.all() total_cars = cars.count() context = {'cars': cars, 'total_cars': total_cars} return render(request, 'cars/dashboard.html', context) def companyList(requst): company_list = Company.objects.all() context = {'company_list': company_list} return render(requst, 'cars/company_list.html', context) and template.html <tbody> {% for company in company_list %} <tr> <td><a href="{% url 'company-list' ?what here? %}"> {{ company.company_name }}</a></td> </tr> {% endfor %} </tbody> -
How to make unique_together both ways?
I am creating a friend model to save a user and his friend. I am using the following model: class Friend(models.Model): user = models.ForeignKey(UserProfile, related_name="user", on_delete=models.CASCADE) friends = models.ForeignKey(UserProfile, related_name="friends", on_delete=models.CASCADE) accepted = models.NullBooleanField(default=None) class Meta: unique_together = ('user', 'friends') In this model, I am able to save ('User1', 'User2') as well as ('User2, 'User1'), which is not what I want. So, how do I make this relation unique? -
facebook api with python error process finished with exit code 0 but not showing output
import json import django_facebook def main(): token={"EAAYweZAE8V28BAEvrqNvhcwiC5Y2KahleAQihgEwKacedR82qEEYWZAGvgQc8OdinAyg6jSNEapN3GR4yBgXNQY9ta2bhuVsBclR8YKRKqDF5CdKmgW0NWRDZCKlvVkmE8ZB1NRqaN6uspKkR38ZA5eVLmROxSRZAm7xgPAfZC2jKSPVmGOYZCivg05pAj0w43CpAS4JKam8xwZDZD"} graph=facebook.GraphAPI(token) fields=['id,name,age_range,hometown'] profile=graph.get_object('me',fields=fields) print(json.dumps(profile,indent=4)) if name=="main": main() i am creating this program and its executing but not showing output??? -
Current user variable in ListView class
I want to execute a database query using the currently logged in user within a ListView class. Then after that I want to put those results into the extra_context variable so I can access them on the html page. After looking on different websites I found this piece of code: class className(LoginRequiredMixin, ListView): context_object_name = 'contextName' template_name = 'app_list.html' def get_queryset(self): return Userproject.objects.filter(user=self.request.user) How can I put the current user into a variable, that I can use later on in a database query? -
Why after applying migrations in django,column is not being added to the table?
I made an app in Django namely facedetection and then after adding it to installedapps in settings.py ,i made its model with the following code:- from django.db import models subchoices=(('Signal Processing','Signal Processing'),('Indian Financial System','Indian Financial System'),('Machine Learning','Machine Learning'),('Embedded System','Embedded System'),('Cloud Computing','Cloud Computing'),) class student(models.Model): name=models.CharField(max_length=50) presentlist = models.CharField(max_length=5000,blank=True) subject=models.CharField(max_length=50,choices=subchoices,default='Signal Processing',blank=True) datelist=models.CharField(max_length=5000,blank=True) batch=models.CharField(max_length=5000) Enrollmentno=models.IntegerField() def __str__(self): return self.name And then i ran commands python manage.py makemigrations and python manage.py migrate.After that when i open the admin panel and entered all the fields in student and then saved it ,i got an error saying,subject was not being added to the column. I also checked migrations files and according to that subject was being successfully added. -
Django admin filtering/searching/sorting for inlines
I want to add changelist-view-like interface to inline models in django admin. E.g. filtering/searching/sorting. No packages or answers found for that sort of thing so far. So... did anyone try to do that yet? Maybe some hints how you would implement it? Use case: user(client) may have quite a big history of transactions, and i'd like to browse that history without having to go to transaction changelist view, filter by user and browse there(that's what i'm doing atm anyway). -
celery beat + django on Windows: [WinError 10061] No connection could be made because the target machine actively refused it
I already tried other solutions on the site and they didn't work, also, many are old questions that reference the now obsolete django-celery-beat package. I'm on Django 3 and Celery 4 which should mean, according to the documentation of the latter, that I don't need anything extra to run Celery with Django anymore. My project is structured so: proj/ |- app1/ |- app2/ |- proj/ |- settings.py |- ... |- celery.py |- tasks.py (I also tried putting tasks.py in one of the apps.) celery.py: import os from celery import Celery from celery.schedules import crontab os.environ.setdefault("DJANGO_SETTINGS_MODULE", "proj.settings") app = Celery("proj") app.config_from_object("django.conf:settings", namespace="CELERY") app.autodiscover_tasks() @app.on_after_configure.connect def setup_periodic_tasks(sender, **_): from .tasks import debug_task sender.add_periodic_task(crontab(), debug_task.apply_async()) tasks.py: from celery import shared_task @shared_task def debug_task(): print("Task executed.") What I do to try and run the project is: py manage.py runserver, celery -A proj.celery beat, celery -A proj.celery worker. On Ubuntu I'd run all three commands with detached screen sessions to run everything on the same terminal in case it's important, but I couldn't find any feasible alternative for Windows, so all three are executed in separate terminals opened after the previous one's command was already running. I tried putting "beat" and "worker" right after "celery" … -
How will i get this output on a ManyToManyField?
I have 3 models VehiclePrice with FK to Vehicle and Vehicle FK to Booking,(but I want to change it to MTM). i need to pull the appropriate price from the price model based on 3 fields. customer_status, duration of days and vehicle_category. (for multiple vehicles booking the customer_status and duration of days won't change) if a customer book only one vehicle it works fine, but a customer can book multiple vehicles under single or multiple categories. how can I re-write the below logic to work with MantToManyFields??? if the model Vehicle had MTM relationship with booking??? @property def unit_price(self): for item in VehiclePrice.objects.all(): if self.customer.customer_status == item.customer_status and (self.duration >= item.slab.start and self.duration <= item.slab.end) and self.vehicle.vehiclecategory == item.category : return item.total_price -
Delete the file object of form after saving or open the file before form saving
What I want is like this below upload the file -> validate -> store in db. form = DocumentForm(request.POST, request.FILES) form.save() # real file stored in directory #open file and validate.. df = pd.read_csv(form.document.path) if validate(df): pass: else: form.remove() # error occurs "DocumentForm object has no attribute 'remove'" Then now, I have two ideas. Is there a way to delete the object in model from Form??? or Is there a way to open the file before it is stored in directory??? -
I can't run the locust in bash console in pythonanywhere for django webapp
I have installed locustio but can't configured it. It is giving errors. I don't know the ports where i can log in. its giving me this error: [2020-03-15 08:29:22,509] blue-liveconsole4/ERROR/stderr: [2020-03-15 08:29:22,509] blue-liveconsole4/ERROR/stderr: File "/home/neso/.virtualenvs/django2/lib/python3.6/site-packages/psutil/__init__.py", line 386, in _init raise NoSuchProcess(pid, None, msg) [2020-03-15 08:29:22,509] blue-liveconsole4/ERROR/stderr: [2020-03-15 08:29:22,509] blue-liveconsole4/ERROR/stderr: psutil.NoSuchProcess: psutil.NoSuchProcess no process found with pid 6475 [2020-03-15 08:29:22,509] blue-liveconsole4/ERROR/stderr: [2020-03-15 08:29:22,509] blue-liveconsole4/ERROR/stderr: 2020-03-15T08:29:22Z [2020-03-15 08:29:22,509] blue-liveconsole4/ERROR/stderr: [2020-03-15 08:29:22,509] blue-liveconsole4/ERROR/stderr: <Greenlet at 0x7f41eaff9148: <bound method LocustRunner.monitor_cpu of <locust.runners.LocalLocustRunner object at 0x7f41eaff2dd8>>> failed with NoSuchProcess i don"t know where to put the locust.py file. my main project is in the mysites blog subdirectory. So i put it there. and run the command$ locust -f blog/locustfile.py my locustfile.py: from locust import HttpLocust, TaskSet, task, between class UserBehaviour(TaskSet): def on_start(self): """ on_start is called when a Locust start before any task is scheduled """ self.login() def on_stop(self): """ on_stop is called when the TaskSet is stopping """ self.logout() def login(self): self.client.post("/login", {"username":"boy", "password":"testing321"}) def logout(self): self.client.post("/logout", {"username":"sourda", "password":"testing321"}) @task(1) def index(self): self.client.get("/") class WebsiteUser(HttpLocust): host = "http://127.0.0.1:8089" task_set = UserBehaviour wait_time = between(5.0, 9.0) -
django oauth toolkit unsupported_grant_type error
I tried to add outh2 to my django app, so I used django oauth toolkit. So I followed the tutorial, but if I try to get the users token it always sends me a unsupported_grant_type error. How can I fix this error? settings.py REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', ), 'DEFAULT_AUTHENTICATION_CLASSES': ( 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', ) } OAUTH2_PROVIDER = { # parses OAuth2 data from application/json requests 'OAUTH2_BACKEND_CLASS': 'oauth2_provider.oauth2_backends.JSONOAuthLibCore', } urls.py urlpatterns = [ path('admin/', admin.site.urls), path('api/', include('myapp.api.urls')), path('o/', include('oauth2_provider.urls', namespace='oauth2_provider')), ] client type: confidential authorization grant type: Resource owner password-based chrome advanced rest client url : http://client_id:client_secret@localhost:8000/o/token/ -
django naturaltime returning the same result
In my model i have a fields like : time = models.DateTimeField(auto_now_add=True) In view page i am getting the value like in this format : 2020-03-15T11:07:07.089Z I am getting the date time in this format. {{ result.time|naturaltime }} but its not working it returning me the same date whick is comming from the data base -
How to configure WSS for AWS Elastic Beanstalk, Django-Channels and Docker
I have set up an AWS Elastic Beanstalk Multi-Container environment using a custom Django-Channels image which I deploy on Amazon ECR. All web-socket functionality is working perfectly when dealing with HTTP and WS protocols. However, when I switch to HTTPS, all HTTPS routes are handled properly but WSS fails to connect. Error in the browser console: WebSocket connection to 'wss://[REMOVED_URL]/' failed: Error during WebSocket handshake: Unexpected response code: 403 No error in the back-end logs because it seems the request from the front-end doesn't reach the back-end server. I'm using a React front-end that calls end-points of the Django-Rest-Framework (+ Django-Channels) back-end, is there any extra configuration required for WSS in the client-side? /docker-compose.yml version: "3" services: channels: build: . ports: - 80:8000 environment: - DEBUG - SECURITY_KEY - DB_HOSTNAME - DB_NAME - DB_PASSWORD - DB_PORT /Dockerrun.aws.json { "AWSEBDockerrunVersion": 2, "containerDefinitions": [ { "essential": true, "image": "[PATH_TO_AWS_ECR_IMAGE]", "name": "channels", "portMappings": [ { "containerPort": 8000, "hostPort": 80 } ], "memory": 256 } ], "family": "", "volumes": [] } /Dockerfile FROM python:3.7.5 ENV PYTHONUNBUFFERED 1 ENV REDIS_HOSTS "redis" WORKDIR /usr/src/app RUN mkdir static COPY requirements.txt . RUN pip install -r requirements.txt COPY . . RUN python manage.py migrate --no-input CMD ["daphne", "-b", …