I am using two databses for my Django app and one of them is an existing MySQL database:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'users.sqlite3'),
},
'calls': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'portal2',
'USER': 'cdraccess',
'PASSWORD': '******',
'HOST': '[MY_HOST]',
},
}
I used inspectdb to create the models for the call and they look like:
class Calls(models.Model):
callid = models.AutoField(db_column='CallID', primary_key=True) # Field name made lowercase.
conferencename = models.CharField(db_column='ConferenceName', max_length=200) # Field name made lowercase.
jointime = models.DateTimeField(db_column='JoinTime') # Field name made lowercase.
leavetime = models.DateTimeField(db_column='LeaveTime', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = True
db_table = 'ConferenceCall2'
I called makemigrations and then migrate and everything looks fine.
However, when I run a query like Calls.objects.all() the result is: [].
Or when I tried Calls..objects.count() the result was: 0. The MySQL database is not empty, but apparently Django ORM believes that it is.
Am I missing something?