How to install mod_wsgi for apache 2.4 and python 3.4 on windows?

It is better to build mod_wsgi yourself from code rather than use an arbitrary binary off the net. The steps are as follows. Ensure you have a decent Apache installation which includes header files, e.g. Apache 2.4.37 Win64 from Apache Lounge . Preferably installed at location of C:/Apache24. Ensure your Python installation is set up … Read more

Django: dynamic database file

The django.db.connections is a simple wrapper around DATABASES defined in your settings. The wrapper class is here: django.db.utils#L137-L227 from django.db import connections # Add connection information dynamically.. connections.databases[‘new-alias’] = { … } # Ensure the remaining default connection information is defined. # EDIT: this is actually performed for you in the wrapper class __getitem__ # … Read more

Forbidden (403) CSRF verification failed. Request aborted

You need to add {% csrf_token %} in your form https://docs.djangoproject.com/en/2.2/ref/csrf/ like that : <form> {% csrf_token %} <anything_else> </form> Also, you have to use RequestContext(request) everytime you use render_to_response : return render_to_response(“login.html”, {“registration_id”:registration_id}, context_instance=RequestContext(request)) And you have to import authenticate and login : from django.contrib.auth import authenticate, login

Creating Partial Indexes with Django 1.7

Django 2.2 and later As of version 2.2 Django supports declarative partial unique indexes on databases that support them (PostgreSQL and SQLite). So you could do something like: from django.db.models import Model, Q, UniqueConstraint class Post(Model): … class Meta: constraints = [ UniqueConstraint( fields=[“title”, “blog”, “category”], name=”idx1″, condition=Q(category__isnull=False)), UniqueConstraint( fields=[“title”, “blog”], name=”idx2″, condition=Q(category__isnull=True)), ] Django … Read more