ruk·si

Django
Basics

Updated at 2018-04-03 23:06

Django is a free and open-source web framework written in Python.

Compared to Ruby on Rails:

  • Django has less "magic." You are required to write more code in Django, but you also need to know less to be productive with Django.
  • __Ruby on Rails is faster to develop with __ if the team already understands RoR.
  • Django uses Python, and there are a lot of non-web related libraries for Python, e.g., for data science and math. If those are important to you, you might as well use Django to avoid using multiple languages. you, you might as well just use Django to avoid using multiple languages.
  • Ruby on Rails ecosystem has more web-centric libraries.

Django project consists of apps.

  • App can be a whole web application or just part of it, e.g., blog.
  • Project is a collection of apps for a particular website.
  • App can be on multiple projects, but not necessary.

Django apps follow the same naming conventions as Python modules.

mydjangoapp   # GOOD
MyDjangoApp   # BAD
my_django_app # BAD
my-django-app # BAD, WONT EVEN WORK

Default apps in a Django project:

  • django.contrib.admin - Admin control panel functionality.
  • django.contrib.auth - Authentication system.
  • django.contrib.contenttypes - Content type management.
  • django.contrib.sessions - Session management.
  • django.contrib.messages - One-time notification framework.
  • django.contrib.staticfiles - Static file management.

Database configuration is in djangor/settings.py. By default, Django uses local SQLite database.