On Sun, 2007-10-28 at 14:45 -0700, niklas.voss wrote:
> I have a Problem, i have one Model, which has some Data, and another
> Model, which has some Data.
> Let's call it Model1 and Model2! The Problem ist there is a Field in
> Model1 which has an ID of a Model2-Object and Model1 has a function
> that return the Model2-Object with that ID, too.
> How can i call the information of the returning object from the
> function in a template.
> 
> When I do it like this, it didnt work:
> 
> {{ model1object.givemodel2datafromid.data1 }}    # data1 is just an
> example-field

It's usually going to be easier for everybody if you explain your
problem with a concrete example, rather than trying to use generic names
for things. Otherwise mistakes will creep in and we (and you) won't be
able to tell.

Can you show us an example of what Model1 and the givemodel2datafromid()
method look like?

It sounds like you should be doing something simple like this:

        class Model1(models.Model):
           model2 = models.ForeignKey(Model2)
           ...
           def get_model2(self):
              return self.model2
        
Then, in a template, 

        {{ model1object.get_model2 }}
        
will be a Model2 object and you can use this further, such as

        {{ model1object.get_model2.data1 }}
        
if "data1" is a field on Model2.

Does that look anything like the situation you are describing. If not,
what's a short example illustrating your problem?

Regards,
Malcolm

-- 
Despite the cost of living, have you noticed how popular it remains? 
http://www.pointy-stick.com/blog/


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to