Re: adding a drop down selection list
Thanks a lot guys. After I have changed my code to sales_person = request.POST['salespeople_dropdown'] it worked perfectly. On Jun 12, 2:55 pm, strelok31 <[EMAIL PROTECTED]> wrote: > Thanks Jeremy, > > I will try out your suggestions. I am not new to programming, I am new > to web programming and Django. I have done all four steps that your > suggested before, I have just done #2 wrong. I will correct it now. > Thanks. > > On Jun 12, 12:54 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > > > On 6/12/07,strelok31<[EMAIL PROTECTED]> wrote: > > > > Any ideas? I have been stuck on this for a while and I got nobody else > > > to ask for help. Thanks again. > > > If you're really stuck, you need pointers as much as you need a > > solution; there really are many sources to find info on how to > > accomplish this fairly simple task. > > > General steps: > > 1) add to html, which you've already done. > > 2) add to python view, which you've done wrong. > > 3) add to python model, which you probably haven't done. > > 3) add to database, which you probably haven't done. > > > For #2, this line: > > sales_person = document.Submit.salespeople_dropdown.value > > most certainly should be something like this: > > sales_person = request.POST['salespeople_dropdown'] > > > Based on this line: > > from django.models.accukeys import acculicenses > > you're using an old version of Django (pre-0.95), which is fine, but > > means you should refer to documents for the version you're using. I > > suggest this:http://www.djangoproject.com/documentation/0_91/ > > > Anyway, for #3, go find the module accukeys.py, find the class in it > > named AccuLicense, and add a field attribute for sales_person. > > > For #4, however you handle your DB migration, add the sales_person > > column to the DB; you should see mysql's docs for how to do that. > > > If you are new to programming, rather than asking a broad question > > hoping for a very specific solution, consider contracting to get the > > job done or taking the time to learn the tools. > > > We want to make Django easy to use, but even so, a fairly large amount > > of knowledge is assumed. > > > Cheers, > > Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
Thanks Jeremy, I will try out your suggestions. I am not new to programming, I am new to web programming and Django. I have done all four steps that your suggested before, I have just done #2 wrong. I will correct it now. Thanks. On Jun 12, 12:54 pm, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > On 6/12/07,strelok31<[EMAIL PROTECTED]> wrote: > > > > > Any ideas? I have been stuck on this for a while and I got nobody else > > to ask for help. Thanks again. > > If you're really stuck, you need pointers as much as you need a > solution; there really are many sources to find info on how to > accomplish this fairly simple task. > > General steps: > 1) add to html, which you've already done. > 2) add to python view, which you've done wrong. > 3) add to python model, which you probably haven't done. > 3) add to database, which you probably haven't done. > > For #2, this line: > sales_person = document.Submit.salespeople_dropdown.value > most certainly should be something like this: > sales_person = request.POST['salespeople_dropdown'] > > Based on this line: > from django.models.accukeys import acculicenses > you're using an old version of Django (pre-0.95), which is fine, but > means you should refer to documents for the version you're using. I > suggest this:http://www.djangoproject.com/documentation/0_91/ > > Anyway, for #3, go find the module accukeys.py, find the class in it > named AccuLicense, and add a field attribute for sales_person. > > For #4, however you handle your DB migration, add the sales_person > column to the DB; you should see mysql's docs for how to do that. > > If you are new to programming, rather than asking a broad question > hoping for a very specific solution, consider contracting to get the > job done or taking the time to learn the tools. > > We want to make Django easy to use, but even so, a fairly large amount > of knowledge is assumed. > > Cheers, > Jeremy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
Any ideas? I have been stuck on this for a while and I got nobody else to ask for help. Thanks again. On Jun 4, 8:47 am, strelok31 <[EMAIL PROTECTED]> wrote: > I wanted to see if people have any ideas, I am sorry if I was not very > clear in my explanation. > > My task is to add a drop down selection list to the > HTML page and the save the value selected to the MySQL database. > > I have added a drop down selection list. The problem that I am having > right now is how to capture the value selected by the user to be able > to store it in the database. In the way that the program is working > right now the file is being uploaded and the information in the file > is decrypted and saved to the database. I just need to figure out a > way to capture the value selected by the user and save it to the > database in the content of the program. Meaning so I don't have to > rewrite the whole program just make a small change. Right now the > program is reading an external file and saving information from there > to the database. > > Thank a lot. > > Russell Keith-Magee wrote: > > On 6/2/07,strelok31<[EMAIL PROTECTED]> wrote: > > > > Any ideas? > > > Let's get this straight: You send a multiple-page email, describing a > > large application, with a vague description of what it does, and a > > body of unindented Python code, and HTML that doesn't appear to come > > from a Django template. As a result of some changes (which you don't > > describe) you say it now "doesn't work" (in some unspecified way). > > > And three hours after your original post, you complain that you > > haven't gotten a response. > > > Have you considered that maybe you might be unreasonable in your > > expectations of a mailing list that is populated by volunteers? > > > Yours, > > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
I wanted to see if people have any ideas, I am sorry if I was not very clear in my explanation. My task is to add a drop down selection list to the HTML page and the save the value selected to the MySQL database. I have added a drop down selection list. The problem that I am having right now is how to capture the value selected by the user to be able to store it in the database. In the way that the program is working right now the file is being uploaded and the information in the file is decrypted and saved to the database. I just need to figure out a way to capture the value selected by the user and save it to the database in the content of the program. Meaning so I don't have to rewrite the whole program just make a small change. Right now the program is reading an external file and saving information from there to the database. Thank a lot. Russell Keith-Magee wrote: > On 6/2/07, strelok31 <[EMAIL PROTECTED]> wrote: > > > > Any ideas? > > Let's get this straight: You send a multiple-page email, describing a > large application, with a vague description of what it does, and a > body of unindented Python code, and HTML that doesn't appear to come > from a Django template. As a result of some changes (which you don't > describe) you say it now "doesn't work" (in some unspecified way). > > And three hours after your original post, you complain that you > haven't gotten a response. > > Have you considered that maybe you might be unreasonable in your > expectations of a mailing list that is populated by volunteers? > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a drop down selection list
Any ideas? On Jun 1, 8:17 am, strelok31 <[EMAIL PROTECTED]> wrote: > I inherited an application written in Python and I need to make a > change to it. The guy who created it is gone and I am not an expert in > Python. I was able to get one thing to work but I am having difficulty > with another part. I need to add a drop down selection list to the > HTML page and the save the value selected to the MySQL database. > Currently application reads the uploaded file, decrypts the info and > stores the results in MySQL database. The structure is already in > place I just need to add the drop down selection list. Any help would > be greatly appreciated. I have already added a field to the table. > > This is the code for the HTML page. Keyfile is the name of the file. > > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> > > http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> > > > > AccuRateS > > > > > AccuRateS - Upload License Key File > > Select file: name="keyfile"/> > Sales Person: > > Angelo > Debbie > James > Gabe > Mark H > Mike > Rob > Ron W > Yieciel > > > > > > > -- > -- > this is the python utility file that decrypts the info in the uploaded > file and generates a field dictionary for database insertion > > def load_file(fname): > '''Loads the AccuraRates license file, reads the first line and splits > the contents by colon''' > f = open(fname,'r') > line = f.readline() > line = line.replace('\r\n','') > return line.split(':') > > def load_string(s): > '''Loads the AccuraRates license file content passed as a string, > reads the first line and splits the contents by colon''' > s = s.replace('\r\n','') > return s.split(':') > > def parse_fields(l): > '''Takes a list of the data values in the AccuRateS and generates a > field dictionary for database insertion''' > import time, datetime > d = {'rio':'', > 'days_licensed':'', > 'volume_id':'', > 'keygen_date':'', > 'accu_id':'' > > } > > d['days_licensed'] = int(l[0]) # days_licensed > d['volume_id'] = l[1] # volume id > d['accu_id'] = l[(len(l)-1)] # accuid > d['rio'] = d['accu_id'][:-12] # rio code is accuid minus 12 digit > timestamp appendix > > # format keygen date > epochsecs = time.mktime( time.strptime(l[2], '%m/%d/%Y') ) > kgd = datetime.datetime.fromtimestamp(epochsecs).date() > d['keygen_date'] = kgd > > return d > > def parse_content(c): > # scrub the input string and split > l = load_string(c) > cleartext = decrypt_string(l[0],l[1]) > return parse_fields( cleartext.split(':') ) > > if __name__ == '__main__': > pass > > - > this is a python file where database insertion is done. But it does > not work after my changes > -- > # Create your views here. > from django.utils.httpwrappers import HttpResponse, > HttpResponseRedirect > from django.core.extensions import render_to_response > from django.core.extensions import DjangoContext > from django.core.exceptions import Http404 > from django.core.template import loader > from accurates.apps.accukeys import util > from django.models.accukeys import acculicenses > from django.views.decorators.auth import login_required > > def index(request): > t = loader.get_template("accukeys/index") > c = DjangoContext(request, {'foo':'yeah'}) > return HttpResponse(t.render(c)) > #return render_to_response("accukeys/index", {'foo':'yeah'}) > > def upload_key(request): > if not request.FILES.has_key('keyfile'): > raise Http404 > # get the file info > fileinfo = request.FILES['keyfile'] > try: > field_dict = util.parse_content(fileinfo['content']) > > # make a new accu_license object > al = acculicenses.AccuLicense( > rio=field_dict['rio'], > days_licensed=f
adding a drop down selection list
I inherited an application written in Python and I need to make a change to it. The guy who created it is gone and I am not an expert in Python. I was able to get one thing to work but I am having difficulty with another part. I need to add a drop down selection list to the HTML page and the save the value selected to the MySQL database. Currently application reads the uploaded file, decrypts the info and stores the results in MySQL database. The structure is already in place I just need to add the drop down selection list. Any help would be greatly appreciated. I have already added a field to the table. This is the code for the HTML page. Keyfile is the name of the file. http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";> http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en"> AccuRateS AccuRateS - Upload License Key File Select file: Sales Person: Angelo Debbie James Gabe Mark H Mike Rob Ron W Yieciel -- -- this is the python utility file that decrypts the info in the uploaded file and generates a field dictionary for database insertion def load_file(fname): '''Loads the AccuraRates license file, reads the first line and splits the contents by colon''' f = open(fname,'r') line = f.readline() line = line.replace('\r\n','') return line.split(':') def load_string(s): '''Loads the AccuraRates license file content passed as a string, reads the first line and splits the contents by colon''' s = s.replace('\r\n','') return s.split(':') def parse_fields(l): '''Takes a list of the data values in the AccuRateS and generates a field dictionary for database insertion''' import time, datetime d = {'rio':'', 'days_licensed':'', 'volume_id':'', 'keygen_date':'', 'accu_id':'' } d['days_licensed'] = int(l[0]) # days_licensed d['volume_id'] = l[1] # volume id d['accu_id'] = l[(len(l)-1)] # accuid d['rio'] = d['accu_id'][:-12] # rio code is accuid minus 12 digit timestamp appendix # format keygen date epochsecs = time.mktime( time.strptime(l[2], '%m/%d/%Y') ) kgd = datetime.datetime.fromtimestamp(epochsecs).date() d['keygen_date'] = kgd return d def parse_content(c): # scrub the input string and split l = load_string(c) cleartext = decrypt_string(l[0],l[1]) return parse_fields( cleartext.split(':') ) if __name__ == '__main__': pass - this is a python file where database insertion is done. But it does not work after my changes -- # Create your views here. from django.utils.httpwrappers import HttpResponse, HttpResponseRedirect from django.core.extensions import render_to_response from django.core.extensions import DjangoContext from django.core.exceptions import Http404 from django.core.template import loader from accurates.apps.accukeys import util from django.models.accukeys import acculicenses from django.views.decorators.auth import login_required def index(request): t = loader.get_template("accukeys/index") c = DjangoContext(request, {'foo':'yeah'}) return HttpResponse(t.render(c)) #return render_to_response("accukeys/index", {'foo':'yeah'}) def upload_key(request): if not request.FILES.has_key('keyfile'): raise Http404 # get the file info fileinfo = request.FILES['keyfile'] try: field_dict = util.parse_content(fileinfo['content']) # make a new accu_license object al = acculicenses.AccuLicense( rio=field_dict['rio'], days_licensed=field_dict['days_licensed'], volume_id=field_dict['volume_id'], keygen_date=field_dict['keygen_date'], accu_id=field_dict['accu_id'], sales_person = document.Submit.salespeople_dropdown.value # I added this line ) # commit to database al.save() # store in session request.session['license']=al return HttpResponseRedirect("/confirmation/") except: raise Http404 def confirmation(request): if 'license' in request.session: license = request.session['license'] else: license = None return render_to_response("accukeys/confirmation", {'license':license}) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---