Friday, April 26, 2019

RE: How to Update Database

You would use the data from request.POST or request.GET.

Here's everything you need to know about views:

https://docs.djangoproject.com/en/2.2/topics/http/views/

 

Here's an example:

 

def my_view(request):

               if request.POST:

                              field1 = request.POST.get('field1')

                              field2 = request.POST.get('field2')

                              model = MyModel.objects.create(field1=field1, field2=field2)

                              return redirect(model.get_absolute_url())

               return whatever

 

From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Aayush Bhattarai
Sent: Friday, April 26, 2019 8:53 AM
To: Django users
Subject: How to Update Database

 

How can I update database. I am not using forms.py and I am using function based view. Can you how example and link for docs. Thanks for help.

--
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/41384b09-ed76-4485-9518-8dc10e26f2fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment