Changes between Version 3 and Version 4 of CookBookManipulatorWithPostpopulatedFields
- Timestamp:
- Jul 8, 2006, 3:11:20 PM (18 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBookManipulatorWithPostpopulatedFields
v3 v4 3 3 == Description == 4 4 5 If 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 the revalues 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.5 If 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 their 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. 6 6 7 7 The 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.