Metadata-Version: 2.4
Name: django-unfold-markdown
Version: 0.1.2
Summary: Markdown editor widget for Django Unfold admin
License: MIT
License-File: LICENSE.md
Keywords: django,unfold,markdown,admin,easymde,widget
Author: Sergei Vasilev
Requires-Python: >=3.10,<4.0
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
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.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
Requires-Dist: django (>=4.2)
Requires-Dist: django-unfold (>=0.70.0)
Project-URL: Homepage, https://github.com/sergei-vasilev-dev/django-unfold-markdown
Project-URL: Repository, https://github.com/sergei-vasilev-dev/django-unfold-markdown
Description-Content-Type: text/markdown

# Django Unfold Markdown Widget

Markdown editor widget for [Django Unfold](https://github.com/unfoldadmin/django-unfold) admin using [EasyMDE](https://github.com/Ionaru/easy-markdown-editor).

## Screenshots

### Editor with Preview
![Markdown Editor](https://github.com/sergei-vasilev-dev/django-unfold-markdown/raw/main/docs/screenshots/editor-preview.png)

### Fullscreen Mode
![Fullscreen Mode](https://github.com/sergei-vasilev-dev/django-unfold-markdown/raw/main/docs/screenshots/editor-fullscreen.png)


### Editor inside tab and Dark theme
![Editor tab and dark theme](https://github.com/sergei-vasilev-dev/django-unfold-markdown/raw/main/docs/screenshots/editor-tab-dark-theme.png)


## Features

- **Plain text editor** with monospace font
- **Side-by-side preview** and fullscreen modes
- **Dark/light theme** integration with Unfold
- **Material Symbols icons** matching Unfold design
- **Toolbar**: bold, italic, strikethrough, headings, lists, links, images, tables, horizontal rules
- **No autosave** (saves on form submit)
- **Responsive** design

## Installation

```bash
pip install django-unfold-markdown
```

## Configuration

Add to your `INSTALLED_APPS`:

```python
# settings.py
INSTALLED_APPS = [
    "unfold",
    "unfold_markdown",  # Add this
    # ...
]
```

## Usage

### For all TextField fields

```python
# admin.py
from django.db import models
from unfold.admin import ModelAdmin
from unfold_markdown.widgets import MarkdownWidget

@admin.register(Article)
class ArticleAdmin(ModelAdmin):
    formfield_overrides = {
        models.TextField: {"widget": MarkdownWidget}
    }
```

### For specific fields

```python
from django import forms
from unfold_markdown.widgets import MarkdownWidget

class ArticleForm(forms.ModelForm):
    content = forms.CharField(widget=MarkdownWidget())
    
    class Meta:
        model = Article
        fields = '__all__'

@admin.register(Article)
class ArticleAdmin(ModelAdmin):
    form = ArticleForm
```

## Storage and Rendering

The widget stores pure Markdown text in your database. To render Markdown as HTML, use a Python library:

```python
# Using markdown
from markdown import markdown
html = markdown(article.content)

# Using mistune
import mistune
html = mistune.html(article.content)
```

## Requirements

- Python ≥ 3.10
- Django ≥ 4.2
- django-unfold ≥ 0.70.0

## License

MIT License

## Repository

https://github.com/sergei-vasilev-dev/django-unfold-markdown

## Credits

- **EasyMDE**: [Ionaru/easy-markdown-editor](https://github.com/Ionaru/easy-markdown-editor) (MIT License)
- **Django Unfold**: [unfoldadmin/django-unfold](https://github.com/unfoldadmin/django-unfold) (MIT License)


