在 2019年8月1日,下午3:39,niranjan shukla <niranjan...@gmail.com> 写道:ModuleNotFoundError
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2956cea0-785d-4e09-ad11-615e48d04f1b%40googlegroups.com.
from common.decorators import ajax_requiredFile "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\common\decorators.py", line 61except Exception, ex:^SyntaxError: invalid syntax
在 2019年8月1日,下午3:49,niranjan shukla <niranjan...@gmail.com> 写道:Python
views.py
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/74db8c7d-0a62-4736-8b0a-e2b355055007%40googlegroups.com.
# -*- coding: utf-8 -*-"""Contains view's decorators which automates common tasks."""import tracebackfrom django.shortcuts import render_to_responsefrom django.template import RequestContextfrom common.http import HttpResponseJsondef render_to(template):"""Render view's output with ``template`` using ``RequestContext``.If decorated view returns dict object then wrap it in RequestContext andrender the template.If decorated view returns non dict object then just return this object.Args::template: path to templateExample::@render_to('blog/index.html')def post_list(request):posts = Post.objects.all()return {'posts': posts,}"""def decorator(func):def wrapper(request, *args, **kwargs):output = func(request, *args, **kwargs)if not isinstance(output, dict):return outputelse:ctx = RequestContext(request)return render_to_response(template, output, context_instance=ctx)return wrapperreturn decoratordef ajax(func):"""Convert views's output into JSON.Decorated view should return dict object.If ``request.method`` is not ``POST`` then deny the request.If view raises Exception then return JSON message with error description."""def wrapper(request, *args, **kwargs):if request.method == 'POST':try:response = func(request, *args, **kwargs)except Exception, ex:response = {'error': traceback.format_exc()}else:response = {'error': {'type': 403, 'message': 'Accepts only POST request'}}if isinstance(response, dict):return HttpResponseJson(response)else:return responsereturn wrapperdef ajax_get(func):"""Convert views's output into JSON.Decorated view should return dict object.If view raises Exception then return JSON message with error description."""def wrapper(request, *args, **kwargs):try:response = func(request, *args, **kwargs)except Exception, ex:response = {'error': traceback.format_exc()}if isinstance(response, dict):return HttpResponseJson(response)else:return responsereturn wrapperdef disable_cache(func):def decorated(*args, **kwargs):resp = func(*args, **kwargs)resp['Pragma'] = 'no-cache'resp['Expires'] = '0'resp['Cache-Control'] = 'no-cache, no-store, must-revalidate'return respreturn decorated
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPcVkjh222cJWGy0zHc4K%3DhXpMCq_2kCJLc3HnEcMBjAdTYiiw%40mail.gmail.com.
在 2019年8月1日,下午4:56,Lim Kai Wey <limk...@gmail.com> 写道:
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPcVkjh222cJWGy0zHc4K%3DhXpMCq_2kCJLc3HnEcMBjAdTYiiw%40mail.gmail.com.
I want to build the follow system in my website how i can do thatbeacuse i am using that ajax so that i can building follow system
在 2019年8月1日,下午5:31,Lim Kai Wey <limk...@gmail.com> 写道:他还有问要怎么弄才行。
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPcVkjgYTFrnYbjDGn0jv3%2B1hcP1dLbZF-L-%3DznyNFHzfZk53w%40mail.gmail.com.
I want to build user following system in Django for my social site