Simple stupid Error: getting super calm!

Hi all,

After spending a few hours to solve such simple stupid issue am currently encountering with Django, I would like to know whether it is possible that Django framework does stop to see the registered table.
I am wondering what might cause such issue? Have cleaned cache, restarted pc.

Simple app

from django.db import models
class Book(models.Model):
    ids = models.IntegerField(null=True, blank=True)
    title = models.CharField(max_length=100, blank=True, null=True)
    subtitle = models.CharField(max_length=200, blank=True, null=True)
    authors = models.CharField(max_length=150, blank=True, null=True)
    publisher = models.CharField(max_length=150, blank=True, null=True)
    published_date = models.DateField()  # auto_no_addw=False, default=False
    category = models.CharField(max_length=100, blank=True, null=True)
    distribution_expense = models.DecimalField(
        max_digits=6, decimal_places=2, default=0, null=True, blank=True

    def __str__(self):
        return self.title

from django.contrib import admin


# OperationalError at /ToDo/admin/myapp/book/

no such table: myapp_book

|Request Method:|GET|
| --- | --- |
|Request URL:|http://localhost:8000/ToDo/admin/myapp/book/|
|Django Version:|4.2|
|Exception Type:|OperationalError|
|Exception Value:|no such table: myapp_book|
|Exception Location:|/home/dostor/.local/lib/python3.10/site-packages/django/db/backends/sqlite3/, line 328, in execute|
|Raised during:|django.contrib.admin.options.changelist_view|
|Python Executable:|/usr/bin/python3|
|Python Version:|3.10.12|
|Python Path:|['/mnt/c/Users/aka_a/Documents/Python ' 'Scripts/nodejs/website_node/Coursera/trackApp', '/usr/lib/', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/dostor/.local/lib/python3.10/site-packages', '/usr/local/lib/python3.10/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.10/dist-packages', '/home/dostor/.local/lib/python3.10/site-packages/odf', '/home/dostor/.local/lib/python3.10/site-packages/odf', '/home/dostor/.local/lib/python3.10/site-packages/odf', '/home/dostor/.local/lib/python3.10/site-packages/odf', '/home/dostor/.local/lib/python3.10/site-packages/odf', '/home/dostor/.local/lib/python3.10/site-packages/odf', '/home/dostor/.local/lib/python3.10/site-packages/odf']|
|Server time:|Wed, 03 Apr 2024 14:23:08 +0000|

Thanks for your reply in advance.

Kind regards,

It’s saying the table doesn’t exist.

Have you run your makemigrations and migrate for your app?

(It may help if you show the output from a showmigrations command.)

Hi Ken,

Thanks for your reply. Of course, I run makemigrations and migrate before to run runserver. Besides, using ./ shell I can import Book model e.g. from myapp.models import Book
The strange things is I tried to check in two laptops OS: Windows10 and ChromeOS. Both laptops throwing the same issues on admin panel when I click on Books table. No clue why?

That’s actually not relevant at all. An import imports the class definition, it makes no attempt to access the database.

Please post the output of a showmigrations command as requested above.

Here is showmigrations:

…B:/mnt/c/Users/aka_a/Documents/Python Scripts/nodejs/website_node/Coursera/trackApp$ python3 showmigrations
admin [X] 0001_initial [X] 0002_logentry_remove_auto_add [X] 0003_logentry_add_action_flag_choices
[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 [X] 0009_alter_user_last_name_max_length [X] 0010_alter_group_name_max_length [X] 0011_update_proxy_permissions [X] 0012_alter_user_first_name_max_length
[X] 0001_initial [X] 0002_remove_content_type_name
[X] 0001_initial [X] 0002_auto_20150501_1515 [X] 0003_query_snapshot [X] 0004_querylog_duration [X] 0005_auto_20160105_2052 [X] 0006_query_connection [X] 0007_querylog_connection [X] 0008_auto_20190308_1642 [X] 0009_auto_20201009_0547 [X] 0010_sql_required [X] 0011_query_favorites [X] 0012_alter_queryfavorite_query_alter_queryfavorite_user [X] 0013_querylog_error_querylog_success
[X] 0001_initial

for some reason model Book is not migrated in Db. Any clues?

Yes. You didn’t create a migration for it.

See the docs for django-admin and | Django documentation | Django

If your app doesn’t have a proper migrations directory, you need to run makemigrations with the name of the app as a parameter.

Thanks Ken,

I really was used to run makemigations without even calling parameter. Then in all my previous projects everything was running smoothly until today. Seems, something is happened with my pc settings.

Thanks again for your time.

Kind regards,