How can i update a choice value in Model Field

16 views
Skip to first unread message

Yash Garg

unread,
Dec 30, 2019, 1:20:38 PM12/30/19
to Django users
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 
Reply all
Reply to author
Forward
0 new messages