Monday, December 30, 2013

New to Django; Question

I am new to Django; I have a legacy database I do not control with some information regarding a user and a database on my server with data pertaining to something that user is doing.  I want to take some information from each database via the ORM methodology Django employs and display it on a webform, but I am struggling.  I search on the patient id and can find what codes they have associated with them, but when it comes to displaying the cost for each code with the associated data, I do not know the best way to do so.  Thanks.

(my database)

class Data(models.Model):
    code = models.CharField(max_length=12)
    cost = models.FloatField()
    unit = models.CharField(max_length=2)

(legacy)

class UserHistory(models.Model)
   userid= models.IntegerField(db_column='userid', blank=True, null=True) 
   code = models.CharField(db_column='code', max_length=11, blank=True)
   firstname = models.CharField(db_column='FirstName', max_length=35, blank=True) 
   middlename = models.CharField(db_column='MiddleName', max_length=35, blank=True) 
   lastname = models.CharField(db_column='LastName', max_length=35, blank=True) 

   

Desired Output:

Here is the cost for user First Name Last Name

Last Name  First Name Code Cost

xxx            zzzzz          2      10.00
xxx            zzzzz          6      10.00
xxx            zzzzz          7      10.00
xxx            zzzzz          11    10.00

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/d9c1494a-1610-43fb-b74e-b500a55cf5bb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment