我想为两种形式使用相同的模型并更改字段的标签如何更改标签?
这是我的一个表格:
class jobpostForm(forms.ModelForm):
class Meta:
model = jobpost
fields = ('job_type','title','company_name','location','country','description','start_date','end_date','how_to_apply')
widgets = {
'job_type':RadioSelect(),
'location':TextInput(attrs={'size':'70','cols': 10, 'rows': 20}),
'description': TinyMCE(attrs={'cols':'100', 'row': '80'}),
'start_date':AdminDateWidget(attrs={'readonly':'readonly'}),
'end_date':AdminDateWidget(attrs={'readonly':'readonly'}),
'how_to_apply':RadioSelect(),
}
def __init__(self, *args, **kwargs):
super(jobpostForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_class = 'horizontal-form'
self.helper.form_id = 'id-jobpostform'
self.helper.form_class = 'blueForms'
self.helper.form_method = 'post'
self.helper.form_action = '/portal/next/post/'
self.helper.add_input(Submit(_('submit_addcontent'), 'Preview'))
super(jobpostForm, self).__init__(*args, **kwargs)
Run Code Online (Sandbox Code Playgroud)
我希望将"位置"更改为"工作地点"..我该怎么做?
我正在尝试使用django-haystack在Solr中为模型建立索引,但是它返回以下错误(使用rebuild_index或update_index时):
Failed to add documents to Solr: [Reason: Error 404 Not Found]
Run Code Online (Sandbox Code Playgroud)
这是search_indexes.py
from haystack import indexes
from haystack.indexes import SearchIndex
from jobpost.models import *
class JobIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
post_type = indexes.CharField(model_attr='post_type')
location = indexes.CharField(model_attr='location')
job_type = indexes.CharField(model_attr='job_type')
company_name = indexes.CharField(model_attr='company_name')
title = indexes.CharField(model_attr='title')
def get_model(self):
return jobpost
def index_queryset(self,**kwargs):
return self.get_model().objects.all()
Run Code Online (Sandbox Code Playgroud)
干草堆连接:
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://127.0.0.1:8983/solr',
'SITECONF': 'jobpost.search_sites'
},
}
Run Code Online (Sandbox Code Playgroud)
我已生成schema.xml多次重新启动solr ..将其放置在solr / conf中..不知道是什么问题
views.py
for user in users:
#for profile in RegistrationProfile.objects.filter(user=user):
#if profile.activation_key_expired():
salt = sha_constructor(str(random())).hexdigest()[:5]
profile.activation_key = sha_constructor(salt+user.username).hexdigest()
user.date_joined = datetime.now()
user.save()
profile.save()
#if Site._meta.installed:
site = Site.objects.get_current()
# else:
site = RequestSite(request)
profile.send_activation_email(site)
context.update({"form" : form})
return render_to_response("registration/registration_complete.html", context)
Run Code Online (Sandbox Code Playgroud)
导入我的观点:
import django.contrib.sessions
from django.core.mail import send_mail
from django.core.mail import EmailMessage
from mail_templated import EmailMessage
from django.db.models import Sum
from tinymce.widgets import TinyMCE
from django.utils.encoding import smart_unicode
import datetime
from django.db.models import Q
from django.utils.hashcompat import sha_constructor
from registration.models import RegistrationProfile …Run Code Online (Sandbox Code Playgroud)