On 8 déc, 13:26, Michael wrote:
> ^ Thanks for that. Have been scratching my head for a while as .id is
> not a field/property for model.user, according to the doco I am
> reading anyway (http://docs.djangoproject.com/en/dev/topics/auth/
> #topics-auth).
When no primary
^ Thanks for that. Have been scratching my head for a while as .id is
not a field/property for model.user, according to the doco I am
reading anyway (http://docs.djangoproject.com/en/dev/topics/auth/
#topics-auth).
I should have just tried .id in the first place : \
... actually you'd think
OK, this did lead me to the solution though.
It seems that, for the ForeignKeyField the initial value should be the primary
key of the record and not the object referenced. So changing
>> form = IncidentForm(initial={
>>'reporter': request.user,
to
>> form =
I want it to be possible to be changed. But I also want the initial selection
to be the current user.
So this isn't really a solution. Thanks anyway.
On Nov 26, 2009, at 10:27 AM, esatterwh...@wi.rr.com wrote:
> in your IncidentForm definition set reporter to a ModelChoiceField
>
in your IncidentForm definition set reporter to a ModelChoiceField
(User.objects.all(), widget=forms.HiddenInput())
then it should work out ok. I usually hide fk fields to a user if i
want the current request.user object, because I don't want to allow
the possibility for it to be changed.
On Nov
I have a (simplified) model
class Incident(models.Model):
title = models.CharField(max_length=128)
when_reported = models.DateTimeField(auto_now_add=True)
reporter = models.ForeignKey(User)
Where User is from auth. When used with a ModelForm, this creates a popup
button with a
6 matches
Mail list logo