小编Lit*_*ain的帖子

将 GA4 链接到 BigQuery 24 小时后不起作用

我正在尝试将最近创建的 Google Analytics GA4 数据流链接到 BigQuery 帐户。我已经检查了我能找到的所有教程,并且据我所知,我已经正确设置了所有内容。然而24小时过去了,却没有任何数据连接。我找不到任何有关如何调试此问题的信息 - 有人有任何想法吗?

下面的图片显示了我所设置的内容。BigQuery 帐户是付费帐户,而不是沙盒帐户。

GA4 报告显示 Google Analytics 中有一些数据:

在此输入图像描述

GA4 到 BigQuery 的链接:

在此输入图像描述

BigQuery 服务帐户:

在此输入图像描述

无数据流动的 BigQuery 项目:

在此输入图像描述

我已经删除了名称,但我只有一个 BigQuery 项目,因此我肯定已将 GA4 链接到正确的项目。

数据流只有一个,web,在链接中选择。

有人能想到我可能需要的任何其他配置或设置吗?

google-bigquery google-analytics-4

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

如何使用 allauth 和 rest-auth 从 React 前端在 Django 中重新发送确认电子邮件

我将 Django 2.0.10 与 rest 框架、rest-auth 和 allauth 一起使用,并带有 React 前端。Rest-auth 使用 JWT 令牌身份验证提供登录和注销功能,但我无法弄清楚如何允许用户请求重新发送验证电子邮件。

我希望用户能够登录并按下“重新发送确认电子邮件”按钮。例如,如果他们不小心删除了电子邮件,他们需要能够请求另一个。

我已经看到帖子建议您可以使用 allauth 的 send_email_confirmation,但这需要一个由模板生成的 CSRF 令牌。我尝试按照文档从 csrf 中排除,但它没有任何不同。我还尝试按照此处的建议设置 authentication_classes = () 。这是我的代码:

设置:

REST_FRAMEWORK = {
    'DEFAULT_AUTHENTICATION_CLASSES': [
        'rest_framework.authentication.TokenAuthentication',
    ],
}
Run Code Online (Sandbox Code Playgroud)

网址.py

from users.views import EmailConfirmation

urlpatterns = [
...
url(r'^/sendconfirmationemail/', EmailConfirmation.as_view(), name='send-email-confirmation')
]
Run Code Online (Sandbox Code Playgroud)

视图.py

from rest_framework.views import APIView
from django.views.decorators.csrf import csrf_exempt
from django.utils.decorators import method_decorator

class EmailConfirmation(APIView):
    @method_decorator(csrf_exempt)
    authentication_classes = ()

    def post(self):
        send_email_confirmation(user=self.request.user)
Run Code Online (Sandbox Code Playgroud)

当我发布到端点“/api/v1/rest-auth/sendconfirmationemail/”时,我收到错误禁止:

<p>You are seeing this …
Run Code Online (Sandbox Code Playgroud)

django email-validation django-allauth

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

如何判断用户的电子邮件地址是否已使用 Django、allauth、rest-auth 和自定义用户进行验证

我将 Django 2.0.10 与 rest-framework、rest-auth 和 allauth 一起使用。我有一个自定义用户模型。

我使用 allauth 视图进行了电子邮件验证。当用户注册时发送验证电子邮件。如果我单击电子邮件中的链接,我将被带到一个页面,其中有一个按钮可以单击以验证电子邮件。这一切都没有错误。但是我无法找出是什么这实际上。用户数据中的字段似乎没有改变。

我想要的行为是让用户能够注册和登录,但只能在他们验证电子邮件后才能向网站添加内容。

编辑:这篇文章给出了部分答案,但没有说明如何将验证状态保存为用户的属性,以便您在加载用户数据时可以在前端进行检查。

设置.py

# django rest auth
ACCOUNT_AUTHENTICATION_METHOD = 'email'
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_USERNAME_REQUIRED = False
OLD_PASSWORD_FIELD_ENABLED = True
LOGOUT_ON_PASSWORD_CHANGE = False
ACCOUNT_EMAIL_VERIFICATION = 'optional'
Run Code Online (Sandbox Code Playgroud)

api/urls.py

from allauth.account.views import confirm_email

urlpatterns = [
    re_path(r'^rest-auth/registration/account-confirm-email/(?P<key>[-:\w]+)/$', confirm_email,
     name='account_confirm_email'),
...
]
Run Code Online (Sandbox Code Playgroud)

用户/模型.py

import uuid 

