Git Product home page Git Product logo

django-allauth-ui's Introduction

AllAuth UI

django-allauth-ui

UI templates for django-allauth built with Tailwind. https://django-allauth-ui.hodovi.ch.

django-allauth is a great library, but the templates it provides out of the box are minimal html. I usually end up re-designing the login / logout / signup pages for each new Django project. This library aims at providing good defaults for new projects.

Table of contents

Features

Installation

pip install django-allauth-ui
pip install django-widget-tweaks
pip install slippers

django-allauth-ui depends on jazzband/django-widget-tweaks and mixxorz/slippers to render templates. Make sure to install both packages and add them to the INSTALLED_APPS.

Add django-allauth-ui before django-allauth in your INSTALLED_APPS. See ./tests/settings.py for an example.

INSTALLED_APPS = [
    "allauth_ui",
    "allauth",
    "allauth.account",
    "allauth.socialaccount",
    "allauth.socialaccount.providers.github",
    "widget_tweaks",
    "slippers",
]

Note:

When going to production you should run python manage.py collectstatic

Configuration

The templates can be themed using Django settings. The theme value corresponds to DaisyUI themes.

# settings.py
ALLAUTH_UI_THEME = "light"

Hacking on the project

# Clone the repo
git clone [email protected]:danihodovic/django-allauth-ui.git
cd django-allauth-ui.git

# Create the virtual env
python -m venv .venv
# Activate the virtual env. This has to be done every time you enter the directory.
source .venv/bin/activate

# Install the dependencies
pip install --upgrade pip poetry
poetry install

# Install tailwind
npm install

# Run the migrations
./manage.py migrate

# Add sample social providers
./manage.py create_test_providers

# Start the server
./manage.py runserver_plus

# Start the tailwind compilation process in another terminal
npm run-script build:watch

Make changes in allauth_ui/templates and open the browser at http://localhost:8000/accounts/login/.

Once you're done compile tailwind with npm run-script build and submit a pull-request πŸƒ

Contributors

Made with contrib.rocks.

django-allauth-ui's People

Contributors

adinhodovic avatar anyidea avatar atopheim avatar cro avatar danihodovic avatar emrhnsyts avatar evelyn-ryan avatar filip-dobrovolny-csob-cz avatar geoffbeier avatar mdslino avatar mohmyo avatar nicokant avatar tjmoon0104 avatar twolfson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-allauth-ui's Issues

Exceptions raised because of base_color

./logs/app.log:7939:[2024-03-14 09:50:51] DEBUG [django.template._resolve_lookup:925] Exception while resolving variable 'base_color' in template 'socialaccount/login.html'.
./logs/app.log:7946:KeyError: 'base_color'
./logs/app.log:7954:AttributeError: type object 'RequestContext' has no attribute 'base_color'
./logs/app.log:7962:ValueError: invalid literal for int() with base 10: 'base_color'
./logs/app.log:7969:django.template.base.VariableDoesNotExist: Failed lookup for key [base_color] in [{'True': True, 'False': False, 'None': None}, {'csrf_token': <SimpleLazyObject: 'abc123'>, 'request': <ASGIRequest: GET '/accounts/google/login/?process=login&next=%2Fsign-up-proxy%2F'>, 'user': <SimpleLazyObject: <function AuthenticationMiddleware.process_request.<locals>.<lambda> at 0x>>, 'perms': PermWrapper(<SimpleLazyObject: <function AuthenticationMiddleware.process_request.<locals>.<lambda> at 0x>>), 'messages': <FallbackStorage: request=<ASGIRequest: GET '/accounts/google/login/?process=login&next=%2Fsign-up-proxy%2F'>>, 'DEFAULT_MESSAGE_LEVELS': {'DEBUG': 10, 'INFO': 20, 'SUCCESS': 25, 'WARNING': 30, 'ERROR': 40}}, {}, {'provider': <allauth.socialaccount.providers.google.provider.GoogleProvider object at 0x>, 'process': 'login'}, {'block': <Block Node: content. Contents: [<TextNode: '\n    <div class="flex fle'>, <Block Node: whitebox. Contents: [<TextNode: '\n        '>]>, <TextNode: '\n    </div>\n  </div>\n    '>]>}, {'block': <Block Node: whitebox. Contents: [<TextNode: '\n<div class="flex items-c'>, <IfNode>, <TextNode: '\n  </p>\n</div>\n<form meth'>, <django.template.defaulttags.CsrfTokenNode object at 0x7f8e2dc6f990>, <TextNode: '\n  '>, <IncludeNode: template=<FilterExpression '"account/_button.html"'>>, <TextNode: '\n</form>\n'>]>}, {'text': 'Continue'}]

