New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Django syntax checking doesn't support Python 3 natively (requires workaround) #140
Comments
It happens with Django 1.7.7, too. |
Could you please provide a sample snippet with which we can reproduce your issue? |
Could it be that something has changed in the latest version of Django, where django.template is no longer a thing/has been renamed to something else? If not, make sure that the django libraries are on your python path, as the linter seems to depend on these. |
The project's python has Django installed, and django.template is still there. Could this problem be related to the Python2 vs. Python3 project problem? Python files in a Python3 project aren't correctly linted due to not using the correct Python installation until you flag the file as being Python3 -- maybe the Django linter is incorrectly assuming Python2 and therefore not locating django? |
That's an interesting point, I will verify this. Are you by any chance working on an open source project? It'd be really useful if I could reproduce this issue on the same project you're using. |
This project isn't open, but I just reproduced the issue by creating a new project, assigned a Python3 virualenv (with Django 1.7 installed) as the default python, and created a test template same as above. |
I installed Django into the system Python2, and the error went away. So the Django linter seems to be trying to use Python2 only, which makes sense because there's no way to tell it which python to use. I suppose it could try Python2, and if it doesn't find Django there try Python3. |
By default the Django linter uses the Python2 interpreter, as we cannot tell the difference between Python2 and Python3 Django files. A workaround would be to change your Python2 interpreter path to point to your Python3 installation (and ignore the warning). Then you wouldn't have to install Django into your Python2 installation. Changing this ticket to an enhancement since this issue is really about detecting whether to use the Python2 interpreter vs Python3 interpreter. However, this is not trivial. |
If Komodo could accept having just one Python interpreter assigned to a project, wouldn't it be trivial? |
Thanks for the suggestion. I will look into this. |
Easiest solution was to fall back on Python3 interpreter if there was a failure in Python2. |
Django linting is still broken in Komodo Edit 10. And after looking at the two python modules involved, I can see at least some of the problems. The djangoLinter module is expecting a tempfile and the Django project's base directory, but koDjango_UDL_Language.py gives it a tempfile and a directory or a string containing the settings module. If If It's not safe to guess at what the settings module will be -- they aren't always going to be "projectname.settings". Just require Similarly, why jump through hoops (as koDjango_UDL_Language.py does) trying to figure out which python interpreter to use? Just use the one that's set for the project (or the file if its prefs override). |
Sorry, I just realized maybe I should've opened a new issue for this? |
I was looking into this a bit, and you don't even need the
EDIT: I take this back -- |
Yes, please open a new ticket :) |
Yo! Just look at that great stuff outta here! You're gonna love it, I swear! More info here http://sisirasi.robertsgeo.com/e4hdgw tony.attwood |
This error appears in my Django 1.8 project templates on the last
{% endblock %}
in the file. The Django template highlighting and code completion work, but the linting fails.The text was updated successfully, but these errors were encountered: