You can, can't you? {{ my_dict.some_key }}.
You're using numerical keys, which might not work as well.
But you can try something like {{ my_dict.42 }}.
Reinout
--
Reinout van Rees http://reinout.vanrees.org/
rei...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Well, I don't know what's in the stored object. How are you supposed to
print it?
Something like <b>{{ my_object.name }}</b>{{ my_object.description }} or so?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
I had the same thought as Reinout did, but after your clarification I
realised you want to get something out of reslibdic by using another
variable as the key. AFAIK, there is no in-built way of doing this.
However, it is worth taking a step back and having a look at what
you're trying to do.
"I have two models (Library and Result) linked by a third linking
model (libraryresult (has id, library_id and result_id fields FKeyed
to respective tables). A many to many relationship."
By the sounds of things, you have actually defined a third model,
libraryresult, that links the Library and Result models together. That
third model is unnecessary (unless you have other attributes to store
with the link, which you don't seem to have - if you do, see
https://docs.djangoproject.com/en/1.4/topics/db/models/#intermediary-manytomany).
If you simply define a ManyToManyField on the Result model pointing to
the Library model, e.g.
class Result(models.Model):
# ...
libraries = models.ManyToManyField(Library)
... then you can get all the related libraries for a particular result
by simply doing -
r = Result.objects.get(pk=1)
print r.libraries.all()
You can do the same in the template. There is no need to build the
reslibdic object.
See https://docs.djangoproject.com/en/1.4/topics/db/models/#many-to-many-relationships
for help defining the model, and
https://docs.djangoproject.com/en/1.4/topics/db/queries/#many-to-many-relationships
for help querying the related objects.
> in template tag file:
>
> def hash2libcode(h,key):
> if key in h:
> return h[key].librarycode
> else:
> return None
>
> register.filter(hash2libcode)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.