1

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)

imports of my views:

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 

this is giving me error ' module' object is not callable..can anyone tell me why? plz tell me what i am missing

4
  • 3
    I would try changing random() to random.random(), but without your actual traceback, it's a shot in the dark. Commented Apr 26, 2013 at 6:59
  • could you update your question with 'import' section? Commented Apr 26, 2013 at 7:19
  • can u plz tell mme whats the profile import? Commented Apr 26, 2013 at 7:35
  • when I wrote 'import section', I meant the part of your views.py, where you import modules Commented Apr 26, 2013 at 7:59

1 Answer 1

13

I think you should check your imports. random is both a module name and a function inside a module. If you have

import random

Then you need to call random.random instead of just random.

Sign up to request clarification or add additional context in comments.

1 Comment

Issue happened to me while moving from "app/forms.py" to "app/forms/formX.py" all my form during big code refactor, imports needed to change accordingly and load the Form instead of the file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.