Friday, 9 July 2021

*Episode 3* DJANGO (Apps Life Cycle of Django)

 


Apps Life Cycle


    A project is made up of many applications. Each of these applications has an object that could equally be used in any other project. A good example of this is the contact form used on a website, as it can be used on other websites. It should be seen as a module for a project.


  •  Creating an Application :-

     Our assumption is that you are in the project folder. The main “project1” folder is similar to the folder “manage.py”.


$ python manage.py startapp myapplication


     At this point, you will have created the application “myapplication” and we can then create the “myapplication” folder with the structure given below:


myapplication/

__init__.py

admin.py

models.py

tests.py

views.py


  •   __init__.py- this will ensure that Python handles the folder as a package.
  •  admin.py- this helps to make the app be modifiable in admin interface.
  •  models.py- this will store all the models for the application.
  •  tests.py- this has the unit tests.
  •  views.py- this is where the application views are stored.

     Now that we have the application “myapplication”, it is a good time for us to register it to the Django project we previously created, which is “project1”. To do this, update the INSTALLED_APPS tuple located in the file settings.py for our project. This is shown below:


INSTALLED_APPS = (

‘django.contrib.admin’,

‘django.contrib.auth’,

‘django.contrib.contenttypes’,

‘django.contrib.sessions’,

‘django.contrib.messages’,

‘django.contrib.staticfiles’,

‘myapplication’,

)


👈Episode 2(D).                                           Episode 4(D)👉

Share This Post

PRINT THIS POST

No comments:

Post a Comment

If you have any doubts. Please let me know.

Featured post

*Episode 1* MCQ for Govt. Job/ Private Job/ MNCs

  Topic:- One Word Substitution 1) Especially skilled in storytelling  Answer:- Raconteur 2) Fear of loneliness Answer:- Eremophobia  3) Usa...