Error when adding "Things" in Chapter Six


#1

So everything was working at the end of Chapter 5. I created my superuser and edited models.py (I double checked the code with the book). I ran “makemigrations” and “migrate” and got the correct responses. I edited admin.py and double checked the code. I’m able to log in to the admin site, and can see the “Things” table. I can type and the automated slugging works. But once I hit Save I get the following error:

“OperationalError at /admin/collection/thing/add/
no such table: main.auth_user__old”

http://dpaste.com/1W90K9D (for the full paste).

I’ve tried deleting and remaking the database. I’ve created new users in the command line (this works), but it fails in the admin panel.

Thanks for any insight you might have!


#2

When you deleted and remade the database, did you also remove the migration files that were already created?

I’m wondering why it’s looking for a table named “old” — sounds like something funky happened before.

Try this process (one more time, if you have already):

  1. Delete your db file.
  2. Delete the migration files in your app.
  3. Run python manage.py migrate to create the database.
  4. Run python manage.py createsuperuser to create your admin user.
  5. Run python manage.py makemigrations to create the migration files based on your models.
  6. Run python manage.py migrate to apply those migrations.

Let me know if funky error messages still occur. :)


#3

Followed the commands (I believe verbatim).

http://dpaste.com/1W90K9D for the full error. Looks to be similar issue. I guess I’ll start over. I’m stumped after spending some time with the Django documentation, StackOverflow, and here.


#4

I ran through it again and got the same result. Really banging my head against the wall on this one. It was a clean virtual environment, clean install of Django, copy/pasted a few things, but all the features up to chapter six worked.


#5

Looks like it may have to do with a SQLite bug that has been fixed in later versions of Django. I guess I’ll figure out how to downgrade SQLite and report back.


https://code.djangoproject.com/ticket/29182


#7

Yeah it’s pretty clearly this: https://github.com/django/django/pull/10733

I’m not quite savvy enough to know how to downgrade the version of SQLite I’m using, or how to apply the patch (though some have said it works in Django 2.0.x).


#8

The reason why I am asking about your version number is that it is not clear to me from those posts what version they’re mentioning (is it just all 2.0.x? is it a specific sub version?) and I’d like to know which exact one that you are using so I can go through and replicate it on my end.


#9

I’m on Django 2.0.9, SQLite 3.26.0, and Python 3.7. I’m not at my home computer right now to tell you what the version number of Pysqlite was, but I think it was 2.6.

It appears that this is an issue with the way all versions of Django expect SQLite to handle ALTER TABLE. I tried to go through and apply this patch to my Django install, but botched something: https://github.com/django/django/pull/10733/files. I’ll try it again tonight.

https://docs.djangoproject.com/en/2.1/releases/2.0.10/ explains that 2.0.10 should fix this incompatibility. It looks like it isn’t scheduled to ship until 1/1/19.


#10

@bradofclark I had the same problem.
I saw that pull request was merged and it’s available on branch stable/2.0.x.
So, if you’re in a hurry and wouldn’t like to wait the release, you can resolve your problem temporarily installing this version: pip install git+git://github.com/django/django.git@stable/2.0.x


#11

Thank you. I’ll finally get to add things to my database!