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 3344862
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:07:07+00:00 2026-05-18T01:07:07+00:00

I have a page, index.html, that contains both a login and registration form. I

  • 0

I have a page, index.html, that contains both a login and registration form. I have a couple of questions about getting this to work properly

My URLConfig looks like this:

urlpatterns = patterns('djangoproject1.authentication.views',
    (r'^$',direct_to_template,{'template':'authentication/index.html'}),
    (r'^register/$','register'),
)

1) Using the Django book is a guide, my form looks like this:

<h1>Register</h1>
    <form action="/register/" method="post">
        {{ form.as_p }}
        <input type="submit" value="Register">
    </form>

Of course, since the file is index.html, the form doesn’t appear when I just go to the page. Do I need a “view” to handle visiting index.html rather than a direct_to_template?

2) My Register code looks like this:

def register(request):
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            new_user = form.save()
            return HttpResponseRedirect("/register/success/")
        else:
            form = UserCreationForm()
    return render_to_response("authentication/index.html", {'form': form})

This is the django authentication built-in stuff. Do people actually use it? It seems limited. I know I can add more fields to the Django User by using a user profile or something, but what about the UserCreationForm? Should I roll my own form? Should it inherit from UserCreationForm somehow?

  • 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-18T01:07:07+00:00Added an answer on May 18, 2026 at 1:07 am

    direct_to_template by itself can neither produce nor handle forms — it simply renders a request directly to a template, as its name describes.

    You might look into django-registration for registration.

    If you’re putting two forms on the same page, you’ll need a custom view that is capable of rendering and handling both forms, though multi-form pages are notoriously tricky to work with properly. If you have separate forms (and submit buttons), you can add a unique name to each submit input and determine which form (class) to validate and handle based on if name in request.POST.


    edit:

    After looking more closely at your code, I see that your registration form redirects to a different view; that simplifies things, but you’ll still need a custom view for your home page that passes both login and registration forms to the template for rendering.

    Alternatively, if you’re simply redirecting to pages that handle each form, you can add those forms using direct_to_template‘s extra_context parameter directly in your urls.py:

    from wherever import LoginForm, RegistrationForm
    
    urlpatterns = patterns('djangoproject1.authentication.views',
        (r'^$',
            direct_to_template,
            {
                'template': 'authentication/index.html',
                'extra_context': {
                    'reg_form': RegistrationForm(),
                    'login_form': LoginForm()
                }
            }
        ),
        (r'^register/$', 'register'),
    )
    

    This approach isn’t the cleanest, but it’s an option if you really wanted to use generic views.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a web page ( /index.html ) that contains the following
I have a page that contains an iframe that gets loaded using Javascript: index.html
I have a html page index.html that link to a page default.aspx, both are
I have a page in HTML(index.html), and a folders named images, css, js that
I'm trying to make a HTML page (lets say index.html) that will have a
I have a HTML form that contains many links (around 17). I want, when
Back in 2009 I wrote a page ( http://www.ikriv.com/dev/dotnet/JavaClone/index.html ) that contains a lot
I am using jQuery for a simple website and have a main page 'index.html'
I am using rails beta 3 and I have a erb page named index.html.erb
I have the following jQueryMobile page anatomy at index.html: <div data-role=page> <div data-role=header>...</div> <div

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.