2013-04-26 80 views
-2

views.py'模块' 对象不是可调用的Django

for user in users: 
    #for profile in RegistrationProfile.objects.filter(user=user): 
    #if profile.activation_key_expired(): 
    salt = sha_constructor(str(random())).hexdigest()[:5] 
    profile.activation_key = sha_constructor(salt+user.username).hexdigest() 
    user.date_joined = datetime.now() 

    user.save() 
    profile.save() 
    #if Site._meta.installed: 
    site = Site.objects.get_current() 
    # else: 
    site = RequestSite(request) 

    profile.send_activation_email(site) 

    context.update({"form" : form}) 
    return render_to_response("registration/registration_complete.html", context) 

进口自己的看法:

import django.contrib.sessions 
from django.core.mail import send_mail 
from django.core.mail import EmailMessage 
from mail_templated import EmailMessage 
from django.db.models import Sum 
from tinymce.widgets import TinyMCE 
from django.utils.encoding import smart_unicode 
import datetime 
from django.db.models import Q 
from django.utils.hashcompat import sha_constructor 
from registration.models import RegistrationProfile 
import random 
from django.contrib.sites.models import Site, RequestSite 

这是给我的错误 '模块' 对象不callable..can告诉任何人我为什么? PLZ告诉我我缺少的东西

+2

我会尝试更改'random()'到'random.random()',但没有你的实际回溯,这是一个黑暗中的镜头。 – Blender 2013-04-26 06:59:46

+0

你可以用'导入'部分更新你的问题吗? – 2013-04-26 07:19:35

+0

你可以告诉我什么是配置文件导入? – 2013-04-26 07:35:40

回答

6

我认为你应该检查你的进口。 random既是模块名称又是模块内部的函数。如果你有

import random 

然后你需要调用random.random,而不是仅仅random

相关问题