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