mfogel / django-simple-email-confirmation Goto Github PK
View Code? Open in Web Editor NEWSimple email confirmation for django.
Simple email confirmation for django.
I am trying to use django-simple-email-confirmation in my django project and install by pip, when I use it and trying to make migration, the following is happended:
"path\simple_email_confirmation\models.py", line 217, in EmailAddress
settings.AUTH_USER_MODEL, related_name='email_address_set',
TypeError: init() missing 1 required positional argument: 'on_delete'
And I fixed it by adding on_delete=models.CASCADE in simple_email_confirmation\models.py, Django 2.0 seems need to add it.
Should the key length be increased from the regular 12 digit to a more bigger number?
def generate_key(self):
"Generate a new random key and return it"
# sticking with the django defaults
return get_random_string(length=30)
Hello!
I installed this app to use in my project and it seems to work nicely. However I realised that the users created before the installation of this app return false for .is_confirmed(). This prevents them from logging in. I tried making a data migration for running user.confirm_email(user.confirmation_key) but user.confirmation_key throws an error saying EmailAddress matching query does not exist. Does this mean that the old users entirely lack some database connections to at all be functioning with this app?
How can I properly migrate to mitigate this issue? Thanks!
First and foremost, thank you for creating a great django module. Its a pleasure to use.
Would it be possible to have a LICENSE file added? I'd like to respect author's intent when using their code.
I get the following error
/views.py", line 115, in post
send_mail(user.email, 'Use %s to confirm your email' % user.confirmation_key)
TypeError: send_mail() missing 2 required positional arguments: 'from_email' and 'recipient_list'
Please update documentation!
Thanks
It would be nice to be able to override the default EmailAddress model. In my case, I would like to use UUID PKs instead of the default AutoField.
Others might want to attach additional fields to the model.
RemovedInDjango19Warning: Model class simple_email_confirmation.models.EmailAddress doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
Hello,
I use Django 2.1.3, and django-simple-email-confirmation 0.23
When I want to check if request.user is confirmed or not, I get the error:
'User' object has no attribute 'is_confirmed'
code:
if request.user.is_confirmed:
So, I'm using this app in my django project, and I noticed one strange thing.
When I create a user using form.
if request.method == 'POST' and 'email' in request.POST:
args['form'] = EmployeeCreationForm()
form = EmployeeCreationForm(request.POST)
if form.is_valid():
user = form.save()
And I try to access: user.confirmation_key
Sometimes I get user's confirmation key, or I can get EmaillAdress DoesNotExist exception.
It doesn't depend on any code. I tested it about 10 times, it happens on random.
So, I came up with this code:
try:
confirmation_key = user.confirmation_key
msg_html = render_to_string('email/confirmation.html', {'key' : confirmation_key})
return send_mail('Confirmation email', '[email protected]', [user.email], html_message=msg_html,
)
except:
confirmation_key = user.add_unconfirmed_email(user.email)
msg_html = render_to_string('email/confirmation.html', {'key' : confirmation_key})
return send_mail('Confirmation email', '[email protected]', [user.email], html_message=msg_html,
)
So, I try to access user.confirmation_key, if I catch DoesNotExist, I create it manually.
Of course, it shouldn't work that way.
Any thoughts?
I believe it is a problem with signals (they can't reach on time or something)
Django version 1.8.2
Also, here is some messages from my terminal:
simple_email_confirmation/models.py:203: RemovedInDjango19Warning: Model class simple_email_confirmation.models.EmailAddress doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class EmailAddress(models.Model):
simple_email_confirmation/models.py:203: RemovedInDjango19Warning: Model class simple_email_confirmation.models.EmailAddress doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.
class EmailAddress(models.Model):
When I run manage.py sqlall <app-name>
, I get this:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
app-name.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
app-name.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
I followed the instructions exactly and each user is also bound to a profile with a OneToOneField
.
what is send_email? the django core lib is called send_mail
Tested with django==3.0.0
and django==3.0.1
File "/home/k/.virtualenvs/focsec/lib/python3.6/site-packages/simple_email_confirmation/models.py", line 9, in <module>
from django.utils.encoding import python_2_unicode_compatible
ImportError: cannot import name 'python_2_unicode_compatible'
It seems that this was dropped in Django 3.0.0 (see release notes) and can simply be fixed by importing directly from six
I extended this package to support Django Rest Framework for a personal project. This is a functionality that is not supported by any other email verification package for Django (that I have found).
Would there be interest in merging this into this package (like what django-filter does). Or, should I create a separate package to bolt on the functionality?
@mdamien maybe you're already aware, but just in case...
New release is here but un-installable via pip.
If version number is unspecified, 0.12 is installed
If 0.20 is specified :
pip install django-simple-email-confirmation==0.20
Collecting django-simple-email-confirmation==0.20
Could not find a version that satisfies the requirement django-simple-email-confirmation==0.20 (from versions: 0.9, 0.9.1, 0.10, 0.10.1, 0.10.2, 0.11, 0.12)
No matching distribution found for django-simple-email-confirmation==0.20
And BTW, thanks for stepping up man!
I use my fork in 2 Django 4 projects.
Need to update migrations for Django 1.7.
https://docs.djangoproject.com/en/dev/topics/migrations/#libraries-third-party-apps
There should be an example on how to use this module without adding the mixin to the user model.
There is a lot of functionality included in our user mixin. Consequently, there is also much complexity inherent in ensuring that the app functions properly both with and without it.
I propose that we drop the line in our docs that mentions that the app can be used without applying the mixin. It would greatly simplify our maintenance and reduce the worry of adding new features to the mixin.
Please reply with any objections you may have!
We should add some detailed documentation and host it on ReadTheDocs. This is required for our Jazzband transfer jazzband/help#27
After following the instructions on the README, I get this error message from the console when trying to run makemigrations command:
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
myauth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
myauth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
My guess was because AUTH_USER_MODEL wasn't pointing to my new User model. However, after setting it to myapp.models.User I got this error message about a missing table:
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py", line 187, in create_user
**extra_fields)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py", line 182, in _create_user
user.save(using=self._db)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 734, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 771, in save_base
update_fields=update_fields, raw=raw, using=using)
File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 201, in send
response = receiver(signal=self, sender=sender, **named)
File "/usr/local/lib/python2.7/dist-packages/simple_email_confirmation/models.py", line 278, in auto_add
user.add_unconfirmed_email(email)
File "/usr/local/lib/python2.7/dist-packages/simple_email_confirmation/models.py", line 115, in add_unconfirmed_email
address = self.email_address_set.create_unconfirmed(email)
File "/usr/local/lib/python2.7/dist-packages/simple_email_confirmation/models.py", line 180, in create_unconfirmed
address = self.create(user=user, email=email, key=key)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/related.py", line 752, in create
return super(RelatedManager, self.db_manager(db)).create(**kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 348, in create
obj.save(force_insert=True, using=self.db)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 734, in save
force_update=force_update, update_fields=update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 762, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 846, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 885, in _do_insert
using=using, raw=raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 127, in manager_method
return getattr(self.get_queryset(), name)(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 920, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 974, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 97, in exit
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/sqlite3/base.py", line 318, in execute
return Database.Cursor.execute(self, query, params)
OperationalError: no such table: simple_email_confirmation_emailaddress
When I have:
AUTH_USER_MODEL = 'MyApp.User' and User model is in MyApp.migrations.0001_initial that depends on ('simple_email_confirmation', '0001_initial')
simple_email_confirmation has migrations 0001_initial that depends on migrations.swappable_dependency(settings.AUTH_USER_MODEL) which means MyApp.migrations.0001_initial
This causes the django migrations not work.
I think it'd be useful a lot of people.
This is just FYI. On accessing https://github.com/mfogel/django-simple-email-confirmation and after waiting for the README to load, it looks like badges from pypi.in show up as broken links and you'll notice 404 errors in the console.
Relevant issue badges/pypipins#37
Not sure if you want those to be removed or switched out to use shields.io . If you prefer removing them, I'd be happy to open a pull request for that :)
As per @mfogel's commit, I was thinking of Jazzband (github, website), which has been designed for this particular case. I believe this project definitely falls into the scope of the guidelines, minus a few tweaks. What do you guys think?
Adding the mixin to the User model is not clear to me as a django newbie:
Auth
app in my project?AUTH_USER_MODEL
in the settings.py
file?I think this part could be made more clear in the docs.
Hello
I realized that the version of the code you install directly from pip is the 0.23, when the last version of the code you have here is the 0.6, with significant changes.
Is there any plans to upgrade the pip version? what about the 1.0 version you mention at the end of the documentation?
Thanks.
Unhandled exception in thread started by <function check_errors..wrapper at 0x0000021DA49B3A60>
Traceback (most recent call last):
File "C:\Users\nEW u\PycharmProjects\prayrollproj3\venv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\nEW u\PycharmProjects\prayrollproj3\venv\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "C:\Users\nEW u\PycharmProjects\prayrollproj3\venv\lib\site-packages\django\core\management\base.py", line 425, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
paymentapp.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
paymentapp.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
In EmailAddress's unicode instead of return '{} ({})'.format(self.email, self.user)
return return '{} <{}>'.format(self.user, self.email)
which would result in a value u"Full Name <[email protected]>"
that can be used as an email parameter to send_email
.
It's just a suggestion, it would be beneficial to some, I think.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.