Hi, It is a good practice to add or edit an object in the same view or is 
it better to separate?

*For example:*

def add_edit(request, id=None):
    form = MyForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            form.save()
            return HttpResponse('success')
    render(request, 'add_edit.html', locals())

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/77ee3182-dc25-4562-b083-e982033164c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to