Hello Folks,
i am using AbstractBaseUser custom user and i need to use authentication system but i dont want to use Class Authentication Views, because it mess with my urls.
can i custom Authentication Views as example can i customize urls and templates folder ?
or
is there any resources i can use make my custom Authentication views with AbstractBaseUser.
Please clarify what you mean by “it mess with my urls”.
Yes you can subclass the system-provided authentication views.
Yes you can change the template_name attribute to refer to a different directory.
Or, you can create the same sub-directory structure to override the templates without subclassing the view.
You’re also not required to use the standard urls for authentication. You’re free to define your own urls that direct a request to the standard authentication views.
Yes, you can read the source code of the existing views to use them as a “pattern” to learn how to create your own views, if you really wanted to do that.
If you would be more specific about what the root issue is that you’re really trying to address, we might be able to provide better advice.
the idea i am thinking is that i edit or custom each view inside django Authentication Views so i will not need Django Authentication Views Urls Anymore.
As Example:
there is a form and logic inside this url, i am trying to edit it or copy to my views functions. so i will be able to use my Urls. instead of Django’s.
I hope it is clear now. and i am very thankful for helping Ken.
There is nothing that requires you to use that path for the auth urls. The docs show that as an example. You are free to assign the auth urls to any path you wish. (You would also want to change the LOGIN_URL and LOGIN_REDIRECT_URL settings to match.)
Now, you can still create and use your own authentication views if you want - but that’s a different question.
Is it that you’re needing to actually change the functionality of the view? Or do you just want to change the template? (You can use a custom template without changing the view.)
but without using the default urls for Django Authentication.
then i can use different folder for templates, and different urls paths and different views names.
Assuming you’re starting from AbstractUser (or AbstractBaseUser), this actually doesn’t matter.
I don’t understand what you’re referring to here.
This actually has nothing to do with the view. A view does not define the url - a url references a view. Changing a view has nothing to do with the urls being used for it.
Yes i am using AbstractBase User, and will inherit from to a Client Class.
Custom Folder: my authentication folder Named accounts not registration as in the views.
custom paths:
accounts/password_reset/ [name='password_reset']
this url as i understand if i will use it i have to use the same url password_reset,
i guess its not very critical i can use the same naming for url paths. if it will not conflict with the django Authentication views itself.
What “folder”? I don’t understand what you’re referring to here. There are no “folders” involved in the views.
Again, I think there’s a terminology issue here - I don’t understand what you’re trying to explain here.
What is your objective behind all this? What specifically do you want the results to be? (I’m beginning to think these questions may be a type of XY problem. Instead of addressing what you think the solution is, I’d like to get to the root issue you’re trying to resolve.)
The Main Goal is To Use or Create Authentication Functions and make it functional in a website.
i need to add in my website:
Reset Password
Reset Password Done
Change Password
Change Password Done
Email Sent
i am really sorry if this is simple task and not a big issue or something need a lot of work.
Why does that matter? That is not something visible to the outside - it’s purely an internal function. If you have 'APP_DIRS': True in your TEMPLATES setting, those templates would still reside in your app. If not, you can include them in your project-level templates directory.
Then work with what’s provided. I don’t understand what it is you’re trying to change, or why.
I have a personal motto I rely upon regularly: “Don’t fight the framework”. Work with Django, not against it. Things work a lot more smoothly that way.