How do I create a field in Django where I might create only one instance of it.
In other words, I don’t want that be stored multiple entries of this item in the database, because is only required just one instance.
In the administrator interface I might only modify this item, and do not add multiple instances of this.
How do I create a field in Django where I might create only one
Share
Implementing single record in DB is not advised and goes against the model. You may want to change how you store the information to achieve what you want to do.
For example, if you want to store this record:
You can change your model to store
Key:Valuepair in a Model.With this you will only have one record with one
key.Downside of this is, type of value is fixed. However, you can add
typefield in model and manipulate the value by converting to string while storing and back to appropriate type when using it.