Sunday, October 29, 2017

Failling to build a Django project in VS 2015 - django\contrib\admin\widgets.py

Leave a Comment

I'm having a hard time building my Django project in VS 2015. Background: I have this project up and running on Eclipse so far, but I would like to import it to VS 2015 (Professional). I've download and installed VS IDE and Python Tools for VS 2.2.6.

--

First, I have had a Build FAILED error with no error messages. After some googling, I've changed the options from Build output messages from Minimal to Diagnostic, and found out that the problem seemed to be with my PYTHONPATH.

Then, I've added a Search Path to my python34 site-packages folder (again, after some research, I believe this is the right path).

After doing so, the build now fails again, but there are several "unexpected token" errors in the same file, localed in django/contrib/admin/widgets.py.

I've compared my file with the file in the official github page of django, and both files have some differences. Running the get version from the interactive window, I can see that my Django version is 1.11.6.

Is overwritting this file for the one in the github a good solution? Perhaps the installation have gone wrong at some point? What should I do?

-- EDIT --

Overwritting the file did not resolve it, as the same block of code appears in both files. It seems to be related with:

if params:     related_url += '?' + '&'.join(         '%s=%s' % (k, v) for k, v in params.items(),     )     context['related_url'] = mark_safe(related_url)     context['link_title'] = _('Lookup') 

Errors are:

Error unexpected token ',' C:\Python34\Lib\site-packages\django\contrib\admin\widgets.py

Error unexpected token ')' C:\Python34\Lib\site-packages\django\contrib\admin\widgets.py

Error unexpected token 'dedent' C:\Python34\Lib\site-packages\django\contrib\admin\widgets.py

Error unexpected token 'newline' C:\Python34\Lib\site-packages\django\contrib\admin\widgets.py

And the last one related to the eof

Error unexpected end of file C:\Python34\Lib\site-packages\django\contrib\admin\widgets.py

--EDIT 2--

I've made a test by creating a new project and build + run it, and it succeeds. As I'm new to Django, I'm not sure if the reason why it succeeds is that this new project is not reaching this widgets.py file.

1 Answers

Answers 1

I think somehow your Django package has got corrupted and altered. You shouldn't repair these things by manually copying files, rather you should re-install the package

Try running

pip install django==1.11.6 --upgrade --force 

--upgrade and --force will make sure the django and its dependencies are reinstalled

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment