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

  • Home
  • SEARCH
  • 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 7814197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T05:07:31+00:00 2026-06-02T05:07:31+00:00

here Every time i enter any data nothing happen except that the page is

  • 0

here Every time i enter any data nothing happen except that the page is reloaded and password and verify password are empty even if i didn’t write them typically the same the raise.ValidationError is not displayed any advice ?

Views.py

    from django.contrib.auth.models import User
    from django.http import HttpResponse
    from django.http import HttpResponseRedirect
    from django.shortcuts import render_to_response
    from shoghlanah.forms import SignUpForm
    from django.template import RequestContext
    from django.views.decorators.csrf import csrf_exempt
    from django.contrib.auth import authenticate, login
    from django.contrib.auth import logout
    from shoghlanah.models import *



    def EmployerRegistration(request):
        if request.user.is_authenticated():
            return HttpResponseRedirect('/profile/')
        if request.method == 'POST':
            form = SignUpForm(request.POST)
            if form.is_valid():
                user=User.objects.create_user(username=form.cleaned_data["username"],password= form.cleaned_data['password'],first_name=form.cleaned_data['first_name'],last_name=form.cleaned_data['last_name'],email=form.cleaned_data['email'],address=form.cleaned_data['address'],mobile=form.cleaned_data['mobile'])
                user.save()
                employer =Employer(user=user,first_name=form.cleaned_data['first_name'],last_name=form.cleaned_data['last_name'],email=form.cleaned_data['email'],address=form.cleaned_data['address'],mobile=form.cleaned_data['mobile'])
                employer.save()
                #Employer=user.get_profile()
                #Employer.first_name=form.cleaned_data['first_name']
                #Employer.last_name=form.cleaned_data['last_name']
                #Employer.address=form.cleaned_data['address']
                #Employer.mobile =form.cleaned_data['mobile']
                #Employer.save()
            return HttpResponseRedirect('/login/') 

            #else:
             #    return render_to_response('Sign_up_Employer.html',{'form':form},context,context_instance=RequestContext(request))

        else:
        #user is not submitting show them the registeration form
                form= SignUpForm()
                context = {'form':form}
                return render_to_response('Sign_up_Employer.html',context,context_instance=RequestContext(request))

forms.py

from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms
from django.forms import ModelForm
from shoghlanah.models import *


class SignUpForm(ModelForm):
    username      = forms.CharField(label=(u'Username'))
    first_name    = forms.CharField(label=(u'First name'))
    last_name     = forms.CharField(label=(u'Last name'))
    address       = forms.CharField(label=(u'Address'))
    email         = forms.EmailField(label=(u'Email Address'))
    password      = forms.CharField(label=(u'Password'),widget=forms.PasswordInput(render_value=False))
    password1     = forms.CharField(label=(u'Verify Password'),widget=forms.PasswordInput(render_value=False))
    mobile        = forms.IntegerField(label=(u'Mobile'))

    class Meta:
        model = Employer

        exclude =('user',)

    def clean_username(self):
        username = self.cleaned_data['username']
        try:
            User.objects.get(username=username)
        except User.DoesNotExist:
            return username

            raise forms.ValidationError("That username  already exists. Please select another")




    def clean(self):
        if self.cleaned_data['password'] != self.cleaned_data['password1']:
              raise forms.ValidationError("not matched")
        return self.cleaned_data

sign_up_Employer.html

{%block content%}
<form action ="" method ="post">
{% csrf_token %}
{% if form.errors %}<p>Please Correct </p> {% endif %}
<div class ="register_div">
{%if form.username.errors%}<p class= "error">{{form.username.errors}}</p>{% endif %}
 <p> <label for ="username"{% if form.username.errors %} class= "error"{% endif %}> Username</label></p>
<p>{{form.username}}</p>
 </div>
 <div class ="register_div">
{%if form.first_name.errors%}<p class= "error">{{form.first_name.errors}}</p>{% endif %}
 <p> <label for ="first_name"{% if form.first_name.errors %} class= "error"{%endif%}>First name</label></p>
