0

I create a project use django, and the upload it to heroku.

It can run successfully in local environment, and functions can also work well. I upload successfully without any problems, but when I visit it in heroku(https://APP_NAME.herokuapp.com/), it have some issues like this:

InvalidTemplateLibrary at /

Invalid template library specified. ImportError raised when trying to load 'bootstrap3.templatetags.bootstrap3': cannot import name 'flatatt'

Request Method:
GET
Request URL:
https://APP_NAME.herokuapp.com/
Django Version:
2.0.2
Exception Type:
InvalidTemplateLibrary
Exception Value:
Invalid template library specified. ImportError raised when trying to load 'bootstrap3.templatetags.bootstrap3': cannot import name 'flatatt'
Exception Location:
/app/.heroku/python/lib/python3.6/site-packages/django/template/backends/django.py in get_package_libraries, line 125
Python Executable:
/app/.heroku/python/bin/python
Python Version:
3.6.4
Python Path:
['/app',
 '/app/.heroku/python/bin',
 '/app',
 '/app/.heroku/python/lib/python36.zip',
 '/app/.heroku/python/lib/python3.6',
 '/app/.heroku/python/lib/python3.6/lib-dynload',
 '/app/.heroku/python/lib/python3.6/site-packages']
Server time:
Sun, 25 Feb 2018 02:19:09 +0000

I tried to use django-bootstrap4, but it also have deployment problems with django-bootstrap3.

How can I do?

Thanks a lot.


update:

  • requirements.txt

    pip freeze > requirements.txt

The requirements.txt contents like this:

dj-database-url==0.4.2
Blockquote
django==2.0.2
-e git+https://git.heroku.com/APP_NAME.git@cbb5b522d**SECRET**710#egg=django_bootstrap3
gunicorn==19.7.1
psycopg2-binary==2.7.4
pytz==2017.3
whitenoise==3.3.1

NOTICE: That is the originial file.I modified the 4th line to a certain version,like django-bootstrap3==6.2.2.

  • bootstrap3 settings

Some settings to reference in my virtual-environment:

ll_env/Lib/site-packages/bootstrap3/bootstrap.py

# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from importlib import import_module
...

ll_env/Lib/site-packages/bootstrap3/utils.py

from django.forms.utils import flatatt
from django.template import Variable, VariableDoesNotExist
from django.template.base import FilterExpression, kwarg_re, TemplateSyntaxError
from django.template.loader import get_template
...
3
  • What does you requirements.txt contain? Does that match the output when you do pip freeze in your local environment?
    – Alasdair
    Feb 26, 2018 at 11:56
  • Thank you for your hint. I have updated my question.
    – Allis Gao
    Feb 27, 2018 at 0:53
  • You haven’t added any new information to your question.
    – Alasdair
    Feb 27, 2018 at 7:37

1 Answer 1

0

Solved.

  1. let requestments.txt to be an empty file;
  2. pull to heroku : git push heroku master;
  3. fill requestments.txt file with privious contents, like:

    dj-database-url==0.4.2
    django==2.0.2
    django-bootstrap3
    gunicorn==19.7.1
    psycopg2-binary==2.7.4
    pytz==2017.3
    whitenoise==3.3.1
    
  4. push to heroku again : git push heroku master

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.