-
Notifications
You must be signed in to change notification settings - Fork 0
Getting Started with Django, and Making Your First Page Show Up!
Using Django, we will create the framework and backend for the FAIRPLAY web application.
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.
Getting started with Django, we have created the models and admin page that work with the database. We are using a PostgreSQL database.
To learn about what models are and the admin page, take a look at the folder webapp > models.py and webapp > admin.py -- this should give you a pretty good idea about what's involved with the models and admin page, and the layout that the postgreSQL database takes from the models we created.
In terms of starting to create actual web pages, you are going to need four things:
- a templates folder,
- a static folder (if you want to have any CSS, Images, JavaScript, etc.),
- a views.py and,
- 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 in the root of this project.
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. To do this, you will need to make changes to webapp > views.py(to "create a view," you will be writing python functions). 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 which lives under the webapp > urls.py folder structure.
OK! So hopefully that helps you get started with Django models, the admin page, and making an html file show up on the web app we're all making!