Ookma-Kyi
09/12/2022, 5:58 PMwriteOutput()
to get it's output it displays as on. However when I it isn't ticketed it simply doesn't exist. I thought it would output either true
or false
at least logically. Am I missing something or am I going to have to do a bit more work to get it to do what I want?Matt Jones
09/12/2022, 6:04 PMOokma-Kyi
09/12/2022, 6:06 PMisNull()
, and isEmpty()
to no success. Trying structKeyExists()
now.Matt Jones
09/12/2022, 6:08 PMMatt Jones
09/12/2022, 6:08 PMAdam Cameron
Ookma-Kyi
09/12/2022, 7:12 PMif request.method == "POST":
form = UpdateNotificationPreferenceForm(<http://request.POST|request.POST>, instance=request.user.profile)
if form.is_valid():
form.save()
return HttpResponseRedirect(reverse("user_profile"))
And yes it was a Boolean value that field:
# Create your models here.
class Profile(models.Model):
"""Model representing a single user profile."""
"""The users notification preference, if true will send notifications to the user."""
user = models.OneToOneField(User, on_delete=models.CASCADE)
notification_preference = models.BooleanField(
default=False,
help_text="If ticked will send you notifications."
)
Adam Cameron
Ookma-Kyi
09/12/2022, 7:29 PMAdam Cameron
Ookma-Kyi
09/12/2022, 7:35 PMAdam Cameron
cfvonner
09/12/2022, 8:32 PMnotification_preference = models.BooleanField(
default=False,
Ookma-Kyi
09/12/2022, 8:33 PM