1👍
There are really many ways to deal with this. For example, you could simply process your html form in the view, in which you would manually create or update all ORM instances.
I believe though that it would be very beneficial for you to take a good read on Django forms and modelforms. The above task could be easily accomplished by using a modelform on the Score model and any other models.
Also this answer explains how to deal with multiple django forms on a single post request.
1👍
here is my code to deal with the table in diagnose_app, believe it would help for you.
#get the distinct time, blade and counts name info
def gettableinfo(request,tablename):
tableinfo={}
datedis=[]
bladedis = []
counts = []
if request.is_ajax():
if request.method=='GET':
for m in get_models(get_app('diagnose_app'), include_auto_created=True):
if m._meta.db_table == request.GET.get('tablename'):
for bd in m.objects.values('STATION_ID').distinct():
bladedis.append(bd['STATION_ID'])
for dt in m.objects.values('Day','Time').distinct():
datedis.append(dt['Day'].isoformat()+' '+dt['Time'].isoformat())
for ct in m._meta.get_all_field_names():
if ct.isupper():
counts.append(ct)
#tableinfo.append(m._meta.get_field('Blade'))
tableinfo['tablename'] = request.GET.get('tablename')
tableinfo['blades'] = bladedis
tableinfo['times'] = datedis
tableinfo['counts'] = counts
#tableinfo=tableinfo.append('abcde')
#table_info_json=json.dumps(tableinfo)
table_info_json=json.dumps(tableinfo)
return HttpResponse(table_info_json,content_type="application/json")
- [Answered ]-Xlsxwriter consuming too much memory and process gets killed
- [Answered ]-How to get Uwsgi working with wagtail (django)
- [Answered ]-Couldn't import django in virtualenv but works when deactivated
- [Answered ]-Construct attribute value of django form
- [Answered ]-Deploy with Apache2, mod_wgi and django 1.9 on ubuntu server 16.04
Source:stackexchange.com