Metadata-Version: 2.4
Name: zfold
Version: 0.2.0
Summary: Django code generator with styled HTML templates
Project-URL: Homepage, https://github.com/zaidanch/zfold
Project-URL: Repository, https://github.com/zaidanch/zfold
Project-URL: Issues, https://github.com/zaidanch/zfold/issues
Author: Zaidan Chaudhary
License-Expression: MIT
Keywords: cli,codegen,django,scaffold
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Software Development :: Code Generators
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# Zfold

Django code generator with styled HTML templates.

Generate complete CRUD stacks from the terminal—models, views, forms, URLs, admin registration, and production-ready styled templates—in one command.

## Install

```bash
pip install zfold
```

## Quick Start

From your Django project root (where `manage.py` lives):

```bash
zfold scaffold blog Post title:CharField content:TextField published:BooleanField
```

This creates a complete `blog` app with:

| File              | Contents                                    |
|-------------------|---------------------------------------------|
| `models.py`       | Post model with your fields                 |
| `forms.py`        | PostForm (ModelForm)                        |
| `views.py`        | List, detail, create, update, delete views  |
| `urls.py`         | URL patterns for all views                  |
| `admin.py`        | Admin registration with list_display        |
| `templates/`      | Styled HTML templates                       |

Then wire it up:

```python
# settings.py
INSTALLED_APPS = [..., 'blog']

# urls.py
path('blog/', include('blog.urls'))
```

Run migrations and open `/blog/`:

```bash
python manage.py makemigrations blog && python manage.py migrate
python manage.py runserver
```

## Commands

### scaffold

Generate a complete app:

```bash
zfold scaffold <app> <Model> [field:Type ...]
zfold s blog Post title:CharField body:TextField    # alias
```

### generate

Generate individual components for an existing app:

```bash
zfold generate <component> <app> <Model> [field:Type ...]
zfold g model blog Comment body:TextField           # alias
```

| Component  | Output                                         |
|------------|------------------------------------------------|
| `model`    | Model class + admin registration               |
| `view`     | CRUD class-based views                         |
| `form`     | ModelForm                                      |
| `template` | Styled HTML templates                          |

## Fields

Use `name:FieldType` format:

```bash
zfold scaffold shop Product name:CharField price:DecimalField in_stock:BooleanField
```

**Common types:** `CharField`, `TextField`, `IntegerField`, `BooleanField`, `DateTimeField`, `DecimalField`, `EmailField`, `SlugField`, `ForeignKey`

Any valid Django field type is accepted.

## Options

| Flag        | Effect                         |
|-------------|--------------------------------|
| `--force`   | Overwrite existing files       |
| `--help`    | Show help                      |
| `--version` | Show version                   |

## Naming Conventions

| Element | Format      | Example                    |
|---------|-------------|----------------------------|
| App     | lowercase   | `blog`, `my_shop`          |
| Model   | PascalCase  | `Post`, `OrderItem`        |
| Field   | snake_case  | `title`, `created_at`      |

## Generated Templates

Zfold generates styled, responsive HTML templates:

- **List view** — Table with all records, empty state
- **Detail view** — Single record with edit/delete actions
- **Form view** — Create and update forms with styling
- **Delete confirmation** — Confirm before deleting

Templates extend `base.html` which you can customize. No CSS framework dependencies—styles are included inline.

## Example Workflow

```bash
# Create a blog app
zfold scaffold blog Post title:CharField content:TextField

# Add another model to the same app
zfold generate model blog Comment body:TextField

# Regenerate templates after changing fields
zfold --force generate template blog Post
```

## Documentation

Full documentation: [github.com/zaidanch/zfold](https://github.com/zaidanch/zfold)

## License

MIT
