Learning Django

Tutorial: Django-Polls App

We start with this amazing tutorial in building a Django polls app. The final code of the tutorial is here.

After this, we will extend the App with additional feature like Bootstrap and Angular 8.

Starting with Django

Installation with Pip

$ pip install Django
$ python -m django --version
$ python -c "import django; print(django.__file__)"
<BASEDIR>/python/lib/python3.7/site-packages/django/__init__.py

Install from Source

$ git clone https://github.com/django/django.git

Tutorial

https://docs.djangoproject.com/en/2.2/intro/tutorial02/

Starting with Django-CRM

Installation with Homebrew (Mac OS)

Installation from Source

pip install django
pip install django-crm
git clone https://github.com/MicroPyramid/Django-CRM
pip install -r requirements.txt
python manage.py makemigrations
python manage.py createsuperuser
python manage.py runserver

Configure development environment

Visual Studio Code

pip install pylint-django

Helpfull links and documentation

Links

https://www.fullstackpython.com/django.html

Tipps and Tricks

Customize 404 Page

If Django could not find a page for a given url, the following page ist used as error page:

<DJANGOINSTALLDIR>/views/templates/technical_404.html

Find the line with

{% for pat in pattern %}
{{ pat.pattern }}
{% if forloop.last and pat.name %}[name='{{ pat.name }}']{% endif %}
{% endfor %}

Replace the content with

{% for pat in pattern %}
<a href="{{ request.build_absolute_uri }}/{{ pat.pattern }}">{{ pat.pattern }}</a>
{% if forloop.last and pat.name %}[name='{{ pat.name }}']{% endif %}        
{% endfor %}