I've got a logical record 0f 500 columns that is broken up into about 20
tables based on an implicit logical grouping of the data. Most of the
time this works well and the code is clean; but there are a few use
cases where I need to get all the equivalent fields for a single record
from all the tables. The "select_related()" seems to only follow to the
"parent" table, while I want to use the parent table to get all the
related "child" (or sibling to be more precise) columns. I know I could
use a for loop and a __dict__.update() to make multiple queries of the
DB and get the data, or I could write some SQL to select all; but
neither seem very Pythonic.
Is there a clean way to do this in Django?
My models.py contains this code (snipped for brevity)
class Assessment(models.Model):
facility = models.ForeignKey(Facility, default='MZ')
resid = models.CharField(max_length=7, default='MZ00001')
status = models.IntegerField(default=0)
class MDSSection(models.Model):
assessment = models.OneToOneField(Assessment, primary_key=True)
class Meta:
abstract= True
class A(MDSSection):
A0100A = models.CharField(max_length=10, help_text='''Text :
Facility National Provider Identifier (NPI)''')
A0100B = models.CharField(max_length=12, help_text='''Text :
Facility CMS Certification Number (CCN)''')
A0100C = models.CharField(max_length=15, help_text='''Text :
State provider number''')
class B(MDSSection):
B0100 = models.CharField(max_length= 1, help_text='''Code :
Comatose''')
B0200 = models.CharField(max_length= 1, help_text='''Code :
Hearing''')
B0300 = models.CharField(max_length= 1, help_text='''Code :
Hearing aid''')
...
--
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.