小编Jam*_* L.的帖子

重定向到最后一页不在python social auth上工作

我正在使用python social auth来使用社交登录,但在成功登录后我无法重定向到最后一页.

例如,如果我在下一页http://localhost:8000/docprofile/14/并单击登录按钮,而不是将我重定向到最后一页,http://localhost:8000/docprofile/14/它会将我重定向到登录页面.

如果我这样说:

<a href="{% url 'social:begin' 'facebook' %}?next={{ request.path }}"> | Login with Facebook</a>
Run Code Online (Sandbox Code Playgroud)

它重定向到登录页面,网址以奇怪的字符结尾:

http://localhost:8000/login/#_=_
Run Code Online (Sandbox Code Playgroud)

我也试过这个:

<a href="{% url 'social:begin' 'facebook' %}?next={{ request.get_full_path }}"> | Login with Facebook</a>
Run Code Online (Sandbox Code Playgroud)

这次它确实采取了路径,/docprofile/14但仍然没有重定向我,并带我到URL的登录页面http://localhost:8000/login/?next=/docprofile/14/#_=_

python django redirect python-social-auth

6
推荐指数
1
解决办法
799
查看次数

python social auth:谷歌登录错误:invalid_client

我正在使用python social auth在我的应用上实现谷歌登录.但是我收到以下错误

Error: invalid_client
The OAuth client was not found.
Run Code Online (Sandbox Code Playgroud)

我尝试添加与项目名称和电子邮件地址相同的产品名称.但我仍然得到这个错误

我在谷歌开发者控制台中重定向uri:

 http://localhost:8000/complete/google-oauth2/ 
Run Code Online (Sandbox Code Playgroud)

的login.html

a href="{% url 'social:begin' 'google-oauth2' %}?next={{ index }}"> | Login with Google</a>
Run Code Online (Sandbox Code Playgroud)

settings.py

AUTHENTICATION_BACKENDS = (
    'social.backends.facebook.FacebookOAuth2',
    'social.backends.twitter.TwitterOAuth',
    'social.backends.google.GoogleOAuth2',
    'django.contrib.auth.backends.ModelBackend',
)

SOCIAL_AUTH_GOOGLE_OAUTH_KEY = ''

SOCIAL_AUTH_GOOGLE_OAUTH_SECRET = ''
Run Code Online (Sandbox Code Playgroud)

python django google-oauth python-social-auth

4
推荐指数
1
解决办法
1813
查看次数

twitter登录:401客户端错误:需要授权

我正在使用python-social-auth在本地实现twitter登录,但我得到401客户端错误.我的django版本是1.6.

Traceback:
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py" in get_response
  112.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/social/apps/django_app/utils.py" in wrapper
  45.             return func(request, backend, *args, **kwargs)
File "/Library/Python/2.7/site-packages/social/apps/django_app/views.py" in auth
  12.     return do_auth(request.social_strategy, redirect_name=REDIRECT_FIELD_NAME)
File "/Library/Python/2.7/site-packages/social/actions.py" in do_auth
  25.     return strategy.start()
File "/Library/Python/2.7/site-packages/social/strategies/base.py" in start
  66.             return self.redirect(self.backend.auth_url())
File "/Library/Python/2.7/site-packages/social/backends/oauth.py" in auth_url
  99.         token = self.set_unauthorized_token()
File "/Library/Python/2.7/site-packages/social/backends/oauth.py" in set_unauthorized_token
  158.         token = self.unauthorized_token()
File "/Library/Python/2.7/site-packages/social/backends/oauth.py" in unauthorized_token
  177.                                 method=self.REQUEST_TOKEN_METHOD)
File "/Library/Python/2.7/site-packages/social/backends/base.py" in request
  205.         response.raise_for_status()
File "/Library/Python/2.7/site-packages/requests/models.py" in raise_for_status
  808.             raise HTTPError(http_error_msg, response=self) …
Run Code Online (Sandbox Code Playgroud)

python django twitter-oauth python-social-auth

4
推荐指数
1
解决办法
3851
查看次数

Django 1.6:清除一个表中的数据

我有一个表名UGC,并希望清除该表中的所有数据.我不想重置整个应用程序,这将删除所有其他模型中的所有数据.是否有可能只清除一个模型?如果有帮助的话,我也可以使用我的应用配置南方.

