Introduce command-line interface and supporting modules for project initialization. - New Features: - Add `cli.py` with Typer commands `secret` and `app` - Implement custom exception hierarchy in `utils/exceptions.py` - Provide secret key generation utilities in `utils/secretkey.py` - Add name validation logic in `utils/validators.py` - Initialize package with empty `__init__.py` - Enhancements: - Update `pyproject.toml` to include new modules and console script entry points - Bug Fixes: - (none)
202 lines
5.2 KiB
Plaintext
202 lines
5.2 KiB
Plaintext
# [[ project_name ]]
|
|
|
|
A Django project folder structure is generated with [djinitx/djinit/dj](https://github.com/S4NKALP/djinit).
|
|
|
|
## Features
|
|
|
|
- Modern project structure with environment-specific settings
|
|
- Pre-configured REST API with JWT authentication
|
|
- Essential dependencies and utilities
|
|
- Production-ready configuration
|
|
|
|
## Setup
|
|
|
|
### Using Just (Recommended)
|
|
|
|
1. Set environment variables in `.env` file
|
|
|
|
2. Run setup (installs dependencies, runs migrations, creates superuser):
|
|
```bash
|
|
just setup
|
|
```
|
|
|
|
3. Start development server:
|
|
```bash
|
|
just dev
|
|
```
|
|
|
|
### Traditional Method
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
pip install -r requirements.txt
|
|
```
|
|
|
|
2. Set environment variables in `.env` file
|
|
|
|
3. Run migrations:
|
|
```bash
|
|
python manage.py migrate
|
|
```
|
|
|
|
4. Create superuser:
|
|
```bash
|
|
python manage.py createsuperuser
|
|
```
|
|
|
|
5. Start development server:
|
|
```bash
|
|
python manage.py runserver
|
|
```
|
|
|
|
## Available Commands
|
|
|
|
Run `just` to see all available commands, including:
|
|
|
|
- `just dev` - Run development server
|
|
- `just migrate` - Run migrations
|
|
- `just makemigrations` - Create migrations
|
|
- `just createsuperuser` - Create superuser
|
|
- `just test` - Run tests
|
|
- `just lint` - Lint code
|
|
- `just format` - Format code
|
|
- `just shell` - Django shell
|
|
- `just clean` - Clean cache files
|
|
- `just install <package>` - Install package
|
|
- `just remove <package>` - Remove package
|
|
- `just server` - Run production server
|
|
- `just ci` - Run all linting and checks
|
|
- `just test-coverage` - Run tests with coverage
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
# @IF predefined_structure
|
|
[[ project_name ]]/
|
|
├── [[ module_name ]]/
|
|
│ ├── settings/
|
|
│ │ ├── base.py
|
|
│ │ ├── development.py
|
|
│ │ └── production.py
|
|
│ ├── urls.py
|
|
│ ├── wsgi.py
|
|
│ └── asgi.py
|
|
├── apps/
|
|
│ ├── users/
|
|
│ │ ├── apps.py
|
|
│ │ ├── models/
|
|
│ │ │ └── user.py
|
|
│ │ ├── serializers/
|
|
│ │ │ └── user_serializer.py
|
|
│ │ ├── services/
|
|
│ │ │ └── user_service.py
|
|
│ │ ├── views/
|
|
│ │ │ └── user_view.py
|
|
│ │ ├── urls.py
|
|
│ │ └── tests/
|
|
│ │ └── test_user_api.py
|
|
│ └── core/
|
|
│ ├── utils/
|
|
│ │ └── responses.py
|
|
│ ├── mixins/
|
|
│ │ └── timestamped_model.py
|
|
│ ├── exceptions.py
|
|
│ └── middleware/
|
|
│ └── request_logger.py
|
|
├── api/
|
|
│ ├── __init__.py
|
|
│ ├── urls.py
|
|
│ └── v1/
|
|
│ ├── __init__.py
|
|
│ └── urls.py
|
|
├── manage.py
|
|
├── requirements.txt
|
|
├── pyproject.toml
|
|
├── uv.lock
|
|
├── .env.sample
|
|
├── justfile
|
|
├── Procfile
|
|
├── runtime.txt
|
|
└── README.md
|
|
# @ELSEIF unified_structure
|
|
[[ project_name ]]/
|
|
├── apps/
|
|
│ ├── admin/
|
|
│ │ └── __init__.py
|
|
│ ├── api/
|
|
│ │ ├── __init__.py
|
|
│ │ ├── urls.py
|
|
│ │ └── v1/
|
|
│ │ ├── __init__.py
|
|
│ │ └── urls.py
|
|
│ ├── models/
|
|
│ │ └── __init__.py
|
|
│ ├── serializers/
|
|
│ │ └── __init__.py
|
|
│ ├── tests/
|
|
│ │ └── __init__.py
|
|
│ ├── urls/
|
|
│ │ └── __init__.py
|
|
│ └── views/
|
|
│ └── __init__.py
|
|
├── core/
|
|
│ ├── asgi.py
|
|
│ ├── __init__.py
|
|
│ ├── settings/
|
|
│ │ ├── base.py
|
|
│ │ ├── development.py
|
|
│ │ ├── __init__.py
|
|
│ │ └── production.py
|
|
│ ├── urls.py
|
|
│ └── wsgi.py
|
|
├── manage.py
|
|
├── requirements.txt
|
|
├── pyproject.toml
|
|
├── uv.lock
|
|
├── .env.sample
|
|
├── justfile
|
|
├── Procfile
|
|
├── runtime.txt
|
|
└── README.md
|
|
# @ELSE
|
|
[[ project_name ]]/
|
|
├── [[ module_name ]]/
|
|
│ ├── settings/
|
|
│ │ ├── base.py
|
|
│ │ ├── development.py
|
|
│ │ └── production.py
|
|
│ ├── admin/
|
|
│ ├── api/ # API endpoints organized by model
|
|
│ │ ├── user/ # Example: if you have a User model
|
|
│ │ │ ├── views.py
|
|
│ │ │ ├── serializers.py
|
|
│ │ │ └── urls.py
|
|
│ │ └── urls.py
|
|
│ ├── models/ # Django models
|
|
│ ├── tests/
|
|
│ ├── urls.py
|
|
│ ├── wsgi.py
|
|
│ └── asgi.py
|
|
├── manage.py
|
|
├── requirements.txt
|
|
├── pyproject.toml
|
|
├── uv.lock
|
|
├── .env.sample
|
|
└── README.md
|
|
|
|
**Note:** For the single folder layout, organize your API endpoints by model name under the `api/` directory.
|
|
For example, if you have a `User` model in `models/user.py`, create:
|
|
- `api/user/views.py` - API views for User
|
|
- `api/user/serializers.py` - Serializers for User
|
|
- `api/user/urls.py` - URL patterns for User endpoints
|
|
|
|
See the README files in `api/` and `models/` directories for more details.
|
|
# @ENDIF
|
|
```
|
|
|
|
## API Documentation
|
|
|
|
When running in development mode, API documentation is available at:
|
|
- Swagger UI: http://localhost:8000/docs/
|
|
- Schema: http://localhost:8000/schema/
|