Custom Template Tag

53 views
Skip to first unread message

Al Johri

unread,
Sep 1, 2016, 7:20:28 AM9/1/16
to Django users
Hi Django Users,

I want to make a custom template tag where the tag's renderer needs to make a POST request.


Is it possible to render the nodes of a template in multiple threads? I would ideally like those POST requests to happen at the same time.

Does anyone know of some similar project?

Thanks,

Al

ludovic coues

unread,
Sep 1, 2016, 8:09:29 AM9/1/16
to django...@googlegroups.com
I wouldn't do it this way.
Personally, I would make the POST request in the view function, put
the return value in the context. The template isn't a good place to
have logic. It should only take data and format them.
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/84ccc6dc-ae1d-404c-9a05-1b72fc36a778%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--

Cordialement, Coues Ludovic
+336 148 743 42

Al Johri

unread,
Sep 1, 2016, 11:02:47 PM9/1/16
to Django users
Ludovic,

I'm using the templates for a different purpose, not in a web framework or view.

Thanks,

Al

Constantine Covtushenko

unread,
Sep 2, 2016, 1:38:39 AM9/2/16
to django...@googlegroups.com

Hi All,
There is no valuable reason to do it in the template. And no matter how to ate using it, cause template should only present view model(s).

But if you tell us your intention may be we can suggest a better place for such request?

Regards,


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...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.

Al Johri

unread,
Sep 10, 2016, 1:45:28 PM9/10/16
to Django users, kosty...@gmail.com
I'm experimenting with creating templates out of subtemplates. These subtemplates can be either (a) simple text or (b) a hash representing a sentence (i.e. {subject: "Dog", verb: "eat", object: "my {{var}}", tense: "past"}). I would like to run the hashes through a realization engine which would render as "Dog ate my homework" given a context dictionary of {var: "homework"}. The realization engine is accessed via a REST API.

Does that make sense?

Abraham Varricatt

unread,
Sep 15, 2016, 5:03:31 AM9/15/16
to Django users, kosty...@gmail.com
The idea of doing a POST request during template rendering seems weird. As others have mentioned - that's not the place for it. 

But perhaps you issue could be a matter of performing your POST operation on the client side, instead of the django server? In that case, it might be worth investigating if you could code in some JS inside your template so that when the client's browser loads it, the POST operation is called and changes are made appropriately on the site. 

Yours,
Abraham V.
Reply all
Reply to author
Forward
0 new messages