I want to use a model to save the system setting for a django app. So, I want to limit the model so it can only have one record. How to do the limit?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
An easy way is to use the setting’s name as the primary key in the settings table. There can’t be more than one record with the same primary key, so that will allow both Django and the database to guarantee integrity.