Re: Error arises again and again\

2019-08-01 Thread Lim Kai Wey
他说,他要在他社交网站弄个 用户关注

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPcVkjgO-W-SM9KXMAkUU77NLMUddn0Yh1Dr-at7aNyCQetsLg%40mail.gmail.com.


Re: Error arises again and again\

2019-08-01 Thread niranjan shukla

>
> I want to build user following system in Django for my social site
>
I want to build user following system in Django for my social site 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/06620258-fe03-40c7-8b69-fdad0ade9a4b%40googlegroups.com.


Re: Error arises again and again\

2019-08-01 Thread Lim Kai Wey
我找了一篇帖子 主要讲如何在django 中使用ajax 来实现前端和后端的通信。
可以参考一下这篇帖子
https://blog.csdn.net/IqqIqqIqqIqq/article/details/52160662
当然这篇帖子中有一部分内容是中文。但是代码逻辑是相同的。

Translate:
I found an article, that mainly teaches the backend and frontend between
Django and Ajax. Although the article is in mandarin, but the logic of the
code is there and same. You can view it as a reference.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPcVkjh2pb6dFitCOJp0zYc8SoUffsrx-_nAHc7TRj7WZ6XT8A%40mail.gmail.com.


Re: Error arises again and again\

2019-08-01 Thread 胡超
多谢了 兄弟:
我找了一篇帖子 主要讲如何在django 中使用ajax 来实现前端和后端的通信。
可以参考一下这篇帖子
https://blog.csdn.net/IqqIqqIqqIqq/article/details/52160662 

当然这篇帖子中有一部分内容是中文。但是代码逻辑是相同的。

帮我翻译。幸苦了兄弟。

> 在 2019年8月1日,下午5:31,Lim Kai Wey  写道:
> 
> 他还有问要怎么弄才行。
> 
> -- 
> 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+unsubscr...@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
>  
> .

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/030A4B2E-AC74-4E6E-BB26-12553E8F9998%40gmail.com.


Re: Error arises again and again\

2019-08-01 Thread Lim Kai Wey
他还有问要怎么弄才行。

-- 
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+unsubscr...@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.


Re: Error arises again and again\

2019-08-01 Thread Lim Kai Wey
>
> I want to build the follow system in my website how i can do that
>>
> beacuse i am using that ajax so that i can
>
building follow system
>
and i am learning from
https://learning.oreilly.com/library/view/django-2-by/9781788472487/d61f6f4a-a9f1-4f9f-b0eb-18ae1518a2dd.xhtml

翻译:
他说,他需要用那系统来设计他网站。他都是靠Ajax 设计那网站的。他都在这学的
https://learning.oreilly.com/library/view/django-2-by/9781788472487/d61f6f4a-a9f1-4f9f-b0eb-18ae1518a2dd.xhtml

Ps. I just wanna say please use propose grammar so I can translate more
accurately. Thanks

Regards,
Kai Wey

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPcVkjj_Ji07K0YznceqwiDNPDn4GD0fLh36fYdffPnNwfxPxQ%40mail.gmail.com.


Re: Error arises again and again\

2019-08-01 Thread niranjan shukla

>
> I want to build the follow system in my website how i can do that
>>
> beacuse i am using that ajax so that i can building follow system
>
and i am learning from 
https://learning.oreilly.com/library/view/django-2-by/9781788472487/d61f6f4a-a9f1-4f9f-b0eb-18ae1518a2dd.xhtml
 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b7a66516-283b-488c-8d43-84b06d5a7c9f%40googlegroups.com.


Re: Error arises again and again\

2019-08-01 Thread niranjan shukla

>
> I want to build the follow system in my website how i can do that
>
beacuse i am using that ajax so that i can building follow system

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7479947d-8f57-4f70-b1c3-979d8b22065f%40googlegroups.com.


Re: Error arises again and again\

2019-08-01 Thread Lim Kai Wey
请翻译 :
问题是由于python2.7 和python3.6 之间的版本差异导致的。
这位小兄弟在使用python3.6 的版本。加载一个python2.7 版本的包。django-common。 需要寻找这个包的python3.6
版本, 如果没有这个版本的话 就需要寻找其他的解决方案。

Translates:
The problem is due to the difference between the Python version 2.7 and
3.6. Because you’re using Python 3.6, you’ll have to have another Python
2.7’s package.  The Django-Common package will search for its package that
is in Python 3.6, if there aren’t any package in this version then you’ll
have to look for another solution.

Regards,
Kai Wey

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPcVkjjHucKbfbhSPqUz%3DEESpqpy8jVYNrkQ-2L2rYupO7_q1g%40mail.gmail.com.


Re: Error arises again and again\

2019-08-01 Thread niranjan shukla
Yes translate and share with us please and how I can talk with you if I got 
another error

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/237feac2-fafe-4c0f-a584-dcabdab4558a%40googlegroups.com.


Re: Error arises again and again\

2019-08-01 Thread Lim Kai Wey
哈哈哈 我真不介意,大家都来这学习嘛。互相帮忙是应该的。

Translation:
I really don’t mind translating, this is where we all learn. It’s a must to
help each other out.

Ps. The three letters he said translate that I’m a nice person

Regards,
Kai Wey

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPcVkjhWMXyrfoCzOC_CD%3DOFPkjUMHN%2BCe44FgbhxbHjVp63jw%40mail.gmail.com.


Re: Error arises again and again\

2019-08-01 Thread 胡超
多谢了。兄弟 ,请翻译 :
问题是由于python2.7 和python3.6 之间的版本差异导致的。
这位小兄弟在使用python3.6 的版本。加载一个python2.7 版本的包。django-common。 需要寻找这个包的python3.6 版本, 
如果没有这个版本的话 就需要寻找其他的解决方案。

> 在 2019年8月1日,下午4:56,Lim Kai Wey  写道:
> 
> 如果有需要, 我能帮忙翻译,看你俩聊好像有点痛苦。
> 
> Translation:
> I can help translate if you guys want... I don’t mind translating 
> 
> Regards,
> Kai Wey
> 
> -- 
> 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+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAPcVkjh222cJWGy0zHc4K%3DhXpMCq_2kCJLc3HnEcMBjAdTYiiw%40mail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3C4F5403-99B2-4209-9266-E3C139DA971D%40gmail.com.


Re: Error arises again and again\

2019-08-01 Thread 胡超
好人啊

> 在 2019年8月1日,下午4:56,Lim Kai Wey  写道:
> 
> 如果有需要, 我能帮忙翻译,看你俩聊好像有点痛苦。
> 
> Translation:
> I can help translate if you guys want... I don’t mind translating 
> 
> Regards,
> Kai Wey
> 
> -- 
> 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+unsubscr...@googlegroups.com 
> .
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAPcVkjh222cJWGy0zHc4K%3DhXpMCq_2kCJLc3HnEcMBjAdTYiiw%40mail.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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4DCA4C43-E075-4890-920D-BFE5F5DA9370%40gmail.com.


Re: Error arises again and again\

2019-08-01 Thread Lim Kai Wey
如果有需要, 我能帮忙翻译,看你俩聊好像有点痛苦。

Translation:
I can help translate if you guys want... I don’t mind translating

Regards,
Kai Wey

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPcVkjh222cJWGy0zHc4K%3DhXpMCq_2kCJLc3HnEcMBjAdTYiiw%40mail.gmail.com.


Re: Error arises again and again\

2019-08-01 Thread 胡超
The answer is change for  python2.7 & python3.6 .
This pack is worked  in python2.7 
Could you try fond the pack worked in python3.6

> 在 2019年8月1日,下午4:07,胡超  写道:
> 
> When you install Django-common , exam the function ajax_required  . Try to  
> fond error.
> 
> Im sorry for my bad English.
> 
>> 在 2019年8月1日,下午4:01,niranjan shukla > > 写道:
>> 
>> views.py
>> 
>> 
>> from django.http import JsonResponse
>> from django.views.decorators.http import require_POST
>> from common.decorators import ajax_required
>> from .models import Contact
>> 
>> @ajax_required
>> @require_POST
>> @login_required
>> def user_follow(request):
>> user_id = request.POST.get('id')
>> action = request.POST.get('action')
>> if user_id and action:
>> try:
>> user = User.objects.get(id=user_id)
>> if action == 'follow':
>> Contact.objects.get_or_create(
>> user_from=request.user,
>> user_to=user)
>> else:
>> Contact.objects.filter(user_from=request.user,
>>user_to=user).delete()
>> return JsonResponse({'status':'ok'})
>> except User.DoesNotExist:
>> return JsonResponse({'status':'ko'})
>> return JsonResponse({'status':'ko'})
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> when I install the common then 
>> 
>> ERROR: 
>> 
>> File "C:\Users\user\Desktop\allauth1 - Copy\users\views.py", line 133, in 
>> 
>> from common.decorators import ajax_required
>> ModuleNotFoundError: No module named 'common.decorators'
>> 
>> 
>>  
>> 
>> -- 
>> 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+unsubscr...@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
>>  
>> .
> 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1414083F-4457-48F6-B694-5816DB6F8C5A%40gmail.com.


Re: Error arises again and again\

2019-08-01 Thread niranjan shukla

>
>
> # -*- coding: utf-8 -*-
> """
> Contains view's decorators which automates common tasks.
> """
>
> import traceback
>
> from django.shortcuts import render_to_response
> from django.template import RequestContext
>
> from common.http import HttpResponseJson
>
> def render_to(template):
> """
> Render view's output with ``template`` using ``RequestContext``.
>
> If decorated view returns dict object then wrap it in RequestContext 
> and
> render the template.
>
> If decorated view returns non dict object then just return this object.
>
> Args:
> :template: path to template
> 
> Example::
>
> @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 output
> else:
> ctx = RequestContext(request)
> return render_to_response(template, output, 
> context_instance=ctx)
> return wrapper
> return decorator
>
>
> def 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 response
> return wrapper
>
>
> def 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 response
> return wrapper
>
>
> def 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 resp
> return decorated
>  
>
Error is 
line 61
except Exception, ex:
^
SyntaxError: invalid syntax 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7a6f6c81-4cc5-4528-9748-b3fe7437f29c%40googlegroups.com.


Re: Error arises again and again\

2019-08-01 Thread 胡超
When you install Django-common , exam the function ajax_required  . Try to  
fond error.

Im sorry for my bad English.

> 在 2019年8月1日,下午4:01,niranjan shukla  写道:
> 
> views.py
> 
> 
> from django.http import JsonResponse
> from django.views.decorators.http import require_POST
> from common.decorators import ajax_required
> from .models import Contact
> 
> @ajax_required
> @require_POST
> @login_required
> def user_follow(request):
> user_id = request.POST.get('id')
> action = request.POST.get('action')
> if user_id and action:
> try:
> user = User.objects.get(id=user_id)
> if action == 'follow':
> Contact.objects.get_or_create(
> user_from=request.user,
> user_to=user)
> else:
> Contact.objects.filter(user_from=request.user,
>user_to=user).delete()
> return JsonResponse({'status':'ok'})
> except User.DoesNotExist:
> return JsonResponse({'status':'ko'})
> return JsonResponse({'status':'ko'})
> 
> 
> 
> 
> 
> 
> 
> 
> 
> when I install the common then 
> 
> ERROR: 
> 
> File "C:\Users\user\Desktop\allauth1 - Copy\users\views.py", line 133, in 
> 
> from common.decorators import ajax_required
> ModuleNotFoundError: No module named 'common.decorators'
> 
> 
>  
> 
> -- 
> 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+unsubscr...@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
>  
> .

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/DEF39E6A-51CD-4134-866F-FD36C90232B2%40gmail.com.


Re: Error arises again and again\

2019-08-01 Thread niranjan shukla

>
> views.py
>


from django.http import JsonResponse
from django.views.decorators.http import require_POST
from common.decorators import ajax_required
from .models import Contact

@ajax_required
@require_POST
@login_required
def user_follow(request):
user_id = request.POST.get('id')
action = request.POST.get('action')
if user_id and action:
try:
user = User.objects.get(id=user_id)
if action == 'follow':
Contact.objects.get_or_create(
user_from=request.user,
user_to=user)
else:
Contact.objects.filter(user_from=request.user,
   user_to=user).delete()
return JsonResponse({'status':'ok'})
except User.DoesNotExist:
return JsonResponse({'status':'ko'})
return JsonResponse({'status':'ko'})









when I install the common then 

ERROR: 

File "C:\Users\user\Desktop\allauth1 - Copy\users\views.py", line 133, in 

from common.decorators import ajax_required
ModuleNotFoundError: No module named 'common.decorators'


 

-- 
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+unsubscr...@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.


Re: Error arises again and again\

2019-08-01 Thread 胡超
You can uninstall Django-common and install common. Try it.

> 在 2019年8月1日,下午3:49,niranjan shukla  写道:
> 
> Python

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1D21D081-6F8C-488E-9225-630B791F4CC8%40gmail.com.


Re: Error arises again and again\

2019-08-01 Thread niranjan shukla
AFTER INSTALLING THE DJANGO-COMMON AND I AM USING PYTHON 3.6

 

> from common.decorators import ajax_required
>   File 
> "C:\Users\user\AppData\Local\Programs\Python\Python36\lib\site-packages\common\decorators.py",
>  
> line 61
> except Exception, ex:
> ^
> SyntaxError: invalid syntax
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4931a13d-fdb0-4471-b0a5-f7dac69f9ed2%40googlegroups.com.


Re: Error arises again and again\

2019-08-01 Thread 胡超
Y

> 在 2019年8月1日,下午3:43,niranjan shukla  写道:
> 
> pip install django-common
> 
> or 
> 
> pip install common
> 
> -- 
> 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+unsubscr...@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
>  
> .

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4E0BAB39-134D-4104-8772-810A845F774A%40gmail.com.


Re: Error arises again and again\

2019-08-01 Thread niranjan shukla
pip install django-common

or 

pip install common

-- 
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+unsubscr...@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.


Re: Error arises again and again\

2019-08-01 Thread 胡超
Maybe you need pip the pack;

> 在 2019年8月1日,下午3:39,niranjan shukla  写道:
> 
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/BA9F2558-31D9-4A0F-8031-42189E88EAA1%40gmail.com.