简体   繁体   中英

'staticfiles' is not a registered tag library: These solutions don't work

I'm new to Heroku and Django.
Now I'm in the middle of Getting Started on Heroku with Python .
When I access https://(...secret...)-app-123.herokuapp.com/db ,
I got the following error:

'staticfiles' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_urls
cache
i18n
l10n
log
static
tz

Then I found these solutions .
However, these solutions don't solve my problem.

Firstly, I changed

{% load staticfiles %}

to

{% load static %}

... in db.html .

It gave me:

run python manage.py migrate
Running python manage.py migrate on ⬢ (...secret...)-app-123... up, run.3361 (Free)
Operations to perform:
  Apply all migrations: admin, auth, contenttypes, hello, sessions
Running migrations:
  No migrations to apply.
  Your models have changes that are not yet reflected in a migration, and so won't be applied.
  Run 'manage.py makemigrations' to make new migrations, and then re-run 'manage.py migrate' to apply them.

Since the error message tells me to run manage.py makemigrations , I ran:

manage.py makemigrations
Traceback (most recent call last):
  File "C:\Users\xxxxx\python-getting-started\manage.py", line 8, in ?
    from django.core.management import execute_from_command_line
ImportError: No module named django.core.management

No module?
Django is installed on my machine.
I didn't know what to do, so I updated Django on my local machine:

C:\Users\xxxxx\python-getting-started>pip install django --upgrade
Requirement already up-to-date: django in c:\users\xxxxx\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (3.1.2)
Requirement already satisfied, skipping upgrade: sqlparse>=0.2.2 in c:\users\xxxxx\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (0.4.1)
Requirement already satisfied, skipping upgrade: pytz in c:\users\xxxxx\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (2020.1)
Requirement already satisfied, skipping upgrade: asgiref~=3.2.10 in c:\users\xxxxx\appdata\local\packages\pythonsoftwarefoundation.python.3.8_qbz5n2kfra8p0\localcache\local-packages\python38\site-packages (from django) (3.2.10)

... But, it doesn't solve my problem.

I also added:

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')]
VENV_PATH = os.path.dirname(BASE_DIR)
STATIC_ROOT = os.path.join(VENV_PATH, 'static_root')

at the end of settings.py , but it doesn't work, too.

What else can I do?

For your info, there hasn't been any error until now at Getting Started on Heroku with Python .
You can't even reach here, if you have any error.

Please freely ask me about my settings, type this, type that, etc. Thank you in advance.

You should use virtual environment. It will be easier to manage your django project inside virtual environment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM