Wagtail 2.14.2 ModulNotFound error after running makemigrations

Viewed 17

3rd try of wagtail

I did install it after having created a virtual environment named wag-env with virtualenv within the directory websites/wag/, not in the .virtualenv folder. Command was "virtualenv wag-env".

Did pip install wagtail

Then ran wagtail start ready_wag

I then ran python3 manage.py makemigrations and get this error messages "ModuleNotFound error wagtail.models". A check in the lib confirmed that there is a models folder at wagtail root level, but no models.py.

That's my third try since yesterday, first was with mkvirtualenv, had the same problem, second was with virtualenv, trying to integrate a finished django project, and now trying to start a project from scratch.

I ran a pip freeze --user, there's a wagtail installed globally. Should I get rid of it ?

Thanks in advance for your answers

1 Answers

I've always used venv to create my environments, never had issue. Sounds like you have conflicting versions of Django to match your version of Wagtail.

Here are my old notes from learning Wagtail, the process I still generally use for every project:

  1. Create project folder, open terminal session in that folder
  2. In project folder, create virtual environment (python -m venv .venv)
  3. Start virtual environment (.\.venv\Scripts\Activate.bat or source .venv/bin/activate)
  4. Install Wagtail (pip install wagtail==3.0.3) <- adjust version as needed
  5. Start new project in current directory (wagtail start project .)
  6. Install wagtail requirements (pip install -r requirements.txt)
  7. If using POSTGRES, follow the POSTGRES setup instructions BEFORE migrating.
  8. Provision database (python manage.py migrate)
  9. Run server and check default site (python manage.py runserver)
  10. Create superuser (python manage.py createsuperuser) and log in to admin area
  11. Move database settings, allowed hosts and secret key from base.py to new file local.py in the same folder. Also any other settings that apply only to the local machine.
  12. Create the git repository.

Setting up POSTGRES backend

With POSTGRES installed, from the command prompt, enter the POSTGRES command prompt:

psql -U username
  • username is the db global admin login created during install

Enter the following commands to add a project database and a user with full rights on the project db:

CREATE DATABASE myproject;
CREATE USER myprojectuser WITH PASSWORD 'password';
ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
ALTER ROLE myprojectuser SET timezone TO 'UTC';
GRANT ALL PRIVILEGES ON DATABASE myproject TO myprojectuser;

Type \q to exit the POSTGRES prompt.

In your virtual environment, install psycopg2:

pip install psycopg2

Note, you may get a warning to install from an alternative source:

pip install psycopg2-binary

Create a blank database for the project. Set this up in the project local.py:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'projectdb',
        'USER': 'myprojectuser',
        'PASSWORD': 'password',
        'HOST': 'localhost',
        'PORT': '5432',
    }
}

Continue on to step 8 above.

Related