-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
iQIcBAEBCAAGBQJU88RnAAoJEC0ft5FqUuEhTucQALsg0YsmG+Mmu94wCbCONSUK
dxneVLQJRqZ+dDuaIVmCJ9qMbpzbGVrFGjfUMoCmjzQvpM8+OqDriHapMz8gjEuR
swW9NZeYNfSmCh1fHKhTeWpVyfiHfyX1X1IUMbZFo10O6JHoHcX02C1PGBS3IZ5w
q/WABuQBZLLYcWAQWvgHU4S1KvnA8gauGAMmDgE1bWd6zCZWIeqeIBP06kdDrwJ2
cOpnP8yr6DDCjV/r7ztyWA5ez8zQHRv/GwZfsFs0FLW0Kn08rfKBpG4fy7JjPsR/
PF1Q84EcsaLFxhKxXjqUEUnlCsCHnqalIqXWgS+rDVGCnvb6yoqCFYHk475E9msl
jKIIIsBIeg0xq34fbnP0zItrkjjoT3nOMt4vTeVfVj8ZaSy1U4m7EkRHEehdL35P
hTLgxBg/o57w33JjpN6KYc9k8dmGLqKYogrpYRlbPQIAK87rb7mgEfUxmaD4yGiM
eqWMKjmDpoSYp9olUvZz2zOBQrZXAjk+uV/KbfkiNI2vzGosJE/khvEJaCqlMS40
kBYLecMCmFNZztHXVHYc787p4NwR4qLOmKZ4idm+/+4wibftTwARQYUn5CMBrNZy
PgCTaL2f8NKdjZYzYhwNuNsYjnteDZwOXnxIUsMlwuNb+UpH6WZCVh+KW7U8nIPH
BK/TRkuCkq3De6ZjUFwi
=ZjW7
-----END PGP SIGNATURE-----
Hi Michael,
On 03/01/2015 01:11 AM, Michael Ackary wrote:
> Smart Selects looked so simple and promising for chained selects
> (https://github.com/digi604/django-smart-selects). However, no matter
> how I install it, it doesn't seem to work. Here is what I've tried:
>
>
> *Attempt #1 - putting it in django.contrib
> *
> Copied the smart_selects folder to /django/contrib/smart_selects
>
> Added "django.contrib.smart_selects" to INSTALLED_APPS in settings.py
>
> But within Django shell I got this error:
>
>>>> from django.contrib import smart_selects
>>>> smart_selects.urls
> AttributeError: 'module' object has no attribute 'urls'
You don't ever want to do this. The "django.contrib" module is for
modules distributed with Django; it's not a place to add your own
additional code.
It also doesn't work, because smart_select expects to be able to import
itself as "smart_select", not as "django.contrib.smart_select."
> *Attempt #2 - installed using pip
> *
> I removed the smart_selects folder from /django/contrib folder (above)
> and then installed using pip... which put smart_selects in the Python
> site-packages folder.
>
> But then trying to use smart_selects within urls.py produced an ugly
> "ImportError: cannot import name simplejson" which suggests
> smart_selects has some outdated dependencies. (I"m using Django 1.7).
This is the right way to make use of third-party code. The problem here,
as you say, is just that smart_select has some outdated code. It's
actually been fixed in master, just not posted to PyPI yet, so you'll
need to install it directly from git, as mentioned in the fourth comment
here: https://github.com/digi604/django-smart-selects/issues/70
> *Attemp #3 - putting smart_packages in the root folder of my Django project
> *
> When smart_selects is placed here, again I can import smart_selects from
> the Django shell but not access smart-selects.urls :
>
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
>>>> import smart_selects
>>>> dir(smart_selects)
> ['__builtins__', '__doc__', '__file__', '__name__', '__package__',
> '__path__', 'models']
>>>> smart_selects.urls
> Traceback (most recent call last):
> File "<console>", line 1, in <module>
> AttributeError: 'module' object has no attribute 'urls'
>
>
> Finally it works if i do this:
>
>>>> import smart_selects.urls
>>>> smart_selects.urls
> <module 'smart_selects.urls' from
> '/Users/chas/Projects/switch/djangoroot/smart_selects/urls.pyc'>
The difference between the "doesn't work" and "works" versions here
doesn't have anything to do with how you've installed the code, it's
simply how submodule imports work in Python. Submodules are never
automatically imported unless you import them explicitly.
> However, I really don't like putting apps here since they clutter up my
> own development (and would rather keep 3rd party apps in django/contrib).
Yes, this installation technique will work fine, but it clutters things
up and makes it harder to upgrade in the future.
Carl
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/54F3C467.7080203%40oddbird.net.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment