1๐
โ
OK so after digging through the source code it turns out the docs have updated since I lasted looked.
So, if you add objects = models.Manager()
to your BaseModel
and pass that to the AutoSlugField
. This will check the slug against BaseModel
rather than the sub class.
class BaseModel(models.Model):
objects = models.Manager()
name = models.CharField(max_length=255)
slug = AutoSlugField(populate_from='name', unique=True, db_index=True, managers=objects)
# ... other fields
๐คrockingskier
0๐
In database you have only one slug field in BaseModel
table, HamsterModel
and ElderberryModel
are connected to BaseModel
using foreign key. The only way I see in this situation is remove unique=True
and check uniqueness at model level in save method.
๐คsneawo
Source:stackexchange.com