Github icon Twitter icon Facebook Globe

From 0 to 100 in Django

Sunday 9:00am, Audobon
Beginner

About This Tutorial

This tutorial will assume the attendees have zero experience with Python and Django. The core concepts explored will be

  • Python/Django best coding practices - We will review PEP 8 as well as well as the Django Coding Style and Django’s Design Philosophies.

  • Using an ideal Django environment - This section will cover how to use pip to install django and dependencies, creating a requirements.txt, using virtualenv/virtualenvwrapper, setting up git, best practices for storing static files (bower/npm with git ignoring vendor js/css files), and how Django lays out projects.

  • Django application design - this section will be based heavily on the Advanced tutorial, but will also cover how to create a “utility” app that has no models, but contains logic that works with multiple other apps/packages yet doesn’t exclusively belong to one app.

  • Dealing with settings file(s) - having a production environment and multiple people working on the same project means there is going to end up being different settings files. This section will walk through creating a “base settings file” that contains shared information, setting up individual developer settings files, and setting up production settings files. There will also be a heavy emphasis on keeping the production code secure using environment variables to hide database passwords and secret keys. This section will also review using post setups in virtualenvwrapper to streamline setting environment variables. If time allows I would also like to spend time explaining some of the more ambiguous settings that people have a hard time with such as staticfiles_dir and static_root

  • Models - keeping less models per app and more apps, working with and understanding how migrations work, keeping models normalized, the difference between null and blank, what are and how to use Model Managers, using functions in models (aka “Fat” models)

  • Function Based or Class Based views - a quick review of the differences and why you would want to use one over the other. This will also touch on CBV mixins.

  • Logging/debugging - to many people use “print()” to debug code when django and Python have great logging capabilities built in. This section will review how to setup logs, rotating logs, and extra third party tools to help with debugging when applications go wrong. This will also cover useful third party packages such as django-debug-toolbar and builtins like pdb.

  • Django Admin - this section will cover some minor customization for the Django admin, specifically; where templates are located, how to add custom actions to an admin section, how to add callables

  • The Django User Model - This section will cover the pros and cons of the django user model, how to extend the user model via OneToOne fields, how to replace the model entirely, and how to link the model to other models.

  • Testing Django - how to write basic tests, additional packages that will help manage tests (coverage, etc), how to test for results and failures, keeping tests DRY, using factories to make testing quicker, the difference between RequestFactory and using self.client, how to use Mock to isolate tests.

  • Signals, good and evil - A lot of beginners jump to signals to try and solve all their problems. This section will review when it is appropriate to use signals, why you shouldn’t use them immediately and how to use signals properly.

  • Setting a production environment - This section will review different choices for production environments such as: what server to use (VPS, PASS, etc), what software to use on a VPS (nginx/apache, uwsgi/gunicorn), how to automate deployment (fabric, invoke, makefiles)

  • How to find help - the tutorial will conclude with a small section about how to get more help if you need it. Links will be provided to the Django IRC channel as well as the help mailing list, and a brief explanation of how to submit issues on github.

Photo of

Jeremy Spencer

I’m a problem solver who likes to help people. In community college I was the classic pessimistic angsty teen but a beloved professor and close personal friend really inspired me to want to help and teach people. Since then I have been actively engaged in multiple different communities from Quora (Top Writer), mailing lists, IRC channels, and any open community revolving around software. Now after years of working with Django I want to give back to this community that helped me so much. Django and Python made me love programming again and I want to get beginners to love Django as well.