Seems like there is a "with base_color" in account/_button that might be the culprit, but I don't see why it won't just default to bg-blue if it's not found.

Should I set the base_color, if so how?

Feels like I'm missing something and this should be a quick one, @danihodovic.

from a beginner:how can i add my own html content?

Sorry to ask that question seems to be foolished , I noticed that the old version's html pages (templates/account/) mostly extend the base html. In the old versions if i want to add a navbar, just add a newfolder named account under my own templates folder and paste the old version's base html in the account folder,then put my own content in the base html .But in the new versions the base html has gone,so where could i change ?

chrome_gwHaJDkxUs
chrome_QEOwu0WIgg

error in template socialaccount/base.html

I'm trying to set up django-allauth-ui, but I get an error:
TemplateDoesNotExist at /accounts/ui/login/

In the template socialaccount/base.html on the first line:
{% extends "socialaccount/base.html" %}

What could be the cause of this?

If i changed the order of installed apps to load allauth itself beforehand it barely works (without styling), but this breaks other stuff.

My current allauth version is 0.58.2.

Missing view for accounts/email

Thanks for the great package. I am testing adding/removing email addresses and noticed accounts/email is missing your improvements.

MFA

Any plans on adding the MFA to this as well?

form url in login.html is never set

In the login.html there are two lines defining the form post url:

