Metadata-Version: 2.4
Name: django-startsubapp
Version: 1.0.0
Summary: A Django management command to create apps in a subdirectory (e.g., apps/) for better project organization
Home-page: https://github.com/Saman-naruee/django-startsubapp
Author: Saman Naruee
Author-email: Saman Naruee <samannaruee@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/Saman-naruee/django-startsubapp
Project-URL: Documentation, https://github.com/Saman-naruee/django-startsubapp#readme
Project-URL: Repository, https://github.com/Saman-naruee/django-startsubapp.git
Project-URL: Issues, https://github.com/Saman-naruee/django-startsubapp/issues
Keywords: django,management-command,app-structure,django-apps
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 3.2
Classifier: Framework :: Django :: 4.0
Classifier: Framework :: Django :: 4.1
Classifier: Framework :: Django :: 4.2
Classifier: Framework :: Django :: 5.0
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=3.2
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-django>=4.5; extra == "dev"
Requires-Dist: black>=22.0; extra == "dev"
Requires-Dist: isort>=5.0; extra == "dev"
Requires-Dist: flake8>=4.0; extra == "dev"
Dynamic: license-file

# 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

```bash
pip install django-startsubapp
```

### Development Installation

```bash
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`:

```python
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    # ... other apps
    'startsubapp',
]
```

### 2. Create a New Sub-App

Run the management command:

```bash
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`:

```python
INSTALLED_APPS = [
    # ... other apps
    'apps.myapp',  # Note: apps.myapp format
]
```

## Usage

### Command Syntax

```bash
python manage.py startsubapp [app_name]
```

### Example

Create an accounts app:

```bash
python manage.py startsubapp accounts
```

This creates `apps/accounts/` with all necessary Django app files.

## How It Works

1. Creates the `apps/` folder if it doesn't exist
2. Uses Django's built-in `startapp` command to create the app structure
3. Moves the app from the project root into the `apps/` folder
4. Ensures proper `__init__.py` exists in the app directory
5. Automatically configures the app's `apps.py` with 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:

```bash
$ 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:

```bash
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](LICENSE) file for details.

## Author

**Saman Naruee**
- Email: samannaruee@gmail.com
- GitHub: [@Saman-naruee](https://github.com/Saman-naruee)

## Support

If you encounter any issues, please open an issue on [GitHub](https://github.com/Saman-naruee/django-startsubapp/issues).

## 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
