Monday, December 30, 2019

How can i update a choice value in Model Field

in models.py i have choices in a field-

APPROVAL_CHOICES = (
        ('APPROVED', 'Approved'),
        ('PENDING','Pending'),
        ('REJECTED','Rejected'),
    )
approval_status = models.CharField(_("Approval Status"),max_length=8,null=False,blank=False,choices=APPROVAL_CHOICES, default='Approved')

i wants to update value of approval_status field from views.py-

if Splash.objects.filter(ip_address = ipaddress).exists():
obj.approval_status = 'Pending'

i also tried-
        obj.approval_status = obj.APPROVAL_CHOICES[1][1]

please suggest how can i update my approval_choices value from views.py.

Also, i'm unable to fetch session id using this statement- 
       obj.session_id = request.session.session_key
please also tell how can i fetch session key of  a user.

Thanks 

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/b0a6a414-219c-43b0-ae07-3c808c82fd84%40googlegroups.com.

No comments:

Post a Comment