Hi all,
I have code that, greatly simplified, looks like the following:
class CheckBoxType(models.Model):
name = models.TextField()
class Course(models.Model):
name = models.TextField()
checkboxes = models.ManyToManyField(CheckBoxType)
Essentially, a Course has multiple properties (represented by a
graphical Check Box image in a view); if there's a ManyToMany link
between the two tables, that property for that class is Checked (so
it gets the checkbox image).
I'm trying to populate a matrix (== HTML <table>) of Course vs.
CheckBoxType; essentially, for a certain subset of Courses and a
certain subset of CheckBoxTypes, display all links above. I want to
do this efficiently. We had previous code that checked each cell in
this <table>, and so executed len(myCourses)*len(myCheckBoxTypes)
queries. This was really slow.
If I could query the ManyToMany table directly, I ought to be able to
do this in a single query. Is this possible in Django? What would
people recommend as a solution in this case?
Thanks,
Adam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" 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-users?hl=en
-~----------~----~----~----~------~----~------~--~---