I'm getting an error while creating Python Django Project - django

C:\Python27\Scripts>django-admin startproject python_tutorial
Traceback (most recent call last):
File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\django-admin.exe\__main__.py", line 9, in <module>
File "c:\python27\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "c:\python27\lib\site-packages\django\core\management\__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "c:\python27\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
self._setup(name)
File "c:\python27\lib\site-packages\django\conf\__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "c:\python27\lib\site-packages\django\conf\__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "c:\python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: Import by filename is not supported.
Can someone please suggest what to do?

By mistake I have set variable "DJANGO_SETTINGS_MODULE" to python path and it messed up. I have deleted this environment variable and it works.

Related

Import by fileName is not supportted

I have a django project and a dump.json file in which all the database dump is present.
I am trying to run this command to load data into my django project
django-admin loaddata dumpdata.json --settings=~/Workspace/odx-lm/lm/settings/local.py
On running the above command from the folder ~/Workspace/odx-lm/,
I am getting the following error:
Traceback (most recent call last): File
"/home/delhivery/Workspace/odx-lm/odx-lm-env/bin/django-admin.py",
line 5, in
management.execute_from_command_line() File "/home/delhivery/Workspace/odx-lm/odx-lm-env/local/lib/python2.7/site-packages/django/core/management/init.py",
line 367, in execute_from_command_line
utility.execute() File "/home/delhivery/Workspace/odx-lm/odx-lm-env/local/lib/python2.7/site-packages/django/core/management/init.py",
line 316, in execute
settings.INSTALLED_APPS File "/home/delhivery/Workspace/odx-lm/odx-lm-env/local/lib/python2.7/site-packages/django/conf/init.py",
line 53, in getattr
self._setup(name) File "/home/delhivery/Workspace/odx-lm/odx-lm-env/local/lib/python2.7/site-packages/django/conf/init.py",
line 41, in _setup
self._wrapped = Settings(settings_module) File "/home/delhivery/Workspace/odx-lm/odx-lm-env/local/lib/python2.7/site-packages/django/conf/init.py",
line 97, in init
mod = importlib.import_module(self.SETTINGS_MODULE) File "/usr/lib/python2.7/importlib/init.py", line 37, in import_module
import(name) ImportError: Import by filename is not supported.
Any help would be highly appreciated.
The value for settings must be a Python module path, not a file path.
... --settings=lm.settings.local

Running Django Project locally: cannot import settings module

I am trying to work on a friend's Django project. I've cloned his repo, and am having trouble running the project locally.
When I run
python manage.py runserver
I get
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python2.7/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named settings
I am unsure if I am running into a problem because I have conflicting versions of Python installed, but I am unsure of how to proceed. Any advice would be much appreciated.
Thanks

django unable to start runserver

unable to start C:\Python27\mysastha>python manage.py runserver
c:\python27\lib\site-packages\djangotoolbox-1.6.2-py2.7.egg\djangotoolbox\db\uti
ls.py:5: RemovedInDjango19Warning: django.utils.unittest will be removed in Djan
go 1.9.
from django.utils.unittest import skip
Traceback (most recent call last):
File "manage.py", line 17, in <module>
execute_from_command_line(sys.argv)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\core\managemen
t\__init__.py", line 330, in execute_from_command_line
utility.execute()
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\core\managemen
t\__init__.py", line 304, in execute
django.setup()
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\__init__.py",
line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\apps\registry.
py", line 108, in populate
app_config.import_models(all_models)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\apps\config.py
", line 197, 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-1.8-py2.7.egg\django\contrib\auth\m
odels.py", line 40, in <module>
class Permission(models.Model):
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\models\base
.py", line 127, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\models\base
.py", line 303, in add_to_class
value.contribute_to_class(cls, name)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\models\opti
ons.py", line 166, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length(
))
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\__init__.py
", line 36, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\utils.py",
line 238, in __getitem__
backend = load_backend(db['ENGINE'])
File "c:\python27\lib\site-packages\django-1.8-py2.7.egg\django\db\utils.py",
line 127, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'django_mongodb_engine' isn't an av
ailable database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'django_mongodb_engine', u'mysql', u'oracle', u'postgresql_psycopg2', u'sql
ite3'
Error was: cannot import name decimal_to_string
Just follow the instructions in the trace back. you need django.db.backends.django_mongodb_engine as the engine. Not just django_mongodb_engine.
If you havent already you will probably need a couple dependencies for the engine to work. im on mobile and dont know what they are called at the moment for mongodb

django-admin.py is blocked by exporting myapp.settings

I've exported some settings by mistake, like:
export DJANGO_SETTINGS_MODULE=example.settings
Now when i try to use django-admin.py it gives me error:
Traceback (most recent call last):
File "/usr/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/usr/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'example.settings.base' (Is it on sys.path? Is there an import error in the settings file?): No module named example.settings.base
I've found command called flush, but django-admin is blocked and i don't know what to do, probably i need to find sys.path file.
Thanks in advance!

django tutorial/app - error when running python manage.py sql polls

Any help would be greatly appreciated. I'm getting this error and not sure how to fix.
C:\dj_stuff\mysite> python manage.py sql polls
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 453, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 263, in fetch_command
app_name = get_commands()[subcommand]
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 109, in get_commands
apps = settings.INSTALLED_APPS
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 48, in _setup
self._wrapped = Settings(settings_module)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 132, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Python27\lib\site-packages\django\utils\importlib.py", line 35, in import_module
__import__(name)
File "C:\dj_stuff\mysite\mysite\settings.py", line 127
) 'polls',
^
SyntaxError: invalid syntax
please paste settings.py.
lines from 100 to 130
but... look at this line:
) 'pools',
you've added appname after tuple.
you should add 'pools' one line upper, before ')'