A Django management command to create apps in a subdirectory (e.g., apps/) for better project organization
Project description
django-startsubapp
A Django management command that creates Django apps inside a dedicated apps/ folder to keep your project structure clean and organized.
Features
- ๐ Create Django apps directly inside the
apps/folder - ๐ฆ Automatically handles app structure and configuration
- ๐ง Simple command:
python manage.py startsubapp [app_name] - ๐ก๏ธ Input validation to prevent errors
- โจ Enhanced user feedback with status messages
Installation
Via PyPI
pip install django-startsubapp
Development Installation
git clone https://github.com/Saman-naruee/django-startsubapp.git
cd django-startsubapp
pip install -e .
Quick Start
1. Add to Django Project
Add startsubapp to your Django project's INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
# ... other apps
'startsubapp',
]
2. Create a New Sub-App
Run the management command:
python manage.py startsubapp myapp
This will create:
myproject/
โโโ apps/
โ โโโ myapp/
โ โโโ migrations/
โ โโโ __init__.py
โ โโโ admin.py
โ โโโ apps.py
โ โโโ models.py
โ โโโ tests.py
โ โโโ views.py
โ โโโ ...
โโโ manage.py
โโโ ...
3. Update Your Settings
Add the new app to INSTALLED_APPS:
INSTALLED_APPS = [
# ... other apps
'apps.myapp', # Note: apps.myapp format
]
Usage
Command Syntax
python manage.py startsubapp [app_name]
Example
Create an accounts app:
python manage.py startsubapp accounts
This creates apps/accounts/ with all necessary Django app files.
How It Works
- Creates the
apps/folder if it doesn't exist - Uses Django's built-in
startappcommand to create the app structure - Moves the app from the project root into the
apps/folder - Ensures proper
__init__.pyexists in the app directory - Automatically configures the app's
apps.pywith the correct path
Error Handling
The command includes validation for:
- Invalid app names: Prevents dots (
.) in app names - Existing apps: Checks for conflicts before creation
- File system errors: Handles file operations safely
Example error message:
$ python manage.py startsubapp my.app
Error: Dots not allowed in app_name. Use simple name like 'accounts'
Project Structure
The package follows modern Python packaging standards:
django-startsubapp/
โโโ src/
โ โโโ startsubapp/
โ โโโ __init__.py
โ โโโ apps.py
โ โโโ management/
โ โโโ commands/
โ โโโ startsubapp.py
โโโ tests/
โ โโโ test_basic.py
โโโ pyproject.toml
โโโ setup.cfg
โโโ README.md
โโโ LICENSE
โโโ .gitignore
Requirements
- Python 3.8+
- Django 3.0+
Testing
Run tests with:
python -m pytest tests/
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Saman Naruee
- Email: samannaruee@gmail.com
- GitHub: @Saman-naruee
Support
If you encounter any issues, please open an issue on GitHub.
Changelog
v1.0.0 (Initial Release)
- Initial release of django-startsubapp
- Basic functionality for creating sub-apps in
apps/folder - Full validation and error handling
- PyPI publication
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_startsubapp-1.0.0.tar.gz.
File metadata
- Download URL: django_startsubapp-1.0.0.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5cfd1a903ce900cee66bd9b7346b68da100d4e0c8ec6a411b25d54054877cd3
|
|
| MD5 |
1b9d2db18321a653479339830322813b
|
|
| BLAKE2b-256 |
c82620c98abbb8e8e2924b794865b7f4530ef6aef6f698ab34ccfd12473adcde
|
File details
Details for the file django_startsubapp-1.0.0-py3-none-any.whl.
File metadata
- Download URL: django_startsubapp-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a422637965db93cc27e98c5ec8605fa0f8e1e2cb598595eb915a60031c4d374f
|
|
| MD5 |
8e510e1dcee94eba66110c427f12ce4f
|
|
| BLAKE2b-256 |
63a6e545466bb4e6c81cd09c66e35c35300768dd361929b21505a5d1303b1624
|