Saving POSTed Data

2007-06-06 Thread robo
I'm wondering if someone can help me out with a similar problem. I'm trying to save to 2 different models (Order and Order_Detail, where in Order_Detail there is a foreign key to Order) from one click of the Submit button. How would I distinguish the POSTed data between which form fields belong to

Re: Saving POSTed Data

2007-06-06 Thread robo
So when data containing fields from both models get POSTed. I would write (pseudo) code like so ?: if request.method == 'POST': ... Orders = form_for_model(Order) f = Orders(prefix='orders') Order_Details = form_for_model(Order_Detail) f2 = OrderDetails(prefix='order_details') ... f.save() f2.sav

Re: admin is inserting empty images

2007-06-07 Thread robo
Try removing the "core = True" in this line: image = models.ImageField(upload_to = 'section/image/', core = True) I had a similar, if not exact, problem that I posted about a month and a half ago. --~--~-~--~~~---~--~~ You received

Re: admin is inserting empty images

2007-06-07 Thread robo
Have you tried moving core=True to the foreignkey field? Tell me if this works. --~--~-~--~~~---~--~~ 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.co

Re: Saving POSTed Data

2007-06-12 Thread robo
This is my view code for this implementation: if request.method == 'POST': form1 = form_for_model(Order) Orders = form1(request.POST, prefix='orders') form2 = form_for_model(Order_Detail) Orders_Details = form2(request.POST, prefix='order_details') if Orders.is_valid():

Javascript-Django image paths

2007-06-24 Thread robo
Hi guys, I've got this piece of javascript code in my template file which is supposed to show an image upon a checkbox toggle: function show_img(suf, val) { img = document.getElementById('image_' + val); img.src = 'media/images/schematics/SKU' + suf + '.jpg'; } The i

Re: Javascript-Django image paths

2007-06-24 Thread robo
You've answered your question intended for me :P I've tried serving static files with as many combinations as I could think of in the following form: (r'^images/schematics/(?P.*)$', 'django.views.static.serve', {'document_root': '/www/htdocs/gfs_chefrevival/images/schematics'}), and matched it w

Re: Javascript-Django image paths

2007-06-25 Thread robo
> I don't mean to offend you, but I think you've misunderstood how the > web works. There's really no difference in the HTTP request of a > human clicking a link and the HTTP request caused by an image tag (or > javascript image.src assignment). I thought that way because I couldn't find any ot

Newforms Attribute Errors

2007-06-26 Thread robo
Hopefully you guys can spot an error I've not been able to. This is the error I get: AttributeError at /vendor/Chef/1/ 'Order_DetailForm' object has no attribute 'save' Request Method: POST Request URL: http://192.168.1.104:8000/vendor/Chef/1/ Exception Type: AttributeError Exception Value: 'Orde

Re: Newforms Attribute Errors

2007-06-27 Thread robo
Hi Malcolm, This is my traceback errors from copy&paste: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 74. response = callback(request, *callback_args, **callback_kwargs) File "/www/htdocs/gfs_chefrevival/../gfs_chefrevi

Re: Newforms Attribute Errors

2007-06-27 Thread robo
I've also tried abandoning form_for_model and created my own custom form like so in forms.py: from django import newforms as forms from django.newforms.widgets import * class OrderDetailForm(forms.Form): order = forms.IntegerField() quantity = forms.IntegerField() unitPrice = FloatField(la

Re: Problem with URL

2007-06-27 Thread robo
Yes, Alberto is right. Also, I ran into this problem a few days ago. Basically, after you write your view processing like Alberto suggested, you need to do a response redirect or HttpResponseRedirect and pass it "." (which is to the same page the user was on). After I did that on my form, the use

Re: Newforms Attribute Errors

2007-06-27 Thread robo
In python shell I typed: >> from gfs_chefrevival.shop.forms import OrderDetailForm >> from django import newforms as forms >> f = OrderDetailForm() >> f.is_bound I get the error: Traceback (most recent call last): File "", line 1, in ? AttributeError: 'lineItemPrice' object has no attribute 'i

Re: Newforms Attribute Errors

2007-06-28 Thread robo
You tried, thanks! The errors I get come before any major piece of code. They come after some simple statements: OrderDetailForm = form_for_model(Order_Detail) f = OrderDetailForm() f.save() f.is_bound which means my 0.96-pre (not a typo :) ) version might not be up to the challenge of newforms.

Re: Newforms Attribute Errors

2007-07-06 Thread robo
. Regards, Robo ps: thanks everyone who tried to help! --~--~-~--~~~---~--~~ 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

Importing Excel/CVS into Database

2007-08-21 Thread robo
Hi, Have any of you guys imported excel/cvs by using Python/Django? I need to import 1000 products for a shopping site and I'd like to learn the fastest and easiest way to do so. Is there any free/shareware programs you guys would recommend? Thanks. --~--~-~--~~~--

