Re: JSONField: which app to choose ?

2012-07-11 Thread Michael Palumbo
Hi Matt,

Correct, using either null=True or blank=True on the field works.
However, I don't get it since I didn't click on "save", I just wanted to 
display the add page containing it. Why does it attempt to validate the 
field at this time and not wait for the form to be sent ? Maybe this is how 
Django works ?

Whatever, I think you can set a default value in the JSONField to avoid the 
error, what do you think ? I think it's handy.
improvement:
def __init__(self, *args, **kwargs):
kwargs['default'] = kwargs.get('default', '{}')
super(JSONField, self).__init__(*args, **kwargs)

It works for me.

Another point: it does not like "extra" comma right ?
{
  "nodes": { "title": "title"*,* }
}
But I guess this is wanted because JSON does not allow it ?


Michael

 

Le mercredi 11 juillet 2012 09:15:23 UTC+2, Matt Schinckel a écrit :
>
> Michael,
>
> I've been able to reproduce it: I'm not quite sure of the best way to deal 
> with it.
>
> One solution is to set either null=True, or blank=True on the field, or 
> set a default.
>
> The trick is, an empty string isn't valid JSON. I guess I've always been 
> using a default (usually of {} or [], depending upon context).
>
> Happy for you to suggest improvements, though.
>
> I believe it's actually related to 
> https://bitbucket.org/schinckel/django-jsonfield/issue/13/integrityerrors-when-using-empty-string
>
> Matt.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/OpX1uuzKTyEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: JSONField: which app to choose ?

2012-07-11 Thread Matt Schinckel
Michael,

I've been able to reproduce it: I'm not quite sure of the best way to deal 
with it.

One solution is to set either null=True, or blank=True on the field, or set 
a default.

The trick is, an empty string isn't valid JSON. I guess I've always been 
using a default (usually of {} or [], depending upon context).

Happy for you to suggest improvements, though.

I believe it's actually related 
to 
https://bitbucket.org/schinckel/django-jsonfield/issue/13/integrityerrors-when-using-empty-string

Matt.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/tymGeL-UuCgJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: JSONField: which app to choose ?

2012-07-11 Thread Matt Schinckel
Hi Michael.

It should 'just work' in the admin: I'm using it fairly extensively, and 
most of our access is through the admin (or a JSON api).

If we can get a minimal failing test, then I'll make sure it gets fixed.

(And thanks, Reinout, for the referral/comment)

Matt.


On Wednesday, July 11, 2012 7:21:45 AM UTC+9:30, Michael Palumbo wrote:
>
> Can you get it work in the admin ?
> I don't understand why I get a ValidationError  "[u"'' is not a valid JSON 
> string."] as soon as I try to reach the Add admin page of my Model...
>
> import jsonfield
> class Mapping(models.Model):
> data_map4 = jsonfield.JSONField()
> -
> class MappingAdmin(admin.ModelAdmin):
> fields = ['data_map4']
> list_display = ('data_map4',)
>
> Thanks.
>
> Le mardi 10 juillet 2012 22:08:50 UTC+2, Reinout van Rees a écrit :
>>
>> On 09-07-12 20:52, Michael Palumbo wrote: 
>> > Hi, 
>> > 
>> > I have found several implementations of a Django JSON Field. 
>> > Have you ever tried one ? Which one do you recommend ? 
>>
>> I'm using the 'django-jsonfield' on pypi: 
>> http://pypi.python.org/pypi/django-jsonfield/  
>>
>> It is https://bitbucket.org/schinckel/django-jsonfield/  on bitbucket. 
>> I looked at it with a colleague and it seemed to have a bit more 
>> validation than some others. Little things. 
>>
>>
>> Reinout 
>>
>> -- 
>> Reinout van Reeshttp://reinout.vanrees.org/  
>> rein...@vanrees.org http://www.nelen-schuurmans.nl/  
>> "If you're not sure what to do, make something. -- Paul Graham" 
>>
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/4PanQBEU2swJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: JSONField: which app to choose ?

2012-07-10 Thread Michael Palumbo
Can you get it work in the admin ?
I don't understand why I get a ValidationError  "[u"'' is not a valid JSON 
string."] as soon as I try to reach the Add admin page of my Model...

import jsonfield
class Mapping(models.Model):
data_map4 = jsonfield.JSONField()
-
class MappingAdmin(admin.ModelAdmin):
fields = ['data_map4']
list_display = ('data_map4',)

Thanks.

Le mardi 10 juillet 2012 22:08:50 UTC+2, Reinout van Rees a écrit :
>
> On 09-07-12 20:52, Michael Palumbo wrote: 
> > Hi, 
> > 
> > I have found several implementations of a Django JSON Field. 
> > Have you ever tried one ? Which one do you recommend ? 
>
> I'm using the 'django-jsonfield' on pypi: 
> http://pypi.python.org/pypi/django-jsonfield/  
>
> It is https://bitbucket.org/schinckel/django-jsonfield/  on bitbucket. 
> I looked at it with a colleague and it seemed to have a bit more 
> validation than some others. Little things. 
>
>
> Reinout 
>
> -- 
> Reinout van Reeshttp://reinout.vanrees.org/  
> rein...@vanrees.org http://www.nelen-schuurmans.nl/  
> "If you're not sure what to do, make something. -- Paul Graham" 
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sgpU7kPSQRUJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: JSONField: which app to choose ?

2012-07-10 Thread Reinout van Rees

On 09-07-12 20:52, Michael Palumbo wrote:

Hi,

I have found several implementations of a Django JSON Field.
Have you ever tried one ? Which one do you recommend ?


I'm using the 'django-jsonfield' on pypi:
http://pypi.python.org/pypi/django-jsonfield/

It is https://bitbucket.org/schinckel/django-jsonfield/ on bitbucket.
I looked at it with a colleague and it seemed to have a bit more 
validation than some others. Little things.



Reinout

--
Reinout van Reeshttp://reinout.vanrees.org/
rein...@vanrees.org http://www.nelen-schuurmans.nl/
"If you're not sure what to do, make something. -- Paul Graham"



--
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.