My Brain Cells

Easiest (and best) learning materials for anyone with a curiosity for machine learning and artificial intelligence, Deep learning, Programming, and other fun life hacks.

Django

 

What is Django?

  Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of Web development, so you can focus on writing your app without needing to reinvent the wheel. It’s free and open source. Here


First Things First:

1. Install python in computer. link

2. Set the path of python in environment variable.

3. now install vs code. link

4. Open the terminal in vs code.

5. Now create a virtual environment by command- “python -m venv env”

6. Open command pallet in vs code and search for python env, activate it.

7. Now your environmet is ready for the django project.

8. Now in terminal install django by command “python -m pip install django”

9. To check use pip freeze to show all the packages that are present or installed.

10. Start project by command “django-admin startproject projectname

11. Go to project directory.

12. To run the project or to run server use command “python manage .py runserver”


MVT(Model View Template) of Django :



NEXT:

1. Check for the migration,by “python manage.py  makemirations”

2. To create the migrations “python manage.py migrate”

3. Now start the app in the project by “python manage.py startapp appname”

4. Now in a the appname folder add urls.py file manually

5. In main setting.py add app in the app list.

6. Now we should include that urls.py to the main urls.py file 

7. So go to the main urls.py and add “path(”,include(‘appname.urls’))

8. Add include after the “path”(in import line)

9.Now add templates in the settings.py , go to the templates section and under dirs=[]

   Add dirs=[os.path.join(BASE_DIR,’templates’],

10. Now add static files so go down in the same settings.py file

     Under 

    STATIC_URL = ‘/static/’

     Add 

     STATICFILES_DIR =(

    os.path.join(BASE_DIR,’static’),

          )

________________________________________________________________________

Django Documentation: Here

Free ebook for Complete Django: Here

__________________________________________________________________________________

Anthony

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top