python - Model create using dictionary in django -
in django possible create through dictionary similar filtering?
here models.py:
class personnels(models.model): name = models.charfield(max_length=100)
here views.py:
from . models import * def artists(request): personnels = personnels.objects.all() if request.method == "post": data = {"name": "dean armada"} personnels.objects.create(data)
however code above throw error. trying do create function coming "request.post" views above serves simple example on doing it
simply unwrap dictionary within create
function like:
personnels.objects.create(**data)
Comments
Post a Comment