我有一個Django項目,並在其中一個網頁上,我想收集一些項目的信息。Python Django獲取或發佈?
一個字段有一個下拉列表,從中用戶可以選擇參與該項目的團隊成員的名字。此下拉列表中有許多預先定義的選項,並且還提供了選擇「其他」的選項。
如果用戶選擇「其他」,領域的變化「列表下拉」到「文本框」,用戶可以在他們想要選擇的人的名字輸入。在他們開始輸入時,數據庫將根據他們迄今輸入的字母來查詢,並在文本框下方顯示可用選項列表(與輸入的字母匹配)。例如,如果用戶鍵入了「D」,那麼將顯示的可用選項列表可能包括:'Dan','Dave','Debbie',但是如果他們鍵入了「Da」,則可用選項列表那將顯示將只包括:'丹'&'戴夫'。
當用戶第一次在項目中加載此頁面時,'name'字段爲空。當我開始在這一領域的打字,然後從所顯示的可用選項列表中的選項,瀏覽器控制檯顯示我該說的錯誤:
jquery-2.2.2.min.js:4 POST http://localhost:8000/projects/5915/submit_3_5_ajax/ 500 (Internal Server Error)
我認爲,這可能意味着我使用錯誤的方法,但我同時使用Get
& Post
已經嘗試過,他們都給予在瀏覽器控制檯同樣的錯誤......
蟒蛇控制檯還顯示了這個錯誤:
ValueError: invalid literal for int() with base 10: ''
[10/Nov/2016 14:05:38] "POST /projects/5915/submit_3_5_ajax/ HTTP/1.1" 500 21537
爲f AR是我所知道的,異常的地方發生的窗體類裏面我forms.py
文件:
class InfoForm(ValidatedForm):
...
def __init__(self, *args, **kwargs):
...
try:
who_will_organise = project.assigned.get(role=Role.O).employee.first_name + project.assigned.get(role=Role.O).employee.surname[0] # I just want to get the first character of the surname here...
except ObjectDoesNotExist: who_will_organise = None
...
def save(self, commit=True):
...
if data['who_will_organise']:
...
else:
# The print statements I'm seeing in the console would indicate that this is where the exception is being thrown...
who_will_organise = Employee.objects.get(id=data['who_will_organise'])
try:
...
except ...
...
...
return ...
這個頁面的網址是:
url(r'^(?P<project_id>\d+)/survey/$', views.survey, name='survey'),
和view
,它的調用與定義:
def survey(request, project_id):
project = Project.objects.get(id=project_id)
survey = Survey.objects.get_or_create(project=project)[0]
context = {
'project': project,
'survey_form': SurveyInformationForm(instance=survey),
}
return render(request, 'projects/survey.html', context)
我的瀏覽器控制檯顯示以下錯誤消息:
POST http://localhost:8000/projects/5915/submit_3_5_ajax/ 500 (Internal Server Error)
autosave_form.js:122 FAIL:(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){n.each(b,function(b,c){n.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==n.type(c)&&d(c)})}(arguments),c&&!b&&i…
FAIL:(){return f&&(c&&!b&&(h=f.length-1,g.push(c)),function d(b){n.each(b,function(b,c){n.isFunction(c)?a.unique&&j.has(c)||f.push(c):c&&c.length&&"string"!==n.type(c)&&d(c)})}(arguments),c&&!b&&i…
在Python控制檯在我的命令行,在那裏我運行Python的服務器,我得到錯誤信息:
OperationalError: (1054, "Unknown column 'costing_addomit.group_id' in 'field list'")
[10/Nov/2016 15:01:24] "GET /projects/pipeline/ HTTP/1.1" 500 337434
任何人都可以指出我,我做錯了什麼嗎?
不符合您所展示的細節;目前還不清楚爲什麼你認爲這與獲得和發佈有關。你需要展示你的網址。py,view,以及瀏覽器開發工具網絡選項卡中顯示的完整錯誤。 –
道歉 - 我已經添加了網址和查看問題。 – someone2088
您發佈的網址中不包含「.../survey/...」... – Javier