Login

Tag "post"

Snippet List

Allow separation of GET and POST implementations

Django does not have a clean, built-in mechanism to separate GET and POST implementations. This simple decorator provides this behavior. Django does provide an alternate way using class-based views, but defining class for each of your view functions may be an overkill. You can name the get and post functions anything you wish, but you need to make sure they are returned in the same order (get first and then post). Example usage: @formview def edit(request, id): form = EditForm(id, request.POST or None) def get(): return render(request, 'edit.html', {'form' : form}) def post(): if form.is_valid(): form.save(id) return redirect('list') return get, post

  • get
  • decorator
  • post
Read More

Manual CSRF check for Django Facebook canvas applications

The way to manually control CSRF correctness for FB applications. Automatic check cannot be used because FB does POST on your canvas URL when initializing your application without CSRF token. If you still want to use Django CSRF stuff do manual checks. You only need to perform manual check when there is no correct signed_request present in your request - correct request means you really deal with FB. Use facebook_csrf_check to verify POST requests when signed_request is absent.

  • django
  • python
  • post
  • facebook
  • csrf
  • fb
Read More

Bypass CSRF check for Facebook canvas apps using POST for canvas

This assumes that you have a method called **decode_signed_request** which will validate the signed_request parameter and return None if the validation check fails. A similar method can be found here - https://github.com/iplatform/pyFaceGraph/blob/70e456c79f1ac1c7eddece03af323346a00481ef/src/facegraph/canvas.py

  • django
  • python
  • post
  • facebook
  • csrf
  • fb
Read More

prevent GET or POST requests

This will return HTTP 405 if request was not POSTed. same way you can forbide POST request, change 'POST' to 'GET' Decorators provided for your convenience.

  • view
  • request
  • post
Read More

7 snippets posted so far.