All Articles

Django - Models Meta Options Part II

9. permissions

Extra permissions to enter into the permissions table when creating a model. Add, change, delete, and view permissions are automatically created for each model. This has to be a tuple like (permission_code, human_readable_permission_name)

10. proxy

if proxy=True, this model is a proxy model. I will write about a proxy model later.

11. constraints

List of constratins you want to define on the model. like an age limit.

from django.db import models

class Customer(models.Model):
    age = models.IntegerField()

    class Meta:
        constraints = [
            models.CheckConstraint(check=models.Q(age__gte=18), name='age_gte_18'),
        ]

I will write about constraints in a later post as well.

May 3, 2020

AI Enthusiast and a Software Engineer