Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Got it!! The problem is that some of the imports are of <code>myproject.myapp.views</code>, and some are just of <code>myapp.views</code>. This is confusing the Python module system enough that it no longer detects the functions as the same object. This is because your main <code>settings.py</code> probably has a line like:</p> <pre><code>ROOT_URLCONF = `myproject.urls` </code></pre> <p>To solve this, try using the full import in your shell session:</p> <pre><code>&gt;&gt;&gt; from django.core.urlresolvers import reverse &gt;&gt;&gt; from myproject.myapp import views &gt;&gt;&gt; reverse(views.myview) '/myview/' </code></pre> <p>Here's a log of the debugging session, for any interested future readers:</p> <pre><code>&gt;&gt;&gt; from django.core import urlresolvers &gt;&gt;&gt; from myapp import myview &gt;&gt;&gt; urlresolvers.get_resolver (None).reverse_dict {None: ([(u'myview/', [])], 'myview/$'), &lt;function myview at 0x845d17c&gt;: ([(u'myview/', [])], 'myview/$')} &gt;&gt;&gt; v1 = urlresolvers.get_resolver (None).reverse_dict.items ()[1][0] &gt;&gt;&gt; reverse(v1) '/myview/' &gt;&gt;&gt; v1 is myview False &gt;&gt;&gt; v1.__module__ 'testproject.myapp.views' &gt;&gt;&gt; myview.__module__ 'myapp.views' </code></pre> <p>What happens if you change the URL match to be <code>r'^myview/$'</code>?</p> <hr> <p>Have you tried it with the view name? Something like <code>reverse ('myapp.myview')</code>?</p> <p>Is <code>urls.py</code> the root URLconf, or in the <code>myapp</code> application? There needs to be a full path from the root to a view for it to be resolved. If that's <code>myproject/myapp/urls.py</code>, then in <code>myproject/urls.py</code> you'll need code like this:</p> <pre><code>from django.conf.urls.defaults import patterns urlpatterns = patterns ('', (r'^/', 'myapp.urls'), ) </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload