On 19 Jan 2014 00:18, "François Schiettecatte"
wrote:
>
> Hi
>
> IANA says the JSON mime type be application/json, so you might want to
use that.
>
> application/javascript should be for javascript.
Yes thats true. My bad.
>
>
> François
>
> On Jan 18, 2014, at 12:05 PM, Babatunde Akinyanmi
wro
Hi
IANA says the JSON mime type be application/json, so you might want to use that.
application/javascript should be for javascript.
François
On Jan 18, 2014, at 12:05 PM, Babatunde Akinyanmi wrote:
> https://docs.djangoproject.com/en/1.6/ref/request-response/#usage
>
> Actually, Google is
https://docs.djangoproject.com/en/1.6/ref/request-response/#usage
Actually, Google is your friend.
On 18 Jan 2014 19:48, "Igor Korot" wrote:
> Hi, Babatunde,
>
> On Sat, Jan 18, 2014 at 8:32 AM, Babatunde Akinyanmi
> wrote:
> > Thats probably because you are returning the json as a context in a
Hi, Babatunde,
On Sat, Jan 18, 2014 at 8:32 AM, Babatunde Akinyanmi
wrote:
> Thats probably because you are returning the json as a context in a response
> with the default "text/html" mime type. Your response should have mime type
> as " application/javascript".
> Your json data should be in the
Thats probably because you are returning the json as a context in a
response with the default "text/html" mime type. Your response should have
mime type as " application/javascript".
Your json data should be in the response
On 18 Jan 2014 09:16, "Igor Korot" wrote:
Hi, guys,
On Sat, Jan 18, 2014
Hi, guys,
On Sat, Jan 18, 2014 at 12:02 AM, Babatunde Akinyanmi
wrote:
>
> On 18 Jan 2014 08:32, "Mario Gudelj" wrote:
>>
>> In your template try {{usb_data|safe}}
>
> ...because django escapes everything in the template by default except
> you ask not to. One of the methods of doing so if b
On 18 Jan 2014 08:32, "Mario Gudelj" wrote:
>
> In your template try {{usb_data|safe}}
...because django escapes everything in the template by default except
you ask not to. One of the methods of doing so if by using the `safe`
filter like Mario suggested.
You can read the documentation on ho
In your template try {{usb_data|safe}}
On 18/01/2014 4:53 pm, "Igor Korot" wrote:
> Hi, ALL,
> I'd like someone to help me understand this situation.
> Looking at the page:
> https://docs.djangoproject.com/en/dev/topics/serialization/ the part
> which says "Serialization formats->JSON" there is a
Hi, ALL,
I'd like someone to help me understand this situation.
Looking at the page:
https://docs.djangoproject.com/en/dev/topics/serialization/ the part which
says "Serialization formats->JSON" there is an example of how the data
would be serialized.
The sample uses the symbol "double quotation
Thank you a lot for this snippet!
I've wondered about how to export objects to excel in a "more natural way"
and this seems to be a great approach, considering all the different
gotchas.
Thank you for taking the time to write this.. I've been postponing this
little bit of research for the longest
Thank you for the suggestion.
I actually ended up extending Django's json serializer. Here is the
code in case you or someone else needs to do something like this.
from django.core.serializers.json import Serializer as JsonSerializer
from django.utils.encoding import is_protected_type
class Displ
> The response is something like:
> 'Content-Type: text/html; charset=utf-8\n\n[{"pk": 1, "model":
> "MyApp.foo", "fields": {"choice_field": "db_name1"}}]'
This is interesting.. But I think the serializer is working properly.
the first element in the tuple is the value stored in the database,
and
Hello,
I'm new to Django and having a problem with serialization.
I am trying to serialize a model that has a CharField with choices,
and the json serializer returns json with the choices' database values
instead of display values.
Is there a way to get the json serializer to use the choices's di
On Tue, May 24, 2011 at 8:36 AM, Sells, Fred
wrote:
> My code looks like this
>
> records = models.Residents.objects.extra( where=[], params=[...])
> data = serializers.serialize('json', records, ensure_ascii=False,
> fields=('fname','lname', 'pt'))
> return HttpResponse(data)
>
> After experi
I'm using AJAX, jquery and JSON for the first time, having used
templates to render XML for Flex/Flash in all my previous Django work.
My code looks like this
records = models.Residents.objects.extra( where=[], params=[...])
data = serializers.serialize('json', records, ensure_ascii=False,
fie
>
> class Serializer(PythonSerializer):
> def end_object(self, obj):
> self.objects.append({
> "fields" : self._current
> })
> self._current = None
>
>
I've made a small mistake I was importing PythonSerializer while It should've
been JsonSerializer
C
>
> Your idea of overriding the Serializer class sounds like a better idea to me.
> It should be possible (and will be interesting) ,I'll think I'll look into
> that tonight.
Overwriting django's default serializers is possible.
This is how I've done it:
In the root of my django project:
mkd
Hi !
I have written a small library that (among other transformations) can
serialize django objects to dict (then you can just use 'json' to make
your dict to a json string) :
Docs on readthedocs :
http://readthedocs.org/docs/any2any/en/latest/doc_pages/djangocast.html
Pypi page : http://pypi.py
On Thu, May 19, 2011 at 1:23 PM, Jonas Geiregat wrote:
> Hello,
> I'm also finding the built in serialization a bit overhead.
Me too! I use a simple HttpResponse subclass for generating JSON though:
from django.http import HttpResponse
from django.utils import simplejson
class JsonResponse(Htt
Hello,
I'm also finding the built in serialization a bit overhead. It puts to much
information in your JSON string that can be modified such as the PK field.
I often import json ( http://docs.python.org/library/json.html ) and serialize
the data myself before passing it to the render method.
Th
I'm trying to return some JSON from one of my views. My objects are
simple and I can get the built-in json serializer working, but wanted
a cleaner object when I deserialize in my webpage, i.e. I don't want
the pk or model entries. What is the best way to go about that? I
played around a little wit
>
> sorry for the confusion.
>
> Sasha Bolotnovwww.gorizont-zavalen.ru
>
> On Sun, Feb 27, 2011 at 2:38 AM, Russell Keith-Magee <
>
>
>
>
>
>
>
> russ...@keith-magee.com> wrote:
> > On Sun, Feb 27, 2011 at 5:30 AM, Alexander Bolotnov
> > wro
On Sun, Feb 27, 2011 at 2:38 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:
> On Sun, Feb 27, 2011 at 5:30 AM, Alexander Bolotnov
> wrote:
> > Is there a way to control json serialization in django? Simple code below
> > will return serialized object in json:
&
On Sun, Feb 27, 2011 at 5:30 AM, Alexander Bolotnov wrote:
> Is there a way to control json serialization in django? Simple code below
> will return serialized object in json:
I've just answered this on django-developers. For the record,
cross-posting topics like this isn't en
Thanks Mike.
The issue is the inflexible handling of fk entries of a model by the
django serializer or more accurately PythonSerializer. The behavior is
inherited by json and xml serializers the same. I've eventually
resorted to rewriting the whole serialization to make it a better fit
for my aja
On Tuesday 01 September 2009 12:29:56 pm Amir Habibi wrote:
> How can I serialize a Queryset along with the related records. For
> example, in Poll and Choice case, I need each poll to have the choices
> encoded in json format.
>
> Thanks
>
you'll want to look at the docs on serialization [1], it
How can I serialize a Queryset along with the related records. For
example, in Poll and Choice case, I need each poll to have the choices
encoded in json format.
Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
When I have arrays of 100,000+ the performance of lists gets
unacceptable in standard c python. That's why arrays exist in python!
After doing research and testing, I have decided to rebuild the
project in java with embedded jython. For some bizarre reason jython
performance increases with large
what's wrong with turning it into a list? If you gzip it it won't be
that big.
On Aug 25, 5:16 pm, John Baker wrote:
> I need to json serialize some very large objects which include large
> arrays. How can I do this in django? The arrays will be very big and
> heavily processed before so need to
I need to json serialize some very large objects which include large
arrays. How can I do this in django? The arrays will be very big and
heavily processed before so need to use efficient array storage.
Testing with arrays I get..
TypeError at /zeros/
array([ 0., 0., 0., 0., 0., 0., 0.,
The reason I'm trying it is due to a requirement, the data rather than
being sent using a normal post request in a multienc form has to be sent
over in a json string
in the post request containing the base64 encoded image.
On Mon, 2009-08-24 at 18:38 +0200, Maksymus007 wrote:
> On Tue, Aug 4, 200
On Tue, Aug 4, 2009 at 10:58 PM, scuzz wrote:
>
> Hi,
>
> I'm trying to receive a file encoded in a json string and store it in
> an ImageField. I was hoping to use the standard Django deserialisation
> like:
>
> serializers.deserialize("json", "...snip..., \"myImageField\":
> \"base64encodedimage
Did you find a way to do this? I'm having the same problem.
Lewis
On Aug 4, 9:58 pm, scuzz wrote:
> Hi,
>
> I'm trying to receive a file encoded in a json string and store it in
> an ImageField. I was hoping to use the standard Django deserialisation
> like:
>
> serializers.deserialize("json",
Hi,
I'm trying to receive a file encoded in a json string and store it in
an ImageField. I was hoping to use the standard Django deserialisation
like:
serializers.deserialize("json", "...snip..., \"myImageField\":
\"base64encodedimage\", ...snip...)
however it tries to store the image content s
But before, is it possible to serialize a form in JSON ?
Thanks
--~--~-~--~~~---~--~~
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
But beforce, is it possible to serialise a form in JSON ?
Thanks
On 11 fév, 00:50, adrian wrote:
> Thank you all for posting this. You saved me probably hours of head
> scratching.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the
sn't seem
> > like Django does this.
>
> > I just wanted to get a general consensus on how people are tackling
> > this in the real world, really. I am personally going to probably go
> > the route of a custom serializer, probably something like
> > this:h
neral consensus on how people are tackling
> this in the real world, really. I am personally going to probably go
> the route of a custom serializer, probably something like
> this:http://wolfram.kriesing.de/blog/index.php/2007/json-serialization-for
>
I have already written a c
Obviously I was tired when I wrote this. I apologize for the
grammatical errors, which were a-plenty.
On Feb 12, 5:51 pm, Russell Keith-Magee
wrote:
> On Thu, Feb 12, 2009 at 10:17 PM, django_fo...@codechimp.net
>
>
>
> wrote:
>
> > I wanted to get the communities thoughts on this subject. I
/wolfram.kriesing.de/blog/index.php/2007/json-serialization-for-django.
On Feb 12, 5:51 pm, Russell Keith-Magee
wrote:
> On Thu, Feb 12, 2009 at 10:17 PM, django_fo...@codechimp.net
>
>
>
> wrote:
>
> > I wanted to get the communities thoughts on this subject. I a
On Thu, Feb 12, 2009 at 10:17 PM, django_fo...@codechimp.net
wrote:
>
> I wanted to get the communities thoughts on this subject. I am
> working on a simple site that has news articles, each of which has a
> reference to a User object provided by django.contrib.auth that is the
> author of the n
I wanted to get the communities thoughts on this subject. I am
working on a simple site that has news articles, each of which has a
reference to a User object provided by django.contrib.auth that is the
author of the news article. This is done right now using the
following code:
class NewsArtic
Thank you all for posting this. You saved me probably hours of head
scratching.
--~--~-~--~~~---~--~~
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
I ran into this same problem but the code snippets you guys gave
weren't working. In case anyone is reading this in the future, here is
what you want:
dict([(k, [unicode(e) for e in v]) for k,v in errors.items()])
The above line will give a dictionary of field names mapping to lists
of errors.
On Dec 28, 10:01 am, "Russell Keith-Magee"
wrote:
> On Sun, Dec 28, 2008 at 5:32 AM, adambossy wrote:
>
> > Russ,
>
> > Thanks for the reply. Specifically, I am wondering if there is some
> > feature of the Models API that allows me to retrieve the foreign key
> > object so that it is included
On Sun, Dec 28, 2008 at 5:32 AM, adambossy wrote:
>
> Russ,
>
> Thanks for the reply. Specifically, I am wondering if there is some
> feature of the Models API that allows me to retrieve the foreign key
> object so that it is included in the serialized string. That is,
> without writing my own se
Russ,
Thanks for the reply. Specifically, I am wondering if there is some
feature of the Models API that allows me to retrieve the foreign key
object so that it is included in the serialized string. That is,
without writing my own serializer (which I suspect I may have to do).
Alternatively, I wa
On Sat, Dec 27, 2008 at 2:11 PM, adambossy wrote:
>
> I have a model that refers to a ForeignKey, e.g.:
>
> class Template(models.Model):
> type = models.ForeignKey(Type)
> ...
>
> class Type(models.Model)
> name = models.CharField(max_length=32)
> ...
>
> I can fetch these objects fine using t
I have a model that refers to a ForeignKey, e.g.:
class Template(models.Model):
type = models.ForeignKey(Type)
...
class Type(models.Model)
name = models.CharField(max_length=32)
...
I can fetch these objects fine using the model API.
t = Template.objects.get(id=1)
print t.type
>>
print t
Hi Russell,
I bumped into the same issue today and was glad I found this post.
However, I found that I had to use unicode() rather than str(),
which turns your example into:
content = dict((key, [unicode(v) for v in values]) \
for key, values in
form.error
On Sun, Oct 19, 2008 at 12:58 AM, justind <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> No one has any ideas?
Settle down, Tiger. You asked this question on a Friday night. You may
need to wait a little more than 18 hours if you want a response.
We're all volunteers here, and many of us have professi
Actually the test form is (I forgot to change the name)
class MyForm(forms.Form):
text = forms.CharField()
link = forms.URLField()
On Oct 18, 4:21 pm, justind <[EMAIL PROTECTED]> wrote:
> I get exactly the same thing.
>
> Here's what I'm entering.
>
> >>> import simplejson
> >>> simple
I get exactly the same thing.
Here's what I'm entering.
>>> import simplejson
>>> simplejson
>>> from myproject.app.models import MyForm
>>> f = MyForm({'link': 'footext'})
>>> f.errors
{'text': [u'This field is required.'], 'link': [u'Enter a valid
URL.']}
>>> simplejson.dumps(f.errors)
Trace
Could you try this with simplejson not bundled with Django? If that works
this is probably a bug in the version bundled with Django.
On Sat, Oct 18, 2008 at 6:58 PM, justind <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> No one has any ideas?
>
> The code I'm actually using in my view is almost identic
Hello,
No one has any ideas?
The code I'm actually using in my view is almost identical to the
validage_contact view from
http://toys.jacobian.org/presentations/2007/oscon/tutorial/ (single
slide:
http://toys.jacobian.org/presentations/2007/oscon/tutorial/images/django-master-class.081.png)
and
Hello,
I'm having a hard time understanding why Django won't let me serialize
a dictionary of form errors. Can anyone explain why Django throws an
error if I try to serialize someform.errors, even if I copy it into a
plain dictionary?
#!/usr/bin/env python
from django.utils import simplejson
fro
After doing more searching I ran across this post, claiming that the
ensure_ascii argument was worthless and caused the bug. I removed it
from the argument list and all is well!!
http://groups.google.com/group/django-users/browse_thread/thread/87b1478c02d743e0/e4849fcf74147466?lnk=gst&q=unicode+
Does anyone have any idea about this one? I'm kind of in a bind on
this one.
Thanks!
Gabe
On Aug 30, 2:12 pm, mynameisgabe <[EMAIL PROTECTED]> wrote:
> Hello All-
>
> I've been told that I may have encountered abug- I'm trying to
> serialize a model that includes fields that could beunicodedat
Hello All-
I've been told that I may have encountered a bug - I'm trying to
serialize a model that includes fields that could be unicode data.
Here is the information I collected. Let me know if there's anything
else that would be helpful.
Specs of the local dev workstation - having the same is
Hey guys,
How do you de-serialize the object back at the ajax response.
class Cart(models.Model):
...
def get_total_quantity():
return quantity;
self.response = self.xmlhttp.responseText;
// parse the response into a JSON object
var json_data = self.response.parseJSON();
alert(jso
Hi Bram,
Here is a possible mechanism to address your second point, i.e., hide
certain fields while serializing.
Consider this model:
class Person(models.Model):
... # various fields here.
@staticmethod
def fields_for_serializing():
return [list of those field names that can
Manoj Govindan wrote:
>
>
>> The serializer in trunk has a fields option, which only serializes the
>> fields supplied.
>>
>> Ex:
>> serializers.serialize('json', my_user_set, fields=('username', 'id'))
>
> This doesn't work at the moment
> http://code.djangoproject.com/ticket/3466
>
> But luc
> The serializer in trunk has a fields option, which only serializes the
> fields supplied.
>
> Ex:
> serializers.serialize('json', my_user_set, fields=('username', 'id'))
This doesn't work at the moment
http://code.djangoproject.com/ticket/3466
But luckily there is also a patch ;)
Regards,
M
On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> hey everyone,
>
>
> 1. is there any way to serialize models and remove some fields? I.e. I
> would like to serialize User for example, but I definitely don't want
> the email to be there.
>
The serializer in trunk has a fields opti
My code will seem like:
def _get_data(request, obj):
if obj.icon:
icon = '' %
(obj.get_icon_url(), obj.title)
else:
icon = '' % obj.title
authors = [x.username for x in obj.authors.all()]
return ({'id':obj.id, 'icon':icon, 'title':obj.title,
'description':o
limodou wrote:
> django also uses simplejson to dump python variable, why you want to
> avoid it? And I think using simplejson is more flexiable and simple.
Because it's more generic and I don't want to recreate what's done in
the models...
In the end I did it like this:
# MODEL --
On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> limodou wrote:
> > On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
> >> hey everyone,
> >>
> >>
> >> 1. is there any way to serialize models and remove some fields? I.e. I
> >> would like to serialize User for example,
limodou wrote:
> On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>> hey everyone,
>>
>>
>> 1. is there any way to serialize models and remove some fields? I.e. I
>> would like to serialize User for example, but I definitely don't want
>> the email to be there.
>>
>> 2. is there a way
On 2/28/07, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote:
>
> hey everyone,
>
>
> 1. is there any way to serialize models and remove some fields? I.e. I
> would like to serialize User for example, but I definitely don't want
> the email to be there.
>
> 2. is there a way to provide "custom" pa
hey everyone,
1. is there any way to serialize models and remove some fields? I.e. I
would like to serialize User for example, but I definitely don't want
the email to be there.
2. is there a way to provide "custom" parts of the serialization? For
example, when serializing a Book I would lik
rialize("json", data), mimetype="text/_javascript_")Any help would shure be appreciated.Kind regards, Stefan Freyr.
-- Forwarded message --From: Waylan Limberg <[EMAIL PROTECTED]>Date: Oct 18, 2006 4:06 PM
Subject: Re: JSON serialization and non-model classesTo
ing etc).
>
> So now (finally) to my problem. I'm trying to get this bar chart to update
> with AJAX so that the whole page isn't refreshed every other second. For
> this I was hoping to use Django's JSON serialization but this is where I'm
> running into trouble.
d every other second. For this I was hoping to use Django's JSON serialization but this is where I'm running into trouble.
I have two model classes. One representing a row in the aforementioned table and another one that represents the database table containing the "summary" inf
2006/7/31, Jyrki Pulliainen <[EMAIL PROTECTED]>:
> I filed a ticket for this, see http://code.djangoproject.com/ticket/2460
Json serialization is now fixed in SVN Trunk version
--
Jyrki // [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
You received thi
2006/7/31, Gábor Farkas <[EMAIL PROTECTED]>:
>
> Jyrki Pulliainen wrote:
> > 2006/7/31, Gábor Farkas <[EMAIL PROTECTED]>:
> >>
> >> datetime.datetime inherits from datetime.
> >>
> >
> > Definetly not
> >
>
>
> sorry, of course i meant
>
> "datetime.datetime inherits from datetime.time"
My bad to
Jyrki Pulliainen wrote:
> 2006/7/31, Gábor Farkas <[EMAIL PROTECTED]>:
>>
>> datetime.datetime inherits from datetime.
>>
>
> Definetly not
>
sorry, of course i meant
"datetime.datetime inherits from datetime.time"
gabor
--~--~-~--~~~---~--~~
You received thi
I filed a ticket for this, see http://code.djangoproject.com/ticket/2460
--
Jyrki // [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to djan
2006/7/31, Gábor Farkas <[EMAIL PROTECTED]>:
>
> siniy wrote:
> > Hi all,
> > I've downloaded today a new release of Django and played with json
> > serialization. I found that if you use DateTime field the resulting
> > json string contains only
siniy wrote:
> Hi all,
> I've downloaded today a new release of Django and played with json
> serialization. I found that if you use DateTime field the resulting
> json string contains only date, but not all datetime. So I viewed a
> source code of django/core/serializers/js
On 7/31/06, Jyrki Pulliainen <[EMAIL PROTECTED]> wrote:
>
> 2006/7/31, siniy <[EMAIL PROTECTED]>:
> > I know that isinstance(o, datetime.date) returns "True" even "o" is a
> > datetime object. But I don't know - may be it's a python bug? My python
> > version 2.4.3 from Ubuntu Dapper.
I think you
2006/7/31, siniy <[EMAIL PROTECTED]>:
> I know that isinstance(o, datetime.date) returns "True" even "o" is a
> datetime object. But I don't know - may be it's a python bug? My python
> version 2.4.3 from Ubuntu Dapper.
I can confirm this behaviour with Debian Testing's Python 2.3.5 too.
--
Jy
Hi all,
I've downloaded today a new release of Django and played with json
serialization. I found that if you use DateTime field the resulting
json string contains only date, but not all datetime. So I viewed a
source code of django/core/serializers/json.py and found that:
def default
82 matches
Mail list logo