Installation of Django
Intially, you should have python in your computer. Then you can type:pip install django
Now, you are ready for your first Django project. To check either your django is installed or not.You can type:
django-admin --version
First Django Project
To start your first django project you have to type:django-admin startproject mysite
Here mysite can be any of your project name. After executing this line of code you will have a directory including:
mysite/
manage.py
mysite/
(Actual Project File)
If you open mysite you can see:
here, __init__.py defines that this is a python package.
settings.py contains all settings of project.
urls.py contains the actual contents on the website.
wsgi.py contains all server management processes.
We will discuss all of them in later. But we are not going to touch __init__.py
Lets begin then:
After successfully execution of django-admin startproject mysite we will have a directory as shown above.
1. __init__.py is a blank page that reminds us only that this is a python package.
2. settings.py is a file which contains all of our project settings. like database management, password validation and so on over here.
3. urls.py stores all the url patterns of your project. Basically different pages link of your web application
4. wsgi.py this is Web Server Gateway Interface. This helps to deploy our project in server.
5. manage.py associates with many of the command we associate with this project.
Lets use manage.py to make our server. For this type:
python manage.py runserver
then open your browser @http//:127.0.0.1:8000/.
Congrats, you are ready now. Now we will begin our website in next tutorial.
Please do comment for any how to do problems. I will try to be as responsive as possible.
No comments:
Post a Comment