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

madeeha ameer
  • 479
  • 2
  • 8
  • 22

1 Answers1

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.

cwallenpoole
  • 79,954
  • 26
  • 128
  • 166
  • 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 – Vadorequest Oct 10 '18 at 11:29