1👍
✅
You could use the inbuilt __dict__
for this, as
from .models import Credentials
current_cre = Credentials.object.get(user=request.user)
current_cre.__dict__['fb_name'] = "Name"
current_cre.__dict__['fb_pass'] = "****"
current_cre.save()
if user
is a unique
field, then you could try this also,
from .models import Credentials
my_dict = {"fb_name": "Name", "fb_pass": "****"}
current_cre = Credentials.object.filtert(user=request.user).update(**my_dict)
👤JPG
2👍
Try this
List_Fields = [(f.verbose_name, f.name) for f in Credentials._meta.get_fields()]
for field_name, value in List_Fields:
current_cre[field_name]=request.POST[field_name]
- [Django]-Django Try Except Not Working
- [Django]-Django template split a string in two parts
- [Django]-How do I treat django's TemporaryUploadedFile as a regular python file
- [Django]-Get method classname inside decorator at __init__ in python
Source:stackexchange.com