Django: Importing python modules into static webpage

12 views
Skip to first unread message

ABHIJIT ROY

unread,
Jun 6, 2017, 5:23:33 PM6/6/17
to Django users

I am very new to Django. Recently I was developing a site just for getting aquainted with the framework and I came to a point where I needed to import a python module such as request,pytube etc into a static webpage so that i can use their functions . So two questions arose -

1. Is it possible to have python code embedded in static content.

2. How can I import a python module into a static webpage.


yingi keme

unread,
Jun 6, 2017, 6:47:51 PM6/6/17
to django...@googlegroups.com
By static files, i believe you are talking about webpage files. First of all, you cant import a module to a static  files. 
What you can do is to use the jinja logic in your webpage files. But then you have to create a context that will enable you render python objects to your webpages.

I deeply suggest you learn jinja logic. It is typically how you code your html files in a logical way. It takes the objects supplied to your context function and then perform the operations you want in your webpage. Although it is quite limited what u can do with jinja logic.

Jinja logic and rendering your context definitely answers your question.

Yingi Kem
--
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/4df7680f-b916-410d-b865-ca744e555734%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages