Skip to content

Commit

Permalink
extra documentation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Willem Van Onsem committed Apr 4, 2024
1 parent 4f13683 commit ed334e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@
Getting started
===============

Once the package is installed, you can use the `ChoicesConstraintModelMetaMixin` mixin in the models, for example:
Once the package is installed, you can use the `FullChoicesConstraintModelMixin` mixin in the models, for example:

.. code-block:: python3
from django.core.validators import MinValueValidator
from django.db import models
from django_enforced_choices import ChoicesConstraintModelMetaMixin
from django_enforced_choices import FullChoicesConstraintModelMixin
class Movie(ChoicesConstraintModelMetaMixin, models.Model):
class Movie(FullChoicesConstraintModelMixin, models.Model):
genre = models.CharField(max_length=1, choices=[('d', 'drama'), ('h', 'horror')])
year = models.IntegerField(validators=[MinValueValidator(1888)])
When we then run `makemigrations` it will create a model with the `genre` field, and include a `CheckConstraint` to restrict the values to `'d'` and `'h'`.
When we then run `makemigrations` it will create a model with the `genre` field, and include a `CheckConstraint` to restrict the values to `'d'` and `'h'`; and the `year` field with a `CheckConstraint` that ensures the value is greater than or equal to 1888.
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ The package can be fetched as `django-enforced-choices`, so for example with `pi
pip3 install django-enforced-choices
The item is not a Django app, so one should not to include it in the `INSTALLED_APPS`. It is only a module that
offers some functionality to use in Django applications.
offers some functionality to use in Django applications.

0 comments on commit ed334e9

Please sign in to comment.