Change the administrator interface of Django 1.9

0

I want to access my custom administration interface in Django and disable the default admin

  • I have my own custom form to login.
  • I would like that at the time of login, access my own personalized administration site.
  • I do not want to use the one Django brings.
  • I already have the login configuration only now I'm a bit lost to put my own administration site.
  • Disable the django admin and practically put the index_admin.html
  • My files are like this:

    rbm / rbm / urls.py

    from django.conf.urls import include, url
    from django.contrib import admin
    from django.views.generic import TemplateView
    
    from django.contrib.auth import views as auth_views
    
    from usuarios import urls as usuarios_urls
    
    urlpatterns = [
        url(r'^admin/', admin.site.urls),
        #url(r'^$', TemplateView.as_view(template_name='login.html'), name='acceder'),
        url(r'^usuarios/', include(usuarios_urls)),
        url(r'^', auth_views.login,{'template_name': 'usuarios/login.html'}),
    
    ]
    

    rbm / rbm / users / templates / login.html

    <!DOCTYPE html>
    {% load staticfiles %}
    <html lang="en">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
        <!--Import materialize.css-->
        <link href="{% static 'css/materialize.min.css' %}" type="text/css" rel="stylesheet" media="screen,projection"/>
        <link href="{% static 'css/styles.css' %}" type="text/css" rel="stylesheet">
    
        <!--Let browser know website is optimized for mobile-->
        <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
        <title>Aceder a RBM-LAPS</title>
    </head>
    <body class="login-fond">
    
        {% if form.errors %}
        <p>Your username and password didn't match. Please try again.</p>
        {% endif %}
    
        {% if next %}
            {% if user.is_authenticated %}
            <p>Your account doesn't have access to this page. To proceed,
            please login with an account that has access.</p>
            {% else %}
            <p>Please login to see this page.</p>
            {% endif %}
        {% endif %}
    
        <div class="row login-top">
          <div class="col offset-l4 l4 s12">
            <div class="card white z-depth-3">
              <div class="card-login card-title login-color white-text">
                  <h3>INICIAR SECIÓN</h3>
              </div>
              <div class="card-content">
                  <div class="row">
                    <form class="col s12" method="post" action='{template_name="bla/nl"}, name='login' '>
                    {% csrf_token %}
    
                      <div class="row">
                        <div class="input-field col s12">
                          <i class="mdi-social-person-outline prefix"></i>                    
                          {{ form.username }}
                          <label for='id_usuario'>{{ form.username.label_tag }}</label>
                        </div>
                        <div class="input-field col s12">
                          <i class="mdi-action-lock-outline prefix"></i>
                          {{ form.password }}
                          <label for="id_password">{{ form.password.label_tag }}</label>
                        </div>
                        <div class="col s12">
                            <button class="btn btn-login waves-effect waves-purple teal accent-4" type="submit" value="login" > 
                                Aceder
                            </button>
                            <input type="hidden" name="next" value="{{ next }}" />
                        </div>
                      </div>
                    </form>
                  </div>
              </div>
            </div>
          </div>
        </div>
    
    
        <!--Import jQuery before materialize.js-->
          <script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
          <script type="text/javascript" src="{% static 'js/materialize.min.js' %}"></script>
    
    </body>
    </html>
    
        
    asked by wootsbot 14.04.2016 в 17:32
    source

    2 answers

    1

    I'll assume you want to make your own admin from 0 and not customize or extend Django's own. First of all, if you do not want to use the Django admin app, you can remove it or comment on the installed applications list INSTALLED_APPS in the settings.py file:

    # settings.py
    INSTALLED_APPS = [
        # 'django.contrib.admin',
    
        # incluyes tu app de admin
        'miadmin',
    
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
    ]
    

    and of course remove it from the urls of your site and include those of your own administration:

    # urls.py
    
    from django.conf.urls import include, url
    # from django.contrib import admin
    
    urlpatterns = [
        # url(r'^admin/', admin.site.urls),
    
        # incluyes las urls de tu propia admin
        url(r'^admin/', include('miadmin.urls')),
    ]
    

    I hope the answer will help

    greetings

        
    answered by 25.05.2017 в 23:49
    -1

    I think you can fix it by commenting on this line

    //url(r'^admin/', admin.site.urls),
    

    in the file urls.py

        
    answered by 14.04.2016 в 19:17