Changes between Version 14 and Version 15 of CookBookNewformsAdminAndUser
- Timestamp:
- Aug 12, 2008, 10:19:53 AM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBookNewformsAdminAndUser
v14 v15 33 33 inlines = [CommentInline] 34 34 35 def save_ form(self, request, form, change):35 def save_model(self, request, form, change): 36 36 37 37 instance = form.save(commit=False) 38 38 39 39 instance.user = request.user 40 40 41 instance.save() 42 41 43 return instance 42 44 43 45 def save_formset(self, request, form, formset, change): 44 46 45 instances = formset.save(commit=False)46 47 47 def set_user(instance): 48 48 instance.user = request.user 49 instance.save() 49 50 50 51 if formset.__name__ == 'CommentInline': 52 instances = formset.save(commit=False) 51 53 return map(set_user, instances) 52 54 else: 53 return instances55 return formset.save() 54 56 55 57 admin.site.register(Post, PostModelAdmin)