{% url 'account_login' as login_url %}
{% #form form=form url=url button_text=heading %}

I think the 'url' in the form tag definition should be 'login_url'.
the formtag action thus now always renders as "" since 'url' is not defined.

I ran into this when displaying the form via a htmx get request to "/account/login/". The login form nicely gets swapped in, but action="" now refers to the page where the htmx tag is located ("/" in my case) and the POST never logs the user in. (it posts to "/" and never redirects to whatver LOGIN_REDIRECT_URL is set

If you use allauth normally by calling "/account/login/", that URL will be the default page for action="" and silently still logs in the user

base_color for buttons

Hi! Thanks for your work!

I just installed and it looks great except the buttons are invisible! For example /accounts/password/reset/
image

To debug I checked the html : base_color template variable was missing. I hacked in a context_processor and set {"base_color": "black"}

Then I see the html is (note "black-600"):
<button type="submit" class="flex items-center justify-center w-64 h-12 px-6 mt-8 text-lg text-white uppercase black-600 rounded text-bold hover:black-700">

But that still appears invisible. I removed all other css to confirm it's not a conflict. I'm unfamiliar with tailwind but happy to have a crack at recompiling.

Questions: How do I set base_color properly? How do I make the buttons appear by default?

Provide build instructions/automation

I'm unfamiliar with Tailwind usage - please provide instructions for dev / contribution to this repo, or ideally just a github action that builds the package

Invalid block tag on line 7: '#container'

Invalid block tag on line 7: '#container', expected 'endblock'. Did you forget to register or load this tag?

This error was introduced with slippers, self closing tags in slippers don't need starting #.

Probably would be useful to have test for these templates, to make sure you are not shipping a broken version.

Screenshot from 2024-06-25 13-48-17

Adding email addresses does not work for django-allauth-ui v. 1.1.6 under django-allauth v. 0.63.4

I have the beginnings of a project utilizing django-allauth and django-allauth-ui setup. I have made no modifications to either django-allauth or django-allauth-ui, nor overridden any templates or project files. They're both stock and as-is. When launching my project to test out basic account functionality, I noticed that nothing happens when I log in as a user and go to add an email address for the first time. I set a breakpoint in the allauth email management view to discover the cause, and it appears to be right here:

# allauth.account.views

...

class EmailView(AjaxCapableProcessFormViewMixin, FormView):
    ...

    def post(self, request, *args, **kwargs):
        res = None
        if "action_add" in request.POST:  # <- problem is here: 'action_add' is not in the POST data
            res = super(EmailView, self).post(request, *args, **kwargs)
        elif request.POST.get("email"):  # <- so it goes to this
            if "action_send" in request.POST:
                res = self._action_send(request)
            elif "action_remove" in request.POST:
                res = self._action_remove(request)
            elif "action_primary" in request.POST:
                res = self._action_primary(request)
            res = res or HttpResponseRedirect(self.get_success_url())  # <- but none of the checks above pass, so this line is executed w/ res being a redirect
            # Given that we bypassed AjaxCapableProcessFormViewMixin,
            # we'll have to call invoke it manually...
            res = _ajax_response(request, res, data=self._get_ajax_data_if())
        else:
            # No email address selected
            res = HttpResponseRedirect(self.success_url)
            res = _ajax_response(request, res, data=self._get_ajax_data_if())
        return res

...

It appears, when submitting the form to add a new email address, that a required POST field is missing. and it reverts to the default behavior of redirecting to the success url. I would suspect that this behavior is not intended, as the way it stands currently is that it is impossible to add new email addresses. I believe a hidden form field is missing which adds the key being checked for to the POST data.

some form action URLs are unintentionally empty

In several of the places where the form component is used in allauth_ui/templates, an uninitialized variable is passed in as the url parameter to the form component.

e.g.

        {% url 'account_signup' as action_url %}
        {% #form form=form url=url button_text=heading %}

The clear intent here is, as happens elsewhere, to call the component with url=action_url. Most of the time, this won't matter because it's overwhelmingly unlikely for this template to get used anywhere other than account_signup, and the default for django templates is to pass "" for an uninitialized variable. ACTION="" just causes a form POST back to the URL it was called from.

All the same, it does kind of make a lie of the form component's interface.

I discovered this because I vendored allauth_ui/templates into a project where django-fastdev is used. (I'd be happy to discuss why I felt the need to vendor it, if that's interesting, but that's a distraction here.) One of the things django-fastdev does is turn accessing non-existent context variables within a template into an error instead of letting the template engine default to "". For the template above (templates/account/signup.html), django-fastdev appropriately reported "url does not exist in context."

Unless you tell me you don't want it, I will follow this issue with a PR that does the following:

  1. Adds django-fastdev as a dependency for the dev group in pyproject.toml
  2. Adds django_fastdev to THIRD_PARTY_APPS in tests/settings.py along with appropriate BASE_DIR and FASTDEV_IGNORED_TEPLATES settings to make it work. This will allow any URL that gets accessed in the test harness to trigger the <variable> does not exist error in the test harness.
  3. Makes the url passed to the form component consistently be named action_url and makes sure that's assigned in the template using the form component.

logout.html button text

Seeing this:

image

But seems to work as expected if I replace:

        {% translate "Sign out" as signout_message }
        {% include "account/_button.html" with text=signout_message %}

with

{% include "account/_button.html" with text=_("Sign out") %}

in templates/account/logout.html

Some kind of scoping issue with signout_message? I'm very new to Django, so very possibly could be some error on my end.

(slippers.E001) Slippers was unable to find a components.yaml file

Guys,
Im using Django 5.1 and here is my packages.

Django==5.1
django-allauth==64.0.0
django-allauth-ui==1.4.0
django-appconf==1.0.6
django-compressor==4.5.1
django-widget-tweaks==1.5.0
slippers==0.6.2

When I run the Django project, I get the following WARNING. Is there anything I can do to fix it?
Im new in Django-Auth

$ python manage.py runserver    
Watching for file changes with StatReloader
Performing system checks...

System check identified some issues:

WARNINGS:
?: (slippers.E001) Slippers was unable to find a components.yaml file.
        HINT: Make sure it's in a root template directory.

System check identified 1 issue (0 silenced).
August 11, 2024 - 02:33:08

Signup screen with social connectors

It's most typical for websites to show new users a signup screen, which offers username or social signup options. However allauth (and this repo of templates) prefers to show either a username-based signup without social signup options, or a username login form with social options for signup or sign-in. I suggest adding a template/view for the most common pattern, a screen with a signup form (or link to signup form is also fine), and social signin options.

Translation Error

Hi,
I'm having an error while compiling locale with `compilemessages.

I'm using Django 5, the error is the following:

Execution of msgfmt failed: /app/.venv/lib/python3.11/site-packages/allauth_ui/locale/fr/LC_MESSAGES/django.po:226: 'msgstr' is not a valid Python format string, unlike 'msgid'. Reason: In the directive number 1, the character 'p' is not a valid conversion specifier.
msgfmt: found 1 fatal error

password_change.html is missing

Hi Dani Hodovic,
congratulations for you great job!
Not sure if it is part of the roadmap but I noticed that the password_change.html, email.html are missing!

link

python 3.6

Any chance this will work with python 3.6 as well? I can not install it because on pipy python 3.8 or higher is required and I am currently running 3.6 for my django-project...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.