[portland] django helper
python at dylanreinhardt.com
Wed Apr 8 20:23:36 CEST 2009
This is a common question for Django. The challenge here is that
request.user is known to the view, but not to the model... so you can't just
make request.user the default value on the model.
Take a look at this and browse down to "The Holy Grail":
On Wed, Apr 8, 2009 at 11:08 AM, Patrick Curtain <pcurtain at gmail.com> wrote:
> > There's a few of us here who work on Django. If you have specific
> > questions, you could probably get several responses. Some might even be
> > helpful. :-)
> I'll start here then, for now. :) Thanks! Anyone else, feel free to
> tell me it's too specific for the pdxpython list.
> I've got a 'Recipe' model that needs to store the author. From what I
> could learn in other examples, this got added to my model:
> member = models.ForeignKey(User, related_name="added_recipes",
> blank=True, null=True)
> When I view the form in the admin interface, it works, but that field
> shows up as a select box of all users in the system.
> My goal is to let some bulk data entry happen in advance of the full
> app being completed. Hence the push to make it work in admin and get
> How do I tell the admin interface form (via the internal 'class Admin'
> magic ideally) that it should get the user from the 'request.user'
> currently using the app?
> Responses of "dumb idea, do this instead" -just- as welcome. :)
> And thanks, everyone!
> Portland mailing list
> Portland at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Portland