I know we can require that the SlugField be unique with unique=True option, but is it possible to require it to be unique only for a particular user, so two different user could have the same SlugField but a user cannot have two identical slugField?
models. py:
from django.db import models
from django.contrib.auth.models import User
class ezApp(models.Model):
name = models.SlugField(max_length=50, unique=True )
date_created = models.DateTimeField('date created')
date_updated = models.DateTimeField('date updated')
created_by = models.ForeignKey(User)
in_use = models.BooleanField()
You’ll want to use unique_together as detailed here:
https://docs.djangoproject.com/en/dev/ref/models/options/#unique-together
You’ll have to do some babysitting at the form level too, so the user gets usable error messages when they try to add duplicate names.