Skip to content

Django

SQLlite as separate package

To use separately from Python version.

pip install pysqlite3-binary

In Django project settings.py add

__import__('pysqlite3')
import sys
sys.modules['sqlite3'] = sys.modules.pop('pysqlite3')

Django run testserver on all interfaces

First add to allowed host in project settings.py:

ALLOWED_HOSTS = ["*"]

Then run the server

python manage.py runserver 0.0.0.0:8000

Django protect from CSRF in form

<h1>Add New Book</h1>
<form method="post">
    {% csrf_token %}
    {{ form.as_p }}
    <div>
        <input type="submit" value="Add Book">
    </div>
</form>