I was trying to disable sending email activation of activation. but it is not happening
What i tried is i copy the registration folder in to my project and by following How to disable email activation in django-registration app? answers i changed in the file but it is not happening .
i also done the same changes in the files of the folder
/usr/local/lib/python2.7/dist-packages/registration/
but still it is not stopping .
When i do register it is going the page that verification email is send and when i check in admin it is showing not activated .
Please suggest what can be problem
Instead of hacking, use SimpleBackend which doesn't send anything but registers user immediately.
Related
So I'm working on this django web app and I want to create a contact me form for my client. My client wants the users of his website to be able to send him emails directly from the form available on the platform. But my client uses a free yahoo email address.
I'm kind of confused of where to begin. But here is my suggested approach see if you can give me an advice:
1- create a form in the forms.py with the different fields of the form.
2 - link the form to the template.
3- create the view for the contact form.
4- add the path in the url pattern.
I read an article that says I need to go through an email service like SendGrid to actually send an email. But it said that I need a professional account to be able to do it.
I really appreciate your attention.
Your way to go looks good.
You do not need any sending service, as long as you have a proper SMTP account to use for sending.
Just add the SMTP credentials to your settings.py and you can use the django core functions to send email messages.
https://docs.djangoproject.com/en/4.0/topics/email/#send-mail
https://docs.djangoproject.com/en/4.0/topics/email/#smtp-backend
I am using Django allauth for authentication to my rest api. I have the whole process working as expected (login, registration, password reset) with email confirmation ..etc.
My question is when a user register the user receives an email with the link that user need to click and confirm to get access to the website. However, i want to use allauth but instead of a link I want a randomly generated activation code (example: 123456). That user can input in a form to confirm.
Allauth currently doesn't support this. You could open up an issue asking for the feature to be implemented, but considering that there's really no obvious advantage of using both systems, I doubt this would be accepted.
Is there a reason why the link method doesn't work for you, but this does? If so, maybe there's some workaround that could work?
Here's a possible workaround (albeit a very complicated one):
Write a template tag that would trim out the website part (ex example.com/confirm/ out of example.com/confirm/sdafsdagfsagfsdafasdfsafgfdsg), so that only the actual code is sent to the user in the email
Make a form that would accept this code, and, on submission, reconstruct the url back to its original state, and go to that url, effectively activating the account. You would almost definitely need to write custom javascript for this.
I have a django project where I want to create users, and some time later be able to send a welcome email with a link inviting them to log in and set a password.
I'm using django-allauth. I found this SO question which shows how to call allauth's password reset form, which is close to what I need, except that:
I want to send a "welcome" email, which would be worded differently.
I want it to send them to a "welcome" page, which would be different to a password reset (although perhaps operate the same way in that it use a token etc...)
I'm thinking I could somehow hijack that, but am not sure how or where that email gets sent.
django-allauth docs mention the routes /accounts/password/set/ and /accounts/password/set/ but I can't access either without logging in first.
This is an existing project I inherited, and I do have a template for "/account/password_reset_from_key.html". Just not sure how it all gets wired together.
Has anyone done anything similar?
You mention:
...and some time later be able to send a welcome email with a link inviting them to log in and set a password.
If sometime later, then you might be interested in queues like Celery to do that for you.
Here's an approach you might take:
Listen to the save django model signal on the User model. Send an email to a user whenever that is triggered (this will happen immediately. However with your "some time later" thing, then you add that sending to the user to a celery job queue for later
Send a dynamic email with html. With this, you can customize the design etc to your taste.
Is there a way to use django's inbuilt password reset function without sending reset links via email or without the email option. I am currently developing a simple system with a few number of users on which sending emails are not needed.Thanks in advance
There are some options in django.contrib.auth that allows you to change the password without needing to send an email:
PasswordChangeForm: A form that lets a user change their password by entering their old password.
SetPasswordForm: A form that lets a user change set their password without entering the old password
You can implement one of them in your view to change the users password.
You can change password with forms and in the views.py use the function
make_password()
if passwordForm.is_valid():
password = passwordForm.cleaned_data['password']
request.user.password = make_password(password)
request.user.save()
[make_password][1]https://docs.djangoproject.com/en/1.11/topics/auth/passwords/
I'm not familiar with django but I've worked on other apps before where access was gained for any user, even the initial admin, via password reset. In all those cases the method of working has been similar - the reset link is formed from some URL stub plus a unique key that is found in some database table somewhere. Manually assembling the link and using it worked out just fine, though one system used an emailsentdate column and refused to do anything unless it was populated , so check for anything similar if you don't get success with a simple approach
If you absolutely have to have an email server, there do exist simple ones intended for dev use like smtpdev, they behave like an smtp server to fool an app that demands one, but they don't send the emails onto anywhere, they just display them. Intended for debugging but might help you if django insists on one being configured that looks like a real mail server
I am using django-allauth to handle user registration in my site. I noticed a strange behavior. Let's say I register a new user in the site. That user get's a new email with a link to click. When the user clicks that link it takes him in the confirm page. There the user clicks the confirm button and users email is confirmed.
The problem is that as as a side effect the user is also logged in. I don't want that. This only happens only the first time I visit that page. If I visit that page again and confirms the email the user does not log in automatically.
My question is how can I prevent the user log in even in the first time he confirms the email. I searched the documentation but couldn't not find any setting to prevent this. Also I looked in the source code of ConfirmEmailView and I can't see a way to turn off this behavior besides manually commenting this line
resp = self.login_on_confirm(confirmation)
Update:
I think I found a workaround to the problem without having to fork or whatever. I just copied that class in my own views file trying to make sure I also imported all the other dependencies that are needed. Then I just deleted that call on login and the function that it calls. I hope I did a good job with that. After that in my urls.py, right before the imports for allauth, I copied the line that is used for confirm-email and redirected it to my own view. And now it looks like this
url(r'^accounts/confirm-email/(?P<key>\w+)/$', 'userprofile.views.confirm_email',
name="account_confirm_email"),
Seems a bit hackish but it seems to work well. I hope someone comes up with a better solution.
There is an option on the configuration ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION. It is True by default. Set it to False.
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = False
looking at the ConfirmEmailView from here one can see that login is done only if LOGIN_ON_EMAIL_CONFIRMATION is true. In order to prevent login on email confirmation you should set LOGIN_ON_EMAIL_CONFIRMATION to False in settings.py.