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 list of users. I want it to default to the currently logged in
user so in my view I have:
def new_incident(request):
form = IncidentForm(initial={
'reporter': request.user,
'title': 'New Incident',
'when_reported' : datetime.now(),
})
media = form.media
return render_to_response('incidents/new.html',{'form': form, 'media':
media},context_instance=RequestContext(request))
However the popup button's selection is never set to the current logged in
user. I have rendered the current logged in user's name elsewhere on the page,
it is set. But the popup selector isn't getting its selection set right. Any
tips?
-Todd Blanchard
--
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.