Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4341440
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T11:29:08+00:00 2026-05-21T11:29:08+00:00

I have a signup form that needs to be loaded for every page of

  • 0

I have a signup form that needs to be loaded for every page of my site if the user is a guest. I figured the easiest way to do this would be to create a “signup” app/module and have the form variable defined in the init.py so it was automatically initiated on every view, assuming I imported the module. However, I’m having a bit of trouble getting my view to find the form variable. “global name ‘form’ is not defined” Below is my setup:

I have a /signup/init.py and /signup/form.py files.

This is my init.py

from django import forms
from signup.form import SignUpForm

form = SignupForm()

This is my form.py

class SignupForm(forms.Form):
    fullname = forms.CharField(min_length=3, max_length=25, initial='name', error_messages={'required': 'A unique username is required.', 'min_length': 'Your username must contain at least 3 characters.'})
    username = forms.CharField(min_length=3, max_length=25, initial='choose a username', error_messages={'required': 'A unique username is required.', 'min_length': 'Your username must contain at least 3 characters.'})
    password = forms.CharField(min_length=7, initial='choose a password', error_messages={'required': 'Please enter a password.','min_length': 'Your password must contain at least 7 characters.'})
    email = forms.EmailField(initial='e-mail address', error_messages={'required': 'Please enter a valid email address.', 'invalid': 'Please enter a valid email address.'})
    find_me = forms.BooleanField(initial=True, required=False)
    tos = forms.BooleanField(error_messages={'required': 'You must accept our Terms of Service.'})

And I’m trying to load those from my /views/index.py file:

from django.http import HttpResponse
from pymongo import *
from user import *
import mongo
from django.shortcuts import render_to_response
from django.template import RequestContext, loader
import signup

#index view
def index(request):

    return render_to_response('index.html',
        {'form': signup.form},
        context_instance=RequestContext(request),
    ) 

I removed the irrelevant code in index.py… but basically.. (i’ll probably have an if else for the return statement to only return the ‘form’:form when the user is unregistered)

Am I approaching this completely wrong? Anyone mind showing me what I’m doing incorrectly?

::Edit::

Also, I noticed that I didn’t have signup.form in the return, but that still throws a

AttributeError at /
'module' object has no attribute 'form'

error. I changed the code above to accommodate that

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T11:29:08+00:00Added an answer on May 21, 2026 at 11:29 am

    I would just point out that the way you’re doing it is an extremely bad idea. You have one instance of the form across every request: that’s always going to be dangerous, allowing the possibility of information leakage across requests. Don’t do it.

    Instead, use the built-in mechanism that Django has to do this for you: context processors. In your signup/form.py, define a simple function:

    def signup_form(request):
        return SignupForm()
    

    and add this to TEMPLATE_CONTEXT_PROCESSORS in settings.py:

    'signup.form.signup_form',
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple signup form that needs to track number of hits from
I'm working on an email series signup form that needs to have a checkbox
I have a simple user signup form with a checkbox that lets users get
I have a signup button that switches screens for a signup form. I'd like
I have a form (signup.php) that pops up in a nyroModal window when I
I have a problem. The client is claiming that a prize signup form I
I have a form allowing a user to signup for a news letter which
I have a sign up form that is displayed to all new site visitors.
I have a signup form of which most fields are pre-filled using user's Facebook
I have a page that should have text on the left and a form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.