Skip to main content

A django user authentication and login application.

Reason this release was yanked:

faulty

Project description

Authentication

A django user authentication and login application.

0. To install and use the package, use:

    pip install django-user-login
    python manage.py makemigrations
    python manage.py migrate

Instructions

1. Add "authentication" to your INSTALLED_APPS setting like this:

    INSTALLED_APPS = [
        ...
        'authentication',
        'authentication.customer',
    ]

2. The App requires bootstrap@5.3.1, bootstrap-icons@1.8.1 and Django Sessions

3. Include the authentication URLconf in your project urls.py like this:

	path('authentication/', include('authentication.urls')),

4. Run python manage.py migrate to create the User models (you'll need the Admin app enabled).

5. In your settings.py file include the following:

    SITE_TITLE = 'your site title'
    LOGIN_URL = '/authentication/'
    EMAIL_HOST = 'email-host'
    EMAIL_PORT = email-port
    EMAIL_HOST_USER = 'email-address'
    EMAIL_HOST_PASSWORD = 'email-password'
    EMAIL_USE_TLS = True
    FAVICON_URL = '/path/to/favicon.ico'
  • Code used to include favicon.ico in the application's html templates is -

          <link rel="icon" href="{{FAVICON_URL}}" type = "image/x-icon">
    

6. Include these lines within the head tag of your base template (optional)

    <link rel="stylesheet" href="{% static 'authentication/authentication.css' %}">
    <script src="{% static 'authentication/authentication.js' %}"></script>
    <script>
    	var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
        var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
            return new bootstrap.Tooltip(tooltipTriggerEl)
        })
    </script>

7. Include this line within the body tag of your base template (optional)

	{% include 'authentication/modals.html' %}

8. For login and logout functionality, use -

  • Login

          <a href="{% url 'authentication:login' %}">Login</a> or
          <a href='/authentication/'>Login</a>
    
  • The above functionality will redirect to the "next" parameter in the url after logging the user in.

  • Logout

          <a href="{% url 'authentication:logout' %}">Logout</a> or
          <a href="/authentication/logout/">Logout</a>
    
  • The above functionality will redirect to the login page after logging the user out.

9. If you have included all the lines mentioned in point 6 and 7, you can also use -

  • Login via Bootstrap Modal

          <button data-bs-toggle="modal" data-bs-target="#loginModal">
              Login
          </button>
    
  • The above functionality will display the bootstrap login form Modal and reload the current page after logging the user in.

  • Logout using JS

          <a href="" onclick="logout(event);">Logout</a>
    
  • The above functionality will reload the current page after logging the user out

10. Optionally, use can set the Site Name as a default template variable for your website, by adding the following command to list of context_processors. This will set sitetitle=SITE_TITLE for all templates. You can use the variable name sitetitle to access the value of SITE_TITLE.

        TEMPLATES = [
            {
                ...
                'OPTIONS': {
                    'context_processors': [
                        ...
                        'authentication.contextprocessor.site_title'
                    ],
                },
            },
        ]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-user-login-0.1.5.tar.gz (17.1 kB view hashes)

Uploaded Source

Built Distribution

django_user_login-0.1.5-py3-none-any.whl (23.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page