K def edit(request): form = None if request.method == 'GET': try: form = IncidentForm(instance = Incident.objects.get(id = request.GET['id'])) except ObjectDoesNotExist: raise Http404 else: form = IncidentForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect('/incidents') media = form.media return render_to_response('incidents/new.html',{'form': form, 'media': media, 'view': 'Edit'},context_instance=RequestContext(request))
class IncidentForm(forms.ModelForm): place = forms.CharField(widget=EditableMap(options={ 'layers': ['google.hybrid', 'google.streets', 'google.physical', 'google.satellite', ], 'default_lat': 39.4421, 'default_lon': -100.0, 'default_zoom': 3, 'geometry': 'point', 'map_div_style': {'width': '400px', 'height': '300px'}, })) when_occurred = forms.DateTimeField(widget=widgets.AdminSplitDateTime()) reporter = forms.ModelChoiceField(User.objects.all(), widget=forms.HiddenInput()) id = forms.CharField(widget=forms.HiddenInput()) class Meta: model = Incident fields = ('title', 'when_occurred', 'place', 'notes', 'what_type', 'reporter', 'id') On Dec 3, 2009, at 1:30 AM, Daniel Roseman wrote: > On Dec 3, 8:53 am, Todd Blanchard <tblanch...@mac.com> wrote: >> Thanks, that makes the form show up populated. >> But saving it creates a new record, despite making sure I have id in a >> hidden field on the form. :-/ > > It does work, so you'll need to show us some code so we can see where > you're going wrong. > -- > DR. > > -- > > 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.