On Mar 24, 3:21 am, Django Grappelli <django.grappe...@gmail.com>
wrote:
> Hi Everyone,
> Django noob here.  How do I write a view function that can modify
> database records without changing the html on the screen?  Also, from
> a best-practices standpoint, is there any reason I shouldn't be
> attempting this?
> Cheers,
> DG

A view can do whatever you like, including changing db records if
that's what you want.

But what do you mean, 'without changing the HTML'? In order to run a
view, the user must make a page request. That will result in new data
being sent to the browser, in some fashion. You could of course
redirect back to the original view after the changes have been done.
Alternatively, you could make the page request via Javascript ("AJAX")
so that the current page remains on screen throughout - although you
should always cater for users who have disabled javascript.

However, I would make two points:
* It's very bad practice to change data via a simple GET page request.
As the name implies, GET is for asking for data - if you want to
change data, you should use a POST. The user should have to explicitly
request an action that changes data.
* Why would you not want to show some sort of indication to the user
that data has changed? That doesn't make much sense.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to