Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing additional arguments to a view #1

Open
vivekdurai opened this issue Feb 12, 2012 · 2 comments
Open

Passing additional arguments to a view #1

vivekdurai opened this issue Feb 12, 2012 · 2 comments

Comments

@vivekdurai
Copy link

I have a view like the following

def delete(request,slug):
    objects = Article.objects.filter(user=request.user)
    msg = ""
    for d in objects:
        if d.lookup== slug:
            d.delete()
            msg = "deleted %s" % d.name
    return HttpResponse({'msg':msg,'lookup':slug}, mimetype='application/json')

def delete_update(request,slug):
    return [{'name':'delete', 'model':Article, 'params':{'pk':request.user.id}, 'data':{'lookup':'object.lookup'}}]

client.js:

$(document).bind('serverpush_delete', function(event, data) {
    alert(data.lookup);
});

What am I doing wrong? what does the delete_object_update view pass? how do I use the slug variable?

@vivekdurai
Copy link
Author

hello? anyone there? tap tap.

@hamax
Copy link
Owner

hamax commented Mar 16, 2012

Sorry, I missed the email.
Currently there is no nice solution to handle object deletes. _update is called on object update (notification), but can't be called on delete, because when you delete an object, you don't have it anymore to make a notification on it. I hope this makes sense :)

Secondly, I think you might be misunderstanding how the whole thing works. In the current version, you have to call the ping_notifier function somewhere (check the example https://github.com/hamax/django-serverpush/blob/master/examples/counter/demoapp/views.py) for _update function to get called at all.

And lastly about the slug. Slug in your case is the object being updated (same one you called ping_notifier on). You can pass additional params to the serializer from _update, but not to the _update from normal view.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants