Re: Class Based CreateView with foreign key question

2013-06-13 Thread Jason Arnst-Goodrich
I should also clarify just in case anyone else runs into the same problem in the future: My form_valid() was not working correctly because I had my form definition excluding a (required) field so it would NEVER be able to save my model under any circumstance. def form_valid(self, form):

Re: Class Based CreateView with foreign key question

2013-06-13 Thread Jason Arnst-Goodrich
That reassures me then. In the past I stayed away from the generic class based views and in my current project I'm using nothing but them. Everything is working but it's not clear by looking at it *why* it works. There might be a little too much magic happening for my liking but I'm going to s

Re: Class Based CreateView with foreign key question

2013-06-13 Thread Dan Gentry
I use the same pattern in my application, and it works just fine. def dispatch(self, *args, **kwargs): self.tc = get_object_or_404(TrainingClass, pk=kwargs.get('class_id', None)) return super(TrainingScheduleCreateView, self).dispatch(*args, **kwargs) def form_vali

Re: Class Based CreateView with foreign key question

2013-06-11 Thread Jason Arnst-Goodrich
Actually that totally didn't work - I don't know what I was thinking. The form_valid method doesn't work for saving the model. I have it working now but I guess the question I had is if using dispatch for setting variables in general is a good idea. On Monday, June 10, 2013 3:38:09 PM UTC-7, Ja

Class Based CreateView with foreign key question

2013-06-10 Thread Jason Arnst-Goodrich
I'm having trouble wrapping my head around how to use generic class based views properly when it comes to creating objects associated with already created objects. The concept here is adding File objects to a Case object. The url pattern would be something like: url(r'^case/(?P\d+)/add/$', Add