Thursday, February 9, 2012

Django code patterns

Dear django-users

I keep doing patterns like:

has_changed = False
if resource.user.email != request.POST['email']:
resource.user.email = request.POST['email']
has_changed = True
if resource.user.is_active != request.POST['is_active']:
resource.user.is_active = request.POST['is_active']
has_changed = True
if has_changed:
resource.user.save()

although it works, I feel like there is a cleaner solution. How would
you solve such a problem?
Thanks!
Rune

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

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate