Guest User

Untitled

a guest
Jun 23rd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. # views.py
  2. from django.http import HttpResponse
  3. from django.shortcuts import render_to_response
  4. from models import Ad
  5. import random
  6.  
  7. def index(request):
  8. total_entries = Ad.all().count()
  9. ad_all = Ad.all()[:total_entries]
  10. ad = random.choice(ad_all)
  11. return HttpResponse(ad.url)
  12.  
  13.  
  14. # models.py
  15. from google.appengine.ext import db
  16.  
  17. class Ad(db.Model):
  18. url = db.StringProperty()
Add Comment
Please, Sign In to add comment