Opened 3 years ago

Closed 3 years ago

#18216 closed Uncategorized (invalid)

Problem run

Reported by: Chriskras Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


I want the code below is run with python. I give the following command: python sql and then I get all errors. What is the solution?

#!/usr/bin/env python
import os
import sys
#os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")

if __name__ == "__main__":
	 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
	 from import execute_from_command_line


Traceback (most recent call last):
  File "", line 12, in <module>
  File "/home/test/django/core/management/", line 443, in execute_from_command_line
  File "/home/test/django/core/management/", line 382, in execute
  File "/home/test/django/core/management/", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/test/django/core/management/", line 69, in load_command_class
    module = import_module('' % (app_name, name))
  File "/home/test/django/utils/", line 35, in import_module
  File "/home/test/django/core/management/commands/", line 4, in <module>
    from import sql_create
  File "/home/test/django/core/management/", line 6, in <module>
    from django.db import models
  File "/home/test/django/db/", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/home/test/django/utils/", line 184, in inner
  File "/home/test/django/conf/", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/test/django/conf/", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings '{{ project_name }}.settings' (Is it on sys.path?): No module named {{ project_name }}.settings

Change History (1)

comment:1 Changed 3 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.
Back to Top