views.py
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
这是给我错误'模块'对象不可调用..谁能告诉我为什么?请告诉我我错过了什么
答案 0 :(得分:7)
我认为你应该检查你的进口。 random
既是模块名称,也是模块内的函数。如果你有
import random
然后,您需要拨打random.random
而不是random
。