Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Refer to admin site using {% url 'admin' %} in app django

i wanna Move user to admin panel site in Django using {% url 'admin' %} but the problem is my template in rendering in an app and i dont wanna rewrite url("^admin/",admin.site.urls) in project/site/urls.py

here it is

project / urls.py

urlpatterns = [
url(r"^admin/", admin.site.urls, name="admin"),
url(r"^", include("core.urls")),]

project / site / urls.py

urlpatterns = [
url(r"^$",indexView.as_view() ,name="index" ),
]
accountspattenrns = {
url(r"^accounts/signup/$",signupView.as_view() ,name="signup" ),    
url(r"^accounts/login/$",loginView.as_view() ,name="login" ),    
url(r"^accounts/logout/$",logoutView.as_view() ,name="logout" ),    
url(r"^accounts/profile/$",ProfileView.as_view() ,name="profile" ),    
}
urlpatterns +=accountspattenrns

template.html

<li><a href="{% url 'admin' %}"><i class="fa fa-black-tie fa-2x"></i>
<div>Admin</div></a></li> 

Error :

Error i got

like image 601
Ebrahim Karimi Avatar asked Jul 15 '17 20:07

Ebrahim Karimi


1 Answers

Try reversing the URL using admin namespace

{% url 'admin:index' %}

Refs: Django docs

like image 53
Arpit Solanki Avatar answered Sep 24 '22 12:09

Arpit Solanki