Programming an Error with respect to "url" "app_model" does not exist LINE 1: SELECT COUNT (*) AS "__count" FROM "app_model"

I searched every question with this error, but none of the answers helped. I get this error when trying to access the administration page of this particular model (AgentBasicInfo).

'manage.py makemigrations' works fine. "manage.py migrate" also works great. "manage.py runningerver" works fine, the whole site is working fine until I try to go to the administration page of this model.

The application is installed correctly in INSTALLED_APPS in settings.py. I am using Postgres for the database.

I tried...

  • Removing a migration and re-executing makemigrations / migrate
  • Delete the entire migration folder for this application and retransmit / migrate
  • Removing all migrations from all my applications and re-executing makemigrations / migrate
  • I tried running 'manage.py migrate' and 'mangae.py migrate app_name'. I still get the same error.

This model (see code below) is pretty simple. I have several other models in my project, and they work fine with the administrator, but this particular model does not work.

models.py

class AgentBasicInfo(models.Model):

    preferred_email = models.EmailField()
    office_phone_number = models.IntegerField()
    brokerage_of_agent = models.CharField(max_length=50)
    agent_title = models.CharField(max_length=20)

    def __str__(self):
        return self.preferred_email

settings.py

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'postgres',
        'USER': 'postgres',
        'PASSWORD': 'lagger123',
        'HOST': '127.0.0.1',
        'PORT': '5432',
    }
}

Error image for reference

0001_initial.py

from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = [
    ]

    operations = [
        migrations.CreateModel(
            name='AgentBasicInfo',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('preferred_email', models.EmailField(max_length=254)),
                ('office_phone_number', models.IntegerField()),
                ('brokerage_of_agent', models.CharField(max_length=50)),
                ('agent_title', models.CharField(max_length=20)),
            ],
        ),
    ]

Conclusion of readings of manage.py:

accounts
 [X] 0001_initial
admin
 [X] 0001_initial
 [X] 0002_logentry_remove_auto_add
auth
 [X] 0001_initial
 [X] 0002_alter_permission_name_max_length
 [X] 0003_alter_user_email_max_length
 [X] 0004_alter_user_username_opts
 [X] 0005_alter_user_last_login_null
 [X] 0006_require_contenttypes_0002
 [X] 0007_alter_validators_add_error_messages
 [X] 0008_alter_user_username_max_length
contenttypes
 [X] 0001_initial
 [X] 0002_remove_content_type_name
coresite
 (no migrations)
databases
 (no migrations)
manage_listings
 [X] 0001_initial
search_listings
 (no migrations)
sessions
 [X] 0001_initial
teams
 (no migrations)
+4
source share
1 answer

Open db command prompt.

python manage.py dbshell

And try this

delete from django_migrations where app="<your_app_name>";

Then delete the migration files and run the migration commands.

0
source

Source: https://habr.com/ru/post/1688532/


All Articles