1

"python manage.py loaddata fixtures \ companies.json"と入力しました。それは私にエラーを与える。gae datastoreに灯台をアップロードするには?

jsonデータを読み込んでgaeデータストアにプッシュする適切な方法は何ですか?ここで

は私のモデルである:ここでは

class Company(models.Model):  
    id = models.AutoField(primary_key=True); 
    name = models.CharField(max_length=100); 
    address = models.CharField(max_length=100, null=True); 
    city = models.CharField(max_length=100); 
    state = models.CharField(max_length=25); 
    zip = models.IntegerField(); 
    latitude = models.CharField(max_length=20, null=True) 
    longitude = models.CharField(max_length=20, null=True) 
    phone = models.CharField(max_length=15, null=True); 
    website = models.CharField(max_length=50, null=True); 
    email = models.EmailField(max_length=50, null=True); 
    hiring = models.BooleanField(default=False);  
    approved = models.BooleanField(default=False); 
    date_added = models.DateTimeField(auto_now_add=True); 
    about_us = models.TextField(max_length=500, null=True); 

は私の治具である:ここでは

[ 
    { 
     "model": "Companies.Company", 
     "fields": { 
      "id": 111, 
      "name": "1-800 Postcards America's Printing Company", 
      "address": "121 Varick Street, 7th Floor", 
      "city": "New York", 
      "state": "NY", 
      "zip": 10013, 
      "latitude": "40.724831999999999", 
      "longitude": "-74.00609", 
      "phone": "212-741-1070", 
      "website": "http://www.1800postcards.com", 
      "email": "[email protected]", 
      "hiring": "FALSE", 
      "approved": "TRUE", 
      "date_added": "April 30, 2012, 6:08 p.m.", 
      "about_us": "With over 30 years of business experience as full service offset printers and over 200 years of combined knowledge in our production department and press rooms, 1-800Postcards is your professional printer. Our state-of-the-art 125,000 square foot facility is located in the heart of New York City, with an additional web offset plant in New Jersey for our larger orders 500,000 and up. This makes it possible for us to print and mail the highest quality postcards on the market today — at the most competitive rates in the country." 
     } 
    }, 
    { 
     "model": "Companies.Company", 
     "fields": { 
      "id": 222, 
      "name": "20x200 ", 
      "address": "6 Spring Street", 
      "city": "New York", 
      "state": "NY", 
      "zip": 10012, 
      "latitude": "40.721052999999998", 
      "longitude": "-73.994322999999994", 
      "phone": "212-219-0166", 
      "website": "http://www.20x200.com/", 
      "email": "[email protected]", 
      "hiring": "TRUE", 
      "approved": "TRUE", 
      "date_added": "April 30, 2012, 6:08 p.m.", 
      "about_us": "(limited editions × low prices) + the internet = art for everyone. That simple formula, devised by 20x200's founder, Jen Bekman, is what launched 20x200 back in 2007. With that, we set our sights on two core goals: We want everyone to collect art, and we want to enable an economy that allows more artists to make a living by making work. More so, we wanted something as awesome as collecting art to be fun. That's right: fun!" 
     } 
    }, 
    { 
     "model": "Companies.Company", 
     "fields": { 
      "id": 333, 
      "name": "Adafruit", 
      "address": "80 Nassau st #4C", 
      "city": "New York", 
      "state": "NY", 
      "zip": 10038, 
      "latitude": "40.709938000000001", 
      "longitude": "-74.007987999999997", 
      "phone": "646-248-7822", 
      "website": "http://www.adafruit.com/", 
      "email": "N/A", 
      "hiring": "TRUE", 
      "approved": "TRUE", 
      "date_added": "April 30, 2012, 6:08 p.m.", 
      "about_us": "We pride ourselves on having great prices, the best customer service, support and fast shipping. We hope we can assist you on your journey of learning – At Adafruit we celebrate “Engineering Happiness”! Adafruit is a 100% Woman-Owned Small Business." 
     } 
    } 
] 

は私が取得エラーです:

Problem installing fixture 'fixtures\companies.json': Traceback (most recent call last): 
    File "C:\Users\Joe\Desktop\My School Stuff\Spring 2012\CS 473\ny-tech\ny-tech\django\core\management\commands\loaddata.py", line 169, in handle 
    for obj in objects: 
    File "C:\Users\Joe\Desktop\My School Stuff\Spring 2012\CS 473\ny-tech\ny-tech\django\core\serializers\json.py", line 35, in Deserializer 
    for obj in PythonDeserializer(simplejson.load(stream), **options): 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\__init__.py", line 332, in load 
    use_decimal=use_decimal, **kw) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\__init__.py", line 388, in loads 
    return _default_decoder.decode(s) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\decoder.py", line 402, in decode 
    obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\decoder.py", line 418, in raw_decode 
    obj, end = self.scan_once(s, idx) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\scanner.py", line 71, in scan_once 
    return _scan_once(string, idx) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\scanner.py", line 44, in _scan_once 
    return parse_array((string, idx + 1), _scan_once) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\decoder.py", line 284, in JSONArray 
    value, end = scan_once(s, end) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\scanner.py", line 42, in _scan_once 
    _scan_once, object_hook, object_pairs_hook, memo) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\decoder.py", line 230, in JSONObject 
    value, end = scan_once(s, end) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\scanner.py", line 42, in _scan_once 
    _scan_once, object_hook, object_pairs_hook, memo) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\decoder.py", line 230, in JSONObject 
    value, end = scan_once(s, end) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\scanner.py", line 39, in _scan_once 
    return parse_string(string, idx + 1, encoding, strict) 
    File "C:\Program Files (x86)\Google\google_appengine\lib\simplejson\simplejson\decoder.py", line 121, in py_scanstring 
    content = unicode(content, encoding) 
UnicodeDecodeError: 'utf8' codec can't decode byte 0x97 in position 484: invalid start byte 

Exception AttributeError: "'NoneType' object has no attribute 'mkstemp'" in <bound method DatastoreFileStub.__del__ of <google.appengine.api.datastore_file_stub 
.DatastoreFileStub object at 0x02930F10>> ignored 
+1

JSONが有効であることを確認できますか?上記をコピーしてjsonlint.comに貼り付けると、エラーが発生します。また、0x97はemダッシュ( - )を参照していますが、その理由がわからないうちに問題が発生する可能性はありますが、JSONから削除することができます。 –

+0

@DanHolevoet私はエラーを参照して、私は真実の/偽のフィールドを、jsonlintのおかげで、そのようなものがあったことを知らなかった! – iCodeLikeImDrunk

+0

これでうれしいです私は、このタイプの問題に問題がある他の誰かのために以下の回答を投稿しました。 –

答えて

1

このタイプのエラーがで発生する可能性がありますJSONが無効です。最も簡単なことは、JSONがJSON Lintで検証されていることを確認し、見つかったエラーを修正してから、もう一度アップロードを試みることです。

+0

まだデータをプッシュしていませんでしたが、jsonファイルを修正してエラーは発生しませんでした。再度、感謝します! – iCodeLikeImDrunk

関連する問題