Django for Designers/Basic views: Difference between revisions

imported>Aldeka
 
(3 intermediate revisions by 3 users not shown)
Line 25:
<div class="instructor">For Django, a ''model'' represents how the data is stored. This is the part of your app that ties your data to storage in a database. You write Python code, and Django converts it and out of into SQL, the language spoken by databases.
 
A ''view'' in Django handles a ''request'' from the website visitor for a web page. What you do with this request is up to you, and is the domain of the view code that you write. For example, when a request comes in, you could send start a background process to send a fax to Tokyo indicating how happy you are that someone came to your website. Or you could provide a HTTP response to the website visitor with a list of recently bookmarked web pages if you are providing a bookmarking app.
 
The ''templates'' in Django control how data is presented. Typically, a view provides a collection of data to the template. The template then might loop over that information, wrap it in HTML bulleted lists, wrap ''that'' in a standard layout for all pages across your site, and serve that out to the site visitor. The templates usually refer to some ''static'' content, such as CSS, that makes the site actually seem designed!
Line 62:
</source>
 
Suppose a visitor to your site goes to (if you view the page, don't worry about the ViewDoesNotExist message, we'll get to that in a minute) [http://localhost:8000/tags/awesome/ http://localhost:8000/tags/awesome/].
* which regex pattern is tripped?
* what function is then called?
Line 192:
 
Now if you go to http://localhost:8000, you should see the webpage we made in our template file!
 
If you do not, you may need to '''restart your development server''' before it "sees" your template.
 
Save and commit your new template and template-based view.
Line 435 ⟶ 437:
Save and commit your work!
 
[[Django_for_Designers/Adding_models|Next page]]
<!-- Teacher git note: git push origin HEAD:pre-part-3 -->
Anonymous user