python database django models

3
推荐指数
1
解决办法
2608
查看次数

Django的营业时间

我想为诊所添加营业时间,并且我已经研究了在Django中实现“开放时间”的任何现有解决方案,但这对我来说不合适。因为这假设您在所有工作日都拥有相同的时间,在特殊的日子拥有相同的时间。鉴于我希望各天有不同的开放时间。此外,我希望一天有不止1个条目。例如,周日的诊所从上午8:30-下午12:00运行,并从下午4:30-晚上10点再次开放。

我希望能够从管理面板添加此内容,类似于Yelp

在此处输入图片说明

python django

3
推荐指数
1
解决办法
1702
查看次数

Django 1.6:sitemap.py文件的位置应该是什么?

我想实现django站点地图,但我对于将sitemaps.py文件放在哪里以及应该修改哪个urls.py文件以包括:

url(r'^sitemap.xml$', 'django.contrib.sitemaps.views.index', {'sitemaps': sitemaps}),
Run Code Online (Sandbox Code Playgroud)

我应该将上面的行放在project(mysite)urls.py文件或app(sampleapp1)urls.py文件中吗?

python django django-sites django-sitemaps

2
推荐指数
1
解决办法
606
查看次数

Django无效的块标记预期为'空'或'结束'

我正在尝试显示诊所列表,但我一直收到以下错误:

Exception Type: TemplateSyntaxError at /clinics/
Exception Value: Invalid block tag: 'c.name', expected 'empty' or 'endfor'
Run Code Online (Sandbox Code Playgroud)

这是clinicList.html

{% for c in clinics %}
    {% c.name %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

这是意见

def clinicList(request):
    d = getVariables(request,dictionary={'page_name':""})
    d.update({'clinics': Clinic.objects.all()})

    return render(request, 'm1/clinicList.html', d)
Run Code Online (Sandbox Code Playgroud)

这是url.py

url(r'^clinics/$', views.clinicList, name='clinicList'),
Run Code Online (Sandbox Code Playgroud)

python django

2
推荐指数
1
解决办法
4623
查看次数

在一行django模板中打印循环输出

我有这段代码:

{% for a in doctor.treatment.all %}
  <p>  {{a}}  </p>
{% endfor %}
Run Code Online (Sandbox Code Playgroud)

它给了我这样的输出:

Teeth Whitening
Braces
Veneers
Run Code Online (Sandbox Code Playgroud)

无论如何,我可以在逗号一行的模板中得到它吗?

Teeth Whitening, Braces, Veneers.
Run Code Online (Sandbox Code Playgroud)

html python django

1
推荐指数
1
解决办法
949
查看次数

Django 1.6:按布尔和喜欢对对象进行排序

我有一个医生模型,我正在显示基于最喜欢的医生对象.如果医生是否获得赞助,我会为每位医生提供一个布尔字段.我想首先向赞助医生展示,然后根据最喜欢的人对其余的医生进行分类.

这是我要按netlikes排序的,它正在工作

doctors = Doctor.objects.all().order_by('-netlikes')
Run Code Online (Sandbox Code Playgroud)

我试过这个,但没有任何区别

doctors = Doctor.objects.all().order_by('sponsored').order_by('-netlikes')
Run Code Online (Sandbox Code Playgroud)

医生model.py

class Doctor(models.Model):
    name = models.CharField(max_length=1300)
    title = models.CharField(max_length=1300, null = True, blank = True)
    specialization = models.ForeignKey(Specialization)
    clinic = models.ForeignKey(Clinic)
    education1 = models.CharField(max_length=1300)
    gender_choices = ( ('Male', 'Male'), ('Female','Female'),)
    gender = models.CharField(max_length=15, choices = gender_choices, null=True, blank = True)
    image = models.ImageField(upload_to='uploads/', null=True, blank = True)
    likes = models.IntegerField(default=0)
    dislikes = models.IntegerField(default=0)
    netlikes = models.IntegerField(default=0)
    submitted_on = models.DateTimeField(auto_now_add=True, null = True, blank = True)
    sponsored = models.BooleanField(default = False)
Run Code Online (Sandbox Code Playgroud)

关于我如何首先展示赞助医生然后最高的喜欢?

python sorting django

0
推荐指数
1
解决办法
4341
查看次数