Basic Template and Views

Now we had our models ready and we need to add we could only add new hall and booking from the default ‘admin panel’ that comes with Django. But if we want that to be done on the user side then we must use html pages. So in Django, we use a proper way to show html pages. The system is called Template system. Templates are generally html files.

Django is based on DRY principle which means Don’t Repeat Yourself. In the template system django follows the same. If we create a base html that can be used as a base for all other html pages, and we can use {% extends “base.html” %} in other html files. And we use {% block content %} {% endblock %} in the base.html for the variable parts of the pages. In other pages we just use {% extends “base.html %} {% block content %}<h3>Bookings</h3> {% endblock %}  Hence we don’t have to repeat the base.html again and we have to write only one new line <h3>Bookings</h3> for a completely new page. The major advantage is that we don’t have to use all the necessary html tags like <html>, <head>, <body> and their closing tags again and again into all the template files. For this we just extend the base page and use all the tags defined in it. I tried my hands on bootstrap and used some of its classes, but it is not properly implemented yet.

Hence till now there is a is created in which 4 functions(home, view, book, cancel) are defined that call the templates (html) to be rendered when a particular URL( is visited in the browser. is a file for defining the regular expressions that can be used to call the views that further call the html to be rendered. Quite confusing!!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s