I am trying to use django-registration package on my project as an APP. All I did was
Downloaded the package from ""
Copied the "registration" folder under SOWL
In my project's URLs.py added
(r'^accounts/', include('registration.backends.default.urls')),
in my project's settings.py added "registration"
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'CATALOG',
'SOWLAPP',
'registration',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
)
it gives the following error -
C:\SHIYAM\Personal\SuccessOwl\SOWL0.1\SOWL>python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
443, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line
382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196,
in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 217,
in execute
translation.activate('en-us')
File "C:\Python27\lib\site-packages\django\utils\translation\__init__.py", lin
e 105, in activate
return _trans.activate(language)
File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", l
ine 194, in activate
_active.value = translation(language)
File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", l
ine 183, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", l
ine 160, in _fetch
app = import_module(appname)
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
__import__(name)
File "C:\SHIYAM\Personal\SuccessOwl\SOWL0.1\SOWL\registration\__init__.py", li
ne 3
<!DOCTYPE html>
^
SyntaxError: invalid syntax
C:\SHIYAM\Personal\SuccessOwl\SOWL0.1\SOWL>
I am looking at the urls.py, __init__.py from the registration package and they all look different from the usual urls.py, __init__.py from in the regular apps under my project. Why are they different and what should I do to make it different?
SHM
It looks like something has gone wrong when you were copying the registration app . The traceback suggests that __init__.py contains html like <!DOCTYPE html>, which it definitely shouldn't.
Related
I am using Django3.1. All was working fine. I pip installed a new app and tried to run makemigrations. It suddenly doesn't work anymore. I get error 'Apps are not loaded yet'. I thought it was the app. Uninstalled it. Didn't work. Deleted the virtualenv directory. Created new one and installed all apps again except the last one. It didn't work. I had installed another version of Postgres and hadn't restarted my computer since then. Restarted but didn't work. Tested by running another project to make sure it was not new Postgres issue. That worked as expected.
Commented out my url confs and installed apps in the settings.py. But still the same error.
Tried multiple SO suggestion related to this error but nothing works. Can anyone please help.
Error from console:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\core\management\base.py", line 368, in execute
self.check()
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\core\management\base.py", line 396, in check
databases=databases,
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\core\checks\translation.py", line 60, in check_language_settings_consistent
get_supported_language_variant(settings.LANGUAGE_CODE)
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\utils\translation\__init__.py", line 299, in get_supported_language_variant
return _trans.get_supported_language_variant(lang_code, strict)
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\utils\translation\trans_real.py", line 488, in get_supported_language_variant
if code in supported_lang_codes and check_for_language(code):
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\utils\translation\trans_real.py", line 451, in check_for_language
for path in all_locale_paths()
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\utils\translation\trans_real.py", line 428, in all_locale_paths
for app_config in apps.get_app_configs():
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\apps\registry.py", line 145, in get_app_configs
self.check_apps_ready()
File "C:\Users\myuser\Envs\myproject\lib\site-packages\django\apps\registry.py", line 136, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Thanks
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app_name', #i hope you added app_name in settings file
or
'app_name.apps.app_nameConfig' #else try this app_name is name of your app,apps is constant key word and you will get class app_nameConfig in apps.py file
]
I'm using django 1.8 and satchmo project. But after successful installation of satchmo project when I try to start the server it's showing me this error
`Traceback (most recent call last):
File "manage.py", line 25, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 308, in execute
settings.INSTALLED_APPS
File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 110, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/Cellar/python#2/2.7.16_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named skeleton.settings`
INSTALLED_APPS = (
'django.contrib.sites',
'satchmo_store.shop',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.auth',
'django.contrib.contenttypes',
#'django.contrib.comments',
'django.contrib.sessions',
'django.contrib.sitemaps',
'django.contrib.staticfiles',
'django.contrib.messages',
'django_comments',
'registration',
'sorl.thumbnail',
'keyedcache',
'livesettings',
'l10n',
'satchmo_utils.satchmo_thumbnail',
'satchmo_store.contact',
'tax',
'tax.modules.no',
'tax.modules.area',
'tax.modules.percent',
'shipping',
#'satchmo_store.contact.supplier',
#'shipping.modules.tiered',
#'satchmo_ext.newsletter',
#'satchmo_ext.recentlist',
'product',
'product.modules.configurable',
'product.modules.custom',
'product.modules.downloadable',
'product.modules.subscription',
#'satchmo_ext.product_feeds',
#'satchmo_ext.brand',
'payment',
'payment.modules.dummy',
#'payment.modules.purchaseorder',
#'payment.modules.giftcertificate',
#'satchmo_ext.wishlist',
#'satchmo_ext.upsell',
#'satchmo_ext.productratings',
'satchmo_ext.satchmo_toolbar',
'satchmo_utils',
#'shipping.modules.tieredquantity',
#'satchmo_ext.tieredpricing',
#'debug_toolbar',
'app_plugins',
'simple',
'store.localsite',
'skeleton',
)
Here I've added to installed apps. Still, it doesn't work. Can you tell me the use of the skeleton?
Also somehow skeleton doesn't compatible with django 1.8.
I want to add a new app in the https://github.com/edx/edx-platform.
I am following this https://docs.djangoproject.com/en/2.2/intro/tutorial01/ document
/edx/app/edxapp/edx-platform/myapp/url.py
from django.conf.urls import url
from . import views
urlpatterns = [
url('', views.hello, name = 'hello'),
]
/edx/app/edxapp/edx-platform/lms/envs/common.py
INSTALLED_APPS = [
# Standard ones that are always installed...
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.humanize',
'django.contrib.messages',
'django.contrib.redirects',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'djcelery',
'myapp',
.............
/edx/app/edxapp/edx-platform/lms/urls.py
urlpatterns = [
url(r'^$', branding_views.index, name='root'), # Main marketing page, or redirect to courseware
url(r'', include('student.urls')),
# TODO: Move lms specific student views out of common code
url(r'^dashboard/?$', student_views.student_dashboard, name='dashboard'),
url(r'^change_enrollment$', student_views.change_enrollment, name='change_enrollment'),
url(r'^myapp/', include('myapp.urls')),
My Error
Traceback (most recent call last):
File "manage.py", line 123, in <module>
execute_from_command_line([sys.argv[0]] + django_args)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 327, in execute
self.check()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 256, in check
for pattern in self.url_patterns:
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 407, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/edx/app/edxapp/edx-platform/lms/urls.py", line 6, in <module>
from django.conf.urls import include, url, path
ImportError: cannot import name path
Where I am going wrong. please let me know.
File "/edx/app/edxapp/edx-platform/lms/urls.py", line 6, in <module>
from django.conf.urls import include, url, path
ImportError: cannot import name path
The above error is saying that you can't import path from django.conf.urls. It seems you are using older version of django. so, try the following command to install old version.
$ pip install Django==1.11
and go to file /edx/app/edxapp/edx-platform/lms/urls.py and remove path from import. Then it looks like below.
from django.conf.urls import include, url
I am using djangae with some third party applications like all-auth, django-invitations and django rest framework. When I hit python manage.py migrate I get the following error.
AttributeError: type object 'ContentType' has no attribute 'objects'
The full trace is following
Traceback (most recent call last):
File "manage.py", line 26, in <module>
execute_from_command_line(sys.argv)
File "/home/salman/Workspace/chaipani/lib/djangae/core/management/__init__.py", line 43, in execute_from_command_line
return _execute_from_command_line(djangae_namespace.sandbox, argv, parser=djangae_parser, **overrides)
File "/home/salman/Workspace/chaipani/lib/djangae/core/management/__init__.py", line 68, in _execute_from_command_line
return django_management.execute_from_command_line(argv)
File "/home/salman/Workspace/chaipani/lib-vendor/django/core/management/__init__.py", line 363, in execute_from_command_line
utility.execute()
File "/home/salman/Workspace/chaipani/lib-vendor/django/core/management/__init__.py", line 355, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/salman/Workspace/chaipani/lib-vendor/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/salman/Workspace/chaipani/lib-vendor/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/home/salman/Workspace/chaipani/lib-vendor/django/core/management/commands/migrate.py", line 227, in handle
self.verbosity, self.interactive, connection.alias, apps=post_migrate_apps, plan=plan,
File "/home/salman/Workspace/chaipani/lib-vendor/django/core/management/sql.py", line 53, in emit_post_migrate_signal
**kwargs
File "/home/salman/Workspace/chaipani/lib-vendor/django/dispatch/dispatcher.py", line 193, in send
for receiver in self._live_receivers(sender)
File "/home/salman/Workspace/chaipani/lib-vendor/django/contrib/auth/management/__init__.py", line 63, in create_permissions
ctype = ContentType.objects.db_manager(using).get_for_model(klass)
AttributeError: type object 'ContentType' has no attribute 'objects'
My installed apps:
INSTALLED_APPS = [
'djangae',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'djangae.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'djangae.contrib.security',
'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.google',
'invitations',
]
Any help anyone?
I am trying to install django-notification app[1] and I get an error when I give manage.py syncdb.
The error states: EnvironmentError: NOTIFICATIONS was not found.
I have installed django-notification using setup tools successfully. This is my stack trace.
File "C:\Tools\Python26\lib\site-packages\django\core\management\__init__.py",
line 438, in execute_manager
utility.execute()
File "C:\Tools\Python26\lib\site-packages\django\core\management\__init__.py",
line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Tools\Python26\lib\site-packages\django\core\management\base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Tools\Python26\lib\site-packages\django\core\management\base.py", line 219, in execute
self.validate()
File "C:\Tools\Python26\lib\site-packages\django\core\management\base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "C:\Tools\Python26\lib\site-packages\django\core\management\validation.py", line 36, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "C:\Tools\Python26\lib\site-packages\django\db\models\loading.py", line 146, in get_app_errors
self._populate()
File "C:\Tools\Python26\lib\site-packages\django\db\models\loading.py", line 61, in _populate
self.load_app(app_name, True)
File "C:\Tools\Python26\lib\site-packages\django\db\models\loading.py", line 78, in load_app
models = import_module('.models', app_name)
File "C:\Tools\Python26\lib\site-packages\django\utils\importlib.py", line 35, in import_module
__import__(name)
File "build\bdist.win32\egg\django_notifications\models.py", line 20, in <module>
File "build\bdist.win32\egg\django_notifications\backends\__init__.py", line 23, in get_available_backends
File "build\bdist.win32\egg\django_notifications\backends\__init__.py", line 90, in get_class_instance_by_key
File "build\bdist.win32\egg\django_notifications\backends\xmpp.py", line 33, in __init__
File "build\bdist.win32\egg\django_notifications\backends\__init__.py", line 5
5, in get_settings
EnvironmentError: NOTIFICATIONS was not found.
Any ideas what went wrong?
*Added settings.INSTALLED_APPS part (corrected 'django-notifications' entry to 'notification' as suggested)*
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'grappelli',
'filebrowser',
'tinymce',
'south',
'avatar',
'django.contrib.admin',
'notification',
'myproject.main',
)
[1] https://github.com/jtauber/django-notification
For whatever reason, you've decided to add django_notifications to settings.INSTALLED_APPS instead of notification. Fix this.