﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
23487	"save() returns error ""Models aren't loaded yet."""	nmarler	nobody	"https://docs.djangoproject.com/en/1.7/intro/tutorial01/

Section ""Playing with the API""

Following along with the tutorial (using default SQLite db) calling save returns the following error (but it appears that the call actually worked?)

{{{
>>> q.question_text = ""What's up?""
>>> q.save()
Traceback (most recent call last):
  File ""<input>"", line 1, in <module>
  File ""C:\Python27\lib\site-packages\django\db\models\base.py"", line 590, in save
    force_update=force_update, update_fields=update_fields)
  File ""C:\Python27\lib\site-packages\django\db\models\base.py"", line 618, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File ""C:\Python27\lib\site-packages\django\db\models\base.py"", line 680, in _save_table
    forced_update)
  File ""C:\Python27\lib\site-packages\django\db\models\base.py"", line 710, in _do_update
    filtered = base_qs.filter(pk=pk_val)
  File ""C:\Python27\lib\site-packages\django\db\models\query.py"", line 691, in filter
    return self._filter_or_exclude(False, *args, **kwargs)
  File ""C:\Python27\lib\site-packages\django\db\models\query.py"", line 709, in _filter_or_exclude
    clone.query.add_q(Q(*args, **kwargs))
  File ""C:\Python27\lib\site-packages\django\db\models\sql\query.py"", line 1287, in add_q
    clause, require_inner = self._add_q(where_part, self.used_aliases)
  File ""C:\Python27\lib\site-packages\django\db\models\sql\query.py"", line 1314, in _add_q
    current_negated=current_negated, connector=connector)
  File ""C:\Python27\lib\site-packages\django\db\models\sql\query.py"", line 1138, in build_filter
    lookups, parts, reffed_aggregate = self.solve_lookup_type(arg)
  File ""C:\Python27\lib\site-packages\django\db\models\sql\query.py"", line 1076, in solve_lookup_type
    _, field, _, lookup_parts = self.names_to_path(lookup_splitted, self.get_meta())
  File ""C:\Python27\lib\site-packages\django\db\models\sql\query.py"", line 1339, in names_to_path
    field, model, direct, m2m = opts.get_field_by_name(name)
  File ""C:\Python27\lib\site-packages\django\db\models\options.py"", line 416, in get_field_by_name
    cache = self.init_name_map()
  File ""C:\Python27\lib\site-packages\django\db\models\options.py"", line 445, in init_name_map
    for f, model in self.get_all_related_m2m_objects_with_model():
  File ""C:\Python27\lib\site-packages\django\db\models\options.py"", line 563, in get_all_related_m2m_objects_with_model
    cache = self._fill_related_many_to_many_cache()
  File ""C:\Python27\lib\site-packages\django\db\models\options.py"", line 577, in _fill_related_many_to_many_cache
    for klass in self.apps.get_models():
  File ""C:\Python27\lib\site-packages\django\utils\lru_cache.py"", line 101, in wrapper
    result = user_function(*args, **kwds)
  File ""C:\Python27\lib\site-packages\django\apps\registry.py"", line 168, in get_models
    self.check_models_ready()
  File ""C:\Python27\lib\site-packages\django\apps\registry.py"", line 131, in check_models_ready
    raise AppRegistryNotReady(""Models aren't loaded yet."")
AppRegistryNotReady: Models aren't loaded yet.
>>> q.question_text
""What's up?""
}}}"	Cleanup/optimization	closed	Documentation	1.7	Normal	worksforme			Unreviewed	0	0	0	0	0	0
