I started using the Django today, and tried building a html form
the code for views.py is
def home(request):
t = get_template('home.html')
html = t.render(Context({ "GetLabel": 'Welcome to the SPACE program.',
"GetInput": '',
"Next": './get_machine' }))
return HttpResponse(html)
def get_machine(request):
t = get_template('home.html')
html = t.render(Context({ "GetLabel": 'Enter the name of the machine: ',
"GetInput": '<input type="text" name="machine_name">',
"Next": './get_beamlines'}))
return HttpResponse(html)
def get_beamlines(request):
machine_name = request.POST["machine_name"]
Context({ "GetLabel": 'Machine already installed<br> Overwrite Existing file',
"GetInput": '<select name="check" > <option value="Yes">Yes</option> <option value="No">No</option> </select>',
"Next": './get_beamline' })
t = get_template('home.html')
html = t.render(Context({"GetLabel": 'Enter the number of beamlines: ',
"GetInput": '<input type="text" name="beamline_no"',
"Key":'Machine Name: ',
"Value": machine_name,
"Next": './get_beamline_name'}))
return HttpResponse(html)
It goes like this; Now I don’t know how to proceed further to get the name of the beamlines(if more than 1)
I’m a novice to django, please correct me if I am wrong.
Is there any other better way of doing the same.
Note: finally, I want to write all the user inputs to an xml file.
I have done the same with the normal python program, by getting the user inputs form raw_imput()
Some basics about forms are covered in tutorial, you might also want to use forms framework available within Django.