Quick Start Guide
=================
This guide will get you up and running with Martor in just a few minutes.
Basic Usage
-----------
Once you've completed the :doc:`installation`, you can start using Martor in your Django applications.
Using Martor in Models
~~~~~~~~~~~~~~~~~~~~~~
The simplest way to add markdown editing to your Django models:
.. code-block:: python
# models.py
from django.db import models
from martor.models import MartorField
class Post(models.Model):
title = models.CharField(max_length=200)
content = MartorField() # This replaces TextField
created_at = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.title
The ``MartorField`` automatically provides:
* Rich markdown editing interface
* Live preview
* Toolbar with formatting options
* Image upload capabilities (when configured)
Using Martor in Forms
~~~~~~~~~~~~~~~~~~~~~
For custom forms, use ``MartorFormField``:
.. code-block:: python
# forms.py
from django import forms
from martor.fields import MartorFormField
class PostForm(forms.Form):
title = forms.CharField(max_length=200)
content = MartorFormField() # Martor field
# Or with ModelForm
class PostModelForm(forms.ModelForm):
class Meta:
model = Post
fields = ['title', 'content']
widgets = {
'content': MartorWidget(), # Optional: explicit widget
}
Template Integration
~~~~~~~~~~~~~~~~~~~~
In your templates, you need to include the necessary CSS and JavaScript files.
**Template for forms (editing):**
.. code-block:: html
{% extends "base.html" %}
{% load static %}
{% block css %}
{% endblock %}
{% block content %}