Forums

Reset my database

Modifying my models.py I deleted an obselete class (carousel_videos). I thenafter, run makemigrations and got error message:

fields.extend(handler.required_fields())
AttributeError: 'str' object has no attribute 'required_fields'

In my admin,, I delteed the post that contained that model and then deleted the row from the db table.

Out of nothing, littereally, the specific ArticleIndexPage disappeared, all children included.

I then tried to reset my sqlite file. I deleted plus all pyc and migrations files. I run migrations and had the same error message.

I then, deleted my virtualenv (cache and local dir included). I still had the same error message, i.e. even if I didn't have a database anymore. So far, I didn't save my project on MySQL, only sqlite3.

I created a new virtualenv and still has the same error.

Using the project's latest git from my local machine,, I could run migrations and also reset sqlite3, without a problem.

The full error message (see below) refers to a certain files...but where is this file? All related files (in the files tab) were deleted. Any help is great, I'm kinda lost...

full error message:

  File "/home/teki/tekieatstail/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/django/core/management/base.py", line 393, in execute
    self.check()
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/django/core/management/base.py", line 419, in check
    all_issues = checks.run_checks(
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/django/core/checks/registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/wagtail/admin/checks.py", line 84, in inline_panel_model_panels_check
    errors.extend(check_panels_in_model(cls))
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/wagtail/admin/checks.py", line 103, in check_panels_in_model
    edit_handler = cls.get_edit_handler()
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/wagtail/utils/decorators.py", line 53, in __call__
    return self.value
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/django/utils/functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/wagtail/utils/decorators.py", line 49, in value
    return self.fn(self.cls)
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/wagtail/admin/edit_handlers.py", line 955, in get_edit_handler
    tabs.append(ObjectList(cls.content_panels,
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/wagtail/admin/edit_handlers.py", line 376, in __init__
    self.show_comments_toggle = 'comment_notifications' in self.required_fields()
  File "/home/teki/.virtualenvs/teki/lib/python3.9/site-packages/wagtail/admin/edit_handlers.py", line 280, in required_fields
    fields.extend(handler.required_fields())
AttributeError: 'str' object has no attribute 'required_fields'

[edit by admin: formatting]

I think the best way to debug this would be to take a look at each of the files mentioned in the error message, and try to trace back where the handler object is coming from; clearly it is a string, and Wagtail is expecting it to be some kind of object with a required_fields member. So, you'd start by opening up /home/teki/.virtualenvs/teki/lib/python3.9/site-packages/wagtail/admin/edit_handlers.py in the editor at line 280, and checking where handler comes from in there, and then if it came in as one of the parameters to that function, move on to line 376 to see where it came from there, and so on, until you can find the place in your code that it came from.

I tried, though, it didn't yield much. The specified lines in the error message are identifcal to the one appears on a local venv, with the exception, the later works without any problem.

For clarity, currently I don't have a db.sqlite file. My migrations and pyc files were deleted*. I restarted my project with a new virtual env and still have the same error message.

The only way for me to run PAW server is to reinclude the piece of code I deleted, as I don't need it anymore. This isn't a serious solution, of course. Can you kindly advise?

find . -path "/migrations/.py" -not -name "init.py" -delete && find . -path "/migrations/*.pyc" -delete

Is the code that you currently have on PythonAnywhere identical to the code that you're running locally? You mention that you're using git, so if the code on our servers is a git clone of the project, then you can see any differences with a "git diff".