HI, I am working on a ad rotation system. currently I got 2 problems.
first problem is that I can display an ad grabphic on only the main index site the home area. However I can't see the ads when you click on navigation tabs to go to other pages on our site. The other problem is that we are passing a wrong value in a variable. I want to pass the ads url when a person clicks our ad. So what really is happening for example lets say I have a ad that is google. Well this is what happens the variable passes a value like /ad/ http://www.google.com that is the url we are using. in the html file we have a link with the image that directs to /ad/ url in the urls pattern that is the url. It then directs the request to a views.py file which grabs that url well suppsoed to and then updates it's record with a counter meaning we just add 1 to the number stored in the database then we redirect the user to that url. However since it's passing only /ad/http://www.google.com we get no matches in the database and also the user gets redirected into our website. so it looks for a url in our domain that is /ad/http:// www.google.com I tried to do a query filter. so far here is our code: key is our veriable holding the url of the ad. here is views.py method(function): def click(request, key): q = Ad.all() q.filter("key =", key) ads = q.fetch(1) if len(ads) > 0: ad = ad[0] ad.clicks += 1 ad.put() return HttpResponseRedirect(ad.url) return HttpResponseRedirect('/') here is our urls.py code: url(r'^(/?P key.*)/$', 'click', name='ad-click'), then here is the root urls.py code located in the base directory of the project folder: (r'^consultation-request/', include('contact.urls')), now if you remeber what I said about /ad/ww.google.com well for now it's /consultation-request/http://www.google.com ok, now here is the code that I use to generate the ads url and also the graphic url to our root html file for the site. def get_random_row(query, count): if count > 0: offset = random.randint(0, count-1) rows = query.fetch(1, offset) if len(rows) > 0: return rows[0] return None def ad_injector(request): query1 = Ad.all() count1 = query1.count() query2 = Adl.all() count2 = query2.count() query3 = Adr.all() count3 = query3.count() ad1 = get_random_row(query1, count1) ad2 = get_random_row(query2, count2) ad3 = get_random_row(query3, count3) return {'ad': ad1, 'adl': ad2, 'adr': ad3} now here is the html: <a href="/consultation-request/{{ adl.url }}"/><img src="{{ adl.adurl }}"/></a></div> that what I have so far. So to sum it up. The problem I face is that the ads would only show on the main website page. Which is like www.domain.com but if you go to like something like www.domain.com/services it dosen't show at all. The other problem is that the variable we are passing has a value of /consulting-request/www.domain.com so I can't redirect the person to a www.google.com because it would have the /consultation-request/ in front of it. So I need to know how I can filter the variable from not passing / consultation-request/ in front of the ads url. plus I need to find how why the ads graphic image is not being generated for the other pages inside our domain name. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---