Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
why are these inputs not posting? I'm using django
Date_from and date-to are posting, but other variables/inputs are not. I don't know why. <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Essers Reverse EDI - Home</title> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <script src="//code.jquery.com/jquery-1.12.3.js" crossorigin="anonymous"></script> <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script> <script src="https://cdn.datatables.net/1.10.12/js/jquery.dataTables.min.js" crossorigin="anonymous"></script> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel="stylesheet" href="/resources/demos/style.css"> <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/smoothness/jquery-ui.css" crossorigin="anonymous"> <link rel="stylesheet" href="https://cdn.datatables.net/1.10.12/css/dataTables.jqueryui.min.css" crossorigin="anonymous"> <!-- Custom styles for this template --> <link href="/static/css/dashboard.css" rel="stylesheet"> <meta name="msapplication-TileColor" content="#ffffff"/> <meta name="msapplication-TileImage" content="/static/img/favicon/redtruck-144-204428.png"> <link rel="shortcut icon" href="/static/img/favicon/favicon.ico"> <link rel="apple-touch-icon-precomposed" href="/static/img/favicon/redtruck-152-204428.png"> <link rel="apple-touch-icon-precomposed" sizes="152x152" href="/static/img/favicon/redtruck-152-204428.png"> <link rel="apple-touch-icon-precomposed" sizes="144x144" href="/static/img/favicon/redtruck-144-204428.png"> <link rel="apple-touch-icon-precomposed" sizes="120x120" href="/static/img/favicon/redtruck-120-204428.png"> <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/static/img/favicon/redtruck-114-204428.png"> <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/static/img/favicon/redtruck-72-204428.png"> <link rel="apple-touch-icon-precomposed" href="/static/img/favicon/redtruck-57-204428.png"> <link rel="icon" href="/static/img/favicon/redtruck-32-204428.png" sizes="32x32"> </head> <body> <nav class="navbar navbar-inverse navbar-fixed-top"> <div class="container-fluid"> <div class="navbar-header"> <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a class="navbar-brand" href="#">Essers Reverse EDI</a> </div> <div id="navbar" class="navbar-collapse collapse"> <script> $(function () { $("#date_from").datepicker(); $("#date_to").datepicker(); }); </script> </div> </div> </nav> <div class="container-fluid"> <div class="row"> <div class="col-sm-2 col-md-2 sidebar"> <form id="navbar-form" class="navbar-form" method="post" action="/"> <input type='hidden' name='csrfmiddlewaretoken' value='cixTdXuo09HJob6xEZnk8DXuHIrUFNAG' /> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title">Filters:</h3> </div> <div class="panel-body"> <div> Pickup date: </div> <input name="date_from" id="date_from" type="text" placeholder="from" class="form-control" value="12/01/2016" β¦ -
the 'package' argument is required to perform a relative import for
I'm not sure what is causing this error I'm looking to try and runsever on django from windows PowerShell but im am getting that error and this wall of issues. Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x03D366A8> Traceback (most recent call last): File "D:\Python\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "D:\Python\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run self.check(display_num_errors=True) File "D:\Python\lib\site-packages\django\core\management\base.py", line 374, in check include_deployment_checks=include_deployment_checks, File "D:\Python\lib\site-packages\django\core\management\base.py", line 361, in _run_checks return checks.run_checks(**kwargs) File "D:\Python\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks new_errors = check(app_configs=app_configs) File "D:\Python\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config return check_resolver(resolver) File "D:\Python\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver for pattern in resolver.url_patterns: File "D:\Python\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "D:\Python\lib\site-packages\django\urls\resolvers.py", line 313, in url_patterns patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "D:\Python\lib\site-packages\django\utils\functional.py", line 35, in __get__ res = instance.__dict__[self.name] = self.func(instance) File "D:\Python\lib\site-packages\django\urls\resolvers.py", line 306, in urlconf_module return import_module(self.urlconf_name) File "D:\Python\lib\importlib\__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 986, in _gcd_import File "<frozen importlib._bootstrap>", line 969, in _find_and_load File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 673, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 665, in exec_module File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed File "D:\Python\courseworkupload\courseworkupload\urls.py", line 26, in β¦ -
Automated website on Django [on hold]
I am beginner level python programmer and I want to build an automated website on Django which can scrap GIF and JPEG files from websites and post it on my website. Can anyone guide me how should I proceed? Thanks! -
Django get object and relation field of a ManyToMany Relationship
I was wondering if this can be done with a single query My models.py has a model that has a M2M with itself class Person(models.Model): objectid = models.AutoField(primary_key=True) name = models.CharField() relations = models.ManyToManyField( self, on_delete = models.CASCADE, through = Person_Person, #This lets you define the model that will act as an intermadiary symmetrical = False, #This needs to be set with recursive relationships ) class Person_Person(models.Model): cod_person_1 = models.ForeignKey('Person', on_delete=models.CASCADE, related_name='%(class)s_cod_person_1') cod_person_2 = models.ForeignKey('Person', on_delete=models.CASCADE, related_name='%(class)s_cod_person_2') relation = models.IntegerField(choices = ((0, 'Parent'), (1, 'Child'), (2, 'Engaged'), (3, 'Widow'), (4, 'Related')), default = 4) Then I added this function to Person model to get all related Person class Person(models.Model): ... def getRelated(self): return self.relations.all() self.relations.all() returns me a QuerySet with Person objects, but I also need to get the relation field from Person_Person with it It doesn't really matter if I get the object itself, all I need are the field values. -
Django make field disabled depending on another field value
I'm new to django and trying to do something with an issue.I have this model: class MyModel(models.Model): value = models.CharField(max_length=50, choises=...) custom_value = models.CharField(max_length=50, blank=True) And I need custom_value field to be enabled to edit only if value of value field is "CUSTOM" Thank you in advance. -
Celery Redis returns "Received unregistered task of type"
My problem is that when I try to call test() it works pretty well but when I call test.delay() it returns βreceived unregistered taskβ. starting the service. running test() and test.delay() (as you can see, the first one works.) result from test.delay() Settings.py BROKER_URL = 'redis://localhost:6379/0' CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERY_IMPORTS=("tasks") INSTALLED_APPS = ( "systech_account", #... ) Tasks.py from __future__ import absolute_import from celery import shared_task @shared_task def test(): return "Just a Test" celeryconfig.py from __future__ import absolute_import import os from celery import Celery from django.conf import settings # set the default Django settings module for the 'celery' program. os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'root.settings') app = Celery() # Using a string here means the worker will not have to # pickle the object when using Windows. app.config_from_object('django.conf:settings') app.autodiscover_tasks(lambda: settings.INSTALLED_APPS) . I'm using django 1.9 celery 4.0 Redis Server 2.8.4 Python 2.7 Ubuntu 14.04 -
oauth2 issue with user api
I'm creating an application and I will have both a client, who posts ad's and users who view and accept adds. The clients will loginto the main Web server site to post the add and the users will log into (get authorized) to view the mobile site. Where I'm stuck is with oauth2 authorization... I have set up the server, used curl to get an authorization code, however, can someone please clarify something for me? Are my clients and users stored in the same database table? Am I supposed to store each person who wants to view the api into Users, or do I create a new model for Users/Whatever? Do I even need oauth2 in this scenario because a lot of tutorials on this are about a 3rd party application getting authorization to like google for instance. Whereas my mobile application and web server are both part of the same company or site. -
django-crispy-forms. Inserting fields in template
I have the following form: class RehabilitationSessionForm(forms.ModelForm): def __init__(self, *args, **kwargs): # user = kwargs.pop('user', None) super(RehabilitationSessionForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_method = 'post' self.helper.add_input(Submit('submit', u'Guardar')) class Meta: model = RehabilitationSession widgets = { 'pain_extremity':forms.RadioSelect, 'upper_extremity':forms.RadioSelect, } fields = ['patient', 'medical', 'therapist', 'date_session_begin', 'upper_extremity', 'pain_extremity','movement_up','movement_down', 'movement_left','movement_right', 'games','game_levels','iterations','game_observations','patient_behavior', 'observations','period','date_session_end', ] I want renderize all these fields in my template, of a separate way to place each fields in specifics divs places in my html template keeping the bootstrap styles. For the moment, I am rendering the fields of a separate way, but using the {{form.}} this mean rendering fields manually of this way: <div class="row"> <div class="col-md-2 pacient-pic">&nbsp &nbsp<img class="img-circle " src="{{ sessionedit.patient.user.photo.url }}" alt="User Avatar"> </div> {{ form.non_field_errors }} <div class="col-md-3 col-xs-12 col-sm-6"> <ul class="pacient-ul"> {{ form.patient.errors }} <li><strong>Paciente:</strong>&nbsp {{ form.patient }} </li> </ul> </div> <div class="col-md-4 col-xs-12 col-sm-6"> <ul class="pacient-ul"> <li><strong>Terapeuta:</strong>&nbsp {{ form.therapist }}</li> <li><strong>MΓ©dico:</strong>&nbsp {{ form.medical }}</li> </ul> </div> </div> . . And so sucessively more divs and fields But this make that I miss the bootstrap effect, due to I am not using my RehabilitationSessionForm forms.py My form is renderized without css styles and js scripts own of bootstrap How to can I rendering my form β¦ -
Django runserver giving a 301 error
I'm trying to setup a development version of a Django site (developed by someone else) so that I can make edits and test before putting changes live. I'm getting a HTTP 301 error when I try going into 127.0.0.1:8000. I've tried other ports to ensure I'm not already using it. I believe the settings should allow me to run this app, for example I've got: DEBUG = True ALLOWED_HOSTS = ['*'] The live site is running from HTTPS so I figure there is something within settings.py which is specifying SSL but I cannot find anything. Two questions: Is there any way to emulate HTTPS using runserver? If not, what should I be looking for which might be forcing HTTPS? -
Create a local structured database of the items belonging a fix category on an e-commerce website
I want to create a dummy ecommerce website running on a local machine containing items belonging to jeans category only.I have a website but require data to be inserted in it.The website is in Django.Please tell me the easiest way to create a copy of the database of websites like amazon, myntra,flipkart etc.The database should contain an image, price, sizes, name of company, name of item, type of jeans,rating,customer reviews, other feature present on the site. -
External login with Oauth2
I'm working on a Django application with users through Django's auth, on the other side there is an Oauth2.0 server that already has all users and their permitions registerered. My goal now is to integrate the Django app with the Oauth2.0 server so we won't have to administrate the users ourselves. This would make it so the when the users want to log into our app they are redirected to the Oauth2.0 login site and then redirected to the home of our app once they login successfully. I think I understand how Oauth2.0 works but I have a couple of questions I couldn't find anywhere else. Is the scenario I'm describing possible? As in the users would no longer have to be registered in our app and a 3rd party Auth server would provide access to our app or not. Once I get the access token after the user login where is it safe to keep the access token? I was thinking I could save to AT as a session variable so as to keep the end user's session linked to his account which is external to our Django app. Every time the user makes a request I would check β¦ -
Start celery worker throws "no attribute 'worker_state_db'
When I am trying to start celery worker in Django app as: celery -A myApp worker -l info I get following error: File "/home/alexander/.pyenv/versions/3.5.1/envs/myApp/lib/python3.5/site-packages/celery/utils/collections.py", line 134, in __getattr__ type(self).__name__, k)) AttributeError: 'Settings' object has no attribute 'worker_state_db' If you know how to solve it please write your idea! -
Django views in project directory
I have a project with two apps whit their respective views, but I want to create a views.py in django project directory for some generic pages such as about, login... It is correct to place the views.py and templates in the root project folder for this purpose? -
Filter a model with a list and then set another field with another list
I have the following Django model: class Profile(models.Model): idNum = models.charField(max_length=10, unique=True) active = models.BooleanField(default=False) idType = models.charField(max_length=10) And I have two lists: idNums and idTypes (with the same length): idNums = ['1', '3', '5', '7', ...] idTypes = ['1', '1', '0', '2', '2', ...] I would like to filter Profile according to idNums and set the corresponding field values with idTypes. The obvious way is: for idNum, idTypes in zip(idNums, idTypes): profile = Profile.objects.get(idNum=idNum) profile.active = True profile.idType = idType profile.save() Is this OK? I mean, if there are thousands of profile instances to process, would it take a long time? Is there is a faster way? What I can think of is, for example, get the list of instance first: profiles = Profile.objects.filter(idNum__in=idNums) Then what? -
django authentication fail search for registration/login.html
I try to add authentication for a page. In my main url.py, i added: url(r'^accounts/login/$', auth_views.login, {'template_name': 'test/login.html'}), and in my view: @login_required() def result(request): ... When I try to see the result view I am sent to the login page (good). When i enter a bad login/password there is an error because the template registration/login.html does not exist. Why does django look for this template while I tell it to use test/login.html? -
Django: join on DateTimeField
How to join two models on DateTimeField? class ExchangeRate(models.Model): date = models.DateTimeField(...) usd_btc = models.DecimalField(...) class LedgerEntry(models.Model): account = models.ForeignKey(...) date = models.DateTimeField(...) amount = models.DecimalField(...) Here is an example of what I want. Note that records in ExchangeRate table have arbitrary date and time (there're not corresponding to the dates in LedgerEntry table). It's okay to join ExchangeRates just on date or hours (it is safe to ignore minutes, seconds, etc.) ExchangeRate LedgerEntry βββββββββββββββββββββββββββ- βββββββββββββββββββββββββββ--------- | Date | USD_RUB | | account | Date | Amount | |---------------|----------| |βββββββββ|---------------|--------| | 29 Nov, 14:15 | 100.00 | | 13 | 29 Nov, 14:40 | 10.0 | | 29 Nov, 14:04 | 200.00 | | 37 | 29 Nov, 14:45 | 11.0 | | 29 Nov, 13:51 | 150.00 | | 19 | 01 Oct, 10:32 | 12.0 | | ............. | .........| βββββββββββββββββββββββββββ--------- | 01 Oct, 10:23 | 500.00 | βββββββββββββββββββββββββββ- Join result βββββββββββββββββββββββββββ------------------------------------- | account | Date | Amount | USD_RUB | USD_RUB amount | |βββββββββ|---------------|--------|----------|----------------| | 13 | 29 Nov, 14:40 | 10.0 | 100.00 | 1000.0 | | 37 | 29 Nov, 14:45 | 11.0 | 100.00 | 1100.0 | | 19 | 01 Oct, 10:32 | β¦ -
Having a global variable available to your templates in Django
I would like to have a common variable available to all my templates. I've been working on this all morning and the only way I can find to do it is to have middleware like this: class GetNameMiddleware(object): def __init__(self, get_response): self.get_response = get_response def __call__(self, request): response = self.get_response(request) return response def process_template_response(self, request, response): response.context_data['name'] = 'dave' return response and have a view like this: from django.template.response import TemplateResponse from django.shortcuts import render def home(request): return TemplateResponse(request, 'home.html', {}) and then I can access it in the template Hello {{ name }} It just seems a bit ugly that I can't use render any more (I know I can do from django.template.response import TemplateResponse as render but that's not really a solution) (Django 1.10, python 3.5.2) -
Set filename in Base64FileField in django rest framework extra fields
I'm creating a Rest API with Django Rest Framework, and in some call, I need upload one of different file types. For do this, I am using drf-extra-fields and I have this problem: When the client convert file to Base64, the filename change and lose the file extension, for suply this, I created in serializer, new CharField called "file_extension": class MySerializer(serializers.ModelSerializer): # Some other fields... file = FileField(required=False) file_extension = serializers.CharField(required=False) class Meta: # model and fields... I created my custom Base64FileField, and set some allowed types and my method for get file extension: class FileField(Base64FileField): ALLOWED_TYPES = ['pdf', 'txt', 'xml'] def get_file_extension(self, filename, decoded_file): # Not working because the filename not include extension. return filename.split('.')[-1] For solve this, I thinked set filename in serializer with file extension (taked for the other field) before get_file_extension is called. Thanks you! -
Django photologue return image urls
I am using django-photologue (https://github.com/jdriscoll/django-photologue/tree/master/photologue) to manage images in my project. I have a view that ideally should return urls of the images in a specific gallery. @api_view(('GET',)) def get_gallery(request, id): gallery = Gallery.objects.get(id=id) data = [] for photo in gallery.sample(): data.append(photo.image) return HttpResponse(data) HttpResponse gives me: photologue/photos/superman_PucGOkm.jpgphotologue/photos/spiderman.png This doesn't look too promising. Response gives me those long jpg symbols like ΒΆΒ³βCΓ©3J<8β¬ΓΏ. What is the correct way of returning such urls, so that I can conveniently handle them on my angular2 frontend? I would then hit those urls from frontend to fetch actual images. -
Django: Intermittent 'template not found'
I have an app that is deployed at 15 sites and has been running for 6 years. All these deployments are with django 1.5, python 2.6, CentOS6, and apache, and they all work perfectly. I just deployed the app at a new site, but this one is django 1.9, python 2.7, CentOS7, and nginx/uwsgi. Only at this site we are seeing intermittent 'template not found' errors. A refresh of the page always works. It happens with different templates, and there are no errors in any of the logs (except for the template not found error). I've checked the system logs, the nginx logs, the uwsgi logs and the django logs. Anyone know why this would be happening, and/or how I can debug it further? One thing I noticed, and this may be normal, but I don't know as I've never encountered this error before, is that in the template not found error when it lists the directories it searched, they all are in /tmp. For example if the template is in /usr/local/foo/bar/templates/baz/template.html the search path in the error will have /tmp/foo/bar/templates/baz. Is that any indication of a problem? -
Django-google-analytics import error
I've installed django-google-analytics using: env/bin/pip install django-google-analytics with this response: Requirement already satisfied: django-google-analytics in ./env/lib/python2.7/site-packages. I've added 'google_analytics', to INSTALLED_APPS and I've added GOOGLE_ANALYTICS_MODEL = True in settings.py When I run env/bin/python manage.py syncdb I get ImportError: No module named google_analytics What do I need to do? -
Django: Interacting with a SOAP web service
I am working with Django 1.8 and I have to interact with a certain web service. I have to send an XML like this: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wtp="http://wtp"> <soapenv:Header/> <soapenv:Body> <wtp:QueryEntrSAF> <wtp:id_parameter_one>654321></wtp:number> <wtp:id_parameter_two>123456</wtp:system> </wtp:QueryEntrySAF> </soapenv:Body> </soapenv:Envelope> Note that it is sending two parameters ("id_parameter_one" and "id_parameter_two"). And I should recevice something like this: <?xml version="1.0" encoding="UTF-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <SalidaConsultaSAF xmlns="http://wtp"> <coderror>01</coderror> <dserror>Error de Aplicacion</dserror> </SalidaConsultaSAF> </soapenv:Body> How can this be done with Django/Python? -
Parsing the django template language code from a variable
from django import template from django.template import engines from django.utils.html import format_html register = template.Library() @register.simple_tag def external_link(link): ''' Creates an anchor tag ''' return format_html('<a target="_blank" href="%s"> Some External Link </a>' % (link)) link = '{% external_link https://stackoverflow.com %}' template_context = '<div> {{ a_link }} </div>' template = engines['django'].from_string(template_context) template.render({ 'a_link': link, }) Current output: u'<div> {% external_link https://stackoverflow.com %} </div>' What I need is: u'<div> <a target="_blank" href="https://stackoverflow.com"> Some External Link </a> </div>' How to achieve this by keeping the template code in the variable link ? -
Why does my Django failed to runserver after I installed channels?
Everything worked fine until I installed 'channels'. After I installed channels, I added 'channels' in INSTALLED_APPS in settings.py, and then when I do $ python3 manage.py runserver I get the following errors: pi@raspberrypi:~/Desktop/project $ python3 manage.py runserver Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x75966300> Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/django/core/management/commands/runserver.py", line 113, in inner_run autoreload.raise_last_exception() File "/usr/local/lib/python3.4/dist-packages/django/utils/autoreload.py", line 249, in raise_last_exception six.reraise(*_exception) File "/usr/local/lib/python3.4/dist-packages/django/utils/six.py", line 685, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.4/dist-packages/django/utils/autoreload.py", line 226, in wrapper fn(*args, **kwargs) File "/usr/local/lib/python3.4/dist-packages/django/__init__.py", line 27, in setup apps.populate(settings.INSTALLED_APPS) File "/usr/local/lib/python3.4/dist-packages/django/apps/registry.py", line 115, in populate app_config.ready() File "/home/pi/channels/channels/apps.py", line 22, in ready monkeypatch_django() File "/home/pi/channels/channels/hacks.py", line 10, in monkeypatch_django from .management.commands.runserver import Command as RunserverCommand File "/home/pi/channels/channels/management/commands/runserver.py", line 5, in <module> from daphne.server import Server File "/usr/local/lib/python3.4/dist-packages/daphne/server.py", line 4, in <module> from twisted.internet import reactor, defer File "/home/pi/twisted/src/twisted/internet/reactor.py", line 38, in <module> from twisted.internet import default File "/home/pi/twisted/src/twisted/internet/default.py", line 56, in <module> install = _getInstallFunction(platform) File "/home/pi/twisted/src/twisted/internet/default.py", line 44, in _getInstallFunction from twisted.internet.epollreactor import install File "/home/pi/twisted/src/twisted/internet/epollreactor.py", line 24, in <module> from twisted.internet import posixbase File "/home/pi/twisted/src/twisted/internet/posixbase.py", line 18, in <module> from twisted.internet import error, udp, tcp File "/home/pi/twisted/src/twisted/internet/tcp.py", line 28, in β¦ -
Docker user Permission denied on accessing folder in container
I am running docker-compose to bring together django with a few other services with the following config: Dockerfile: FROM ubuntu:16.10 FROM python:3.5.0 ENV EXTRACTOR_SRC=. ENV EXTRACTOR_SRVHOME=/srv ENV EXTRACTOR_SRVPROJ=/srv/extractor_django #Install package dependencies RUN apt-get update && apt-get -y upgrade RUN apt-get install -y python python-pip virtualenvwrapper # Create application subdirectories WORKDIR $EXTRACTOR_SRVHOME RUN mkdir media static logs VOLUME ["$EXTRACTOR_SRVHOME/media/", "$EXTRACTOR_SRVHOME/logs/"] # Copy application source code to SRCDIR COPY $EXTRACTOR_SRC $EXTRACTOR_SRVPROJ # Install Python dependencies RUN pip install -r $EXTRACTOR_SRVPROJ/requirements.txt # create user RUN adduser --disabled-password --gecos '' dockeruser (Relevant) Docker-compose.yml: version: '2' services: # Django web server web: build: context: . dockerfile: Dockerfile hostname: web command: /srv/www/run_web.sh volumes: - .:/srv/www ports: - "8000:8000" run_web.sh: #!/bin/bash set -o verbose sleep 15 cd /srv/extractor_django su -m dockeruser -c "python manage.py makemigrations" su -m dockeruser -c "python manage.py migrate" su -m dockeruser -c "python manage.py collectstatic --noinput" # Start Gunicorn processes echo Starting Gunicorn. su -m dockeruser -c "gunicorn extractorService.wsgi:application \ --name extractor_django \ --bind 0.0.0.0:8000 \ --workers 10 \ --log-level=info" During runtime one of the python requirements (spacy) tries to store and access files in a restricted folder causing the error: PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/site-packages/spacy/data' Is there a way I can β¦