Metadata-Version: 2.1
Name: django-nice
Version: 0.1.2
Summary: Library to bind Django models with NiceGUI elements using DRF and SSE.
Home-page: https://github.com/rexsum420/django-nice
Author: Jeffery Springs
Author-email: rexsum420@gmail.com
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=3.2
Requires-Dist: djangorestframework
Requires-Dist: django-sse
Requires-Dist: nicegui
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: black; extra == "dev"
Requires-Dist: flake8; extra == "dev"

# Installation: 

```bash
pip install django-nice
```

## Usage:

set these settings in your settings.py file:

```python
from django_nice.config import Config

# Configure the base URL (host) for the API
Config.configure(host='http://your-production-server.com', api_endpoint='/api')
```

add these to your projects urls.py file:

```python
from django_nice.config import Config

# Register API and SSE endpoints for a model (e.g., Data model in app 'myapp')
Config.add_urls_to_project(urlpatterns, app_label='myapp', model_name='Data')
```

then use inside your NiceGUI component like this:

```python
from nicegui import ui
from django_nice.frontend import bind_element_to_model

@ui.page('/')
def index():
    textarea = ui.textarea('This is data that is bound to the django model').classes('w-full')
    bind_element_to_model(textarea, app_label='myapp', model_name='Data', pk=1, field_name='data_to_display')

ui.run()
```
