0

I am trying to add some extra fields on Django-registration's registration page such as "city". I followed this method but form doesn't render the extra field "city" and "terms and services" check mark. Also when i check whether view is correct via Django debug toolbar, it displays the additional fields correctly. Not sure why the extra fields are not rendered on the form.

Forms.py

from django.contrib.gis import forms
from django.contrib.auth.models import User
from django.db.models import Q
from dirapp.models import UserProfile
from django import forms
from registration.forms import RegistrationForm, RegistrationFormTermsOfService
from django.forms import ModelForm
from django.utils.translation import ugettext_lazy as _
from registration.models import RegistrationProfile
from forms import *

class UserProfileForm(forms.ModelForm):

    class Meta:
        model = UserProfile
        exclude = ('user')
        widgets = {
                 'point': forms.HiddenInput(),
                 }

RegistrationForm.base_fields.update(UserProfileForm.base_fields)

attrs_dict = { 'class': 'required' }

class UserRegistrationForm(RegistrationFormTermsOfService):
        city = forms.CharField(max_length=3, label='whatisyourcity', widget=forms.TextInput(attrs=attrs_dict))

Urls.py

from django.conf.urls.defaults import *
from django.views.generic import *
from django.conf import settings
from django.conf.urls.static import static
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
#from companies.models import Lead,Company
from dirapp.views import index, user_profile_crud, user_profile, add_listing, listing_detail, edit_listing, place_query, lead_detail, software_detail, add_vote_soft, software_list, add_classified, classified_detail,classified_list
from dirapp.models import UserProfile, Listing,Software,classified
admin.autodiscover()
from django.contrib.auth.decorators import login_required
from django.views.generic import list_detail
from djangoratings.views import AddRatingFromModel
from dirapp.forms import UserRegistrationForm
from registration.views import register
import registration.backends.default.urls as regUrls

listing_list = {"queryset":Listing.objects.all()}


urlpatterns = patterns('',


    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),


    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
    #url(r'^contact/$', login_required(TemplateView.as_view(template_name="companies/contact.html"))),   
    url(r'^$',index,name='index'),
    url(r'^accounts/vendor-register/$', register, { 'backend': 'registration.backends.default.DefaultBackend','form_class':UserRegistrationForm}, name='registration_register'),    
    url(r'^accounts/', include(regUrls)), 
    url(r'^profile/$', user_profile, name='user-profile-view'),
    url(r'^profile/edit/$', user_profile_crud, name ='user-profile-crud'),
shaytac
  • 3,789
  • 9
  • 36
  • 44

1 Answers1

0

since you're extending RegistrationFormTermsOfService, instead of

RegistrationForm.base_fields.update(UserProfileForm.base_fields)

use

RegistrationFormTermsOfService.base_fields.update(UserProfileForm.base_fields)
mHxDave
  • 55
  • 7