I have a (old) Model like this:
------------------------------------------------
class SessionData(models.Model):
     session_id = models.CharField(maxlength=96)
     expiry_time = models.DateTimeField()
     ip = models.CharField(maxlength=45)
     domain_name = models.CharField(maxlength=150)
     session_data = models.TextField()

     class Admin:
         pass

     class Meta:
         db_table = '%ssession_data' % TABLE_PREFIX
         verbose_name_plural = 'Session Data'
------------------------------------------------



the i make this:
------------------------------------------------
from django.core.management import dump_data
print dump_data(app_labels=[])
------------------------------------------------



and i get this traceback:
------------------------------------------------
Traceback (most recent call last):
   File "<stdin>", line 2, in ?
   File "/home/jens/servershare/SVN/SVN 
PyLucid/branches/0.8(django)/django/core/management.py", line 1438, in 
dump_data
     objects.extend(model.objects.all())
   File "/home/jens/servershare/SVN/SVN 
PyLucid/branches/0.8(django)/django/db/models/query.py", line 108, in 
__iter__
     return iter(self._get_data())
   File "/home/jens/servershare/SVN/SVN 
PyLucid/branches/0.8(django)/django/db/models/query.py", line 468, in 
_get_data
     self._result_cache = list(self.iterator())
   File "/home/jens/servershare/SVN/SVN 
PyLucid/branches/0.8(django)/django/db/models/query.py", line 181, in 
iterator
     cursor.execute("SELECT " + (self._distinct and "DISTINCT " or "") + 
",".join(select) + sql, params)
   File "/home/jens/servershare/SVN/SVN 
PyLucid/branches/0.8(django)/django/db/backends/util.py", line 12, in 
execute
     return self.cursor.execute(sql, params)
   File "/home/jens/servershare/SVN/SVN 
PyLucid/branches/0.8(django)/django/db/backends/mysql/base.py", line 42, 
in execute
     return self.cursor.execute(sql, params)
   File "/usr/lib/python2.4/site-packages/MySQLdb/cursors.py", line 163, 
in execute
     self.errorhandler(self, exc, value)
   File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 
35, in defaulterrorhandler
     raise errorclass, errorvalue
OperationalError: (1054, "Unknown column 'pylucid_session_data.id' in 
'field list'")
------------------------------------------------



Yes, there is no column "id" for the table "pylucid_session_data".
Is that an error? Or must all tables have an ID? (or primary key?)




I have made a small patch, so the table skipped:

Index: ./django/core/management.py
===================================================================
--- ./django/core/management.py (revision 4692)
+++ ./django/core/management.py (working copy)
@@ -1434,7 +1434,10 @@
      objects = []
      for app in app_list:
          for model in get_models(app):
-            objects.extend(model.objects.all())
+            try:
+                objects.extend(model.objects.all())
+            except Exception, e:
+                sys.stderr.write(style.ERROR("unable to get data: %s\n" 
% e))
      try:
          print serializers.serialize(format, objects, indent=indent)
      except Exception, e:



-- 
Mfg.

Jens Diemer


----
CMS in pure Python CGI: http://www.pylucid.org


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to