小编And*_*Viá的帖子

注册django后发送电子邮件确认

我在django应用程序中注册过程后发送电子邮件确认.我需要找出出于安全原因如何在不在用户模型中添加新代码字段的情况下验证在网址中发送的代码.到目前为止,我发送了一个随机代码在url和用户名,验证但不是代码.

注册视图

def registrar_usuario_view(request):
alphabet = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
code = ''.join(random.choice(alphabet) for i in range(16))
print code
if request.method == 'POST':
    f = RegisterForm(request.POST)
    if f.is_valid():
        usuario = f.cleaned_data['usuario']
        email = f.cleaned_data['email']
        clave = f.cleaned_data['clave']
        confirmar_clave = f.cleaned_data['confirmar_clave']
        captcha = f.cleaned_data['captcha']
        u = User.objects.create_user(username = usuario, email = email, password = clave)
        u.is_active = False
        u.save()
        # Mandamos mail de activacion
        to = email
        html_content = """<h3>Bienvenido Sr/a: %s </h3><p>Para confirmar su registro en el sitio Margonari Servicios Inmobiliarios le solicitamos …
Run Code Online (Sandbox Code Playgroud)

python django

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

MongoDB聊天模式

我尝试使用MongoDB,并且作为起点我为将来可能很容易扩展的聊天应用程序创建模式,所以我想知道这看起来是否正如我在文档中看到的那样.到目前为止,我有3个收藏用户,房间,消息.此外,我还需要执行一些查询,例如从特定房间获取所有消息,获取特定用户的所有消息等

采用猫鼬设计:

var user = new mongoose.Schema({
     username: { type: String, lowercase: true, unique: true },
     email: { type: String, lowercase: true, unique: true },
     password: String,
     is_active: { type: Boolean, default: false },
});

var room = new mongoose.Schema({
    name: { type: String, lowercase: true, unique: true },
    topic: String,
    users: [user],
    messages: [message],
    created_at: Date,
    updated_at: { type: Date, default: Date.now },
});

var message = new mongoose.Schema({
    room: room,
    user: user,
    message_line: String,
    created_at: { type: Date, …
Run Code Online (Sandbox Code Playgroud)

javascript mongoose mongodb node.js

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

检查当前用户是否使用任何django社交身份验证提供程序登录

我想检查用户是通过社交身份验证还是使用django默认身份验证登录.

就像是

如果user.social_auth = true?

django django-socialauth python-social-auth

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