Thursday, February 17, 2011

Creating the main page view

A view in Django terminology is a regular Python function that responds to a page request by generating the corresponding page. To write our first Django view for the main page, we first need to create a Django application inside our project. You can think of an application as a container for views and data models. To create it, issue the following command within our django_working_directory folder:

$ python manage.py startapp <app_name>


After running this command, Django will create a folder named <app_name> inside the project folder with these three files:

• __init__.py: This file tells Python that <app_name> is a Python package
• views.py: This file will contain our views
• models.py: This file will contain our data models



No comments:

Post a Comment