Thank you both for those suggestions. I got Tundebazby's to work as it was closest to what I was doing. I'll have to study the post_save some more.
On Wednesday, July 30, 2014 2:33:57 AM UTC-4, Tundebabzy wrote: > > Hi Brad, my response is inline > > On 30 Jul 2014 02:26, "Brad Rice" <brad...@gmail.com <javascript:>> wrote: > > > > I have three tables. The first one is application which has a flag for > if an app has been submitted as well as created date and modified date. The > other two tables relate to the application table. I have two forms that get > update those tables. What I want to do is update the application modified > date from the save on the other forms. > > > > I have this in the Application model > > modified = models.DateTimeField(auto_now_add=True) > > > > but since it is the other tables I am saving to, I'm not sure how to > update that field whenever the other two tables update. > > > > My view for one of the forms looks like this: > > > > class AnswersUpdate(UpdateView): > > model = Answers > > form_class = AnswersForm > > slug_field = 'created_by' > > template_name = 'requestform/applicant_form.html' > > > > @method_decorator(login_required(login_url='/accounts/login/')) > > def dispatch(self, *args, **kwargs): > > return super(AnswersUpdate, self).dispatch(*args, **kwargs) > > > > def get_object(self, queryset=None): > > return Answers.objects.get(created_by=self.request.user) > > > > def form_valid(self, form): > > obj = form.save(commit=False) > > obj.created_by = self.request.user > > obj.save() > > a = Application.objects.get(created_by=self.request.user) > > ## how do I save to the Application here? > > #if its a new record, something like .... > application = Application.objects.create(...) > > #if you are updating a record, something like... > application = Application.objects.get(...) # can throw exception > application.field_name = something > application.save () > > > return HttpResponseRedirect(reverse('requestform:app_check', > kwargs={'app_id': obj.id})) > > > > Any help would be appreciated. > > > > -- > > 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...@googlegroups.com <javascript:>. > > To post to this group, send email to django...@googlegroups.com > <javascript:>. > > 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/2a2b6f24-b4c2-4575-9a52-85a892256c79%40googlegroups.com > . > > For more options, visit https://groups.google.com/d/optout. > -- 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/99b2a53f-5388-4b90-8313-7e7c29f9ce60%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.