Re: Importing Excel/CVS into Database

2007-08-23 Thread robo
the fieldname1 to fieldname3 would be the data from "first", "last", and "phone"? **Amirouche, your method is similar to Ben's, could you give me some examples? Thanks -Robo --~--~-~--~~~---~--~~ You received this message beca

Re: Importing Excel/CVS into Database

2007-08-24 Thread robo
t cursor.execute(""" INSERT INTO people (first, last, phone, email) VALUES (%s, %s, %s, %s) """, (data_first, data_last, data_phone, data_email) ) return "Job Finished" This

Re: Importing Excel/CVS into Database

2007-08-24 Thread robo
e its catching blank/empty lines because the print statements aren't executed. What is the appropriate way to catch blank/empty lines? Thanks, - robo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

Re: Importing Excel/CVS into Database

2007-08-24 Thread robo
Wow, your tip works like a charm. Do you personally know of a good tutorial that teaches things like this? I'd like to read them. Thanks, - robo On Aug 24, 2:54 pm, Boris Samorodov <[EMAIL PROTECTED]> wrote: > Hi, All! > > On Fri, 24 Aug 2007 21:05:07 - robo wrote: >

Images being overridden

2007-05-07 Thread robo
I have to temporarily settle for this fix. That's 1 problem, the other is that only one caption gets displayed for all images shown, and I can see why because pict.caption never iterates. How can I display images along with their distinct caption? Thank you in advance, robo. --~--~-

How to Display 2 items of an Object

2007-05-17 Thread robo
Hi everyone, I've set up my code to display a page that shows all categories and projects belonging to each category. Pseudo code like so: for category in category for project in project ifequal project.category_id category.id {{project.title}} endifequal endfor endfor Right no

Re: How to Display 2 items of an Object

2007-05-18 Thread robo
Hi Kelvin, > You could limit the list from the query ... Model.objects.all()[:2] I have tried Project.objects.all()[:3] in hopes that the 3rd time through the loop, it would show the "see more ..." link. But what this actually gives me is the first 3 projects, not 3 projects for each category. H

Re: How to Display 2 items of an Object

2007-05-19 Thread robo
I assume you guys also know python. If so, I wish to get some help with this implementation: What I want to return is a new variable each time through the for loop: catQuantity = len(categoryList) for x in catQuantity: cat(x) = get_object_or_404(Category, cat_order=x) return cat(x) Thi

Re: How to Display 2 items of an Object

2007-05-21 Thread robo
Great ideas! Thanks Kelvin. I'll definitely try it out and post the results here, robo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Django Forms

2007-05-24 Thread robo
Hi everyone. for the code below at http://www.djangoproject.com/documentation/forms/ def create_place(request): manipulator = Place.AddManipulator() if request.method == 'POST': # If data was POSTed, we're trying to create a new Place. new_data = request.POST.copy()

Re: Django Forms

2007-05-25 Thread robo
Thanks guys! I will mess around with it more to get the feel. --~--~-~--~~~---~--~~ 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

Having Django iterate through JSON possible?

2007-09-14 Thread robo
hrPost(form_data); } Right now the way my template displays JSON is by using innerHTML as above. But I would like to convert the data somehow so that Django can iterate in the {{...}} syntax. Thanks, robo --~--~-~--~~~---~--~~ You received this message becaus

Re: Having Django iterate through JSON possible?

2007-09-14 Thread robo
Hi Richard, Can you give an example of what you are suggesting? > One thing that you can do is to pass a > render_to_response call a template and the python dictionary you want > modified and let django work its majic on it before returning the > '._container' to the page via json. Thanks. To

Re: Having Django iterate through JSON possible?

2007-09-18 Thread robo
Hi Richard, I think I got the idea of your view. What I'd like to see is an example of your template and javascript to see how you are accessing the json data. Thanks a lot, robo --~--~-~--~~~---~--~~ You received this message because you are subscribed t

Re: Having Django iterate through JSON possible?

2007-09-19 Thread robo
n, I ALWAYS get errors no matter what. The code is as simple as this: def ajax_form_test(request): data = Manager.objects.all() return HttpResponse(simplejson.dumps(data), mimetype="application/ javascript") Help me solve this bizzare mystery! Thanks, robo --~--~-~--~~~-

Re: Having Django iterate through JSON possible?

2007-09-19 Thread robo
Hmm ... I tested these in non-Django templates and Django itself gave me no errors. But now that I've tested it on a Django template, it's giving me "Decimal("0.00") is not JSON serializable" errors. --~--~-~--~~~---~--~~ You received this message because you are

Re: Having Django iterate through JSON possible?

2007-09-20 Thread robo
nt to use it: from dev_gfs.shop.json import json_encode def hello(): return HttpResponse(json_encode(OrderDetail.objects.all()), mimetype="application/javascript") To Russel: you said that this decimal serialization issue was fixed a long time ago. How so?