Hi All,

Django comes with its own authentication scheme, which includes the
User model.  So let's say I created my Django app, and I connect some
of my models to the User model using the ForeignKey field type.  If I
delete a User object, I now have objects that used to refer to a valid
User, but now return None as the User.  Is there a preferred method
for handling this?  A real world example could be a corporate
timesheet system.  A user enters their time for their duration at the
company, say 8 months.  But when the user is terminated, their account
in Django is removed as well.  Now all the time entries would refer to
"None" as the user.  So what if, for historical purposes, you need to
keep the users there so your data still makes sense.

Is there a recommended way to design your application to accommodate
this?  Looking at the "on_delete" kwarg for the ForeignKey field
mentions some options, but nothing usable, to me.
http://docs.djangoproject.com/en/1.3/ref/models/fields/#django.db.models.ForeignKey.on_delete

Perhaps, use a save signal on the User model that will create a
duplicate of that User object as an instance of a similar model
(perhaps inherited from User??), and that similar model is what I
connect all my other models to.  I could then delete my User objects
and still keep the SimilarUser objects intact so my app still works.

Thanks for any ideas...

Keith

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to