erayerdin / sos-django-template

SOS Django Template is a starter template for new Django projects with modern defaults, power cable included.
Do What The F*ck You Want To Public License
20 stars 2 forks source link

createapp command #51

Open erayerdin opened 3 years ago

erayerdin commented 3 years ago

See #50.

The provided modules are sometimes needed and sometimes not.

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 py file while package is a directory with __init__.py in 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.\n
2. 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.