Re: Zip code lookup field

2007-06-27 Thread leif strickland
I figured it out! The problem was that my custom zip code field's clean() function was returning the profile object's *id*, not the actual zip code instance. > zip_code_id = Postal_Code.objects.get(postal_code=value).id > return int(zip_code_id) As it turns out, the function should have

Re: Zip code lookup field

2007-06-27 Thread leif strickland
Here's a bit of the testing I have run in the shell... >>> from mysite2.profile.models import Profile >>> from django import newforms >>> from mysite2.admin import ProfileOptions >>> # instantiate a Profile object >>> test_profile = Profile.objects.get(id=1) >>> # instantiate the adminoptions

Re: Zip code lookup field

2007-06-27 Thread leif strickland
Here's a bit of the testing I have run in the shell... >>> from mysite2.profile.models import Profile >>> from django import newformms >>> from mysite2.admin import ProfileOptions >>> >>> # instantiate a Profile object >>> test_profile = Profile.objects.get(id=1) >>> >>> # instantiate the

Re: Zip code lookup field

2007-06-27 Thread leif strickland
Yes, the ModelAdmin is registered with django.contrib.admin.site. And the change and add pages for the model are displaying correctly. It even provides the expected error message if I enter an invalid Zip code. But when I enter a correct Zip code and Save, it gives me an Integrity Error:

Re: Zip code lookup field

2007-06-27 Thread leif strickland
Yes, the ModelAdmin is registered with django.contrib.admin.site. And the change and add pages for the model are displaying correctly. It even provides the expected error message if I enter an invalid Zip code. But when I enter a correct Zip code and Save, it gives me an Integrity Error:

Re: Zip code lookup field

2007-06-27 Thread Jeremy Dunck
On 6/27/07, leif strickland <[EMAIL PROTECTED]> wrote: ... > zip_code_id = > Postal_Code.objects.get(postal_code=value).id Is Postal_Code.postal_code a string or numeric? ... > try: > zip_code = Postal_Code.objects.get(id = >

Re: Zip code lookup field

2007-06-27 Thread leif strickland
OK, I've been tinkering with this all day, and I'm still having one big problem As Jeremy suggested, I created custom ZipCodeField and MyAdmin classes. In addition, I created a custom ZipcodeLookupInput widget. I've tested this in the shell and on the test server, and the clean and render

Re: Zip code lookup field

2007-06-27 Thread leif strickland
OK, I've been tinkering with this all day, and I'm still having one big problem As Jeremy suggested, I created custom ZipCodeField and MyAdmin classes. In addition, I created a custom ZipcodeLookupInput widget. I've tested this in the shell and on the test server, and the clean and render

Re: Zip code lookup field

2007-06-27 Thread leif
Great advice -- thanks! I'll work on it today and let you know how it comes together. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Zip code lookup field

2007-06-27 Thread Jeremy Dunck
On 6/27/07, leif <[EMAIL PROTECTED]> wrote: ... > Thanks for the input, Jeremy. I've actually decided to use newforms- > admin since I won't be going to production for another few months Sorry for missing that the first time. :) Admin uses django.newforms.models.form_for_model, which takes an

Re: Zip code lookup field

2007-06-27 Thread leif
> Django's existing admin uses oldforms. The newforms-admin branch is > working to rewrite admin to be more flexible and use newforms. If you > need it on trunk now, you'll need to use oldforms. Thanks for the input, Jeremy. I've actually decided to use newforms- admin since I won't be going

Re: Zip code lookup field

2007-06-26 Thread Jeremy Dunck
On 6/26/07, leif <[EMAIL PROTECTED]> wrote: > My main problem, though, is figuring out how to create a text input > lookup field for the ZIP code foreign key. > Do I need to code a new > widget? A new form field class? A function to hook into newforms' > validation? > And if I create a widget

Re: Zip code lookup field

2007-06-26 Thread leif
Very good point, Tim. I'll consider that issue as I move forward with my application. My main problem, though, is figuring out how to create a text input lookup field for the ZIP code foreign key. Do I need to code a new widget? A new form field class? A function to hook into newforms'

Re: Zip code lookup field

2007-06-26 Thread Tim Chase
> My question, then, is this: What's the most elegant way to > pull off this hack? By the way, I am using newforms and the > newforms-admin branch. (I want my customizations to work with > 1.0 and beyond.) Generally, zip-codes and cities have a one-to-one correspondence. However, this isn't