Skip to content

Instantly share code, notes, and snippets.

@buchanae
Created November 26, 2013 05:07
Show Gist options
  • Save buchanae/7653736 to your computer and use it in GitHub Desktop.
Save buchanae/7653736 to your computer and use it in GitHub Desktop.
Question for django rest framework group regarding fully qualified reverse URL when using APIClient
class Album(Model):
...
class Track(Model):
album = ForeignKey(Album)
class AlbumSerializer(HyperlinkedModelSerializer):
...
class TrackTest(APITestCase):
def test_track_list(self):
response = self.client.get(reverse('tracks-list'))
album_url = reverse('album-detail', args=(1,))
expected = [{'album': album_url, ...}]
# album_url = '/albums/1' but response.data[0]['album'] is 'http://testserver/albums/1'
self.assertEqual(response.data, expected)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment