Thanks for the replies, but I guess I didn't make myself clear
enough.  Counter was just as an example, I don't want an actual page
counter.

I guess part of my question is:  Yes, I can use AJAX-y XMLHttpRequest
to send info to the server in the background, but has someone done
this already in django somewhere and posted code that can be plugged
in?

The idea is to have a view like this:
def my_view(request,num=0):
     counter = Counter.objects.get(id=someid)
     counter.count += num
     counter.save()
     # setup view stuff

but without specifying num in the URL or having to use a <form> in my
template.

Thanks

On Apr 10, 6:34 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Taylor wrote:
> > Does something exist so that a link on a page performs an action
> > rather than just showing a view?
> > For example: I have a counter saved to the db, and every time a user
> > clicks the link, the counter increases by a certain number and saves.
>
> > without even visiting the page that the link
> > is on by visiting the URL directly.
>
> They can only visit the page if you provide an url it.  Just don't make
> any url that displays page without your counter
>
> I don't think I understand what you want, since what I think you want is
> super trivial. But...
>
> def my_view(request):
>      counter = Counter.objects.get(id=someid)
>      counter.count += 1
>      counter.save()
>      # Or seehttp://www.djangoproject.com/documentation/request_response/if 
> you want
> to use different value/counter based on what page led them to current view.
>      # referer is unreliable
>      refer = request.META.get( "HTTP_REFERER", None)
>      counter = Counter.objects.get(refer=refer)
>      counter.count += 1
>      counter.save()
>      # do whatever to show view
>
> Which is not a great way of doing it (db hit every page view, fails when
> you start caching results) but those don't matter unless your site is
> real busy.
>
> another option parsing apache/nginx/whatever logs for whenever
> particular url(s) where responded to.
>
> --
> Norman J. Harman Jr.  512 912-5939
> Technology Solutions Group, Austin American-Statesman
>
> ___________________________________________________________________________
> Get out and about this spring with the Statesman! In print and online,
> the Statesman has the area's Best Bets and recreation events.
> Pick up your copy today or go to statesman.com 24/7.
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to