Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Feb 29, 2024
1 parent 7936ae0 commit a2246c8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 6 additions & 5 deletions _modules/apis_core/generic/api_views.html
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@

<h1>Source code for apis_core.generic.api_views</h1><div class="highlight"><pre>
<span></span><span class="kn">from</span> <span class="nn">rest_framework</span> <span class="kn">import</span> <span class="n">viewsets</span>
<span class="kn">from</span> <span class="nn">.serializers</span> <span class="kn">import</span> <span class="n">serializer_factory</span>
<span class="kn">from</span> <span class="nn">.serializers</span> <span class="kn">import</span> <span class="n">serializer_factory</span><span class="p">,</span> <span class="n">GenericHyperlinkedModelSerializer</span>
<span class="kn">from</span> <span class="nn">.helpers</span> <span class="kn">import</span> <span class="n">first_match_via_mro</span>


Expand Down Expand Up @@ -124,10 +124,11 @@ <h1>Source code for apis_core.generic.api_views</h1><div class="highlight"><pre>
<div class="viewcode-block" id="ModelViewSet.get_serializer_class">
<a class="viewcode-back" href="../../../modules/apis_core.generic.html#apis_core.generic.api_views.ModelViewSet.get_serializer_class">[docs]</a>
<span class="k">def</span> <span class="nf">get_serializer_class</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">serializer_class</span> <span class="o">=</span> <span class="n">first_match_via_mro</span><span class="p">(</span>
<span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="s2">&quot;serializers&quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;Serializer&quot;</span>
<span class="p">)</span> <span class="ow">or</span> <span class="n">serializer_factory</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="p">)</span>
<span class="k">return</span> <span class="n">serializer_class</span></div>
<span class="n">serializer_class</span> <span class="o">=</span> <span class="p">(</span>
<span class="n">first_match_via_mro</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="p">,</span> <span class="n">path</span><span class="o">=</span><span class="s2">&quot;serializers&quot;</span><span class="p">,</span> <span class="n">suffix</span><span class="o">=</span><span class="s2">&quot;Serializer&quot;</span><span class="p">)</span>
<span class="ow">or</span> <span class="n">GenericHyperlinkedModelSerializer</span>
<span class="p">)</span>
<span class="k">return</span> <span class="n">serializer_factory</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">model</span><span class="p">,</span> <span class="n">serializer</span><span class="o">=</span><span class="n">serializer_class</span><span class="p">)</span></div>
</div>

</pre></div>
Expand Down
4 changes: 3 additions & 1 deletion _modules/apis_core/generic/serializers.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ <h1>Source code for apis_core.generic.serializers</h1><div class="highlight"><pr
<span class="k">def</span> <span class="nf">serializer_factory</span><span class="p">(</span>
<span class="n">model</span><span class="p">,</span> <span class="n">serializer</span><span class="o">=</span><span class="n">GenericHyperlinkedModelSerializer</span><span class="p">,</span> <span class="n">fields</span><span class="o">=</span><span class="s2">&quot;__all__&quot;</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span>
<span class="p">):</span>
<span class="n">meta</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="s2">&quot;Meta&quot;</span><span class="p">),</span> <span class="p">(</span><span class="nb">object</span><span class="p">,),</span> <span class="p">{</span><span class="s2">&quot;model&quot;</span><span class="p">:</span> <span class="n">model</span><span class="p">,</span> <span class="s2">&quot;fields&quot;</span><span class="p">:</span> <span class="n">fields</span><span class="p">})</span>
<span class="n">defaultmeta</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="s2">&quot;Meta&quot;</span><span class="p">),</span> <span class="p">(</span><span class="nb">object</span><span class="p">,),</span> <span class="p">{</span><span class="s2">&quot;fields&quot;</span><span class="p">:</span> <span class="n">fields</span><span class="p">})</span>
<span class="n">meta</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">serializer</span><span class="p">,</span> <span class="s2">&quot;Meta&quot;</span><span class="p">,</span> <span class="n">defaultmeta</span><span class="p">)</span>
<span class="n">meta</span><span class="o">.</span><span class="n">model</span> <span class="o">=</span> <span class="n">model</span>
<span class="n">serializer</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span>
<span class="nb">str</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2">ModelSerializer&quot;</span> <span class="o">%</span> <span class="n">model</span><span class="o">.</span><span class="n">_meta</span><span class="o">.</span><span class="n">object_name</span><span class="p">),</span>
<span class="p">(</span><span class="n">serializer</span><span class="p">,),</span>
Expand Down

0 comments on commit a2246c8

Please sign in to comment.