<p>{{form.first_name}}</p>
 </div>
 <div class ="register_div">
{%if form.last_name.errors%}<p class= "error">{{form.last_name.errors}}</p>{% endif %}
 <p> <label for ="last_name"{% if form.last_name.errors %} class= "error"{%endif%}>Last name</label></p>
<p>{{form.last_name}}</p>
 </div>
<div class ="register_div">
{%if form.address.errors%}<p class= "error">{{form.address.errors}}</p>{% endif %}
 <p> <label for ="address"{% if form.address.errors %} class= "error"{%endif%}>Address'</label></p>
<p>{{form.address}}</p>
 </div>
 <div class ="register_div">
{%if form.email.errors%}<p class= "error">{{form.email.errors}}</p>{% endif %}
 <p> <label for ="email"{% if form.email.errors %} class= "error"{%endif%}>Email Address</label></p>
<p>{{form.email}}</p>
 </div>
 <div class ="register_div">
{%if form.password.errors%}<p class= "error">{{form.password.errors}}</p>{% endif %}
 <p> <label for ="password"{% if form.password.errors %} class= "error"{%endif%}>Password</label></p>
<p>{{form.password}}</p>
 </div>

 <div class ="register_div">
{%if form.password1.errors%}<p class= "error">{{form.password1.errors}}</p>{% endif %}
 <p> <label for ="password1"{% if form.password1.errors %} class= "error"{%endif%}>Verify Password</label></p>
<p>{{form.password1}}</p>
 </div>

 <div class ="register_div">
{%if form.mobile.errors%}<p class= "error">{{form.mobile.errors}}</p>{% endif %}
 <p> <label for ="mobile"{% if form.mobile.errors %} class= "error"{%endif%}>Mobile</label></p>
<p>{{form.mobile}}</p>
 </div>
 <p><input type =submit alt =register></p>
</form>
{% endblock %}

models.py

from django.db import models
class Employer(models.Model):#Employer inherits from User
    user = models.OneToOneField(User)
    employer_verified = models.BooleanField(default=False)
    profile_picture = models.ImageField(upload_to='ProfilePictureDB', null=False , blank=False) 
    #profile pictures will be uploaded to ProfilePictureDB 
    hidden_values = models.CharField(max_length=200) 
    #hidden_values will contain all the attributes that the employer/contractor wants to hide
    signature = models.OneToOneField(Signature)
    mobile = models.IntegerField(max_length=20)
    address = models.CharField(max_length=100)
    def __unicode__(self):
        return self.name
  • 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-06-02T05:07:33+00:00Added an answer on June 2, 2026 at 5:07 am
    if request.method == "POST":
    
        if form.is_valid():
            # ....
        return HttpResponseRedirect('/login/')  # not indented
    

    The return is unindented out of the is_valid() block. So, a POST, regardless of the form’s validity, will redirect. Change to

    if request.method == "POST":
    
        if form.is_valid():
            # ....
            return HttpResponseRedirect('/login/')  # indented
    

    Update:

    def clean_username(self):
        username = self.cleaned_data['username']
        try:
            User.objects.get(username=username)
        except User.DoesNotExist:
            return username
    
            raise forms.ValidationError("That username  already exists. Please select another")
    

    This is wrong; you can’t raise after you return. The raise should go in the try block.

    def clean_username(self):
        username = self.cleaned_data['username']
        try:
            User.objects.get(username=username)
            raise forms.ValidationError("That username already exists. "
                                        "Please select another")
        except User.DoesNotExist:
            return username
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A term that I see every now and then is Cyclomatic Complexity. Here on
I have a php page where users may enter data into fields inside a
Every time I try this: long crypt(int *integer) { printf("Enter five digit integer:\n"); scanf("%i",integer);
Every time I enter in a new player in the Admin portion of Django
here's the situation: I have a where in every cell all the area has
Here's what I need to do: 1) Loop through every cell in a worksheet
here is the code: http://jsfiddle.net/duNHJ/2/ Basically there is an animations every div so when
I am setting up a SaaS application that multiple clients will use to enter
I have a GridView that allows editing the values in every column, in every
Here's the basic idea: There is a java window (main) that opens another java

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.