Metadata-Version: 2.1
Name: micro-django-base
Version: 1.0.0
Summary: A Reusable RTL Django Base App
Home-page: https://github.com/debeski/micro-base
Author: DeBeski
Author-email: DeBeski <debeski1@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/debeski/micro-base
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5
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: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django (>=5.1)

# Micro Base - A Reusable RTL Django Base App

[![PyPI version](https://badge.fury.io/py/micro-django-base.svg)](https://pypi.org/project/micro-django-base/)

**RTL** lightweight, reusable django app that provides a dynamic base for your django projects.
It includes base templates, authentication utilities, and file management helpers.

## Features
- **Dynamic Model Lookup**: Reference models by name (e.g., `'Decree'`) or app label (e.g., `'documents.Decree'`).
- **App-Agnostic Utilities**: Generic file downloaders, permission checkers, and archiving helpers.
- **RTL Support**: Built-in RTL styling for Arabic applications.
- **Unified Base Templates**: Ready-to-use `base.html` with sidebar and topbar integration.

## Installation

1.  **Install the package:**
    ```bash
    pip install micro-django-base
    ```

2.  **Add to `INSTALLED_APPS`:**
    In your `settings.py`:
    ```python
    INSTALLED_APPS = [
        ...
        'base',
        'users',  # Required dependency (micro-users-pkg)
        ...
    ]
    ```

3.  **Run Migrations:**
    Since `base` is a reusable app, run migrations from your main project:
    ```bash
    python manage.py makemigrations base
    python manage.py migrate base
    ```

## Usage

### File Downloading
Use the universal downloader in your views or templates.

**`file_type` Parameters:**
- `'all'`: **(Default)** Dynamically finds and downloads *all* `FileField` and `ImageField` files attached to the record.
- `'field_name'`: Downloads a specific field by its name (e.g., `'pdf_file'`, `'custom_doc'`, `'cover_image'`).

**Usage in Python Views:**
```python
from base.fetcher import download_single_file

def my_download_view(request, record_id):
    # Download ALL files for this record
    return download_single_file(request, 'Decree', record_id, file_type='all')

    # Download only a specific field
    return download_single_file(request, 'Decree', record_id, file_type='my_custom_field')
```

**Usage in HTML Templates:**
You can use the built-in URL pattern directly:
```html
<!-- Download specific file -->
<a href="{% url 'base:download_file' model_name='Decree' record_id=obj.id file_type='pdf_file' %}" class="btn btn-primary">
    Download PDF
</a>

<!-- Download ALL files (zipped) -->
<a href="{% url 'base:download_file' model_name='Decree' record_id=obj.id file_type='all' %}" class="btn btn-info">
    Download All
</a>
```
*Note: Ensure you include `base.urls` in your project's `urls.py` with `namespace='base'`.*

### Static Files
Base templates are available under `base/templates/`. Extend them in your project:
```html
{% extends "base.html" %}

{% block content %}
    <h1>My Page</h1>
{% endblock %}
```
Static files (CSS/JS) are allocated in `base/static/base/`.

## Version History

| Version | Changes |
| :--- | :--- |
| **v1.0.0** | Initial Release. |
