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 > (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 25, 10:32 pm, Todd Blanchard <tblanch...@mac.com> wrote: >> 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 django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.