Merge pull request #29 from MELScience/required

Improved functionality of required parameter
This commit is contained in:
Swen Kooij
2017-07-18 09:33:24 +03:00
committed by GitHub
11 changed files with 199 additions and 68 deletions

View File

@@ -129,21 +129,42 @@ Constraints
**Required/Optional**
At the moment, it is not possible to select two languages to be marked as required. The constraint is **not** enforced on a database level.
Constraints is enforced on a database level.
* Make the primary language **required** and the others optional (this is the **default**):
* Optional filling
.. code-block:: python
class MyModel(models.Model):
title = LocalizedField(required=True)
title = LocalizedField(blank=True, null=True, required=False)
* Make all languages optional:
* Make translation required for any language
.. code-block:: python
class MyModel(models.Model):
title = LocalizedField(null=True)
title = LocalizedField(blank=False, null=False, required=False)
* Make translation required for specific languages
.. code-block:: python
class MyModel(models.Model):
title = LocalizedField(blank=False, null=False, required=['en', 'ro'])
* Make translation required for all languages
.. code-block:: python
class MyModel(models.Model):
title = LocalizedField(blank=False, null=False, required=True)
* By default the primary language **required** and the others optional:
.. code-block:: python
class MyModel(models.Model):
title = LocalizedField()
**Uniqueness**