Take a look at:
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser
-richard


On 9/24/07, heru <[EMAIL PROTECTED]> wrote:
>
>
> Hi,
> i'm new in django and python as well.
> i'm trying to create a model for my article
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class Article(models.Model):
>   title = models.CharField(maxlength=32)
>   content = models.TextField()
>   publish = models.DateTimeField()
>   editor = models.ForeignKey(User,blank=True)
>
>   def __str__(self): return self.title
>
>   class Admin:
>     fields = (
>         (None, {
>             'fields': ('title', 'content', 'publish',)
>         }),
>     )
>
>   def save(self):
>     """
>     user_id = (get user id by current session)
>     self.editor = user_id
>     """
>     super(Article, self).save()
>
> as it seen in commented lines, i'm trying to get the current logged
> user id.
> because somehow i want to add user_id automatically in my article
> table instead lookup
> onto django_admin_log table.
> is it possible to grab the user id from request object, or from
> session ?
>
>
> -heru-
> new kid on django
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to