#13155: Iteration of a Many To Many Relationship raises Field Error
---------------------------------------------------+------------------------
Reporter: callen | Owner: nobody
Status: reopened | Milestone:
Component: Database layer (models, ORM) | Version: 1.1
Resolution: | Keywords: m2m, orm,
field error
Stage: Unreviewed | Has_patch: 0
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
---------------------------------------------------+------------------------
Comment (by callen):
Replying to [ticket:13155 callen]:
> As seen here: http://gist.github.com/337546
>
> Cannot resolve keyword 'bimport' into field. Choices are:
archive_column, archive_order, article, construct, day, edition,
frequency, frequency_text, from_email, html_template, id, is_public,
list_name, name, newsletterarticle, newsletterarticles, slug, subject,
subject_type, subscription, text_template, time
>
> # Caused by
>
> # this is a many-to-many relationship
> for nl in bimport.newsletters.all():
>
Relevant models here:
{{{
class Bimport(models.Model):
content_type = models.ForeignKey(ContentType)
source = models.ForeignKey(Source)
import_date = models.DateField(auto_now_add = True)
datafile = models.FileField(upload_to='bimport/uploads')
newsletters = models.ManyToManyField(Newsletter, help_text=None,
null=True)
error = models.CharField(max_length=200)
status = models.CharField(choices=STATUS_CHOICES, default='N',
max_length=100)
class Newsletter(models.Model):
name = models.CharField(max_length=50)
html_template = models.CharField(max_length=300,
default="merx/newsletters/default.html",verbose_name='HTML Template')
text_template = models.CharField(max_length=300,
default="merx/newsletters/default.txt",verbose_name='Text Template')
day = models.IntegerField(null=True, blank=True, choices=DAYS)
time = models.TimeField(null=True, blank=True)
frequency =
models.IntegerField(blank=True,null=True,choices=FREQUENCY)
frequency_text =
models.CharField(max_length=200,blank=True,null=True,verbose_name='Frequency
Display Text')
slug = models.SlugField()
construct = models.ForeignKey(Construct,blank=True,null=True)
is_public =
models.BooleanField(blank=False,null=False,default=False,verbose_name='Public')
list_name = models.CharField(max_length=30, blank=True, null=True)
archive_column = models.IntegerField(blank=False,null=False,default=0)
archive_order = models.IntegerField(blank=False,null=False,default=0)
from_email = models.CharField(
max_length=300,
null=True,
blank=True,
help_text="Please use the following format: [Newsletter Name]
<[[email protected]>"
)
subject =
models.CharField(max_length=300,blank=True,null=True,help_text='Can
contain one string substitute as defined by subject type.')
subject_type =
models.IntegerField(blank=True,null=True,choices=SUBJECT_TYPE,help_text="Object
used as string substitute for subject.")
}}}
Here's the trace:
{{{
for nl in bimport.newsletters.all():
File "/Library/Python/2.5/site-packages/django/db/models/manager.py",
line 105, in all
return self.get_query_set()
File "/Library/Python/2.5/site-
packages/django/db/models/fields/related.py", line 424, in get_query_set
return
superclass.get_query_set(self)._next_is_sticky().filter(**(self.core_filters))
File "/Library/Python/2.5/site-packages/django/db/models/query.py", line
498, in filter
return self._filter_or_exclude(False, *args, **kwargs)
File "/Library/Python/2.5/site-packages/django/db/models/query.py", line
516, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
File "/Library/Python/2.5/site-packages/django/db/models/sql/query.py",
line 1675, in add_q
can_reuse=used_aliases)
File "/Library/Python/2.5/site-packages/django/db/models/sql/query.py",
line 1569, in add_filter
negate=negate, process_extras=process_extras)
File "/Library/Python/2.5/site-packages/django/db/models/sql/query.py",
line 1737, in setup_joins
"Choices are: %s" % (name, ", ".join(names)))
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/13155#comment:4>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.