views:

46

answers:

2

Does anyone have a list of things they do to associate some model with a user?

I.e. if a blog entry has a user, you have to do a few things: - Add a foriegnkey field - Make the foreign key field editable = False - On save/load make sure that request.user matches entry.user

This is what I could come up with. Is there an easier way to do this? Anything else to keep in mind?

A: 

That is an appropriate way, although it may be useful to have it editable. The user should be assigned in the view, not pushed through to the model, in order to maintain clean MVP separation.

Ignacio Vazquez-Abrams
+1  A: 

It may make more sense to associate the model with a user Profile object than to associate directly with User. That way it's easier to connect the model to custom attributes of the user.

shacker