Thanks for your suggestion, but I cannot... I need to do that from a
method of the model itself.
Basically, I need to use some stored procedures to modify datas in the
database (and these stored procs can also modify some other tables),
thus I need to reload after calling these procedures in order to
update the modified values. And this must be done from the instance
because it's only a part of a process.

Example:
action=Scheduler.objects.get(id_schedule=22)
action.do_something()


and in the Scheduler class I have
def do_something(self):
    call_proc_stock_1() --> this will update id_status in table
schedule and modify the line corresponding to the id_release in table
release
    do_smething_else() etc...

So after call_proc_stock_1() I need to reload to have the correct
(updated) id_status and id_release objects (and not only the value of
the key, the whole associated object).

F.




On Jul 30, 3:26 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Jul 30, 2009 at 9:10 AM, Fleg <francois.legr...@gmail.com> wrote:
>
> > Nobody knows ?
>
> Simply re-get the instance from the DB?
>
> Karen
>
>
>
> > On Jul 29, 6:12 pm, Fleg <francois.legr...@gmail.com> wrote:
> > > Hi,
> > > I have a model mapping tables in a database with several foreign keys.
>
> > > class Scheduler(models.Model):
> > >         id_schedule = models.AutoField(primary_key=True)
> > >         id_parent = models.ForeignKey
> > > ("Scheduler",db_column='id_parent',to_field='id_schedule')
> > >         id_object_type = models.ForeignKey(ObjectTypes,
> > > db_column='id_object_type',to_field='id_object_type')
> > >         id_action = models.ForeignKey(Actions,
> > > db_column='id_action',to_field='id_action')
> > >         id_status = models.ForeignKey(Status,
> > > db_column='id_status',to_field='id_status')
> > >         id_release = models.ForeignKey(Releases,
> > > db_column='id_release',to_field='id_release')
> > >         id_object = models.IntegerField()
> > >         begin_execute = models.DateTimeField(null=True,blank=True)
> > >         end_execute = models.DateTimeField(null=True,blank=True)
> > >         pid = models.IntegerField()
>
> > > I am working with an instance of this model and at some point I need
> > > to reload it's attributes from the database.
> > > I couldn't find a correct way to do it. Can somebody help me ?
>
> > > PS: I tryed to write a "reload" method like this:
> > > def __reload__(self):
> > >                 self.__init__(**Scheduler.objects.filter
> > > (id_schedule=self.id_schedule).values()[0])
>
> > > but unfortunately, it updates only the keys but not the objects
> > > associated with the foreign keys !
>
>
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to