0

「都市」など、Django-registration の登録ページにいくつかのフィールドを追加しようとしています。私はこの方法に従いましたが、フォームは余分なフィールド「都市」と「条件とサービス」のチェックマークをレンダリングしません。また、Django デバッグ ツールバーを使用してビューが正しいかどうかを確認すると、追加のフィールドが正しく表示されます。余分なフィールドがフォームに表示されない理由がわかりません。

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'),
4

1 に答える 1