PusherBadRequest Unknown Auth_Key

自闭症网瘾萝莉.ら 提交于 2019-12-24 07:58:02

问题


I'm building this app so that whenever I update an user in the update view, The other view with user's detail displays a change notification.

I'm getting PusherBadRequest Unknown Auth_Key, But all the configs are right as you can see in my settings.py.

Settings.py

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'users',
    'pusherable'
]

PUSHER_APP_ID = "340365"
PUSHER_KEY = "bbc35fac8ee3918e0048"
PUSHER_SECRET = "[REDACTED]"


pusher_client = pusher.Pusher(
  app_id=PUSHER_APP_ID,
  key=PUSHER_KEY,
  secret=PUSHER_SECRET,
  cluster='us2',
  ssl=True
)

Models.py

from django.db import models


    class Users(models.Model):
        GENDER_CHOICES = (
            ('M', 'Male'),
            ('F', 'Female'),
        )

        RELATIONSHIP_STATUS = (
            ('Single', 'solteiro'),
            ('Engaged', 'engaged'),
        )

        name = models.CharField(max_length=200)
        sex = models.CharField(max_length=1, choices=GENDER_CHOICES)
        Birth_Date = models.DateTimeField('Data de Nascimento')
        Relationship_Status = models.CharField(max_length=20, choices= RELATIONSHIP_STATUS)

        def __str__(self):
            return self.name

Views.py

from django.shortcuts import render
from django.urls import reverse
from django.views import generic
from.models import Users
from .forms import UpdateUser
from pusherable.mixins import PusherDetailMixin, PusherUpdateMixin


class User(PusherDetailMixin, generic.DetailView):
    model = Users
    template_name = "Users.html"


class UsersUpdate(PusherUpdateMixin, generic.UpdateView):
    model = Users
    form_class = UpdateUsers
    template_name = "UpdateUsers.html"

    def get_success_url(self):
        return reverse('users', kwargs={'pk': self.object.pk})

Templates

Users.html

{% load pusherable_tags %}
{% pusherable_script %}
{% pusherable_subscribe 'update' object %}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>

    <script>
    function pusherable_notify(event, data) {
        alert(data.user + "has begun to " + event + " " + data.model);
    }
</script>

</head>
<body>
Name: {{ object.name }} <br>
Sex: {{ object.sex }} <br>
Relationship: {{ object.Relationship_Status }}
</body>
</html>

UpdateUsers.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<form action="" method="post">{% csrf_token %}
    {{ form.as_p }}
    <input type="submit" value="Update" />
</form>

</body>
</html>

回答1:


This is because the django-pusherable library is unaware of Pusher clusters, and configures your app to use the mt1 cluster. Your app is on the us2 cluster, which does not know about your app.

This is a bug in django-pusherable, and we'll fix it promptly. I'll get back to you when we've released a fix. (I work for Pusher!)



来源:https://stackoverflow.com/questions/44052109/pusherbadrequest-unknown-auth-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!