Issue
I'm working on some django apps, pretty noob still. Would like to use crispy-forms, but eclipse and django doesnt recognize it.
Trying to runserver or shell:
$ python manage.py runserver
this happens:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 87, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named crispy-forms
This is the forms.py I recently added to the site-folder alongside views.py, and it complains about unresolved import of crispy_forms...:
from django.contrib.auth.forms import UserCreationForm
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, ButtonHolder, Submit
from wx.lib.pubsub.core import kwargs
class RegistrationForm(UserCreationForm):
def __init__(self, *args, **kwargs):
super(RegistrationForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.layout = Layout(
'username',
'password1',
'password2',
ButtonHolder(
Submit('register',
'Register',
css_class='btn-prima'
)
)
)
This is my part of my settings.py:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
'crispy-forms',
)
...
CRISPY_TEMPLATE_PACK = 'bootstrap'
I'm running virtualenv, my venv-dir looks like this:
venv/bin$ ls -la
total 2916
drwxr-xr-x 3 nr1 nr1 4096 Feb 17 11:24 .
drwxr-xr-x 6 nr1 nr1 4096 Feb 16 19:38 ..
-rw-r--r-- 1 nr1 nr1 2220 Feb 16 19:35 activate
-rw-r--r-- 1 nr1 nr1 1276 Feb 16 19:35 activate.csh
-rw-r--r-- 1 nr1 nr1 2489 Feb 16 19:35 activate.fish
-rw-r--r-- 1 nr1 nr1 1137 Feb 16 19:35 activate_this.py
-rwxr-xr-x 1 nr1 nr1 300 Feb 16 19:44 django-admin
-rwxr-xr-x 1 nr1 nr1 159 Feb 16 19:44 django-admin.py
-rw-r--r-- 1 nr1 nr1 304 Feb 16 19:44 django-admin.pyc
-rwxr-xr-x 1 nr1 nr1 267 Feb 17 11:24 easy_install
-rwxr-xr-x 1 nr1 nr1 267 Feb 17 11:24 easy_install-2.7
drwxr-xr-x 7 nr1 nr1 4096 Feb 16 19:47 .git
-rwxr-xr-x 1 nr1 nr1 2364 Feb 17 00:13 pilconvert.py
-rwxr-xr-x 1 nr1 nr1 15631 Feb 17 00:13 pildriver.py
-rwxr-xr-x 1 nr1 nr1 2609 Feb 17 00:13 pilfile.py
-rwxr-xr-x 1 nr1 nr1 1055 Feb 17 00:13 pilfont.py
-rwxr-xr-x 1 nr1 nr1 2410 Feb 17 00:13 pilprint.py
-rwxr-xr-x 1 nr1 nr1 239 Feb 17 11:24 pip
-rwxr-xr-x 1 nr1 nr1 239 Feb 17 11:24 pip2
-rwxr-xr-x 1 nr1 nr1 239 Feb 17 11:24 pip2.7
-rwxr-xr-x 1 nr1 nr1 2884984 Feb 17 11:24 python
lrwxrwxrwx 1 nr1 nr1 6 Feb 17 11:24 python2 -> python
lrwxrwxrwx 1 nr1 nr1 6 Feb 17 11:24 python2.7 -> python
-rwxr-xr-x 1 nr1 nr1 3886 Feb 17 00:11 sqlformat
I accidentally managed to type in: pip install python today, and it seems it did. Could that have any impact on it? I mean, isnt it virtualenv's task to make sure there is no software-conflicts?
Anyway, I cant get any Django-work going now until i figure this out, any help out there?
Update 1 changes:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls',
'crispy_forms',
)
$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 87, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named crispy_forms
$ cat requirements.txt
Django==1.7.4
django-crispy-forms==1.4.0
django-debug-toolbar==1.2.2
django-extras==0.3
django-grappelli==2.6.3
django-haystack==2.3.1
django-reversion==1.8.5
django-tastypie==0.12.1
easy-thumbnails==2.2
Pillow==2.7.0
python-dateutil==2.4.0
python-mimeparse==0.1.4
requests==2.5.1
six==1.9.0
sqlparse==0.1.14
update 2: Installing a new django-project, new virtualenv, all new.. SAME THING HAPPENS
(abc)nr1@kali:~/workspace/websites/abc$ pip install django-crispy-forms Collecting django-crispy-forms Using cached django-crispy-forms-1.4.0.tar.gz Installing collected packages: django-crispy-forms Running setup.py install for django-crispy-forms Successfully installed django-crispy-forms-1.4.0
(abc)nr1@kali:~/workspace/websites/abc$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/nr1/Envs/abc/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/nr1/Envs/abc/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/home/nr1/Envs/abc/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/nr1/Envs/abc/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/nr1/Envs/abc/local/lib/python2.7/site-packages/django/apps/config.py", line 123, in create
import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named crispy_forms
I now try to install crispy_forms to a completely project, looking in my virtualenv, I see its there:
nr1@kali:~/Envs/abc/local/lib/python2.7/site-packages$ ls -la
total 56
drwxr-xr-x 12 nr1 nr1 4096 Feb 17 21:50 .
drwxr-xr-x 4 nr1 nr1 4096 Feb 17 20:31 ..
drwxr-xr-x 5 nr1 nr1 4096 Feb 17 21:50 crispy_forms
drwxr-xr-x 17 nr1 nr1 4096 Feb 17 20:40 django
drwxr-xr-x 2 nr1 nr1 4096 Feb 17 20:40 Django-1.7.4.dist-info
drwxr-xr-x 2 nr1 nr1 4096 Feb 17 21:50 django_crispy_forms-1.4.0-py2.7.egg-info
-rw-r--r-- 1 nr1 nr1 126 Feb 17 20:31 easy_install.py
-rw-r--r-- 1 nr1 nr1 315 Feb 17 20:31 easy_install.pyc
drwxr-xr-x 2 nr1 nr1 4096 Feb 17 20:31 _markerlib
drwxr-xr-x 10 nr1 nr1 4096 Feb 17 20:31 pip
drwxr-xr-x 2 nr1 nr1 4096 Feb 17 20:31 pip-6.0.8.dist-info
drwxr-xr-x 4 nr1 nr1 4096 Feb 17 20:31 pkg_resources
drwxr-xr-x 4 nr1 nr1 4096 Feb 17 20:31 setuptools
drwxr-xr-x 2 nr1 nr1 4096 Feb 17 20:31 setuptools-12.0.5.dist-info
So, its clear. Django doesn't even recognize that its installed it. How can that be?? virtualenv says its there, but django cant see it??? wtx...
Solution
Ok, so I found by chance(almost) another post, this one: Getting stuck at Django error: No module named registration
and thought it might have something to do with pythonpath.
so then I tried easy_install, like suggested:
$ easy_install -Z django-crispy-forms
Searching for django-crispy-forms
Best match: django-crispy-forms 1.4.0
Adding django-crispy-forms 1.4.0 to easy-install.pth file
Using /home/nr1/Envs/abc/lib/python2.7/site-packages
Processing dependencies for django-crispy-forms
Finished processing dependencies for django-crispy-forms
Now it works! I still think there might be something missing with the pythonpath, because I keep getting this in eclipse:
SignUpView Found at: __module_not_in_the_pythonpath__
, and I would like someone to clarify it, so feel free to contribute here...
but django and crispy_forms now works together. YippikayeyMF!!
Answered By - beowwwulf
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.