I'm getting JINJA not found error in a Python program - python

I'm trying to set up a blog using pelican. After running the initial steps and setting Theme= Flex, This error keeps popping. But if I change the Theme to something else like resume, etc. no error arises.
I don't know what I'm doing wrong.

What version of Pelican are you using?
JINJA_ENVIRONMENT was introduced in v3.7.0, replacing JINJA_EXTENSIONS.
So if you by any chance installed a version older than v3.7.0, the template uses a variable which is not set by default.

Related

django.db.utils.ProgrammingError: relation "cms_cmsplugin" already exists

While upgrading an old project to django 1.8 and djangocms 3.5 I am getting an error that says:
django.db.utils.ProgrammingError: relation "cms_cmsplugin" already
exists
Does anyone understand what is wrong and can help with that?
Thanks.
I have tried some solution propositions on other titles but none worked.
did --fake-initial, tried migrating commenting out all other plugins of cms etc but none worked.
I can only give little advice on your specific error: The table cms_cmsplugin" is already existing. But I guess you can read errors...starting with a fresh db could be a solution (restarting the upgrade process, with the orignal db from before the upgrade). I can give some general advice for upgrading django/django-cms projects.
Key point for me always was: make it reproducable. So you can try things, but also start over again, without much of an effort. I for myself once made a tool for this purpose: project-updater. I normaly had scripts to automatically reset db and media files and git tag to the starting point of my upgrade, then execute steps required up to where I was currently stuck, and from there move on...wether using project updater, your own workflow, or another tool is not of that importance...

Invalid Salt on Local versus Heroku (Encoding UTF-8 problems)

The Issue:
It appears there is some sort of encoding/decoding issue going on with flask-bcrypt for my Mac. I'd like to know if there is an easy solution to fix this so I can run my local with a similar setup to my Heroku version.
Comparison:
Local
If I use .decode("utf-8") with generate_password_hash it returns AttributeError: 'str' object has no attribute 'decode'. Without decode, it saves my password to the database properly and I'm able to login with no issues.
When I test bcrypt.generate_password_hash [without decode] in terminal on local it
returns like '$2b$12$yTBsCi.....`
Heroku
If I use .decode("utf-8") with generate_password_hash it saves to the database properly and I"m able to login. If I don't use decode("utf-8"), it saves the password incorrectly (something like: \x243261243132245a4e64696e4d7062327......) and when I try to login it returns ValueError: Invalid salt.
When I test bcrypt.generate_password_hash [without decode] on heroku bash it returns
b'$2b$12$amVQ6f2.d......'
Current Setup:
Both are running Python 3.6.4. Both Heroku and my local version have identical requirements installed. bcrypt==3.1.4 Flask-bcrypt==0.7.1 py-bcrypt==0.4
Documentation:
https://flask-bcrypt.readthedocs.io/en/latest/
In Python 3, you need to use decode(‘utf-8’) on generate_password_hash(), like below:
pw_hash = bcrypt.generate_password_hash(‘hunter2’).decode(‘utf-8’)
Final Thoughts:
Any solutions to get my Mac encoding/decoding correctly? Perhaps because MacOS relies on Python 2.7 it's messing it up? But this shouldn't be the case within my virtualenv.....
I've run echo $LANG and looked at the psql server_encoding on local/heroku and they are both identical for utf8.
So! This is a mind boggling problem for a lot of people. Now that I have found a solution, I'm back to post the results.
Solution Part A: [The most important piece is in Solution Part B, this is a minor fix]. The first thing I realized was that I was using double quotes around my utf-8. I then rechecked the documentation and realized it was a single quote .decode('utf-8'). As soon as I did this, it seemed to fix the problem (at least temporarily). Why that fixes it, I'm uncertain, but that's something to try and a small detail to overlook. After a few days of more pushes, the bug popped back up.
Solution Part B: This is the much larger problem that I learned. After hours of searching I stumbled on a google search that was something along the lines of "Flask-bcrypt py-bcrypt conflict". There were some ambiguous stack overflow questions and github issues that lead me to realize there was likely something conflicting between these packages. So naturally I removed them an reinstalled py-bcrypt, flask-bcrypt, and bcrypt. Same problem. Then I did it again in a different order....new problem....about ffi being missing. So then I uninstalled all of them and ONLY installed flask-bcrypt. Well wouldn't you know...that fixed the problem for Heroku and my local. It turns out that when you install flask-bcrypt it auto installs bcrypt. I left py-bcrypt uninstalled entirely. It seems bcrypt and py-crypt really don't like each other.
Hope that fixes it for you!
(note: I do have this feeling that bcrypt is still accessing py-bcrypt in some way, maybe through headers or the python package itself. Regardless, removing it from my virtual environment did the trick).
(alternative solution: I heard if these packages just really don't play nice, you can use generate_password_hash from something like werkzeug or try installing the cryptography package. I didn't want to go that route though, but worth a shot).

Fixing broken django module that was installed from pip, where is the code?

I have been trying to use the django-visits module, though I seem to not even get this to run cause the minute I follow the instructions for just adding it to my application here:
https://bitbucket.org/jespino/django-visits/src/c3ac83b91969?at=default
It gives me an error when I try to run server:
ERRORS:
visits.Visit.ip_address: (fields.E900) IPAddressField has been removed
except for support in historical migrations.
HINT: Use GenericIPAddressField instead.
Their hint was helpful enough, but I have no idea where pip instaleld my django-visits to where I can change the model code of this module to fix the IPAdressField
Am I approaching solving this error wrong? Should I not be looking for the original code that was installed somewhere on my machine? Do I need to somehow install this from source and not use Pip since I have to change the models.py in this module?
(I am trying to make this work on my OS X machine but ultimately will need to get this to work on CentOS box). Also the database is postgres/postgis

Should I stop using a deprecated module?

I am using django-registration v0.7 and django 1.2.4. Everything works fine but I am wondering why I'm getting this warning message each time I run the server:
C:\Python26\lib\site-packages\registration\models.py:4: DeprecationWarning: the sha module is deprec
ated; use the hashlib module instead
import sha
Could be a problem in the future? Can I avoid it without changing django-registration original code?
EDIT
This deprecation warning comes up in Python 2.6.2
No, if it works, leave it. You can consider this something to think about when you upgrade to a new version of Python which actually removes this module.
Deprecated means that you are encouraged not to use it in new code, it doesn't mean you need to modify (and hence break) existing code which uses it.
you should create new issue/ticket/bug on project's site, or report this to developers of the project.
if there is no activity in project, you are free to fix the code locally.
i had the same problem and kept getting mail about a cron job which was throwing deprecation warning so i ran my python script with
-W ignore::DeprecationWarning
since the script is running in a virtualenv which won't be moving to py3k i can live with this
This deprecation warning comes up in Python 2.6 and django-registration v0.7, it dissapears upgrading django-registration to v0.8

Could not find the GEOS library

i am working on a simple employee listing Django application. i wanted to include filtering in my app, so tried installing django-filter module. i think django-filter is not installed properly ( i am not going to use it anyway). But after doing this, when i try to run my application, it gives this ,
"`ViewDoesNotExist at /employeeList/` ;
Could not import task.employeeDetails.views. Error was: Could not find the GEOS library (tried "geos_c", "GEOS"). Try setting GEOS_LIBRARY_PATH in your settings "
. while i searched for the error,came to know the error is due to some wrong geoDjango installation. But i dont need geoDjango and i am wondering how its throwing this error. Before doing this, my app was working fine. Somebody please help me to solve this problem.
Things to check:
Are you using the GeoDjango database classes? If your database engine is set to something like django.contrib.gis.db.backends.postgis or django.contrib.gis.db.backends.mysql, those are the geo backends. What you want is something like django.db.backends.postgresql_psycopg2 or django.db.backends.mysql. Not the lack of the "contrib.gis" part.
The other most likely possibility is that task.employeeDetails.views is importing or running something that requires GEOS.

Categories