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
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
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
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:
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:
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 =
>
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
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
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
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
> 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
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
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'
> 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
14 matches
Mail list logo