0

I'm trying to send data from a form to a database using this model, but i keep getting this error:

("Table 'trades.main_SomeModel' doesn't exist")

Here is my model:

class SomeModel(models.Model):
     data = models.CharField(max_length=100)

     def save(self):
         super(SomeModel, self).save(using='dataset')

And here is my form:

 class DataForm(forms.ModelForm):

        class Meta:
            model = Trade
            fields = ("data",)

        def save(self, commit=True):
            send = super(DataForm, self).save(commit=False)
            if commit:
                send.save()
            return send

I already tried this but it's not working: when i got to step 3, in fact, i got the error table "main_SomeModel" already exists

Note: i'm using two DBs. There is a default one and a second one. The data from this model should be sent to the second DB.

What am i doing wrong? Should i migrate again?

Jack022
  • 867
  • 6
  • 30
  • 91

1 Answers1

1

You need to run the migrations for both of your databases but you have run it for one database.

python manage.py migrate --database dataset

Here dataset is the name of the database other than your default database.

Khuram
  • 1,820
  • 1
  • 26
  • 33