Django Starter with Allauth and Htmx
Тәжірибелік нұсқаулар және стиль
In this tutorial we build a Django Starter project as a foundation for future tutorials, using the Allauth package for User authentication and Htmx to update the User email address.
Assets: github.com/andyjud/django-sta...
Full Code: github.com/andyjud/django-sta...
Live Site: awesomepixx.com
0:00 Demo
3:20 Django Setup
5:40 Homepage
11:05 Profile Pages
21:50 Allauth and Sign Up
30:25 Settings Page with Htmx
40:48 404 Page
Support me on:
Patreon: / andreasjud
Buy me a Coffee: www.buymeacoffee.com/andreasjud
Thank you.
Follow me on:
Twitter: / ajudmeister
Instagram: / ajudmeister
#django #htmx #deployment #allauth #python #pythonprogramming #selftaughtdeveloper #webdevelopment #webapp #stayathomedad
Пікірлер: 49
As always, I enjoy your great videos. Thanks for the great effort you always put into your work
Thank for this. Keep making htmx and django
This is really great. Thanks for sharing.
Thank you so much for this. It helped me a lot with my project
Thank you for the template, very helpful
Awesome video! thank you!
Wonderful new video, thank you for the video.
I loved it, keep going
I like before I watch, I am sure this will be great.
@ajudmeister
3 ай бұрын
Risky …
thanks for the vid
Minor suggestions: 1) Get rid of try except in profile avatar property. I changed it to this: @property def avatar(self): if self.image: return self.image.url return static("images/avatar.svg") 2) Add hyphenation to frontend for profile info. If you type a very long word it is not split into several lines.
@ajudmeister
17 күн бұрын
Awesome! Thanks a lot. Updated.
@twiceasviewtiful
16 күн бұрын
@@ajudmeister tried it but even with hyphens-auto long word in info is still not split and goes as far as it can go as if there was no limit to width.
@ajudmeister
16 күн бұрын
@@twiceasviewtiful hmm, when i tried the word was split with hyphens-auto. maybe need to add break-words aswell
@twiceasviewtiful
16 күн бұрын
@@ajudmeister it seems that it has to follow some quirky rules to work properly, it works if you type "Kraftfahrzeughaftpflichtversicherung Kraftfahrzeughaftpflichtversicherung Kraftfahrzeughaftpflichtversicherung Kraftfahrzeughaftpflichtversicherung" but it doesn't if you try "Coooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooool". break-all did help, changed it to {{ profile.info|linebreaksbr }}
your videos are awesome you make any django-backend developer to a frontend developer :)
@ajudmeister
3 ай бұрын
haha, you bet!
Also noticed that there is a little inconsistency with User model/admin.py. When we login/signup email field is required but it is optional if you create object yourself or through django admin (it's not even present in the Add form).
@ajudmeister
17 күн бұрын
Do you mean when the admin creates a new object it should tell him the email is required? How would you go about this?
@twiceasviewtiful
16 күн бұрын
@@ajudmeister I made custom user model inhereted from AbstractUser. from django.contrib.auth.models import AbstractUser class User(AbstractUser): email = models.EmailField(unique=True) USERNAME_FIELD = 'email' REQUIRED_FIELDS = ['username'] Added custom model to settings: AUTH_USER_MODEL = "users.User" Added email to add userform in admin: from django.contrib.auth.admin import UserAdmin as BaseUserAdmin @admin.register(User) class UserAdmin(BaseUserAdmin): add_fieldsets = ( ( None, { "classes": ("wide",), "fields": ( "email", "username", "password1", "password2", ), }, ), ) And replaced everywhere from django.contrib.auth.models import User to from django.contrib.auth import get_user_model User = get_user_model()
Good thank
darn you shorts for converting me... and all hail the algorithm for putting this in front of me. I was looking for a simple oauth integration with django!
@ajudmeister
2 ай бұрын
All hail the algorithm then! I am glad you find it useful.
@la009895
2 ай бұрын
@@ajudmeister so reading the docs, it would be pretty easy to add in google oauth to this, right?
@ajudmeister
2 ай бұрын
@@la009895 yes it should be, but haven’t done it yet myself.
@la009895
2 ай бұрын
@@ajudmeister I smell a new short. How to add oauth to your project quickly!
@ajudmeister
2 ай бұрын
@@la009895 lol, we will see. maybe it takes 2 seconds, no idea yet
Thank You. That was great great great ♥. Sir, Do you plan to teach multiple user types example: [teacher, admin, student, parent] ? Best Wishes and Good Luck
@ajudmeister
2 ай бұрын
Thank you! I assume you are talking about different permission settings for different groups. I might integrate it in a future project, yes.
by the way, i see that you use alpineJS and hyperscript as well, my question is which of them both would you prefer and why?
@ajudmeister
3 ай бұрын
i really like alpine because it's easy to use for many often used behaviours. hyperscript is still a bit obscure to me, if I need some custom javascript I might opt to use vanilla javascript instead if I had to choose.
Great video! Currently looking into how to use social login with management and connecting accounts, and 2FA with Authenticator apps but can't find anything on KZread :(
@ajudmeister
3 ай бұрын
Thanks. Will put social login and 2FA authentication in the list. allauth has documentation for the different logins, but haven’t tried them out myself yet.
@codernerd7076
3 ай бұрын
@ajudmeister thank you! 😊
@fernandtape9363
3 ай бұрын
Very nice, thanks. Can you plz add tailwind configuration with the django-tailwind package?
@ajudmeister
2 ай бұрын
i will make another deep dive into tailwind when Tailwind v4 is out.
Thanks, this is great, but there may be a bug, or I missed a step. If you go to Login, then select "sign up" from the hyperlink after a new user is created they redirect to home rather than profile creation. To fix it update the login.html href --> href="{% url 'account_signup' %}?next={% url 'profile-onboarding' %}"
@ajudmeister
2 ай бұрын
Thank you, well spotted! I made a copy of the login.html file from the allauth templates and added the "next" parameter. I also deleted the {% blocktrans %} tag, that was causing an issue there. Cheers!
Encountered a problem with {% if user.emailaddress_set.first.verified %} in templates/users/profile_settings.html. Had to change first to last ({% if user.emailaddress_set.first.verified %} to show the correct status. Maybe some recent updates to Allauth changed ordering. UPD: Turned out it doesn's matter because there should be only one EmailAddress object. But somehow I had two (initial and changed). Tried to replicate it again but everything's working as intended.
@ajudmeister
18 күн бұрын
Are you using allauth? With allauth a user could have more email addresses associated with the same user, thats why I am using .first because it gives me back a list, but should only have one object in it. If you got somehow two, maybe the save method didn't update the email but created a new object instead, then the last might be verified.
@twiceasviewtiful
17 күн бұрын
@@ajudmeister Yeah. Turned out I had two because I changed email once before writing post_save signal part that's why a new object was created.
is this project use ORM? and i wonder if instead of using orm, can we use raw sql🤔
@ajudmeister
10 күн бұрын
Yes, it is using Django’s ORM system, however you can write raw SQL queries aswell if you prefer.
Why can't you explain what are you writing? This is for beginners, so please explain how is this working
@ajudmeister
4 күн бұрын
Hello, as I mentioned in the intro this video is a bit advanced and not for absolute beginners. You should check out my backend tutorial series if you are new to django as I explain the concept there in detail. All the best
would be very helpful if you could point out how can we load allauth with another language as I believe it supports multi language templates.
@ajudmeister
8 күн бұрын
Django indeed supports multi language templates, however I have not worked with them yet, so I can only refer to the official Django documentation.
@anouarben779
8 күн бұрын
@@ajudmeister thanks Andreas I managed to get them working after a bit of back and forth.