我正在使用tastypie并创建了我的第一个资源。但我该如何做到以下几点:Django API tastypie和FK POST
用户名在URL上传递,在帖子上我想'保存'之前做'的东西'。 tastypie有这个方法吗?
class CommonMeta:
authentication = ApiKeyAuthentication()
authorization = UserObjectsOnlyAuthorization()
class SMSResource(ModelResource):
class Meta(CommonMeta):
queryset = Batch.objects.all()
resource_name = 'sms'
list_allowed_methods = ['get', 'post']
detail_allowed_methods = ['get']
型号:
content = models.TextField(validators=[validate_GSM_characters])
type = models.CharField(max_length=16, choices=TYPES,
default="Standard", null=True, blank=True)
priority = models.CharField(max_length=16, choices=PRIORITIES,
default="Normal", null=True, blank=True)
status = models.CharField(max_length=16, choices=STATUSES,
default="Pending", null=True, blank=True)
created = models.DateTimeField(auto_now_add=True, help_text="Shows when object was created.")
schedule = models.DateTimeField(blank=True, null=True, help_text="Shows when object was created.")
#FK
sender_name = models.ForeignKey(Originator)
user = models.ForeignKey(User)
我们需要你的模型能够看到你指的是什么,你的问题不是那么清楚。 –
增加了模型更新的问题:) – GrantU
目前仍不清楚你想要做什么。你可以包含你试图发送给你的服务器的Json,以及你试图从FK创建的东西吗? –