I've got a problem I can't figure out, and from the silence in IRC I'm either doing something really stupid or it's as strange as I think it is. I'd appreciate any assistance.
For a nice highlighted version try: http://dpaste.com/11163/ """ I'm sorry this is so long. The nutshell version is that I have two models related by M2M field. I can use the shell to create one object. It all works perfectly. I exit the shell, run my code which causes a weird Type Error when trying to do model.m2mrelatedset.all() That same query worked for me in a shell. What's even more bizarre, is that if I go back to the shell I can't do it there anymore. I have to drop and let syncdb recreate the tables. I have two files of interest, manager.py, and models.py both in the same app folder """ #--- models.py --- class EventType(models.Model): name = models.CharField(maxlength=72) desc = models.CharField(maxlength=255,null=True) timeout = models.IntegerField(default=60) active = models.BooleanField(default=True) class EventClass(models.Model): types = models.ManyToManyField(EventType) name = models.CharField(maxlength=72) desc = models.CharField(maxlength=255,null=True) class EventManager(object): def meta_load(self): meta = {} klasses = EventClass.objects.all() for k in klasses: meta[k.name] = {'obj': k} for e in k.types.all(): meta[k.name][e.name] = {'obj': e} self.event_meta = meta --- snip the rest of this, because the only code that runs is meta_load() --- #--- manager.py --- import models events = models.EventManager() #events.meta_load() #this is commented so I can run syncdb in next step #Deleted all related tables, and reinitialized with syncdb In [1]: from event.models import EventClass,EventType In [2]: kls = EventClass.objects.all() In [3]: ec = EventClass(name='system',desc='Events defined in the event module') In [4]: ec.save() In [5]: ec.types.all() Out[5]: [] #Exited, and restarted shell In [1]: from event.models import EventClass,EventType In [2]: ec = EventClass.objects.get(pk=1) In [3]: ec.id Out[3]: 1 In [4]: ec.types.all() Out[4]: [] #Exited, uncommented the line in manager.py that calls meta_load() ./manage.py validate project.common: Cannot resolve keyword 'eventclass' into field -- snipped other files that import manager.py --- Now I go back to the shell: In [1]: from event.models import EventClass,EventType In [2]: ec = EventClass.objects.get(pk=1) In [3]: ec.name Out[3]: 'system' In [4]: ec.id Out[4]: 1 In [5]: ec.types.all() #--- snip most of large traceback --- /usr/lib/python2.4/site-packages/django/db/models/query.py in lookup_inner(path, lookup_type, value, opts, table, column) 936 pass 937 else: # No match found. --> 938 raise TypeError, "Cannot resolve keyword '%s' into field" % name 939 940 # Check whether an intermediate join is required between current_table TypeError: Cannot resolve keyword 'eventclass' into field --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---