I've been stuck on this problem for what seems like forever, and none of the other threads I've found seem to help.
When I run python manage.py runserver in cmd, I get this output:
C:\Documents and Settings\ltiokhin\My Documents\DJCode\mysite>python manage.py runserver
Validating models...
0 errors found
Django version 1.4.3, using settings 'settings'
Development server is running at http:___________________________
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x010689 F0>>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 109, in inner_run
handler = self.get_handler(*args, **options)
File "C:\Python27\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 24, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line 39, in get_handler
return get_internal_wsgi_application()
File "C:\Python27\lib\site-packages\django\core\servers\basehttp.py", line 58, in get_internal_wsgi_application
"could not import module '%s': %s" % (app_path, module_name, e)) django.core.exceptions.ImproperlyConfigured: WSGI application 'mysite.wsgi.appli cation' could not be loaded; could not import module 'mysite.wsgi': No module na med mysite.wsgi
Thanks in advance for the help.
Do you use the same version as in the book?
Last time I had this kind of error it was because of that!
Or did you add wsgi to the installed_apps in settings.py?
Look for "wsgi.py" under the folder "C:\Documents and Settings\ltiokhin\My Documents\DJCode\mysite\mysite". Its possible that the standard django application file is missing or its named as something else.
Related
I am new to Django, I mostly work in rails. I just forked a friends project and am trying to get the server up and running. I have installed all requirements and am running into the following error when i try to call runserver
└─(06:50 PM Fri Apr 12)─(22 files, 128b)─> ./runserver
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of
< django.contrib.staticfiles.management.commands.runserver.Command object at
0x10c252f50>>
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/core/management/commands/runserver.py",
line 92, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.7/site-packages/django/core/management/base.py", line 280, in
validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.7/site-packages/django/core/management/validation.py", line 35,
in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 166, in
get_app_errors
self._populate()
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 72, in
_populate
self.load_app(app_name, True)
File "/Library/Python/2.7/site-packages/django/db/models/loading.py", line 96, in
load_app
models = import_module('.models', app_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in
import_module
__import__(name)
File "/Users/RobertZyskowski/Applebutter/calendezi/south/models.py", line 2, in <module>
from south.db import DEFAULT_DB_ALIAS
File "/Users/RobertZyskowski/Applebutter/calendezi/south/db/__init__.py", line 78, in
<module>
db = dbs[DEFAULT_DB_ALIAS]
KeyError: 'default'
Any help is appreciated, thanks!
In order for Django to work, you have to provide settings to it. One of the required settings for Django to function normally is DATABASES. It should be provided as a Python dictionary and within that dictionary, Django looks for the default key. More about that here.
The error you are getting means that Django does not have databases provided to it with the key default. There could be multiple reasons for that. One is that your settings file might not actually have the setting defined for various reasons (e.g. security). In that case all you have to provide that settings and the issue should be resolved. For a sample configuration of the setting, please refer to the link to the docs above. The second reason might be that you might have multiple settings files and you are not providing the correct settings file to the runserver. I noticed that you are not using the manage.py runserver command to start the server. If you will try that command, normally you can provide a --settings parameter:
manage.py runserver --settings=dot.notation.path.to.settings
Also if you are new to Django, please read the Django tutorial. It is very good and should get you started very well. The tutorial is here.
i am using aptana for creating a website using django. I have installed mysql but not able to link the database when i run this command *Python2.7 manage.py runserver* i get a message that Python2.7 not recognized and when i run this command Python manage.py runserver
i get a error message
C:\Users\George\Documents\Aptana Studio 3 Workspace\Firstwebsite>python manage.py runserver
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <dja
ngo.contrib.staticfiles.management.commands.runserver.Command object at 0x028E5C
70>>
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\django\core\management\commands\runserver.py", line
92, in inner_runself.validate(display_num_errors=True)
`File "C:\Python27\lib\site-packages\django\core\management\base.py", line 280, in
validate num_errors = get_validation_errors(s, app)`
File "C:\Python27\lib\site-packages\django\core\management\validation.py", line 28, in
get_validation_errors from django.db import models, connection
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "C:\Python27\lib\site-packages\django\db\__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python27\lib\site-packages\django\db\utils.py", line 93, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python27\lib\site-packages\django\db\utils.py", line 27, in load_backend
return import_module('.base', backend_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in
import_module__import__(name)
File "C:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 17, in
<module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" %
e)django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module
named MySQLdb
I am using Django 1.5 and python 2.7 and aptana 3
I am confused whether i am tying this commands in the correct directory.
any help !!!
Did you install MySQLdb? which is a system library. A quick search on google shows a couple sites you can download this from
One of which is (link pulled from here), another post that addresses this:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
http://sourceforge.net/projects/mysql-python/files/mysql-python/
We would need to see your settings.py file to do more in depth review.
On the surface, it seems like you have not linked it to a database in the settings file. Here is a link that will help you get it installed:
http://decoding.wordpress.com/2012/01/23/how-to-setup-django-and-mysql-python-on-mac-os-x-lion/
(At least on a MAC/Unix. Windows is a different story)
After that, I would just follow any guide on linking the two.
(Some Generic one from a blog)
http://nisthaonweb.com/blog/2012/02/setting-up-django-with-mysql-with-and-without-mamp/
I'm starting to learn Django and have been following the online tutorial on the Django website.
Everything was working fine and I have a folder called mysite and then sub folders called mysite/ and manage.py like it says in the tutorial: https://docs.djangoproject.com/en/1.5/intro/tutorial01/#creating-a-project
However when I run the command
$ python manage.py runserver
I get this:
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x10165aed0>>
Traceback (most recent call last):
File "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py", line 92, in inner_run
self.validate(display_num_errors=True)
File "/Library/Python/2.6/site-packages/django/core/management/base.py", line 280, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Python/2.6/site-packages/django/core/management/validation.py", line 35, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 166, in get_app_errors
self._populate()
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 72, in _populate
self.load_app(app_name, True)
File "/Library/Python/2.6/site-packages/django/db/models/loading.py", line 96, in load_app
models = import_module('.models', app_name)
File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Python/2.6/site-packages/django/contrib/auth/models.py", line 21, in <module>
from django.contrib.contenttypes.models import ContentType
File "/Library/Python/2.6/site-packages/django/contrib/contenttypes/models.py", line 127, in <module>
class ContentType(models.Model):
File "/Library/Python/2.6/site-packages/django/db/models/base.py", line 97, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
TypeError: Error when calling the metaclass bases
__init__() keywords must be strings
According to the tutorial it should say this:
Validating models...
0 errors found
April 14, 2013 - 15:50:53
Django version 1.5, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
I've tried to go to http://127.0.0.1:8000/ in my web browser but I just get te error cant connect.
Does anybody know where I am going wrong or what I need to do to rectify the issue?
I'm using Django 1.5 and Python 2.6.1.
According to the Django docs:
Django 1.5 works with any Python version from 2.6.5 to 2.7.
And according to this ticket, I would suggest you to upgrade your Python version. Or, if you can't upgrade it, you have another way, which is presented in the last comment of the ticket:
Use Django 1.4, which supports Python 2.5+
I'm trying to learn Python and figured I'd build an app to host on GAE because it's free.
I'm following this guide here: http://code.google.com/appengine/docs/python/gettingstartedpython27/helloworld.html
and have the exact files: helloworld.py and app.yaml inside my helloworld directory but when I launch it I get this error:
Traceback (most recent call last):
File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 187, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "C:\Program Files\Google\google_appengine\google\appengine\runtime\wsgi.py", line 225, in _LoadHandler
handler = __import__(path[0])
ImportError: No module named helloworld
INFO 2012-03-21 19:36:47,219 dev_appserver.py:2865] "GET / HTTP/1.1" 500 -
Python is still greek to me and it's no fun struggling with environment configuration when you're new to something. What did I do wrong? Does it matter than I have GAE/J installed?
I'm new to python and django but wanted to start following some tutorials. I installed python, then django, and then the pydev plugin for eclipse. I created a new django project and tried running it. In eclipse I set up a run configuration for manage.py with argument runserver and it said "Validating Models" but never said anything else.
I tried running via command line also but got some errors that I didn't see in eclipse:
C:\Users\JP\workspace\mysite\src\mysite>python manage.py runserver
Validating models...
Unhandled exception in thread started by <function inner_run at 0x02851E30>
Traceback (most recent call last):
File "c:\Python27\lib\site-packages\django\core\management\commands\runserver.
py", line 48, in inner_run
self.validate(display_num_errors=True)
File "c:\Python27\lib\site-packages\django\core\management\base.py", line 245,
in validate
num_errors = get_validation_errors(s, app)
File "c:\Python27\lib\site-packages\django\core\management\validation.py", lin
e 22, in get_validation_errors
from django.db import models, connection
File "c:\Python27\lib\site-packages\django\db\__init__.py", line 75, in <modul
e>
connection = connections[DEFAULT_DB_ALIAS]
File "c:\Python27\lib\site-packages\django\db\utils.py", line 91, in __getitem
__
backend = load_backend(db['ENGINE'])
File "c:\Python27\lib\site-packages\django\db\utils.py", line 32, in load_back
end
return import_module('.base', backend_name)
File "c:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in im
port_module
__import__(name)
File "c:\Python27\lib\site-packages\django\db\backends\mysql\base.py", line 14
, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No mo
dule named MySQLdb
I assume it has something to do with my sql setup, but I'm not sure since it's a blank project and I haven't written any code yet. I'm more concerned with why nothing showed up in eclipse.
I'm just starting myself. Apparently there's a MySQLdb plugin (sorry if that's not the right term) that you need to use in addition to a standard MySQL install. This is so Python can communicate with MySQL.
It sounds like that you need to include the module in Eclipse System PYTHONPATH.
Go to Windows -> Preference -> Pydev -> Interpreter - Python.
After Select your desired python interpreters (if you have a virtual env), include your MySQL egg and all your other dependencies in your library.
It seems you don't have mysql installed. If you're only trying out django, you could use sqlite which ships with python. You can change the db backend in your settings.py file.