AttributeError: module 'myapp' has no attribute 'startswith' in Django - django

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x046E1780>
Traceback (most recent call last):
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\commands\runserver.py", line 112, in inner_run
autoreload.raise_last_exception()
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\core\management\__init__.py", line 327, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\BS146\AppData\Local\Programs\Python\Python36-32\lib\importlib\__init__.py", line 117, in import_module
if name.startswith('.'):
AttributeError: module 'myapp' has no attribute 'startswith'

Your INSTALLED_APPS has an entry that is not a string.
It should be
INSTALLED_APPS = [..., 'myapp']
, not
INSTALLED_APPS = [..., myapp]

Related

type error module object is not iterable error in django

C:\IT Career\Python\shop>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 600, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 419, in check
all_issues = checks.run_checks(
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 413, in check
messages.extend(check_resolver(pattern))
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in get
res = instance.dict[self.name] = self.func(instance)
File "C:\Users\THE KING\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 607, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf '<module 'products.urls' from 'C:\IT Career\Python\shop\products\urls.py'>' does not appear to have any
patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
As far as i think you dont have urlpatters in urls.py. There must be a list that contains paths or urls.
Your urls.py should look something like this-:
from django.urls import path, include
from . import views
app_name = "<your_app_name>"
urlpatterns = [
path("your_url", views.your_view),
path("second_url/",views.second_view)]

python-django/python manage.py runserver error

I am trying to run the server using this command python manage.py runserver but i am getting this error even i have installed mysqlclient and mysql-python:
C:\Users\neethu\sencha\sencha-sdks\sencha_workspace\webapp>python manage.py runserver
Unhandled exception in thread started by <function wrapper at 0x0397EC70>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
autoreload.raise_last_exception()
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 251, in raise_last_exception
six.reraise(*_exception)
File "C:\Python27\lib\site-packages\django\utils\autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Python27\lib\site-packages\django\apps\registry.py", line 108, in populate
app_config.import_models()
File "C:\Python27\lib\site-packages\django\apps\config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Python27\lib\site-packages\django\contrib\auth\models.py", line 4, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "C:\Python27\lib\site-packages\django\contrib\auth\base_user.py", line 52, in <module>
class AbstractBaseUser(models.Model):
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 124, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "C:\Python27\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Python27\lib\site-packages\django\db\models\options.py", line 214, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python27\lib\site-packages\django\db\utils.py", line 211, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python27\lib\site-packages\django\db\utils.py", line 115, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 30, in <module>
'Did you install mysqlclient or MySQL-python?' % e
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: DLL load failed: %1 is not a valid Win32 application..
Did you install mysqlclient or MySQL-python?

Django-cms ImportError: No module named sitescms

I am trying install django-cms. But I got following error
Traceback (most recent call last):
File "/home/savad/virtuals/kw/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/home/savad/virtuals/kw/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 107, in inner_run
autoreload.raise_last_exception()
File "/home/savad/virtuals/kw/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 252, in raise_last_exception
six.reraise(*_exception)
File "/home/savad/virtuals/kw/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 229, in wrapper
fn(*args, **kwargs)
File "/home/savad/virtuals/kw/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/savad/virtuals/kw/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/savad/virtuals/kw/local/lib/python2.7/site-packages/django/apps/config.py", line 119, in create
import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named sitescms
I used django-cms==3.4.2 and django==1.8.17.
To me it looks like you're missing a comma in the list of your INSTALLED_APPS in settings.py.
Could it be that it says
...,
'sites'
'cms',
...
instead of
...,
'sites',
'cms',
....
The missing comma results in sitescms.

Django ImportError: No module named although it is already in my python search path

I am solving this for quite a long time already.
I print like this.
python2.7 -c "import sys; print sys.path"
And I saw my module directly there.
['', '/home/khantthulinn/lib/python2.7/pip-8.1.2-py2.7.egg',
'/home/khantthulinn/lib/python2.7',
'/home/khantthulinn/lib/python2.7', '/usr/lib64/python27.zip',
'/usr/lib64/python2.7', '/usr/lib64/python2.7/plat-linux2',
'/usr/lib64/python2.7/lib-tk', '/usr/lib64/python2.7/lib-old',
'/usr/lib64/python2.7/lib-dynload',
'/home/khantthulinn/.local/lib/python2.7/site-packages',
'/usr/lib64/python2.7/site-packages',
'/usr/lib64/python2.7/site-packages/PIL',
'/usr/lib64/python2.7/site-packages/geos',
'/usr/lib/python2.7/site-packages']
But I always get this error. How shall I solve?
Unhandled exception in thread started by Traceback (most recent call last): File
"/home/khantthulinn/webapps/mmspeaker/lib/python2.7/Django-1.8.14-py2.7.egg/django/utils/autoreload.py",
line 229, in wrapper
fn(*args, **kwargs) File "/home/khantthulinn/webapps/mmspeaker/lib/python2.7/Django-1.8.14-py2.7.egg/django/core/management/commands/runserver.py",
line 107, in inner_run
autoreload.raise_last_exception() File "/home/khantthulinn/webapps/mmspeaker/lib/python2.7/Django-1.8.14-py2.7.egg/django/utils/autoreload.py",
line 252, in raise_last_exception
six.reraise(*_exception) File "/home/khantthulinn/webapps/mmspeaker/lib/python2.7/Django-1.8.14-py2.7.egg/django/utils/autoreload.py",
line 229, in wrapper
fn(*args, **kwargs) File "/home/khantthulinn/webapps/mmspeaker/lib/python2.7/Django-1.8.14-py2.7.egg/django/init.py",
line 18, in setup
apps.populate(settings.INSTALLED_APPS) File "/home/khantthulinn/webapps/mmspeaker/lib/python2.7/Django-1.8.14-py2.7.egg/django/apps/registry.py",
line 85, in populate
app_config = AppConfig.create(entry) File "/home/khantthulinn/webapps/mmspeaker/lib/python2.7/Django-1.8.14-py2.7.egg/django/apps/config.py",
line 86, in create
module = import_module(entry) File "/usr/lib64/python2.7/importlib/init.py", line 37, in
import_module
import(name) ImportError: No module named push_notifications

my Django app has broken for some reason getting anerror message

I was cleaning out some of the unused projects on my computer and when I tried to use my latest project I get this error message
Unhandled exception in thread started by <function wrapper at 0x107b01d70>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/Library/Python/2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Library/Python/2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Library/Python/2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named crispy_forms
is this even fixable. This is a lot of work and hours for me so I hope it is
ImportError: No module named crispy_forms
pip install --upgrade django-crispy-forms
Add crispy_forms to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = (
...
'crispy_forms',
)