File tree Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Expand file tree Collapse file tree 3 files changed +36
-4
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ any parts of the framework not mentioned in the documentation should generally b
1515* Avoid exception when trying to include skipped relationship
1616* Don't swallow ` filter[] ` params when there are several
1717* Fix DeprecationWarning regarding collections.abc import in Python 3.7
18+ * Allow OPTIONS request to be used on RelationshipView.
1819
1920## [ 2.7.0] - 2019-01-14
2021
Original file line number Diff line number Diff line change @@ -274,6 +274,39 @@ def test_new_comment_data_patch_to_many_relationship(self):
274274
275275 assert Comment .objects .filter (id = self .second_comment .id ).exists ()
276276
277+ def test_options_entry_relationship_blog (self ):
278+ url = reverse (
279+ 'entry-relationships' , kwargs = {'pk' : self .first_entry .id , 'related_field' : 'blog' }
280+ )
281+ response = self .client .options (url )
282+ expected_data = {
283+ "data" : {
284+ "name" : "Entry Relationship" ,
285+ "description" : "" ,
286+ "renders" : [
287+ "application/vnd.api+json" ,
288+ "text/html"
289+ ],
290+ "parses" : [
291+ "application/vnd.api+json" ,
292+ "application/x-www-form-urlencoded" ,
293+ "multipart/form-data"
294+ ],
295+ "allowed_methods" : [
296+ "GET" ,
297+ "POST" ,
298+ "PATCH" ,
299+ "DELETE" ,
300+ "HEAD" ,
301+ "OPTIONS"
302+ ],
303+ "actions" : {
304+ "POST" : {}
305+ }
306+ }
307+ }
308+ assert response .json () == expected_data
309+
277310
278311class TestRelatedMixin (APITestCase ):
279312
Original file line number Diff line number Diff line change @@ -29,10 +29,8 @@ class ResourceIdentifierObjectSerializer(BaseSerializer):
2929
3030 def __init__ (self , * args , ** kwargs ):
3131 self .model_class = kwargs .pop ('model_class' , self .model_class )
32- if 'instance' not in kwargs and not self .model_class :
33- raise RuntimeError (
34- 'ResourceIdentifierObjectsSerializer must be initialized with a model class.'
35- )
32+ # this has no fields but assumptions are made elsewhere that self.fields exists.
33+ self .fields = {}
3634 super (ResourceIdentifierObjectSerializer , self ).__init__ (* args , ** kwargs )
3735
3836 def to_representation (self , instance ):
You can’t perform that action at this time.
0 commit comments