django-survey
django-survey copied to clipboard
Default value for a field
I have a use case where I need to be able to put a default value for a field for one of the questions. The user can always change it but that is not the scope of this issue.
Nice feature! It's probably a small change doable by adding a default value field here: https://github.com/Pierre-Sassoulas/django-survey/blob/master/survey/models/question.py#L73 with default value = None in order to make migrations from older survey possible. There might be more work to be able to handle all possible type of questions and make sure not having a default still works.
I don't see how putting the default value in the model is the answer. You already have a "default value" for when the user did not enter any data with USER_DID_NOT_ANSWER in settings.py. I was really thinking that when a survey question is created, the user creating it can enter a default value. Like, in my other issues, the week the survey is for. That way the user can see it is entered and keep the value. So it is really a per-question default rather than a model default that I am after.
Hmm, yeah it makes sense to have the value for USER_DID_NOT_ANSWER as default instead of None. If this is a default value for a question to a survey by a user for each user, maybe it needs another concept than the Question model. I'm not sure about it but I don't think the Question model has the necessary N-N relationship with Survey and User. It looks harder to do than I thougth.