Skip to content
This repository has been archived by the owner on Mar 21, 2023. It is now read-only.

Welcome and Introduction to Quakers and Mental Health (QMH) and Django

Lindsay R. Silver edited this page Sep 22, 2015 · 1 revision

Introduction to Django

Using Django, I was able to create the framework and backend for the QMH website.

Django has pretty exceptional documentation on its own site, https://docs.djangoproject.com/en/1.8/intro/tutorial01/, and also on stackoverflow, and other online forums. After you get through the installation of Django and also finish getting everything set in the settings.py file, follow the instructions below to really get your Django site started!

Creating Models and the Admin Page

Getting started with Django, I created the models and admin page that work with the database. Primarily we were using a sqlite3 database, and then moved everything over to a PostgreSQL database.

To learn about what models are and how to make an admin page, take a look at FriendsAsylum > models.py and FriendsAsylum > admin.py -- this should give you a pretty good idea about how to start making an admin page and the layout that your database will take from the models you create.

Making a Web Page

In terms of starting to create actual web pages, you are going to need four things:

  1. a templates folder,
  2. a static folder (if you want to have any CSS, Images, JavaScript, etc.),
  3. a views.py and,
  4. a urls.py.

In your templates folder, you can do some pretty great things with Django's {% include %} statements, but I would just look that up on the Django documentation (https://docs.djangoproject.com/en/1.8/ref/templates/builtins/#include). To get started, simply make a .html file and put it in your templates folder.

To get that page to actually show up on your test site, go into your views folder and create a view for the .html file you just created. Look at FriendsAsylum > views.py to get a better sense of what I mean by "create a view"--it's a type of python function. Then, to get that view to actually be found when someone types in: yoursite.com/yourhtmlfile.html you will need to have a url listed in urls.py. Again, reference FriendsAsylum > urls.py to see what I mean (it has a pretty standard format).

OK! So hopefully that helps you get started with Django models, the admin page, and making an html file show up on your site-in-testing.