Creating a new Django application

A Django application is a submodule of the project which is self-contained and not intertwined with other applications. In theory, you could copy it and put it in another project without much, or any, change.

Typically, to start a Django app, you have to run the manage.py startapp command in the command line, which will create a new folder in your projectwhere you can find a view, a model, an admin, and a test Python file.

Visual Studio provides an easy way of creating a new Django app right in the IDE, automating the whole process; furthermore, the command is also in the process of creating a template folder. To create a new Django application, just right-click on the project node in the Solution Explorer window and select the Django app command in the Add menu:

Creating a new Django application

This opens the Add Django App window in which you can assign the name of the Django app to be created:

Creating a new Django application

By clicking on OK, the Django app is created in the project, and a list of added files can be found in the Solution Explorer window:

Creating a new Django application

Now you can create the code for the app as we usually do for Django. Take into account that even if Visual Studio automates the creation of the Django application, it doesn't necessarily create the entry in the settings file. This has to be done manually as usual, adding the reference into the Installed_Apps section; to do this, just open the main settings.py file and add the newly created application in the Installed_Apps section:

Creating a new Django application
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.29.119