<input type="hidden" name="next" value="{{ next }}" />
at urls.py
urlpatterns += patterns('',
url(r'^login$', 'user_login'),
...
)
at method to process login (e.g. user_login())
def apu_login(request):
...
if request.method == "GET":
return render(request, "login.html", {'next': request.GET.get('next', '/default_page')})
...
return HttpResponseRedirect(request.POST.get('next', '/default_page'))
at method that require login, add decorator e.g. like below (require user to be staff)
from django.contrib.auth.decorators import user_passes_test
...
@user_passes_test(lambda u: u.is_staff)
def import_excel_view(request):
...
ไม่มีความคิดเห็น:
แสดงความคิดเห็น