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
method to your admin class, something like this:

class DocumentAdmin(admin.ModelAdmin):
    def save_model(self, request, obj, form, change):
        obj.user = request.user
        if not obj.author_id:
            obj.author_id = obj.user_id
        obj.save()

One other thing ... if you're going to populate 'author' with user_id,
you might want to change the model thusly:

    author = models.ForeignKey(User)


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to