Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Deserializing json to a python object without actually save the object in DB
I use Django and the model classes to access data from DB. I would like to add cache layer on top of DB. For example, let's say I have a User model and UserSerializer (inherited from ModelSerializer). When storing an User object in cache, I need to serialize the object to json import json serializer = UserSerializer(obj) serialized_data = json.dumps(serializer.data) However, when I retrieve this json from cache, I had trouble to convert it back to User object data = json.loads(serialized_data) deserializer = UserSerializer(data=data) user_obj = deserializer.save() # this return an User object but intenally it will create a new record in DB Any better ideas that I can use the serializer that django provided to deserialize json to object without actually creating the record in DB? -
Hyperlinks in Django Quill Editor are not displaying as expected
Problem I added the Quill Editor to my Django admin. When I input hyperlinks in the QuillEditor such as "www.example.com", instead of creating the hyperlink exactly as I type it, the URL will appear on the template page as "localhost:8000/plants/www.example.com". Directing me to a broken page instead of www.example.com Context I've read through the full quill documentation but I don't see a way to make sure hyperlinks added in the QuillEditor display without the project domain being prepended to the front of the hyperlink url. Heres how I input the URL 'www.example.com' in the django admin: Here is how the URL appears on the actual template page (you can see the url in the bottom left when I hover over it: Maybe I need to edit something in the urls.py? plants > urls.py urlpatterns = [ path('admin/', admin.site.urls), path('accounts/', include('allauth.urls')), path('accounts/', include('django.contrib.auth.urls')), path('', include('pages.urls')), path('plants/', include('plants.urls')), ] -
Wrap python decorator with another decorator
I have a common decorator call throughout my Django codebase: @override_settings( CACHES={ **settings.CACHES, "default": generate_cache("default", dummy=False), "throttling": generate_cache("throttling", dummy=False), } ) def test_something(): ... The decorator code is too verbose. I'd love to wrap this code into a new decorator called @use_real_cache so the test function looks much cleaner: @use_real_cache def test_something(): ... How can I wrap a decorator with another decorator? -
Using fonts in django HTML email templates
I have a html template for a password reset email that I am trying to set up instead of the default django email. The code is as follows: <!DOCTYPE html> <html> <head> <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300&display=swap" rel="stylesheet" /> <style> body { font-family: "Inter", sans-serif; font-size: 20px; color: #434343; margin: 0; } .main-container { max-width: 60%; } .centered-contents { display: flex; justify-content: center; } .pswd-button { background: #677db6; border-radius: 25px; color: #ffffff; cursor: pointer; text-decoration: none; padding: 15px; padding-top: 10px; padding-bottom: 10px; } .top-bar { width: 100%; background-color: #d9d9d9; display: flex; align-items: center; } .top-bar-title { color: #677db6; margin: 20px; } </style> </head> <body> <div class="top-bar"> <p class="top-bar-title">Nombre de Web</p> </div> <div class="centered-contents"> <div class="main-container"> <p style="font-size: 24px"> Hola <span style="color: #677db6">nombre</name></span>! </p> <p> Está recibiendo este correo porque ha solicitado un cambio de contraseña en <span style="color: #677db6">web</span>. Para continuar, por favor utilice el botón que se muestra a continuación: </p> <div class="centered-contents"> <a class="pswd-button" href="#"> Restablecer Contraseña </a> </div> <p> Le recordamos su nombre de usuario: <span style="color: #677db6">usuario</span> </p> <p> Si no ha solicitado ningún cambio de contraseña, no se preocupe. Puede ignorar este correo. </p> <p>Atentamente,</p> <p>El equipo técnico de <span style="color: #677db6">Web</span></p> </div> </div> </body> </html> And, rendered … -
generated json to csv to django model
Is there any way to do what I'm trying to do - generate json from api url request, transform it to csv, store in Django model? No idea how to make this work views.py def view(request): if request.method == 'GET': data1 = request.GET.get("data1") data2 = request.GET.get('data2') url = f'https://api.com/{data1}?d={data2}&format=json' response = requests.get(url=url) df = pd.json_normalize(response.json()) file = df.to_csv('data.csv') csv_file = File.objects.create(csv_file=file) csv_file.save() return render(request, 'template.html') models.py class File(models.Model): file = models.FileField() -
Want a unicode character in django crispy strictbutton
I'm trying to get a chevron to be the value in a crispy strictbutton. It should look like this: https://icons.getbootstrap.com/icons/chevron-down/ But, all I get is code in a little box: unicode in the box I've tried this: def __unicode__(self, this_char): return u"%s" % this_char StrictButton(self.__unicode__('\uF282'), css_class="btn btn-outline-secondary btn-sm", id="button-id-right") and this: StrictButton('\uF282', css_class="btn btn-outline-secondary btn-sm", id="button-id-right") and get the same result. I've tried embedding the html string hoping the browser would catch it - didn't work. Thanks -
Is there an efficient way to get the Django model of a modeladmin object from within an Admin action?
I have an action that is added to multiple Django model admins. Part of that action relies on the modeladmin and queryset like so: def my_action(modeladmin, request, queryset): queryset_model_name = queryset.first().__class__.__name__ model_to_update = apps.get_model(app_label='main', model_name=queryset_model_name) # more code here that relies on both queryset_model_name and model_to_update Is there a way to refactor this? Possibly a way to get the model string itself directly from modeladmin instead? I did a search through the django doc page for ModelAdmin but came up short. Any assistance would be appreciated! Thank you in advance. -
Is there a way to convert from ISO Date format to an Month, DD, YYYY at local time in Python
I am trying to convert my last_updated field from ISO Date format 2022-06-05T14:38:59.927753-07:00 into June 5th, 2022 at 2:38pm My code is try: if timefield.school_id: school = SchoolBell.object.get(school_id=timefield.school_id) return '{}'.format(datetime.strftime(school.last_updated)) except School.DoesNotExist: return '' Is there a way to call it inside the table field last_updated into the word format -
Django python requests library send and receive array values through POST
I am sending a POST request (with indexed array value) in Django (Python 3+) like: def wordgrpocc_ajax(request): woccs= [] postVars= request.POST print('postVars= '+str(postVars)) # OUTPUT: postVars= <QueryDict: {'syear': ['0'], 'eyear': ['0'], 'word_id[]': ['629c48a694c367c0e07f1d3a', '629c481e94c367c0e07ee8bc', '629c48c694c367c0e07f2864']}> url = skpsettings.API_URL+"word/group/occurrence" headers = {'Content-type': 'application/json'} bresplist = requests.post(url= url, data=json.dumps(postVars), headers=headers) woccs= bresplist.text return HttpResponse(woccs, content_type="application/json") Output of the print in above def: postVars= <QueryDict: { 'syear': ['0'], 'eyear': ['0'], 'word_id[]': ['629c48a694c367c0e07f1d3a', '629c481e94c367c0e07ee8bc', '629c48c694c367c0e07f2864']}> When I catch the request (in skpsettings.API_URL+"word/group/occurrence"), the array value is corrupted. Only the last value of the array is received: @csrf_exempt def api_WordGroupYearOcc(request): wocclist= [{}] if request.method == "POST": postVars= json.loads(request.body) word_ids= postVars.get("word_id") #word_ids= request.POST.getlist('word_id', []) syear = int(postVars.get("syear", 0)) eyear = int(postVars.get("eyear", 0)) print('postVars= '+str(postVars)) # OUTPUT: postVars= {'syear': '0', 'eyear': '0', 'word_id[]': '629c48c694c367c0e07f2864'} Output of the print in above def: postVars= {'syear': '0', 'eyear': '0', 'word_id[]': '629c48c694c367c0e07f2864'} What am I doing wrong? Thanks in advance. -
Browser loads an empy css
css located in my_blog/my_blog/blog/static/blog/style.css manage.py in my_blog/my_blog head of html: {% load static %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="{% static 'blog/style.css' %}"> <title>{% block title%} My blog {% endblock %}</title> </head> I'm using pycharm pro. Browser successfully load css file, but it's empty. Why this is happenning? -
How Django async view handle simultaneous requests
I test 2 views in Django 3.2: def sync_view(request): return HttpResponse("Hello, sync Django!") async def async_view(request): await asyncio.sleep(10) return HttpResponse("Hello, async Django!") start uvicorn as uvicorn myapp.asgi:application First request to async_view, right after to sync_view. My expectation that sync_view will response immediately, however it is handled only after 10 seconds. What is wrong? Why requests are not handled simultaneously? -
How to pass pk argument within class based view to queryset in Django
I have the following Django urls/views and Models: Models ORDER_COLUMN_CHOICES = Choices( ('0', 'id'), ('1', 'code'), ('2', 'code_type'), ('3', 'created'), ('4', 'updated'), ('5', 'valid'), ) class Identifier(TimeStampMixin, models.Model): code_type = models.CharField(max_length=10, null=True) code = models.CharField(max_length=12) account = models.ForeignKey(Account, on_delete=models.CASCADE, null=True) actflag = models.CharField(max_length=1, blank=True) valid = models.BooleanField(default=False) def __str__(self): return self.code class Meta: db_table = "portfolio_identifier" def query_identifier_by_args(**kwargs): draw = int(kwargs.get('draw', None)[0]) length = int(kwargs.get('length', None)[0]) start = int(kwargs.get('start', None)[0]) search_value = kwargs.get('search[value]', None)[0] order_column = kwargs.get('order[0][column]', None)[0] order = kwargs.get('order[0][dir]', None)[0] order_column = ORDER_COLUMN_CHOICES[order_column] # django orm '-' -> desc if order == 'desc': order_column = '-' + order_column queryset = Identifier.objects.all() total = queryset.count() if search_value: queryset = queryset.filter(Q(id__icontains=search_value) | Q(code__icontains=search_value) | Q(code_type__icontains=search_value) | Q(created__icontains=search_value) | Q(updated__icontains=search_value) | Q(valid__icontains=search_value)) count = queryset.count() queryset = queryset.order_by(order_column)[start:start + length] return { 'items': queryset, 'count': count, 'total': total, 'draw': draw } URLS from . import views from rest_framework.routers import DefaultRouter from apps.portfolio.views import IdentifierViewSet router = DefaultRouter() router.register(r'portfolio', IdentifierViewSet) urlpatterns = [ path('portfolios/', views.portfolios, name="portfolios"), path('portfolio/<str:pk>/', views.portfolio, name="portfolio"), path('api/', include(router.urls)), ] Views def portfolio(request, pk): portfolio = Account.objects.get(id=pk) identifiers = Identifier.objects.filter(account=pk) context = {"portfolio": portfolio, "identifiers": identifiers} return render(request, 'portfolio.html', context) class IdentifierViewSet(viewsets.ModelViewSet): queryset = Identifier.objects.all() serializer_class = IdentifierSerializer authentication_classes = … -
Django: Code only executing on watcher reload?
I'm working with Django and I have code that I'm attempting to execute on page load, but it isn't executing. All I've set it to do is print something and it only prints when Django's watcher sees a code change (and it's immediate on watcher reload, after that it won't print at all)... Here's my codebase: https://github.com/varlenthegray/wcadmin/blob/master/qb/views.py#L590 Here's the view: def update_db_from_changes(request): # Get all records that do not equal 12 for service interval all_non_standard_invoices = Invoice.objects.filter(~Q(service_interval=12)).select_related('job_site') print("I don't get it, this should work.") return HttpResponse("Did nothing!") Watcher results: System check identified no issues (0 silenced). June 09, 2022 - 16:01:06 Django version 4.0.5, using settings 'wcadmin.environment.production' Starting development server at http://127.0.0.1:3000/ Quit the server with CONTROL-C. I don't get it, this should work. Watching for file changes with StatReloader Page refresh results: Watching for file changes with StatReloader [09/Jun/2022 16:06:50] "GET /qb/update_changes/ HTTP/1.1" 200 12 Page results: Did nothing! Any thoughts on how to best approach debugging this issue? -
Access domain (and port) URL in settings.py file while in localhost development
How do you dynamically access the domain name URL in the settings.py file of Django? (ie "http://localhost:8000") I am trying to overwrite a package CDN while the internet is unavailable during development, and want to point to the local file in the static files directory. While os.path.join(BASE_DIR, "path/to/local.file") should work, it is context-dependent as to which app/url (ie "http://localhost:8000/app/static/css/bootstrap.min.css "), and not just the main domain with the static file location appended to the starting server with ./manage.py runserver 0:8000 (ie " http://localhost:8000/static/css/bootstrap.min.css"). Notes: Because this is in the settings.py, I can't load any apps or reverse because of the error *** django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. I am not in a template, so I can't use the static url statically defining it won't allow for different port loadings when starting via ./manage.py runserver 0:8000 Basically in the settings.py file: # If in local dev if "RDS_DB_NAME" not in os.environ: # the setting for the package I am pointing to a local version BOOTSTRAP5 = { "css_url": { ### dynamically get domain here ### # "href": os.path.join(LOCAL_DIR, "static/css/bootstrap.min.css"), "href": "static/css/bootstrap.min.css", } -
Django model form won't save/validate
I am new to Django and I have a comments form on a listing page of a marketplace site I am working on. When trying to enter a comment they don't save. I assume the is_valid() is not returning True so the saving never occurs, but I don't see why it wouldn't be valid. I thought that function primarily checked all fields were filled with valid data. As I said I'm new to Django so any advice would be appreciated. The Else redirect is temporary until I get it working correctly. Views.py @login_required def comment(request, listing): listing = AuctionListings.objects.get(name=listing) form = NewCommentForm(request.POST) if form.is_valid(): comment = form.save(commit=False) comment.user = request.user comment.listing = listing comment.save() return HttpResponseRedirect(reverse("listing", args=[listing.name])) else: return HttpResponseRedirect(reverse("listing", args=[listing.name])) models.py class Comments(models.Model): listing = models.ForeignKey(AuctionListings, on_delete=models.CASCADE) user = models.ForeignKey(User, on_delete=models.CASCADE) comment = models.CharField(max_length=255, validators=[MinLengthValidator(1)]) date = models.DateTimeField(auto_now_add=True) forms.py class NewCommentForm(forms.ModelForm): class Meta: model = Comments fields = [ 'comment' ] widgets = { 'comment': forms.Textarea(attrs={ 'placeholder': 'Enter your comment (255 char. max)', }) } -
Reliably accessing request.user in Django custom LoginView
I have a custom LoginView and I'd like to take the shopping cart of a LazyUser pre-login and consolidate it with the cart of the user after login: class LoginView(FormView): ... def form_valid(self, form): request_user = self.request.user user = authenticate(email=form.cleaned_data['email'], password=form.cleaned_data['password']) if user is not None: login(self.request, user) try: user.consolidate_carts(request_user) except Exception as e: print('error in consolidate_carts: ', e) return HttpResponseRedirect(self.success_url) else: return render(self.request, 'users/login.html') This seems to work some of the time, but it is unreliable - I believe that is because I am simply referencing self.request.user and it is a SimpleLazyObject. What would be the pythonic/optimal way to store the user pre-login? -
Can not deserialize instance of io.vavr.collection.Seq out of VALUE_STRING
I was trying to build a python request module passing API tokens, however I am running into below issue every time. Sharing my entire code : import requests import json def bitbucketFunction(): variables = {"test":"1234"} callBitBucketAPI(variables) def callBitBucketAPI(variables): try: headers = { 'Content-Type': 'application/json' } url = "https:xyz/pipelines/" data = { "target": { "type": "pipeline_ref_target", "ref_type": "branch", "ref_name": "master", "selector": { "type": "custom", "pattern": "create-aws-account" } },"variables":json.dumps(variables, indent=2)} response = requests.request("POST",url, auth=('token-key', 'token-value'), data=json.dumps(data),headers=headers) print(response.text) except Exception as e: print("Exception occured in callBitBucketAPI method: ", e) bitbucketFunction() Error: {"error": {"message": "An invalid field was found in the JSON payload.", "fields": ["variables"], "detail": "Can not deserialize instance of io.vavr.collection.Seq out of VALUE_STRING token\n at [Source: (org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream); line: 1, column: 167] (through reference chain: com.atlassian.pipelines.rest.model.v1.pipeline.ImmutablePipelineModel$Builder[\"variables\"])", "data": {"key": "rest-service.request.invalid-json"}}} -
Django: I need to supersede a particular Python module in a no-longer-maintained package
Well, I think that the "Pinax" package is no longer maintained ... Anyway, it refers to a now-deprecated django.utils.tzinfo package. I need to make a one-line change to one source module, and then cause that version of the package to be loaded instead of the one in the module directory. Is there a generic way in Django to do that sort of thing? (I know that some packages such as the Machina forum software can do this.) -
djago-gis: Can't serialize dictionary with GeoFeatureModelSerializer: KeyError: 'id', even with .is_valid=True and excluding id
I'm trying to prototype a view receiving some geojson. I'm using a jupyter notebook, with (https://gist.github.com/codingforentrepreneurs/76e570d759f83d690bf36a8a8fa4cfbe)[the init_django script in this link). Trying to serialize this geojson (that has been transformed into a dict) {'id': '0', 'type': 'Feature', 'properties': {'area': 0.74, 'gloc1': sensitive, 'gloc2': sensitive, 'gloc3': sensitive, 'gloc4': sensitive, 'gloc5': sensitive}, 'geometry': {'type': 'MultiPolygon', 'coordinates': [some_coordinates]}} Is giving me problems with some id field. Here is the model serializer using the rest_framework_gis library. class Local(GeoFeatureModelSerializer): # cliente = PrimaryKeyRelatedField(queryset=ClienteModel.objects.all()) class Meta: model = LocalModel fields = "__all__" geo_field = "geom" Here is the model i'm using from django.contrib.gis.db.models import Model class Local(Model): status_choice = TextChoices('status', 'ATIVO INATIVO PONTUAL') gloc1 = TextField(null=False) gloc2 = TextField(null=False) gloc3 = TextField(null=False) gloc4 = TextField(null=False) gloc5 = TextField(null=False) latitude = FloatField(null=True, blank=True) longitude = FloatField(null=True, blank=True) altimetria = FloatField(null=True, blank=True) capacidade_retencao_agua = FloatField(null=True, blank=True) coef_textura_agua_solo = FloatField(null=True, blank=True) coef_potencia_agua_solo = FloatField(null=True, blank=True) sk1m = FloatField(null=True, blank=True, default=0) sk2m = FloatField(null=True, blank=True, default=1) smaw = FloatField(null=True, blank=True, default=0) sfer = FloatField(null=True, blank=True, default=1) profundidade_efetiva_maxima = FloatField(null=True, blank=True) cti = FloatField(null=True, blank=True) slo = FloatField(null=True, blank=True) geom = GeometryField(srid=4326, null=False) data_criacao = DateField(auto_now=True) data_atualizacao = DateField(auto_now_add=True) #null-False here cena_s2 = TextField(null=True, blank=True) area = FloatField(null=True, blank=True) grupo = … -
CKEditor RichTextUploadingWidget preventing page scroll
I'm using a fullpage.js frontend with a Django backend. In the Django models, I defined some fields with the RichTextUploadingField. The fullPage.js page does not work with scrolloverflow if I do this. I cannot scroll down to the next page. If I change the RichTextUploadingField back to a normal TextField everything works fine. Any ideas? -
Django/Apache authentication successful but does not return @loginrequired view instead redirects to index
I have a Django application with token-based auth. I served this app on AWS before without problem. Now I want to serve it via Apache2 but it fails to open a 'login required' page after successful login. Here is my code: views.py def index(request): print('Access to page "home"') return render(request, 'index.html') @login_required(login_url='/') def memory(request): print('Access to page "memory"') return render(request, 'memory.html') user_api.py @api_view(["POST"]) @permission_classes((AllowAny,)) @csrf_exempt def doLogin(request): body_unicode = request.body.decode('utf-8') user = json.loads(body_unicode) dbUser = User.objects.filter(username=user['username']) if not dbUser: return HttpResponse(status=404) authenticatedUser = authenticate(username=user['username'], password=user['password']) if authenticatedUser: login(request, authenticatedUser) token, _ = Token.objects.get_or_create(user=authenticatedUser) return Response({'token': token.key}, status=HTTP_200_OK) else: return Response(status=401) LoginModal.vue login() { if (!this.user.username || this.user.username == '' || !this.user.password || this.user.password == '') { this.warningText = 'All fields must be filled.' return } axios.post(this.backendAddress + 'api/user/login', this.user) .then((response) => { sessionStorage.setItem('token', response.data.token) document.cookie = 'apitoken=' + response.data.token window.location.href = 'memory' }, function (err) { printError(err) }) } After I entered my username/password and hit login, it makes the request and redirects to index with ?next=memory, meaning that it doesn't recognized user as logged in. After successfull login I store my token as 'apitoken' parameter in the cookie. What's wrong with my method? Thanks. -
django form not showing in template to add data
the goal of my code is to make a school management system where the admin can log in and add teachers to their respective classes that they are leading and be able to add students to their respective classes and then take the attendance of those students present on any given day. however, I am having an issue where the form to add the student to the class isn't rendering when I click on the add student button. I have been searching but can't seem to find the error in my code, I am new to Django so any help will be appreciated. the closest I got was to make the modal show up but the fields to select the student from to add to the class wasn't showing models class Teacher(models.Model): first_name = models.CharField(max_length=60, blank=False, null=False) last_name = models.CharField(max_length=80, blank=False, null=False) address = models.CharField(max_length=120, blank=True, null=True) contact = models.CharField(max_length=10, blank=True, null=True) email = models.EmailField(blank=True, null=True) birth = models.CharField(max_length=20, blank=True, null=True) gender = models.CharField(max_length=100, choices=[('Male', 'Male'), ('Female', 'Female')], blank=True, null=True) comment = models.TextField(max_length=10000, blank=True, null=True) def __str__(self): return f"{self.first_name + ' ' + self.last_name}" class Student(models.Model): student_code = models.CharField(max_length=250, blank=True, null=True) first_name = models.CharField(max_length=20, blank=False, null=False) last_name = models.CharField(max_length=20, blank=False, … -
Django way to make a chat app without django-channels
how can I make a chat app without django-channels. I want to do it with something like socketio. I found in Google a module named django-socketio. Should I do it with this? Please write me the code to do this or write a link of a tutorial. Should I do it with something different? Thanks. -
Can't connect with my django rest framework API with axios in react native
I'm developing an application with React Native and I can't connect to my own API. I made a database with django rest framework and I'm trying to connect to it with axios. I'm receiving an error with "Network Error" message with the name "AxiosError". Here is the error (with error.toJSON()): Object { "code": "ERR_NETWORK", "columnNumber": undefined, "config": Object { "adapter": [Function xhrAdapter], "data": undefined, "env": Object { "FormData": null, }, "headers": Object { "Accept": "application/json, text/plain, /", }, "maxBodyLength": -1, "maxContentLength": -1, "method": "get", "timeout": 0, "transformRequest": Array [ [Function transformRequest], ], "transformResponse": Array [ [Function transformResponse], ], "transitional": Object { "clarifyTimeoutError": false, "forcedJSONParsing": true, "silentJSONParsing": true, }, "url": "http://127.0.0.1:8000/api/usuario", "validateStatus": [Function validateStatus], "withCredentials": false, "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN", }, "description": undefined, "fileName": undefined, "lineNumber": undefined, "message": "Network Error", "name": "AxiosError", "number": undefined, "stack": undefined, "status": null, } Currently I'm doing it without authentification needed because i thought I should have less errores (tried it also with authentification earlier a lot and same error). This is my axios function: try { const axios = require('axios'); const students = await axios.get('http://127.0.0.1:8000/api/usuario', {withCredentials: false}); //const students = await axios.get('https://jsonplaceholder.typicode.com/todos/1'); setPrueba(JSON.stringify(students.data)); The line commented is a API that gives a placeholder json, and … -
mod_wsgi: "No module named 'django'"
Maybe some needed context: I installed python3.9 into a directory /opt/python39/. I compiled mod_wsgi with this version of python and was able to conduct a test to make sure that it was working correctly. I am not using a virtual environment. I am trying to move my django project to production, so naturally, I am following the django docs. When I use the default file configurations at the very beginning, i.e.: WSGIScriptAlias / /path/to/mysite.com/mysite/wsgi.py WSGIPythonHome /opt/python39/bin/python3.9 WSGIPythonPath /path/to/mysite.com <Directory /path/to/mysite.com/mysite> <Files wsgi.py> Require all granted </Files> </Directory> It works (for the most part - there are resources missing on the page, but thats for another SO post) like a charm. So I continue through the docs (which is now telling me that I should move it to "Daemon mode"): “Daemon mode” is the recommended mode for running mod_wsgi (on non-Windows platforms). To create the required daemon process group and delegate the Django instance to run in it, you will need to add appropriate WSGIDaemonProcess and WSGIProcessGroup directives. A further change required to the above configuration if you use daemon mode is that you can’t use WSGIPythonPath; instead you should use the python-path option to WSGIDaemonProcess, for example: So I change …