You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
</code></pre></div></td></tr></table></div></div></div></div><detailsclass=tipopen=open><summary>Components are automatically registered!</summary><p>ReactPy-Django will automatically register any component that is referenced in a Django HTML template. This means you <ahref=../../reference/utils/#register-component>typically</a> do not need to manually register components in your <strong>Django app</strong>.</p><p>Please note that this HTML template must be properly stored within a registered Django app. ReactPy-Django will output a console log message containing all detected components when the server starts up.</p></details><detailsclass=warning><summary>Do not use context variables for the component path</summary><p>The ReactPy component finder requires that your component path is a string.</p><p><strong>Do not</strong> use Django template/context variables for the component path. Failure to follow this warning will result in render failures.</p><p>For example, <strong>do not</strong> do the following:</p><divclass="tabbed-set tabbed-alternate" data-tabs=3:2><inputchecked=checkedid=__tabbed_3_1name=__tabbed_3type=radio><inputid=__tabbed_3_2name=__tabbed_3type=radio><divclass=tabbed-labels><labelfor=__tabbed_3_1>my_template.html</label><labelfor=__tabbed_3_2>views.py</label></div><divclass=tabbed-content><divclass=tabbed-block><divclass=highlight><tableclass=highlighttable><tr><tdclass=linenos><divclass=linenodiv><pre><span></span><spanclass=normal>1</span>
23
+
</code></pre></div></td></tr></table></div></div></div></div><detailsclass=tipopen=open><summary>Components are automatically registered!</summary><p>ReactPy-Django will automatically register any component that is referenced in a Django HTML template. This means you typically do not need to <ahref=../../reference/utils/#register-component>manually register</a> components in your <strong>Django app</strong>.</p><p>Please note that this HTML template must be properly stored within a registered Django app. ReactPy-Django will output a console log message containing all detected components when the server starts up.</p></details><detailsclass=warning><summary>Do not use context variables for the component path</summary><p>The ReactPy component finder requires that your component path is a string.</p><p><strong>Do not</strong> use Django template/context variables for the component path. Failure to follow this warning will result in render failures.</p><p>For example, <strong>do not</strong> do the following:</p><divclass="tabbed-set tabbed-alternate" data-tabs=3:2><inputchecked=checkedid=__tabbed_3_1name=__tabbed_3type=radio><inputid=__tabbed_3_2name=__tabbed_3type=radio><divclass=tabbed-labels><labelfor=__tabbed_3_1>my_template.html</label><labelfor=__tabbed_3_2>views.py</label></div><divclass=tabbed-content><divclass=tabbed-block><divclass=highlight><tableclass=highlighttable><tr><tdclass=linenos><divclass=linenodiv><pre><span></span><spanclass=normal>1</span>
24
24
<spanclass=normal>2</span>
25
25
<spanclass=normal>3</span>
26
26
<spanclass=normal>4</span>
27
-
<spanclass=normal>5</span></pre></div></td><tdclass=code><div><pre><span></span><code><spanclass=x><!-- This is good --></span>
</code></pre></div></td></tr></table></div></div></div></div><detailsclass=question><summary>Which urls.py do I add my views to?</summary><p>For simple <strong>Django projects</strong>, you can easily add all of your views directly into the <strong>Django project's</strong><code>urls.py</code>. However, as you start increase your project's complexity you might end up with way too much within one file.</p><p>Once you reach that point, we recommend creating an individual <code>urls.py</code> within each of your <strong>Django apps</strong>.</p><p>Then, within your <strong>Django project's</strong><code>urls.py</code> you will use Django's <ahref=https://docs.djangoproject.com/en/stable/ref/urls/#include><code>include</code> function</a> to link it all together.</p></details><h2id=viewing-your-component>Viewing your component<aclass=headerlinkhref=#viewing-your-componenttitle="Permanent link">¶</a></h2><p>To test your new Django view, run the following command to start up a development web server.</p><divclass=highlight><pre><span></span><code>python<spanclass=w></span>manage.py<spanclass=w></span>runserver
0 commit comments