-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
commandA management command.A management command.enhancementNew feature or requestNew feature or request
Milestone
Description
See #50.
The provided modules are sometimes needed and sometimes not.
- Sometimes, apps are created for SRP, which means they are created to isolate a functionality in an app. For instance, a project might have an
ajaxapp for providing JSON endpoints to bring dynamism to a web page or arestapp to isolate REST endpoints. - Sometimes, apps are created as an extension. For instance, if a project has a different text formatting specification (like BBCode), it is better to isolate it into an app.
- Sometimes, apps are created to isolate a part of whole project. Let's say we have a web app with a homepage, a forum, a QA platform and a messaging platform. We would create separate apps for each.
So, adding models, views, tests and not including urls module is not always desirable. We can, however, provide a command that can create an app interactively, asking what part exactly a developer needs.
createapp will be a command in core app. It is an alternative to startapp command but different in behavior.
Interactivity
Upon python3 manage.py createapp, an interactive session will start. It is represented in order in the table below.
Note
In the table below, a module is a single
pyfile while package is a directory with__init__.pyin it.
| Condition | Order | Question | Answer Type | Default Answer | Description |
|---|---|---|---|---|---|
| - | 1 | Would you like to have models in your app? | y/n/Y/N |
y |
1. Creates models module.2. Adds # noqa comment at the end of models import.3. Adds a # TODO remove noqa comment above import.4. Adds explanation as to factories and drawio files. |
If y to 1 |
2 | Would you like to have factories in your app? | y/n/Y/N |
y |
1. Creates factories module.2. Adds appname.factories to conftest.py at root.3. Adds explanation as to how to write factories. |
If y to 1 |
3 | Would you like to create arch.drawio file? |
y/n/Y/N |
n |
Creates arch.drawio file. |
| - | 4 | Would you like to have views in your app? | y/n/Y/N |
y |
Creates views package. |
If y to 4 |
5 | Would you like to have urls in your app? | y/n/Y/N |
y |
1. Creates urls module.\n2. Adds app_name variable to urls module so we can have namepsaces on urls.3. Adds urlpatterns list.4. Imports path and adds # noqa comment at the end.5. Adds appname.urls to projects.url module. |
If y to 5 |
6 | What should be the root URL for your app? | text | empty | If left empty, attaches url to the root url. |
| - | 7 | Would you like admin integration for your app? | y/n/Y/N |
n |
1. Creates admin module.2. Imports admin and adds # noqa to the end. |
If y to 4 |
8 | Would you like Laravel Mix support? | y/n/Y/N |
n |
Sets up Laravel Mix for the app. |
Gitignore
A .gitignore should be present at the root of each app so that it won't include unwanted files on commit.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
commandA management command.A management command.enhancementNew feature or requestNew feature or request