Ticket #19582: proposal_1.rst

File proposal_1.rst, 2.0 KB (added by jpic, 3 years ago)

Proposal for the tutorial06, based on Jannis suggestion to kind of follow the structure of the tutorial about templates (project-specific override first, app templates next)

Writing your first Django app, part 6

This tutorial begins where :doc:`Tutorial 5 </intro/tutorial05>` left off. We've built a tested Web-poll application, and we'll now add some scripts and stylesheets.

?

Customize your project's look and feel

In tutorial02 -> Customize the admin look and feel -> Customizing your project's, we introduce TEMPLATE_DIRS.

As such, it would make sense to introduce STATICFILES_DIRS the same way here. A way to do it is to:

  • make polls/templates/polls/base.html
  • make polls/templates/polls/{detail,index,result}.html to extend polls/base.html
  • make polls/base.html to extend mysite/templates/base.html
  • set STATICFILES_DIRS=[so.path.join(BASE_DIR, 'static')]
  • add mysite/static/style.css
  • (open http://localhost:8000/static/style.css ?)
  • load {% static 'style.css' %} in mysite/templates/base.html

So we would have to introduce the concept of template inheritance, another way to do it is:

  • set STATICFILES_DIRS=[so.path.join(BASE_DIR, 'static')]
  • create mysite/static/style.css
  • (open http://localhost:8000/static/style.css ?)
  • make polls/templates/polls/detail.html to load style.css
  • realize that we want style.css in all our poll templates
  • make polls/templates/polls/base.html
  • make polls/templates/polls/{detail,index,result}.html to extend polls/base.html

Appfinder

At this point we could introduce the appfinder. That would be consistent with the tutorial about templates.

What's next?

The beginner tutorial ends here for the time being. In the meantime, you might want to check out some pointers on :doc:`where to go from here </intro/whatsnext>`.

?

If you are familiar with Python packaging and interested in learning how to turn polls into a "reusable app", check out :doc:`Advanced tutorial: How to write reusable apps</intro/reusable-apps>`.

?
Back to Top