I connected my app to my database in my settings.py and then ran migrations and my model 0001_initial.py file was created. However, when I try to apply those migrations to the database and create a table, it says no migrations to apply and it doesn't create the table. I don't know why.
Machine 0001_initial.py
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Appear',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('Show', models.CharField(max_length=100)),
('Media', models.CharField(blank=True, choices=[('TV', 'TV'), ('Radio', 'Radio'), ('Youtube', 'Youtube'), ('Podcast', 'Podcast')], max_length=30, null=True)),
('Episode', models.IntegerField()),
('Date', models.DateField(max_length=100)),
('Time', models.TimeField()),
('Producer', models.CharField(max_length=100)),
('Producer_Email', models.EmailField(max_length=254)),
],
),
]
Why is the table not being created?
settings.py
INSTALLED_APPS = [
'machine.apps.MachineConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
}]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'Houston',
'USER': 'postgres',
'PASSWORD': '1234',
'HOST': 'localhost'
}
I've added my settings.py hopefully this helps.
my stupid mistake. I was using the master password for the database but on settings.py file. I used the default postgres password that's why it wasn't adding the migration. as soon i changed the password it added it.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'Houston',
'USER': 'postgres',
'PASSWORD': '1234',
'HOST': 'localhost'
}
I changed it and used my master password that I was using to log into my database and it worked.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'Houston',
'USER': 'postgres',
'PASSWORD': 'A*******',
'HOST': 'localhost'
}