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 trying to set up a default value the author field in the model > above as the current user as the default value. > Is there any way to access the request object from here? > The fact that you say "current user" implies that instances of the model are created in response to a web request (i.e. when a view is running). At that time, obviously, yo have access to the web request and so can get hold of the user's identity.
But there is no way to know that information in advance, so you can't specify it as a default value. regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC http://www.holdenweb.com/ --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---