i am trying to query base on the id of the table and i get a big error, when i do it using .all() i can get the objects
>>> Restaurant.objects.all()
[<Restaurant: angry dog>, <Restaurant: cafe brazil>, <Restaurant: papa johns>, <Restaurant: lolos>]
this works for looping and getting the information such
for i in Restaurant.objects.all():
1
angry dog
2
cafe brazil
3
papa johns
4
lolos
and here when i want to get by the id (or doing name="lolos")
>>> Restaurant.objects.get(id=3)
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Python27\lib\site-packages\django\db\models\manager.py", line 92, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py", line 345, in get
clone = self.filter(*args, **kwargs)
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.
reading the tutorials and my book thats it, not sure if i have to activate something somewhere else? or linke bewteen all the files some code?
thanks guys.