Question

I would like to create table "A" in one database (assume in SQL Server 2008) and another table in "B" (My SQL) using models.py through Django.

Both the tables structures "A" and "B" may differ. I have verified that through router.py can achieve this.

I want to do it without "router.py" file.

Could anyone guide me on this please.

Thanks, Shiva.

Was it helpful?

Solution

Try to use super in save() method.
When you save, it will launch others commands like write in other database.

For example :

You have :

class Chair(models.Model) :
  name = models.Charfield(max_length=30)

You can implement save() def like that :

class Chair(models.Model) :
  name = models.Charfield(max_length=30)

  def save(self, *args, **kwargs):
    <your cmd here>
    super(Chair, self).save(*args, **kwargs)

It could seems impossible like that, but you can use arguments for make anything you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top