django two apps with same urls in each url's.py file
<p>I have two apps in my django project one is "home" and other is "administrator". I am using home app for frontend of the site and administrator app for admin panel and the urls' for accessing both frontend and admin panel respectively are :-</p>

<pre><code>www.domainname.com/home
www.domainname.com/administrator
</code></pre>

<p><strong>main urls.py file is :-</strong></p>

<pre><code>from django.conf.urls import include, url
from django.contrib import admin

urlpatterns = [
    url(r'^home/', include('home.urls')),
    url(r'^administrator/', include('administrator.urls'))
]
</code></pre>

<p><strong>Home's urls.py file is :-</strong></p>

<pre><code>from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^sport$', views.sport, name='sport'),
    url(r'^register$', views.signup_signin, name='register'),
    url(r'^login$', views.login, name='login'),
    url(r'^signup$', views.signup, name='signup'),
    url(r'^registered-successfully$', views.registered_successfully, name='registered-successfully'),
    url(r'^logout$', views.logout_view, name='logout'),
    url(r'^dashboard$', views.dashboard, name='dashboard'),
    url(r'^create-new-event$', views.create_new_event, name='create-new-event'),
    url(r'^help$', views.help, name='help'),
    url(r'^account-settings$', views.account_settings, name='account-settings')
]
</code></pre>

<p><strong>Admin's urls.py file is :-</strong></p>

<pre><code>from django.conf.urls import url
from . import views

urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^logout$', views.logout, name='logout'),
    url(r'^dashboard$', views.dashboard, name='dashboard'),
    url(r'^profile$', views.profile, name='profile'),
    url(r'^edit-profile$', views.edit_profile, name='edit-profile'),
    url(r'^check-password$', views.check_password, name='check-password'),
    url(r'^help$', views.faq_management, name='help')
]
</code></pre>

<p>As you can check that there are some common url's in both app's file, like index, dashboard, logout help.</p>

<p>These urls are creating problem if i link them in href, for example if i link "help" url in frontend using</p>

<pre><code>&lt;a href="{% url 'help' %}" &gt;
</code></pre>

<p>It tries to redirect me to admin panel's help url, and if i change the order of apps in main urls.py file than vice versa problem occurs. </p>

<pre><code>urlpatterns = [
    url(r'^home/', include('home.urls')),
    url(r'^administrator/', include('administrator.urls'))
]
</code></pre>

<p>My suggestion</p>

<p>Set Site URL in Settings.py </p>

<p>Example : </p>

<pre><code>SITE_URL = "http://localhost:8000/"
</code></pre>

<p>in Template you can pass the URL regex directly.</p>

<pre><code>&lt;a href="{{SITE_URL}}/home/help/" &gt;
&lt;a href="{{SITE_URL}}/administrator/help/"&gt;
</code></pre>

<p>if you dont put the Site url , chances is there to get page not found error</p>

python django