0
對不起,我在Django和python..i創建一個項目一個初學者,我這樣的models.py:DJANGO simplejson
from django.db import models
class Shoes(models.Model):
type = models.CharField(max_length=30)
start_date = models.DateTimeField()
number = models.IntegerField()
def __unicode__(self):
return str(self.id)
class Meta:
verbose_name_plural = "Shoes"
class Bottom(models.Model):
type = models.CharField(max_length=30)
finish = models.BooleanField()
size = models.IntegerField()
def __unicode__(self):
return str(self.id)
class Meta:
verbose_name_plural = "Bottoms"
class Relation(models.Model):
shoes = models.OneToOneField(Shoes)
bottom = models.ForeignKey(Bottom)
class Meta:
verbose_name_plural = "Relations"
我想序列中json..sorry theese類我需要了解在哪裏編寫特定代碼以及如何編寫特定代碼。 我已經寫了一個文件views.py和一個file.html來查看帶有這些對象表的網頁,但現在因爲我需要編寫一個jQuery函數,當我添加一個新對象時允許自動更新網頁,我認爲我們需要在json之前序列化數據。 如果我說了一些愚蠢的東西,因爲我真的是這個領域的初學者,感謝並忍耐着我。
並通過轉儲序列化和負載反序列化utils的是不是更好?所以關於urls.py我可以寫什麼來查看json? – dottorg 2012-04-25 08:12:16
Django內部生成很多字段,使用'simplejson'很難序列化。而且,Django'serializers'只允許序列化你想要的字段。這是一個很棒的簡化。至於另一個問題:我不明白。您可以像其他任何模式一樣編寫urlpattern。 – freakish 2012-04-25 09:56:56
另一個問題,請.. – dottorg 2012-04-26 09:58:12