Skip to content

Patch request with "meta" attribute fails #654

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions example/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class Migration(migrations.Migration):
('modified_at', models.DateTimeField(auto_now=True)),
('body', models.TextField()),
('author', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='example.Author')),
('meta', models.CharField(max_length=50)),
],
options={
'abstract': False,
Expand Down
1 change: 1 addition & 0 deletions example/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class Comment(BaseModel):
on_delete=models.CASCADE,
related_name='comments',
)
meta = models.CharField(max_length=50)

def __str__(self):
return self.body
Expand Down
15 changes: 15 additions & 0 deletions example/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ def test_delete_relationship_overriding_with_none(self):
assert response.status_code == 200, response.content.decode()
assert response.data['author'] is None

def test_patch_meta(self):
url = '/comments/{}'.format(self.second_comment.id)
request_data = {
'data': {
'type': 'comments',
'id': self.second_comment.id,
'attributes': {
'meta': "test"
}
}
}
response = self.client.patch(url, data=request_data)
assert response.status_code == 200, response.content.decode()
assert response.data['meta'] == "test"

def test_delete_to_many_relationship_with_no_change(self):
url = '/entries/{}/relationships/comments'.format(self.first_entry.id)
request_data = {
Expand Down