From 6b60d04e44d8d803f253a095e4ea8080911d05ac Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Tue, 28 Jun 2022 16:48:59 +0200 Subject: [PATCH] Fix documentation problem in usage.rst --- docs/source/usage.rst | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/docs/source/usage.rst b/docs/source/usage.rst index 05154f6..eaa3ed3 100644 --- a/docs/source/usage.rst +++ b/docs/source/usage.rst @@ -21,9 +21,12 @@ your models to Auditlog is even easier than using signals. Registering your model for logging can be done with a single line of code, as the following example illustrates:: - from auditlog.registry import auditlog +.. code-block:: python + from django.db import models + from auditlog.registry import auditlog + class MyModel(models.Model): pass # Model definition goes here @@ -59,7 +62,12 @@ during the `register()` call. .. code-block:: python - class MyModel(modelsModel): + from django.db import models + + from auditlog.models import AuditlogHistoryField + from auditlog.registry import auditlog + + class MyModel(models.Model): sku = models.CharField(max_length=20) version = models.CharField(max_length=5) product = models.CharField(max_length=50, verbose_name='Product Name') @@ -211,9 +219,10 @@ Auditlog ships with a custom field that enables you to easily get the log entrie functionality is built on Django's content types framework (:py:mod:`django.contrib.contenttypes`). Using this field in your models is equally easy as any other field:: + from django.db import models + from auditlog.models import AuditlogHistoryField from auditlog.registry import auditlog - from django.db import models class MyModel(models.Model): history = AuditlogHistoryField()