[Fixed]-Superuser being able to create multiple posts while restricted one post for one user rule kept

1👍

You should change the ‘author’ field to a ForeignKeyField

A one-to-one relationship. Conceptually, this is similar to a ForeignKey with unique=True, but the “reverse” side of the relation will directly return a single object.

models.py

class Category(models.Model): 
name = models.CharField(max_length=128, unique=True)
description = models.CharField(max_length=200, unique=True)
image = models.FileField(upload_to='images',blank=True, null=True)
author = models.ForeignKey(settings.AUTH_USER_MODEL)


def __unicode__(self): 
👤Anoop

Leave a comment