I'm relatively new to Django and struggleing a bit trying to extend
Django's native User model.
What I'd like to achieve is the following:
- Add a few fields to the existing User model
- Have these fields editable on Django's Admin screen
- When a new User is saved, execute a bit of code to tell another
application about it
- When an existing User is deleted, execute a bit of code to tell
another application about it
I've looked in the Django book and googled for help and this is what I
currently have:
In settings.py
# AUTH_PROFILE_MODULE string
AUTH_PROFILE_MODULE = 'es.esuserprofile'
In models.py
from django.contrib.auth.models import User
class ESUserProfile(models.Model):
user = models.ForeignKey( User,
unique = True,
edit_inline = models.STACKED,
num_in_admin = 1, min_num_in_admin = 1, max_num_in_admin = 1,
num_extra_on_change = 0,
help_text = "Additional user information")
notes = models.CharField(max_length = LENGTH_NOTES,
blank = True,
core=True,
help_text = "Notes.")
def __unicode__(self):
return self.user.username
def save(self):
print 'in save'
#ssSaveESUser(self)
super(ESUserProfile, self).save()
return
def delete(self):
print 'in delete'
#ssDeleteESUser(self)
super(ESUserProfile, self).delete()
return
When I add a new user in Django admin the extra field IS displayed and
IS editable. However, when I save the print 'in save' never
executes! Examination of the MySQL table shows that auth_user was
properly modified and es_esuserprofile was NOT.
When I edit the just added user the user's notes field is blank (as
expected given the above).
When I delete the just added user the print 'in delete' doesn't
execute (probably not surprising).
I'm stumped. What am I missing?
Thanks for any help.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---