Django

Code

Ticket #5622 (new)

Opened 8 months ago

Last modified 5 months ago

empty ipaddress raises an error (invalid input syntax for type inet: "")

Reported by: anonymous Assigned to: anonymous
Component: Database wrapper Version: SVN
Keywords: sprintdec01, postgresql Cc:
Triage Stage: Design decision needed Has patch: 1
Needs documentation: 0 Needs tests: 1
Patch needs improvement: 0

Description

That is - the admin interface raises an exception when saving an object with an empty IPAddressField

Attachments

5622.patch (0.5 kB) - added by toke on 12/01/07 18:59:42.
5622.1.patch (420 bytes) - added by toke on 12/10/07 16:40:59.
Alternative Patch at newforms-level

Change History

09/27/07 05:48:27 changed by anonymous

  • needs_better_patch changed.
  • component changed from Uncategorized to Admin interface.
  • needs_tests changed.
  • needs_docs changed.

(follow-up: ↓ 3 ) 09/27/07 21:57:19 changed by ubernostrum

  • status changed from new to closed.
  • resolution set to invalid.

Sounds like you've perhaps set blank=True on the field and forgotten to supply a fallback value elsewhere in your code. Please ask -- with detailed information -- on the django-users mailing list.

(in reply to: ↑ 2 ) 09/28/07 03:36:19 changed by anonymous

  • status changed from closed to reopened.
  • resolution deleted.

Replying to ubernostrum:

Sounds like you've perhaps set blank=True on the field and forgotten to supply a fallback value elsewhere in your code. Please ask -- with detailed information -- on the django-users mailing list.

the model definition has this field:

reported_ip = models.IPAddressField(blank=True, null=True, default=None)

The problem is that when i edit an object containing this field, in the admin site, i want to be able to leave this field empty. I'm only working with models definition and I don't have other code.

12/01/07 09:27:57 changed by toke

  • keywords set to sprintdec01.
  • status changed from reopened to closed.
  • resolution set to worksforme.

I can not reproduce this with newforms-admin [6783].

class Host(models.Model):
    name = models.CharField(maxlength=100)
    ip = models.IPAddressField(blank=True, null=True, default=None)

Create, Update, Delete. Maybe the Database-Field is "NOT NULL"?

(follow-up: ↓ 6 ) 12/01/07 09:47:44 changed by anonymous

  • status changed from closed to reopened.
  • resolution deleted.

It's an Postgresql issue. When using postgresql_psycopg2 the described error will occour. Not in sqlite3!

(in reply to: ↑ 5 ) 12/01/07 09:49:27 changed by toke

  • keywords changed from sprintdec01 to sprintdec01, postgresql.

Replying to anonymous:

It's an Postgresql issue. When using postgresql_psycopg2 the described error will occour. Not in sqlite3!

That was me.

12/01/07 10:10:50 changed by toke

  • stage changed from Unreviewed to Design decision needed.

Postgresql inet type don't allow empty inet fields. Null is OK. Should an empty string in the admin be converted to a NULL value in the DB?

http://www.postgresql.org/docs/7.4/interactive/datatype-net-types.html#DATATYPE-INET

12/01/07 10:19:17 changed by toke

See also #4684

12/01/07 11:47:02 changed by toke

  • owner changed from nobody to toke.
  • status changed from reopened to new.

12/01/07 18:59:42 changed by toke

  • attachment 5622.patch added.

12/01/07 19:00:10 changed by toke

  • has_patch set to 1.

12/01/07 19:58:40 changed by toke

  • component changed from Admin interface to Database wrapper.

This Problem applies to whole newforms. In oldforms this is AFAIK handled by html2python.

Maybe more such Bugs?

12/02/07 06:20:20 changed by anonymous

  • owner changed from toke to anonymous.

12/10/07 10:51:24 changed by brosner

  • version changed from newforms-admin to SVN.
  • component changed from Database wrapper to django.newforms.

This looks to be a bug in newforms and not only newforms-admin. Moving it out of newforms-admin.

12/10/07 16:40:59 changed by toke

  • attachment 5622.1.patch added.

Alternative Patch at newforms-level

12/10/07 16:44:35 changed by toke

The alternative Patch solves the same issue as the first one.

IMHO it's a issue at the database layer (the data representation in the database) so I would tend to fix such things at db-layer.

12/10/07 18:24:16 changed by SmileyChris

  • component changed from django.newforms to Database wrapper.
  • needs_tests set to 1.

Needs some tests to show the problem being solved. On the surface, it looks like this should work, since IPAddressField has empty_strings_allowed = False

I concur that it should be fixed at the db level.


Add/Change #5622 (empty ipaddress raises an error (invalid input syntax for type inet: ""))




Change Properties
Action