0

私はtastypieを使用しており、最初のリソースを作成しました。しかし、次のようにするにはどうすればよいですか。

ユーザー名は 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)
4

1 に答える 1