Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/10/2014, 06:54
Avatar de kojicomics
kojicomics
 
Fecha de Ingreso: junio-2013
Mensajes: 49
Antigüedad: 11 años, 5 meses
Puntos: 1
Importar modelo en settings.py

Hola a todos

Estoy tratando de importar un modelo en el "settings.py" para guardar el valor de un queryset en una variable, pero me lanza varios errores que no consigo identificar con el import

Mi import es el siguiente:

Código Python:
Ver original
  1. from apps.languages.models import Language

Y ésta es la salida del error:

Código:
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 238, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/core/management/__init__.py", line 41, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/home/user/myapp/virtualenv/project/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/core/management/commands/runserver.py", line 14, in <module>
    from django.db.migrations.executor import MigrationExecutor
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/migrations/executor.py", line 5, in <module>
    from .loader import MigrationLoader
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/migrations/loader.py", line 8, in <module>
    from django.db.migrations.recorder import MigrationRecorder
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 9, in <module>
    class MigrationRecorder(object):
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 23, in MigrationRecorder
    class Migration(models.Model):
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/migrations/recorder.py", line 24, in Migration
    app = models.CharField(max_length=255)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 1012, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 146, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/conf/__init__.py", line 46, in __getattr__
    self._setup(name)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/conf/__init__.py", line 94, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/user/myapp/project/project/settings/local.py", line 3, in <module>
    from .base import *
  File "/home/user/myapp/project/project/settings/base.py", line 17, in <module>
    from apps.languages.models import Language
  File "/home/user/myapp/project/apps/languages/models.py", line 6, in <module>
    class Language(models.Model):
  File "/home/user/myapp/project/apps/languages/models.py", line 7, in Language
    title = models.CharField(max_length=25)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 1012, in __init__
    super(CharField, self).__init__(*args, **kwargs)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/db/models/fields/__init__.py", line 146, in __init__
    self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/conf/__init__.py", line 46, in __getattr__
    self._setup(name)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/home/user/myapp/virtualenv/project/lib/python3.4/site-packages/django/conf/__init__.py", line 115, in __init__
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.
Un saludo