如何在Ecto中的两列上创建唯一索引,这对应于:
CREATE TABLE someTable (
col1 int NOT NULL,
col2 int NOT NULL,
primary key (col1, col2)
)
Run Code Online (Sandbox Code Playgroud)
?
我正在尝试在django中实现python-social-auth.
我希望用户通过Facebook进行身份验证并保存他们的电子邮件.
我能够对用户进行身份验证,但是电子邮件的扩展权限未显示在facebook身份验证框中,并且不会将电子邮件存储在数据库中.
在settings.py我有以下内容:
SOCIAL_AUTH_FACEBOOK_KEY='xxx'
SOCIAL_AUTH_FACEBOOK_SECRET='xxx'
FACEBOOK_EXTENDED_PERMISSIONS = ['email']
AUTHENTICATION_BACKENDS = (
'social.backends.facebook.FacebookOAuth2',
'social.backends.email.EmailAuth',
'django.contrib.auth.backends.ModelBackend',
)
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/done/'
LOGOUT_REDIRECT_URL = '/'
URL_PATH = ''
SOCIAL_AUTH_STRATEGY = 'social.strategies.django_strategy.DjangoStrategy'
SOCIAL_AUTH_STORAGE = 'social.apps.django_app.default.models.DjangoStorage'
SOCIAL_AUTH_PIPELINE = (
'social.pipeline.social_auth.social_details',
'social.pipeline.social_auth.social_uid',
'social.pipeline.social_auth.auth_allowed',
'social.pipeline.social_auth.social_user',
'social.pipeline.user.get_username',
'social.pipeline.social_auth.associate_by_email',
# 'users.pipeline.require_email',
'social.pipeline.mail.mail_validation',
'social.pipeline.user.create_user',
'social.pipeline.social_auth.associate_user',
'social.pipeline.social_auth.load_extra_data',
'social.pipeline.user.user_details'
)
Run Code Online (Sandbox Code Playgroud)
facebook对话框......
我怎么解决这个问题?
我正在尝试抓取此产品的尺寸:
问题:在选择产品颜色后加载尺寸.
在产品页面的源代码中,我可以看到下拉列表中有一个onchange-method:它单击了#postColor onchange形式.
选择下拉列表:
<select name="color" id="color" class="cposelect" onchange="document.getElementById('postColor').click();" style="width:150px;margin-right: 20px; float: left;">
<option selected="selected" onfocus="if (this.storeCurrentControl != null) storeCurrentControl(event, this);" value="0">Select colour</option>
<option onfocus="if (this.storeCurrentControl != null) storeCurrentControl(event, this);" value="-8027">Light Camel</option>
<option onfocus="if (this.storeCurrentControl != null) storeCurrentControl(event, this);" value="-9999">black</option>
</select>
Run Code Online (Sandbox Code Playgroud)
#postColor表单,单击onchange:
<input type="submit" name="postColor" value="" onclick="location.href=('./?model=10344-4180&color='+document.forms[0].color.value+'&size='+document.forms[0].size.value+'&addbread=OUTLET&addbread2=DRIZIA&currentimage='+document.getElementById('currentimage').value+'&selectedmi=a1_INDEX_14&prev=10850-4314&next=10413-4183'); return false;" id="postColor" class="cpobutton " style="display: none;">
Run Code Online (Sandbox Code Playgroud)
到目前为止这是我的代码,它不起作用:
casper.start('http://shop.baumundpferdgarten.com/showmodel/?model=10344-4180&addbread=OUTLET&addbread2=DRIZIA&color=0¤timage=1&selectedmi=a1_INDEX_14', function() {
this.test.assertExists('select[name="color"] option:nth-child(2)');
this.click('select[name="color"] option:nth-child(2)');
this.waitForSelector('select[name="size"] option:nth-child(2)', function() {
this.test.pass('selector is !');
var sizes = this.evaluate(function() {
console.log("======== evaluating ========");
// …
Run Code Online (Sandbox Code Playgroud) 在使用allauth登录时,如何使用django-rest-framework-jwt生成令牌并将其传递给可以将令牌存储在localstorage中的模板?
我知道django-rest-framework-jwt允许你通过POST生成令牌:
$ curl -X POST -d "username=admin&password=abc123" http://localhost:8000/api-token-auth/
Run Code Online (Sandbox Code Playgroud)
但是你如何在allauth的登录/注册流程中实现这一点?
我的docker-compose.yml看起来像这样:
django:
build: .
user: django
links:
# LINK TO AMAZON RDS?
command: /gunicorn.sh
env_file: config/settings/.env
nginx:
build: ./compose/nginx
links:
- django
ports:
- "0.0.0.0:80:80"
Run Code Online (Sandbox Code Playgroud)
如何将django容器链接到Amazon RDS,其中包含以下URL: example.blahblahblah.eu-west-1.rds.amazonaws.com:5432
我有两个MySQL表
每种产品都可以有多种尺寸
我需要进行查询
我现在的查询如下.我工作,但不限制类别,只返回指定的一个尺寸(这里'10') - 我需要所有尺寸,但只适用于其尺寸'10'的产品...
SELECT products.*
, products_sizes.*
FROM (
SELECT *
FROM products
LIMIT $limit OFFSET $offset
) AS products
LEFT JOIN products_sizes
ON products.products_id = products_sizes.products_id
WHERE products_sizes.size = 10
Run Code Online (Sandbox Code Playgroud)
...如果我添加WHERE category ='something'查询什么都不返回...
SELECT products.*
, products_sizes.*
FROM (
SELECT *
FROM products
WHERE category = 'shoes'
LIMIT $limit OFFSET $offset
) AS products
LEFT JOIN products_sizes
ON products.products_id = products_sizes.products_id
WHERE products_sizes.size = 10
Run Code Online (Sandbox Code Playgroud)
??
更新:越来越近了...... …
phantomjs outputEncoding.js示例未显示正确的字符(丹麦字符)...
我在Windows上运行phantomjs 1.7。
(这曾经在我在linux上运行phantomjs 1.4时起作用,但在更新到1.8.2版本后在linux上也给出了错误)
outputEncoding.js:
function helloWorld() {
console.log(phantom.outputEncoding + ": æøå");
}
console.log("Using default encoding...");
helloWorld();
console.log("\nUsing other encodings...");
var encodings = ["euc-jp", "sjis", "utf8", "System"];
for (var i = 0; i < encodings.length; i++) {
phantom.outputEncoding = encodings[i];
helloWorld();
}
phantom.exit();
Run Code Online (Sandbox Code Playgroud)
来自控制台的结果:
任何帮助都非常感谢!
谢谢。
我正在尝试在phoenixframework项目中实现Guardian jwt.
我有一个user_controller.ex模块,它具有以下功能:index,create,show,update和delete
我只想确保用户在更新和删除时进行身份验证
如果我放在plug Guardian.Plug.EnsureAuthenticated, handler: SessionController
模块的顶部,所有功能都需要验证.
我试着这样做:
plug Guardian.Plug.EnsureAuthenticated, %{ on_failure: { SessionController, :unauthenticated } } when not action in [:index, :create, :show]
,它确实工作,根据需要,但我在控制台中出现以下错误:[warn] :on_failure is deprecated. Use the :handler option instead
所以问题是:如何只使用handler参数要求更新和删除身份验证?
是否可以使用 utf-8 编码名称(如“åøæ.jpg”)向 s3 添加密钥?
使用 boto 上传时出现以下错误:
<Error><Code>InvalidURI</Code><Message>Couldn't parse the specified URI.</Message>
Run Code Online (Sandbox Code Playgroud) 我可以像这样使用 Ecto 获取当前日期时间:
Ecto.DateTime.utc
Run Code Online (Sandbox Code Playgroud)
但是我如何得到明天的约会
Ecto.DateTime.utc + timedelta 1 day
Run Code Online (Sandbox Code Playgroud)
?
尝试撰写与以下psql查询对应的查询(查找超过30天前创建的所有用户):
SELECT * FROM users
WHERE date_part('day', now()-inserted_at) > 30;
Run Code Online (Sandbox Code Playgroud)