Thursday, July 19, 2012

Re: Can a method call inside save() display its return on template?

> In my models.py I override the save method like this:
>
> def save(self, *args, **kwargs):
> self.directiondb = get_direction_db(self.nod_id1.id,
> self.nod_id2.id)
> get_direction_descr(self.nod_id1.id, self.nod_id2.id)
> get_vrd_code(self.nod_id1.id, self.nod_id2.id)
> self.vrd_id = get_vrd_id(self.nod_id1.id, self.nod_id2.id)
> super(Webrequests, self).save(*args, **kwargs)
>
> and it works fine.
> Is it now possible what get_direction_descr() and get_vrd_code() return to

well, what does get_vrd_code do? why aren't you saving the value
anywhere? same question with get_direction_descr.

The easy answer will be:
self.vrd_code = get_vrd_code(self.nod_id1.id, self.nod_id2.id)

and then use that on the template, but that save() method seems
awfully redundant, so.. can you explain what your model does better?

--
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment