Re: Request object from models

2008-11-21 Thread barbara shaurette
Yeah, you want to assign that user_id value in the view, when you're saving the instance: mydocument.author_id = request.user.id mydocument.save() Are you trying to solve for a case where you want the current *admin* user to be the author_id for the record? You can also add a save

Re: Request object from models

2008-11-21 Thread Steve Holden
FT wrote: > class Document(models.Model): > > created = models.DateTimeField( > help_text='Timestamp when the document is created', > blank=True, > default=datetime.datetime.now) > > author = models.EmailField(blank=True, default=request.user) > > Hi there, > > I'm

Re: Request object from models

2008-11-21 Thread Alex Koshelev
No. Request object does not exist when model classes are created. On Fri, Nov 21, 2008 at 13:47, FT <[EMAIL PROTECTED]> wrote: > > class Document(models.Model): > >created = models.DateTimeField( >help_text='Timestamp when the document is created', > blank=True, >

Request object from models

2008-11-21 Thread FT
class Document(models.Model): created = models.DateTimeField( help_text='Timestamp when the document is created', blank=True, default=datetime.datetime.now) author = models.EmailField(blank=True, default=request.user) Hi there, I'm trying to set up a default value the