I get the same error across CBV and FBV when trying to create the second o2o relationship to the super/concrete model Job
[2014-09-17 11:49:26] null value in column "date_opened" violates not-null constraint "date_opened" is a var on the Job model. I don't understand why it's trying to create a new Job when I've already assigned one? Details: When I moved from CBV to FBV I explicitly created the secondary Job, then assigned the o2o var to the job in question. My urls are modelled on the job, to make passing the job easier. The two "add" functions here are for adding the second o2o relationship: url(r'^job/(?P<slug>[-\w]+)/workshop/$', views.WorkshopJobDetail.as_view(), name='wsjob_detail'), url(r'^job/(?P<slug>[-\w]+)/workshop/add/$', views.workshop_add, name='ws_add'), url(r'^job/(?P<slug>[-\w]+)/engineering/$', views.EngineeringJobDetail.as_view(), name='enjob_detail'), url(r'^job/(?P<slug>[-\w]+)/engineering/add/$', views.engineering_add, name='en_add'), In the view: def workshop_add(request, slug): job = Job.objects.get(slug=slug) if request.method == 'POST': form = WSAddForm(request.POST) if form.is_valid(): workshop_job = WorkshopJob() workshop_job = job workshop_job.quote_required = form.cleaned_data['quote_required'] workshop_job.invoice_number = form.cleaned_data['invoice_number'] workshop_job.part = form.cleaned_data['part'] workshop_job.serial_or_lot = form.cleaned_data['serial_or_lot'] workshop_job.serial_or_lot_number = form.cleaned_data['serial_or_lot_number'] workshop_job.work_order = form.cleaned_data['work_order'] workshop_job.save() return redirect(workshop_job) else: form = WSAddForm() return render(request, 'jobs/workshop_form.html', {'form':form, 'object':job}) On 18 September 2014 01:13, Collin Anderson <cmawebs...@gmail.com> wrote: > what happens when you try? > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/dea67a67-a3ee-4439-9a61-2f6f6cae98ef%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You have to be really clever to come up with a genuinely dangerous thought. I am disheartened that people can be clever enough to do that and not clever enough to do the obvious thing and KEEP THEIR IDIOT MOUTHS SHUT about it, because it is much more important to sound intelligent when talking to your friends. This post was STUPID. ----------------------------------------------------------------------------------------------------------- The Most Terrifying Thought Experiment of All Time http://www.slate.com/articles/technology/bitwise/2014/07/roko_s_basilisk_the_most_terrifying_thought_experiment_of_all_time.html -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGBeqiOUGzHZe_Xab7PY1rEJUKWuYTLLxTt0jCrgjuNBwLwKGA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.