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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:18:20+00:00 2026-05-13T08:18:20+00:00

I have the following view code: def activate( request = ”, actkey = ):

  • 0

I have the following view code:

def activate( request = '', actkey = "" ):
    message = ""
    if len( actkey ) != 40:
        message += str( len(actkey))
        if request.method == 'POST':
            form = ActivateForm( request.POST )
            if form.is_valid():
                actkey = request.POST['actkey']
                activate( '', actkey )
        else:
            form = ActivateForm()
    else:
        profile = userprofile.objects.get( actkey = actkey )
        user = User.objects.get( id = profile.user_id )
        user.is_active = True
        user.save()
        profile.actkey = ""
        profile.save()
        message += "Uw account is succesvol geactiveerd."
        return render_to_response( 'profile/register.html', { 'message' : message } )
    return render_to_response( 'profile/register.html', { 'message' : message, 'form' : form } )

What it does is simple, when the activation key is given through the URL, it goes to:
profile = userprofile…. etc.
But when it’s not given it loads the django form so the user can type it’s activation code (all works well so far)
But when the user posts his activation key it comes in the if len( actkey ) != 40:
That shouldn’t happen because the activation key is 40… But since it shows the form again, but activates the user as well i get unwanted behavior…

How can i fix this?

Thanks for the help

  • 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-13T08:18:20+00:00Added an answer on May 13, 2026 at 8:18 am

    I may misunderstand your intension.
    But I think when the form is valid you should do something like:

    if form.is_valid():
        actkey = request.POST['actkey']
        activate( '', actkey )
        return render_to_response( 'profile/register.html', { 'message' : message } )
    

    ie. omit the form object after you activate the user.

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

Sidebar

Ask A Question

Stats

  • Questions 278k
  • Answers 278k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The main function should have a signature like: public static… May 13, 2026 at 3:10 pm
  • Editorial Team
    Editorial Team added an answer The declarative syntax of doing this in the actual ascx… May 13, 2026 at 3:10 pm
  • Editorial Team
    Editorial Team added an answer Mind the dot: .interview Also, there is no slideIn, try… May 13, 2026 at 3:10 pm

Related Questions

I've got a requirement that I believe must occur very frequently around the world.
I have a standard User controller with the normal set of actions (index, show,
I cannot seem to get a nested form to generate in a rails view
I am creating an application in .NET that will serve as a second UI
I have the following code in the view call.. def view(request): body = u

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.