from django.contrib.auth.models import AbstractUser, UserManager
from django.db import models
from django.utils.http import int_to_base36

class CustomUserManager(UserManager):
    def get_by_natural_key(self, username):
        case_insensitive_username_field = '{}__iexact'.format(self.model.USERNAME_FIELD)
        return self.get(**{case_insensitive_username_field: username}) …
Run Code Online (Sandbox Code Playgroud)

django email-confirmation django-allauth

6
推荐指数
2
解决办法
4375
查看次数

Proxyquire 显示错误“找不到模块”

我正在尝试使用proxyquire替换私有函数,以便在我的 Meteor 应用程序中进行测试。

流星1.6.1

流星测试:mocha@1.1.2

在我的parentFunction.js中:

import { some function } from 'anotherFile';

function childFunction() {
  ...
  return someValue;
}

export default function parentFunction() {
  return childFunction()
}
Run Code Online (Sandbox Code Playgroud)

在我的测试文件中:

const proxyquire = require('proxyquire');

if (Meteor.isServer) {
  ...

  describe('parentFunction', () => {
    it('uses the mocked child function', () => {
      const testThing = proxyquire('./parentFunction', {
        'childFunction': () => ({ 'name': 'bob' }),
      });
  });
}
Run Code Online (Sandbox Code Playgroud)

ParentFunction.js 与我的测试文件位于同一文件夹中,为了仔细检查路径,我确保它有效:

import parentFunction from './parentFunction';
Run Code Online (Sandbox Code Playgroud)

但是当我运行测试时,我看到一个错误:

Error: Cannot find module './parentFunction.js'
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?我试过绝对路径,没用。据我从文档中看到,需要 proxiquire …

javascript testing mocha.js meteor proxyquire

6
推荐指数
0
解决办法
623
查看次数

如何通过Passenger/Nginx在Digital Ocean上部署Django/React/Webpack app

我正在尝试在 Digital Ocean 液滴上部署使用 Django/Redux/React/Webpack 构建的 Web 应用程序。我在部署服务器上使用 Phusion Passenger 和 Nginx。

我使用 create-react-app 来构建一个 Django 应用程序,它有一个使用 React/Redux 的前端和一个使用 django-rest-framework 的后端 api。我使用npm run build.

Django 应用程序配置为在 frontend/build 文件夹中查找其文件,一切都按预期工作,包括身份验证。它基于本教程:http : //v1k45.com/blog/modern-django-part-1-setting-up-django-and-react/

在 settings.py 中:

ALLOWED_HOSTS = ['*']

TEMPLATES = [
... 
       'DIRS': [
            os.path.join(BASE_DIR, 'frontend/build'),
        ],
...
]

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, 'frontend/build/static'),
]
Run Code Online (Sandbox Code Playgroud)

在我的开发机器上,我激活了一个 Python 3.6 虚拟环境并运行./manage.py runserver,应用程序显示在 localhost:3000。

在部署服务器上,我将文件克隆到 var/www/ 中的文件夹中并构建了前端。

我已经根据带有文件passenger_wsgi.py的文档设置了Passenger:

import myapp.wsgi
application = myapp.wsgi.application
Run Code Online (Sandbox Code Playgroud)

wsgi.py 文件位于下面的 djangoapp 文件夹中:

import os
from …
Run Code Online (Sandbox Code Playgroud)

python django passenger reactjs webpack

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

热重载时Create-React-App失去Redux存储状态

我已经使用Create-React-App创建了一个应用程序,并且热重装工作正常,但是Redux状态丢失了。如果我编辑任何组件(例如,更改标题),则状态会丢失-最令人讨厌的是,由于该状态中存储的令牌丢失,用户已注销。我已经遵循了各种示例,包括(https://redux.js.org/recipes/configuring-your-store),并且无法弄清这里出了什么问题。

有什么想法我错过了吗?谢谢!

index.js

const renderApp = () => {
    ReactDOM.render(
        <App />, document.getElementById('root')
    );
};

if (process.env.NODE_ENV !== 'production' && module.hot) {
    module.hot.accept('./App', renderApp);
}

renderApp();
Run Code Online (Sandbox Code Playgroud)

store.js

const inititalState = {};

const store = createStore(
    rootReducer, 
    inititalState, 
    compose(applyMiddleware(thunk), 
        window.__REDUX_DEVTOOLS_EXTENSION__&& window.__REDUX_DEVTOOLS_EXTENSION__()));

if (process.env.NODE_ENV !== 'production' && module.hot) {
    module.hot.accept('./reducers', () => store.replaceReducer(rootReducer));
}

export default store;
Run Code Online (Sandbox Code Playgroud)

reducers / index.js

import { combineReducers } from 'redux';
import errorReducer from './errorReducer';
import authReducer from './authReducer';

export default combineReducers({
    'errors': errorReducer,
    'auth': …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux hot-module-replacement create-react-app

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

如何在 Django rest 框架中为“删除”操作编写测试

我正在为我的 Django Rest Framework API 编写测试。

我一直在测试“删除”。

我对“创建”的测试工作正常。

这是我的测试代码:

import json

from django.urls import reverse
from rest_framework import status
from rest_framework.test import APITestCase
from users.models import CustomUser
from lists.models import List, Item

class ListAPITest(APITestCase):
    @classmethod

    def setUp(self):
        self.data = {'name': 'Test list', 'description':'A description', 'item': [
        {'name': 'Item 1 Name', 'description': 'Item 1 description', 'order': 1},
        {'name': 'Item 2 Name', 'description': 'Item 2 description', 'order': 2},
        {'name': 'Item 3 Name', 'description': 'Item 3 description', 'order': 3},
        {'name': 'Item 4 Name', …
Run Code Online (Sandbox Code Playgroud)

python testing api http-delete django-rest-framework

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

在 Ubuntu 16.04 上使用 ssl 从 www 重定向到非 www 无法在 Nginx 中工作

我在 DigitalOcean Ubuntu 16.04 Droplet 上有一个 Meteor 1.6 站点,使用 Phusion Passenger 和 Nginx 部署。

我已经在我的服务器上设置了 ssl。

http://mysite重定向到https://mysite并且该网站工作正常。

然而,http://www.mysite重定向到https://mysite并且显示的只是默认的 Nginx 页面“欢迎来到 nginx!”。

我已经按照教程并尝试了其他论坛帖子中的内容,但我找不到我的设置有什么问题。

来自 DigitalOcean 控制面板的 DNS 记录:

A   www.mysite.org directs to xxx.xx.xx.xx 3600
A   mysite.org directs to xxx.xx.xx.xx 1800
Run Code Online (Sandbox Code Playgroud)

然后,我按照本教程使用 Certbot 和 LetsEncrypt 配置 ssl: https://www.digitalocean.com/community/tutorials/how-to-set-up-let-s-encrypt-with-nginx-server-blocks-on- ubuntu-16-04

我添加了一个服务器块,按照本教程将 www 重定向到普通域:https: //www.digitalocean.com/community/tutorials/how-to-redirect-www-to-non-www-with-nginx-在 ubuntu-14-04 上

这是我的 nginx 配置:

sudo nano /etc/nginx/sites-enabled/mysite.conf

server {
    server_name mysite.org www.mysite.org;

    ...Meteor app config

    # added by Certbot
    listen 443 …
Run Code Online (Sandbox Code Playgroud)

ssl redirect nginx

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

如何使用我自己的自定义表单覆盖 django-rest-auth 中的表单?

我正在使用 django-rest-auth 并且我试图通过覆盖表单的方法之一来修复密码重置视图中的错误。尽管我已经使用不同的 django-rest-auth 表单成功地完成了类似的操作,但我无法让它在这个表单上工作。无论我做什么,都使用旧形式。

api/urls.py

from django.urls import include, path
from django.contrib.auth import views
from django.conf.urls import include, url
from django.views.generic.base import RedirectView
from .forms import SetPasswordFormCustom
from .forms import PasswordResetFormCustom

urlpatterns = [
    path('password/reset/',
        views.PasswordResetView.as_view(form_class=PasswordResetFormCustom),
        name='rest_password_reset'),
    path('rest-auth/', include('rest_auth.urls')),
    path('rest-auth/registration/', include('rest_auth.registration.urls')),
    path('users/', include('users.urls')),
    path('reset/<uidb64>/<token>/',
        views.PasswordResetConfirmView.as_view(template_name='account/password_reset_confirm.html', form_class=SetPasswordFormCustom),
        name='password_reset_confirm'),
    path('reset/done/', views.PasswordResetCompleteView.as_view(template_name='account/password_reset_complete.html'),
        name='password_reset_complete'),
    path('content/', include('lists.endpoints')),
    # content is a path for lists, items etc found in the lists app
]
Run Code Online (Sandbox Code Playgroud)

表格.py

from django import forms
from django.contrib.auth.forms import SetPasswordForm
from django.contrib.auth import …
Run Code Online (Sandbox Code Playgroud)

python django-forms django-rest-auth

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