I've got a use case where I need to find the fields that are different
between two querysets in the same model and then use those fields to
modify another queryset in that model.  The first two represent "masks"
of allowed fields for a specific version while the third is the actual
data.  Assessment_id's below 1000 are templates while >1000 are data.

 

Based on a date entered in one field (not shown) the version of the form
could change and thus the applicable sections could change.  This will
not happen often and therefore does not need to be efficient.    There
will be cases where the all the fields in the templates are identical,
but it may not be practical to merge those templates due to the need to
find/fix design bugs and requirements changes in template definitions.


 

The best idea I can come up with is to:

                Get a queryset for each template based on it's pk
(derived elsewhere)

                Convert the __dict__ from each queryset to a set of
(name,value) pairs.

                Find the differences between the two sets

                Convert the remaining set back to a dict() called
"changes"

                Data = get the queryset for the actual data using it's
pk

                Use Data.__dict__( changes)

                And of course save

 

Snippets of models module below:

 

class MDSSection(models.Model):

    assessment     = models.OneToOneField(Assessment, primary_key=True) 

    . . .

 

class A(MDSSections):

    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''') 

    A0200     = models.CharField(max_length= 1, default='1',
help_text='''Code      :  Type of provider''') 

    A0310A    = models.CharField(max_length= 2, help_text='''Code      :
Type of assessment: OBRA''') 

                . . .

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to