Monday, December 30, 2013

Re: New to Django; Question

There seems to be no correlation between your User model and your Data model. And also I dont see a field called patientid in any of the forms. Do you mean userid by any chance? 
So think about your schema and rebuild your models. 

The way to display data in Django is through templates. You could write a view the same way you write a query in the python shell to query data and return those values you want using the render function. The use a template to display the data. 


On Monday, December 30, 2013 11:56:48 PM UTC+5:30, Frank Jaworski wrote:
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/a52f20f6-9d94-44ce-85de-dbe6a3a17cca%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment