Changes between Version 1 and Version 2 of CookBookManipulatorWithPostpopulatedFields


Ignore:
Timestamp:
09/16/05 16:57:18 (10 years ago)
Author:
hugo <gb@…>
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • CookBookManipulatorWithPostpopulatedFields

    v1 v2  
     1= CookBook - Using Manipulators With Only Some Fields =
     2
     3== Description ==
     4
    15If your template should only edit part of an object because some fields are not to be changed by the user, you can use the following view-function-template to do the job. It just populates those fields that are left out of the template and the form and fills in there values from known content. Especially it overwrites fields in the new_data with known values so that users can't just fake POST requests to populate left-out fields.
    26
    37The code is stolen from my gallery project - there you have a picturefolder that has a path and a slug that point to the filesystem and a user_id that denotes the owner (actually it's a ForeignKey to the auth.users model). So users should never be able to change the owner or change the filesystem path (otherwise they might be able to fetch files from security relevant parts of the filesystem). The following code prevents changing those fields by overwriting them in the POST data with data from the original object. That way even faked POST requests won't get access to those attributes.
     8
     9== Code ==
    410
    511{{{
Back to Top