Hi all, I've been stumped by this error for the past few days and haven't made any progress. Could someone please help out?
I've created a formset of seven entries, one for each day of the previous week. The first submission works fine; all seven entries are successfully submitted. Subsequent submissions, however, generate the following error for each of the seven entries: (Hidden field id) Status report with this None already exists. I found an django issue from a few months ago which might be related [1]. However, this bug was resolved back in Oct. and I'm running 1.0.2, so I assume the CL is included. Is there any way to be certain? Here are my models, simplified for space: class Vehicle(models.Model): number = models.IntegerField(unique=True) class StatusReport(models.Model): date = models.DateField() vehicle = models.ForeignKey(Vehicle, to_field='number') status = models.CharField ('status',max_length=8,choices=STATUS_REPORT_CHOICES) class Meta: unique_together = ("date", "vehicle") And here's my view: def GenerateReportDate(request, vehicle_id, date): # removed verification code for clarity # week_start = monday before date. # week_end = week_start + datetime.timedelta(7) for i in range(7): check_date = week_start + datetime.timedelta(i) obj, created = StatusReport.objects.get_or_create(vehicle = int (vehicle_id), date = check_date, defaults={'date': check_date, 'vehicle':vehicle[0]}) # Pull 7 reports for this week reports = StatusReport.objects.filter( vehicle__exact=vehicle_id ).filter( date__gte = week_start ).filter( date__lte = week_end ).order_by("date") ReportFormSet = modelformset_factory(StatusReport, extra=0) if request.method == 'POST': formset = ReportFormSet(request.POST, request.FILES) if formset.is_valid(): formset.save() return HttpResponseRedirect('../done/') # Redirect after POST else: formset = ReportFormSet(queryset=reports) return render_to_response('ops/report.html', {'formset': formset, 'number': vehicle_id, 'weekof': week_start}) Thanks for any help, -Josh [1] http://code.djangoproject.com/ticket/9039 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---