AttributeError: 'AppConfig' object has no attribute 'urls' - python

Issue Summary
Installed django-oscar sandbox app successfully but getting a small error in django-oscar/sandbox/urls.py at the line url(r'^', include(apps.get_app_config('oscar').urls[0])),
Error Message:
AttributeError: 'AppConfig' object has no attribute 'urls'
The 'apps' above is comming from django package:
from django.apps import apps
and using it in
url(r'^', include(apps.get_app_config('oscar').urls[0])),
I googled it but didn't find the solution. I am following the instuructions available on your official django-oscar website: https://django-oscar.readthedocs.io/en/releases-1.6/internals/sandbox.html to make the sandbox app up and running locally.
Technical details
Python version: 3.5.2
Django version:2.1.7
Oscar version: 1.6.7(django-oscar)

Related

Django got error cannot import name AppRegistryNotReady while importing session_security

I am facing one error on Django 1.5.12 while importing session_security.middleware. I got the message below:
File "/opt/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 51, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s: "%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware session_security.middleware: "cannot import name AppRegistryNotReady"
Can someone advise please? Thanks in advance.
Your version of django-session-security does not support Django 1.5. The current release 2.6.1 supports Django 1.8 - 2.0.
You could try installing version 2.3.2, which is the last version to support Django 1.4+ according to the readme. 2.3.3 requires Django 1.7+.
However note that Django 1.5 is years out of date and missing security fixes. You should upgrade.

Issue with import name(conflict app name with python module name) in celery

I have an app in django as social(app name) also using 'social_django' module
but 'social_django' django have dependency module python 'social'
both having same name as 'social' due to this autodiscover_tasks giving wrong path for django app social
installed app for django
INSTALLED_APPS = [
'social_django',
'social'
]
Steps to reproduce
add social_django in installed app also create django app with same name as social
now check path coming in fuction find_related_module at /lib/python3.5/site-packages/celery/loaders/base.py
the following line is creating the bug
pkg_path = importlib.import_module(package).__path__
Expected behavior
expected path : /home/user/workspace/project/social
Actual behavior
actual path:: /lib/python3.5/site-packages/social

Why newly created project doesn't display built-in API Django documentation?

I have a problem described in this post I have no idea what is the reason of the problem so I decided to create a new project both in Docker like without it. In both cases I get the same problem. To wit to newly created project I add only to urls.py:
from rest_framework.documentation import include_docs_urls
API_TITLE = 'API title'
API_DESCRIPTION = '...'
urlpatterns = [
url(r'^docs/', include_docs_urls(title=API_TITLE, description=API_DESCRIPTION))
]
and in Docker requirements.txt I add coreapi. In case of project without Docker I install via virtualenv pip3 install coreapi. That is all what in my opinion I should do in order to get a view like at the top of this site from documentation Obviously at http://localhost:8000/docs/ However in both cases I get
TemplateDoesNotExist at /docs/
rest_framework/docs/index.html
Django tried loading these templates, in this order:
Using engine django:
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.6/site-packages/django/contrib/admin/templates/rest_framework/docs/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python3.6/site-packages/django/contrib/auth/templates/rest_framework/docs/index.html (Source does not exist)
(in virtualenv there is only different path)
Does anyone have an idea what might be wrong? If more details will be needed I will add it immediately to this post, just let me know.
UPDATE
When I add rest_framowork to INSTALLED_APPS I get:
AttributeError at /docs/
'NoneType' object has no attribute 'items'
Request Method: GET
Request URL: http://localhost:8001/docs/
Django Version: 1.11
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'items'
Exception Location: /usr/local/lib/python3.6/site-packages/rest_framework/templatetags/rest_framework.py in items, line 244
Python Executable: /usr/local/bin/python3
Python Version: 3.6.1
Python Path:
['/code',
'/usr/local/lib/python36.zip',
'/usr/local/lib/python3.6',
'/usr/local/lib/python3.6/lib-dynload',
'/usr/local/lib/python3.6/site-packages']
In template /Users/myUser/Projects/DjangoTest/lib/python3.6/site-packages/rest_framework/templates/rest_framework/docs/sidebar.html, error at line 8
UPDATE2
I have in my app on heroku rest_framowork at the top of INSTALLED_APPS however http://myapp.herokuapp.com/docs/ returns:
AttributeError at /docs/
'NoneType' object has no attribute 'items'
Request Method: GET
Request URL: http://myapp.herokuapp.com/docs/
Django Version: 1.11
Exception Type: AttributeError
Exception Value:
'NoneType' object has no attribute 'items'
Exception Location: /app/.heroku/python/lib/python3.6/site-packages/rest_framework/templatetags/rest_framework.py in items, line 244
Python Executable: /app/.heroku/python/bin/python
Python Version: 3.6.1
Python Path:
['/app/Project/backend/project',
'/app/.heroku/python/bin',
'/app',
'/app/.heroku/python/lib/python36.zip',
'/app/.heroku/python/lib/python3.6',
'/app/.heroku/python/lib/python3.6/lib-dynload',
'/app/.heroku/python/lib/python3.6/site-packages']
Server time: Mon, 17 Jul 2017 12:49:49 +0000
SOLTUION
I used djangorestframework==3.6.2 instead of djangorestframework==3.6.3 in requirements.txt. I have no idea why version 3.6.3 doesn't work.
This likely means that you didn't add rest_framework to the INSTALLED_APPS in the settings.py file.

python django 1.9 ImportError: No module named djano.conf.urls

Im following the tutorial on the Django website https://docs.djangoproject.com/en/1.9/intro/tutorial01/
im down to the mysite/urls.py section, i have added the code
from django.conf.urls import url, include
from django.contrib import admin
urlpatterns = [
url(r'^networks/', include('networks.urls')),
url(r'^admin/', admin.site.urls),
]
However when I run the server I get:
ImportError: No module named djano.conf.urls
Ive searched through here and everything points to an old version of Django, but im running the latest version i believe
python -c "import django; print(django.get_version())"
1.9.5
Can anyone help me out?
Thanks
I think you have a Typo error:
ImportError: No module named **djano**.conf.urls
That's why you're getting this ImportError.

django-taggit exception error: Table 'app_name.taggit_taggeditem' doesn't exist

I have installed django-taggit for a blog as part of my project using python 2.7 & django 1.4.6.
I have pip installed django-taggit and then used south migration to add the db settings.
When I attempt to add the blog entry through the admin page, I receive the following error:
Exception Value: (1146, "Table 'app_name.taggit_taggeditem' doesn't exist")
I have checked the south migration logs - these seem ok.
I have added from taggit.managers import TaggableManager to my models.py page.
I have added 'taggit', to my installed_apps in my settings.
I have gone over my work - but cannot locate the issue.
Any suggestions?

Categories