| 1 | C:\tmp\djt\mysite>manage shell
|
|---|
| 2 | Could not open file <shell> for safe execution.
|
|---|
| 3 | Python 2.4 (#60, Feb 9 2005, 19:03:27) [MSC v.1310 32 bit (Intel)]
|
|---|
| 4 | Type "copyright", "credits" or "license" for more information.
|
|---|
| 5 |
|
|---|
| 6 | IPython 0.7.1.fix1 -- An enhanced Interactive Python.
|
|---|
| 7 | ? -> Introduction to IPython's features.
|
|---|
| 8 | %magic -> Information about IPython's 'magic' % functions.
|
|---|
| 9 | help -> Python's own help system.
|
|---|
| 10 | object? -> Details about 'object'. ?object also works, ?? prints more.
|
|---|
| 11 |
|
|---|
| 12 | In [1]: from mytest.models import *
|
|---|
| 13 |
|
|---|
| 14 | In [2]: m = mymodel.objects.get(id=1)
|
|---|
| 15 |
|
|---|
| 16 | In [3]: m
|
|---|
| 17 | Out[3]: <mymodel: mymodel object>
|
|---|
| 18 |
|
|---|
| 19 | In [4]: m.submodel.count()
|
|---|
| 20 | ---------------------------------------------------------------------------
|
|---|
| 21 | exceptions.TypeError Traceback (most recent ca
|
|---|
| 22 | last)
|
|---|
| 23 |
|
|---|
| 24 | C:\tmp\djt\mysite\<ipython console>
|
|---|
| 25 |
|
|---|
| 26 | C:\Python24\lib\site-packages\django\db\models\manager.py in count(self)
|
|---|
| 27 | 52
|
|---|
| 28 | 53 def count(self):
|
|---|
| 29 | ---> 54 return self.get_query_set().count()
|
|---|
| 30 | 55
|
|---|
| 31 | 56 def dates(self, *args, **kwargs):
|
|---|
| 32 |
|
|---|
| 33 | C:\Python24\lib\site-packages\django\db\models\query.py in count(self)
|
|---|
| 34 | 184 counter._limit = None
|
|---|
| 35 | 185 counter._select_related = False
|
|---|
| 36 | --> 186 select, sql, params = counter._get_sql_clause()
|
|---|
| 37 | 187 cursor = connection.cursor()
|
|---|
| 38 | 188 if self._distinct:
|
|---|
| 39 |
|
|---|
| 40 | C:\Python24\lib\site-packages\django\db\models\query.py in _get_sql_clause(sel
|
|---|
| 41 |
|
|---|
| 42 | 407
|
|---|
| 43 | 408 # Convert self._filters into SQL.
|
|---|
| 44 | --> 409 tables2, joins2, where2, params2 = self._filters.get_sql(opts)
|
|---|
| 45 | 410 tables.extend(tables2)
|
|---|
| 46 | 411 joins.update(joins2)
|
|---|
| 47 |
|
|---|
| 48 | C:\Python24\lib\site-packages\django\db\models\query.py in get_sql(self, opts)
|
|---|
| 49 | 538 tables, joins, where, params = [], SortedDict(), [], []
|
|---|
| 50 | 539 for val in self.args:
|
|---|
| 51 | --> 540 tables2, joins2, where2, params2 = val.get_sql(opts)
|
|---|
| 52 | 541 tables.extend(tables2)
|
|---|
| 53 | 542 joins.update(joins2)
|
|---|
| 54 |
|
|---|
| 55 | C:\Python24\lib\site-packages\django\db\models\query.py in get_sql(self, opts)
|
|---|
| 56 | 587
|
|---|
| 57 | 588 def get_sql(self, opts):
|
|---|
| 58 | --> 589 return parse_lookup(self.kwargs.items(), opts)
|
|---|
| 59 | 590
|
|---|
| 60 | 591 class QNot(Q):
|
|---|
| 61 |
|
|---|
| 62 | C:\Python24\lib\site-packages\django\db\models\query.py in parse_lookup(kwarg_it
|
|---|
| 63 | ems, opts)
|
|---|
| 64 | 695 raise TypeError, "Cannot parse keyword query %r" % kwarg
|
|---|
| 65 |
|
|---|
| 66 | 696
|
|---|
| 67 | --> 697 tables2, joins2, where2, params2 = lookup_inner(path, clause
|
|---|
| 68 | , value, opts, opts.db_table, None)
|
|---|
| 69 | 698 tables.extend(tables2)
|
|---|
| 70 | 699 joins.update(joins2)
|
|---|
| 71 |
|
|---|
| 72 | C:\Python24\lib\site-packages\django\db\models\query.py in lookup_inner(path, cl
|
|---|
| 73 | ause, value, opts, table, column)
|
|---|
| 74 | 798 raise
|
|---|
| 75 | 799 else: # No match found.
|
|---|
| 76 | --> 800 raise TypeError, "Cannot resolve keyword '%s' into field" % name
|
|---|
| 77 |
|
|---|
| 78 | 801
|
|---|
| 79 | 802 # Check to see if an intermediate join is required between current_t
|
|---|
| 80 | able
|
|---|
| 81 |
|
|---|
| 82 | TypeError: Cannot resolve keyword 'mymodel' into field
|
|---|
| 83 |
|
|---|