Django

Code

Ticket #714 (closed: duplicate)

Opened 3 years ago

Last modified 2 years ago

access to id of current user on admin

Reported by: flavio.curella@gmail.com Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

The model code of admin application doesn't have access to the request, so if I want to save the id of user that is creating the poll, I can't access to it.

this may be more clear, something like this should work:

from django.core import meta from django.models.auth import User

# Create your models here. class Poll(meta.Model):

question = meta.CharField?(maxlength=200) pub_date = meta.DateTimeField?('date published') author = meta.ForeignKey?(User, default=User.id) class META:

admin = meta.Admin()

Attachments

Change History

11/01/05 18:52:26 changed by Flavio.curella@gmail.com

The model code of admin application doesn't have access to the request, so if I want to save the id of user that is creating the poll, I can't access to it.

this may be more clear, something like this should work:

from django.core import meta
from django.models.auth import User

# Create your models here.
class Poll(meta.Model):
    question = meta.CharField(maxlength=200)
    pub_date = meta.DateTimeField('date published')
    author = meta.ForeignKey(User, default=User.id)
    class META:
        admin = meta.Admin()

12/29/05 00:53:41 changed by anonymous

  • priority changed from normal to high.

12/29/05 06:15:23 changed by hugo

  • priority changed from high to normal.

a more general approach is discussed in #1132.

02/28/06 22:18:22 changed by adrian

  • status changed from new to closed.
  • resolution set to duplicate.

Superceded by #1132.


Add/Change #714 (access to id of current user on admin)




Change Properties
Action