Monday, February 8, 2016

Re: How to show python data on html

Database models approuch only the most popular form of manipulate data, but django is MVT so you could have different representation of the "M" (eg. External API) and full use of "VT".
An example.

def myfunc(request):
     mydata = my_dict_get_by_api_call()
     return render(request, 'template.html', mydata)

Suppose that mydata has 'myobj' as a key  so in template.html you can do

{{myobj}}

Of course you could use URLs to access your view :)









El lunes, 8 de febrero de 2016, Derek <gamesbook@gmail.com> escribió:
> Depending on what your console app does or needs to do, you can also look at Flask as a way of serving up HTML pages to your browser; see http://flask.pocoo.org/docs/0.10/quickstart/  - you then do not have to use a database with models if those are not needed.  Django is great but not always appropriate.
>
> On Sunday, 7 February 2016 15:07:52 UTC+2, 123asror wrote:
>>
>> So currently i have a python console application that reads from an api and print some data i want. I followed the django course and they use models/database in it. The data that they show comes from that. So i was wondering how to add a html page to my console application or python code. Is there a tutorial i can follow for that ?
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/548519fc-c84a-4733-8b71-e371aa62dc11%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

--
"La utopía sirve para caminar" Fernando Birri



--
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAG%2B5VyM9Kw3arLADqWiCjfsq1GnB5EiXbaZd27zyx56yTf5PCg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment