Git Product home page Git Product logo

django-improved-user's Introduction

Latest Release: PyPI Version Github Tag

Documentation: Stable Documentation Status

Compatibility: Python Implementation Support Python Support Django Support License Black

Tests: pre-commit.ci status Coverage Status

Read Me

This project provides a custom user model that improves on Django's default by making a few modern and international changes.

  • Uses email as the username to simplify login for users
  • Replace first_name and last_name with international friendly short_name and full_name fields

The project also provides mix-in classes to make building custom User models easier.

For an explanation of why and how the project was built, please see the Project Rationale.

For information about getting started, please refer to the quickstart documentation.

For information about how to help with the project, please see the contributing documentation.

django-improved-user's People

Contributors

dependabot[bot] avatar freakboy3742 avatar jambonrose avatar justinmayer avatar landermkerbey avatar pre-commit-ci[bot] avatar pyup-bot avatar securedirective 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

django-improved-user's Issues

Unable to import AbstractUserCreationForm or AbstractUserChangeForm independently of package

Specifications

  • Platform/System: macOS 10.12.6
  • Python Version: 3.6.2
  • Django Version: 1.11.6
  • Improved User Version: 1.0a1

Expected Behavior

In a Django project, if I can import the abstract models, I should also be able to import the abstract forms. I can also see instances where extending the UserFactory class could be useful. To provide the greatest flexibility, this project should use Django's get_user_model() function in all locations where it needs to reference the User model.

Actual Behavior

Just as Issue #36 described an inability to import the mix-in model classes without needing to add improved_user to INSTALLED_APPS, the same error occurs when attempting to import AbstractUserCreationForm or AbstractUserChangeForm or attempting to extend the UserCreationForm or UserChangeForm classes.

The moment forms.py is loaded, the following error occurs:

  File "/Users/user/ttt/.venv/lib/python3.6/site-packages/improved_user/forms.py", line 7, in <module>
    from .models import User
  File "/Users/user/ttt/.venv/lib/python3.6/site-packages/improved_user/models.py", line 12, in <module>
    class User(AbstractUser):
  File "/Users/user/ttt/.venv/lib/python3.6/site-packages/django/db/models/base.py", line 118, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class improved_user.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

For the record, the offending line of code also exists in your factories.py, and causes the same error when imported. If UserFactory is intended to be available for import/extending, then the fix will have to be applied to both files.

Context

In my project, I am already importing AbstractBaseUser in order to add more fields. To also provide a custom UserAdmin class to show all my extra user model fields, I included the following in my admin.py:

from improved_user.forms import UserCreationForm, UserChangeForm
from .models import User

class UserAdmin(BaseUserAdmin):
    # The forms to add and change user instances
    add_form = UserCreationForm
    form = UserChangeForm

The import above causes the error.

Steps to Reproduce the Problem

  1. Create a new Django project with a new Django app.
  2. Run pip install git+https://github.com/jambonsw/django-improved-user.git.
  3. Include the sample code above.
  4. Run a Django check to trigger the error.

Case sensitivity of email addresses

Specifications

  • Platform/System: Ubuntu 16.04
  • Python Version: 3.5.2
  • Django Version: 1.11
  • Improved User Version: 0.5.3

Expected Behavior

I would expect default behavior to be case-insensitive.

Actual Behavior

After creating a "[email protected]" account, I cannot create another with the same email. But this user model does allow me to create "[email protected]" without any error message. The result is two separate accounts whose emails would actually reach the same inbox, due to ISPs ignoring case.

Context

RFC 5321 Part 2.4 states that only the domain portion of an email is case-insensitive. So django-improved-user is compliant. But since most ISPs treat emails as fully case-insensitive, using this package could end up with unexpected results, compared to the authentication behavior of most websites out there today.

Are there any plans to do this here too? Perhaps a standard-compliant case-sensitive version of EmailAuthMixin and UserManager could be provided in case the developer prefers that?

If you agree with this route, I don't mind doing some research on how case-insensitive uniqueness could be accomplished.

RemovedInDjango40Warning: django.utils.translation.ugettext_lazy() is deprecated...

Specifications

  • Platform/System: Windows 10 (using Windows Subsystem for Linux)
  • Python Version: 3.8.5
  • Django Version: 3.1.4
  • Improved User Version: 1.0.1

Expected Behavior

A Django project with improved user should run without warnings.

Actual Behavior

When I upgrade my project to Django 3,1.4, I receive warnings about being deprecated from the improved user package.

Context

This issue is not currently causing any problems with my codebase. However, when Django 4.x releases in about a year, it will prevent me from upgrading to Django 4.x.

Steps to Reproduce the Problem

  1. Create a Django project with version 3.1.x
  2. Install django improved user 1.0.1
  3. run `python -Wa manage.py runserver' to run with warnings
  4. See multiple warnings like:
    /filelocation/env/lib/python3.8/site-packages/improved_user/model_mixins.py:115: RemovedInDjango40Warning: django.utils.translation.ugettext_lazy() is deprecated in favor of django.utils.translation.gettext_lazy(). verbose_name_plural = _('users')

Thank you for providing this package, and let me know if there is anything I can clarify.

Last Login should only be set if user logs in

The UserManager currently sets both date_joined and last_login to the current date. Later Django versions make it so that last_login is only set if the user has actually logged in.

We ostensibly have a test for this in test_models.py. Some exploration for what is going on here is required.

Thanks to @jschneier for reporting this at DjangoCon US 2017.

Unable to Import Mix-in Classes independently of package

Specifications

  • Platform/System: macOS 10.11
  • Python Version: 3.6
  • Django Version: 1.11
  • Improved User Version: 0.5.3

Expected Behavior

In a Django project: I expect to be able to import the mix-in model classes without needing to add improved_user to INSTALLED_APPS.

Actual Behavior

Django evaluates the User model and attempts to add it to the database.

  File "/Users/andrew/Development/verified-auth/.tox/py36-django111-unit/lib/python3.6/site-packages/verified_auth/models.py", line 7, in <module>
    from improved_user.models import (
  File "/Users/andrew/Development/verified-auth/.tox/py36-django111-unit/lib/python3.6/site-packages/improved_user/models.py", line 167, in <module>
    class User(AbstractUser):
  File "/Users/andrew/Development/verified-auth/.tox/py36-django111-unit/lib/python3.6/site-packages/django/db/models/base.py", line 118, in __new__
    "INSTALLED_APPS." % (module, name)
RuntimeError: Model class improved_user.models.User doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

Context

I am using the provided mix-in classes and manager to create a new User model in a separate app.

from django.contrib.auth.models import (
    AbstractBaseUser, PermissionsMixin,
)
from django.db import models
from django.utils.translation import ugettext_lazy as _
from improved_user.models import (
    DjangoIntegrationMixin, EmailAuthMixin, UserManager,
)

The import above causes the traceback listed above.

If I add improved_user to INSTALLED_APPS I believe Django will pollute my database with a table for User, which I am seeking to replace.

Steps to Reproduce the Problem

  1. Create a new Django project with a new Django app
  2. Install django-improved-user==0.5.3
  3. Import the tools (as seen in the code above)
  4. Run migrations or tests to cause the RunTimeError

Test Naming Conventions

Hi Russ,
In PR #1, some of the test functions are named following the convention test_bug_\d+_\w+. Out of curiosity, what tracker are those issues referring to?

Upgrade Django-Registration to 2.3

PyUp attempted to upgrade django-registration to version 2.3 in PR #40. Unfortunately, due to ubernostrum/django-registration#106, and ubernostrum/django-registration#113 our integration tests fail.

While the first will likely be fixed shortly, the solution to the second problem is less clear. What's more, the long term plan is for django-registration to remove the use of auth_urls, meaning developers will need to import URLs from both Django and django-registration.

In preparation for django-registration v3, the example project should build its own set of URLs, pulling in authentication URLs from Django and using views from django-registration directly (eventually/potentially to be replaced by a URL configuration in django-registration v3). In turn, this will allow django-improved-user to use the most recent version of django-registration.

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.