How can get images from wikipedia api? - django

i have the product keyword, i need images from wikipedia for that search keyword to display in my web application. is it possible? i'm doing this application in python/django framework.

Some simple searching has this example in the tutorial, for fetching search result images:
?action=query&titles=San_Francisco&prop=images&imlimit=20&format=jsonfm.
You can use urllib2 to fetch the results, etc.

Related

displaying restaurants nearby a user location within 5 kilometers in Django

Good morning Everyone,
I would like to display restaurants within 5 kilometers in using google maps api , How could I do it?
I have done the latitudes and longitudes calculs with haversine. But i don't know how rendering the result in django.
Thanks
You don't really need django here, what you're looking for can be done using Google maps API and a map provider (Like Google maps) or Openstreetmap through Leaflet JS.
This is all mostly done with Javascript in a template.
There is a Python version of Leaflet, named folium, if you really want to stick with Python. Not sure you can do everything, as I'm not that familiar with it.

I am new to Django can anyone help me with the below task....?

Go through the sample JSON file given here -
https://drive.google.com/open?id=1xZa3UoXZ3uj2j0Q7653iBp1NrT0gKj0Y
This JSON file describes a list of users & their corresponding periods of activity across
multiple months.
Now, design and implement a Django application with User and ActivityPeriod models, write
a custom management command to populate the database with some dummy data and design
an API to serve that data in the JSON format given above.
To build the application with the mentioned requirements you need to have at least a basic understanding of the Django and Django rest framework. There are plenty of learning materials on the web to get started. Mozilla has a very good tutorial to get begin with. Link: https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django
Similarly, For the REST API, there are free videos on YouTube offered by channels such as Dennis Ivy's, CodingEntrepreneurs which are good to get started with. I would recommend you to check those videos!
All the best!
Happy Coding

How to render a pdf file as pdf in browser using django

I am using Django web frame work. I am taking pdf files from users (notes/book/etc). Then I want to display those pdf in website, but I could not find a way. Methods that failed 1)iframe 2)simple rendering using django 3)pdf.js library. Also browser blocks rendering initially. Care to suggest a method and steps to implement it.
I the answer to your problem is here :
https://docs.djangoproject.com/en/3.0/howto/outputting-pdf/
Well the answer has to be very very clear here. You can not display pdf using. There is no such library for that. Like pdf.js for javascript based frameworks. I have done the research. So if you want a really good pdf viewer for your django powered website you have to use pdf.js for sure. I have asked people working with django professionally.
output in firefox
ouput in chromium browser
Now 2nd output is what we want
here is the code

Django - Flickr feed without sync

I want to show the latest 8 images from a Flickr photostream using Django. I've had a good google and the only articles I can find focus on syncing the results with a database. I'd rather not do this if possible, I just want to show the images and nothing else.
http://code.djangoproject.com/wiki/FlickrIntegration This page has some adaptable code, but the library he uses seems to be offline now.
Does anyone have any examples of how I might integrate with a flickr stream without syncing the results?
Why can't you just use the flickr API from Python? There's probably python packages to do it. All you do is get the user's photostream info, map the photos to URLS:
http://www.flickr.com/services/api/flickr.people.getPhotos.html
Then your Django template just has an <img> tag with the right URL.
Edit: python packages listed on the flickr API page:
http://stuvel.eu/flickrapi
http://code.google.com/p/flickrpy/
I made Flickr Pony for use Flickr with Django Storage API and more.
You'll only need an API KEY and launch this:
>>> from flickr_pony.storage import FlickrStorage
>>> storage = FlickrStorage(api_key="myApiKey")
>>> storage.listdir('140893176#N07')
([], ['https://farm2.staticflickr.com/1586/25309081103_518e989396_o.jpg',
'https://farm2.staticflickr.com/1623/25911906696_84c8cf31ae_o.jpg',
'https://farm2.staticflickr.com/1617/25637193860_98a08d224f_o.jpg',
...
'https://farm2.staticflickr.com/1671/25794942526_5b54c8a908_o.jpg',
'https://farm2.staticflickr.com/1653/25820730145_4040532d03_o.jpg'])

Aggregate feeds and grab image using Django

Im currently have some website running Drupal, using Feeds Image Grabber module (http://drupal.org/project/feeds_imagegrabber)
Because I has started learning Django, I'm trying to look what tools available in Django which can give same functionality as my Drupal site:
-Feed aggregator
-Grab one image (largest image) from the source URL
These links only address the first part of your question, not so much the image grabbing part:
https://github.com/miracle2k/feedplatform implements the core functionality of a feed aggregator
http://birdhouse.org/blog/2009/10/20/generating-rss-mashups-from-django/ looks like a less general approach, re-using an application that powers the Django project website