djangorestframework_emailuser


Namedjangorestframework_emailuser JSON
Version 0.3.1.dev0 PyPI version JSON
download
home_pageNone
SummaryA user for djangorestframework that uses an email as the username.
upload_time2023-07-11 15:04:33
maintainerNone
docs_urlNone
authorNone
requires_python>=3.7
licenseNone
keywords django djangorestframework drf user emailuser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            djangorestframework_emailuser
=============================

.. image:: https://github.com/simlist/django-rest-framework-emailuser/actions/workflows/testing-and-coverage.yml/badge.svg?branch=master
    :target: https://github.com/simlist/pyluach/actions/workflows/testing-and-coverage.yml

.. image:: https://coveralls.io/repos/github/simlist/django-rest-framework-emailuser/badge.svg?branch=master
    :target: https://coveralls.io/github/simlist/django-rest-framework-emailuser?branch=master

Overview
--------

A user for djangorestframework that uses an email as the username.

Features
--------

* Use email as username for loging in
* One name field instead of first name and last name
* Endpoints for creating an account, viewing, and updating accounts
* Django admin to work with EmailUser model.

Requirements
------------

- Python 3.5+
- Django 2.2+
- Djangorestframework 3.10+

Installation and Configuration
------------------------------

Install using ``pip``:

.. code-block:: sh

  $ pip install djangorestframework_emailuser

Add ``'emailuser'`` to ``INSTALLED_APPS``:

.. code-block:: Python

  # mysite/settings.py
  INSTALLED_APPS = [
      ...
      'emailuser',
  ]

Add the following line to ``settings.py`` to override django's default User
model with the 'EmailUser' model:

.. code-block:: Python

  # mysite/settings.py
  AUTH_USER_MODEL = 'emailuser.EmailUser'

Add urls to url conf:

.. code-block:: Python

  # mysite/urls.py
  from django.urls import path, include
  urlpatterns = [
    ...
    path('accounts/', include('emailuser.urls')),
  ]

Using
-----
To create a user programatically:

.. code-block:: Python

  from django.contrib.auth import get_user_model

  normal_user = get_user_model().objects.create_user(
      email='me@example.com',
      name='My Name',
      password='MyPassword'
  )

  superuser = get_user_model().objects.create_superuser(
      email='admin@example.com',
      name='Super Name',
      password='MySuperPassword'
  )

Using Endpoints:
~~~~~~~~~~~~~~~~
Assuming emailuser urls were set to ``/accounts/``:

Creating user
?????????????
``POST`` ``{"email": email, "name": name, "password": password}``
to ``/accounts/users/register``

Updating User
?????????????
``PUT`` ``{"email": email, "name": name, "password": password}``
to ``/accounts/users/<int:pk>/``
or
``PATCH`` the attribute you want to change
to ``/accounts/users/<int:pk>/``

Referencing User
????????????????
To reference user object in your code as a string (As for foreign keys):

.. code-block:: Python

  from django.conf import settings

  user_model = settings.AUTH_USER_MODEL

To reference the user class directly:

.. code-block:: Python

  from django.contrib.auth import get_user_model

  user_model = get_user_model()

See `Django docs <https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#referencing-the-user-model>`_  for more details.

Attributes
~~~~~~~~~~
The EmailUser model has the following attributes:

email
  The email address used as the login username.

name
    A single field for the name of the user.
password
  The password is hashed as set by the django settings.

is_superuser
  A boolean attribute that can only be set programatically.

is_staff
  A boolean attribute that can be set by the admin site or
  programatically.

EmailUser also subclasses ``django.contrib.auth.models.PermissionsMixin``.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "djangorestframework_emailuser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "django,djangorestframework,drf,user,emailuser",
    "author": null,
    "author_email": "MS List <simlist@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4d/0e/a7e4377d691661c9c9ec3252e291a33c9a28782da4d50f50602541ba866d/djangorestframework_emailuser-0.3.1.dev0.tar.gz",
    "platform": null,
    "description": "djangorestframework_emailuser\n=============================\n\n.. image:: https://github.com/simlist/django-rest-framework-emailuser/actions/workflows/testing-and-coverage.yml/badge.svg?branch=master\n    :target: https://github.com/simlist/pyluach/actions/workflows/testing-and-coverage.yml\n\n.. image:: https://coveralls.io/repos/github/simlist/django-rest-framework-emailuser/badge.svg?branch=master\n    :target: https://coveralls.io/github/simlist/django-rest-framework-emailuser?branch=master\n\nOverview\n--------\n\nA user for djangorestframework that uses an email as the username.\n\nFeatures\n--------\n\n* Use email as username for loging in\n* One name field instead of first name and last name\n* Endpoints for creating an account, viewing, and updating accounts\n* Django admin to work with EmailUser model.\n\nRequirements\n------------\n\n- Python 3.5+\n- Django 2.2+\n- Djangorestframework 3.10+\n\nInstallation and Configuration\n------------------------------\n\nInstall using ``pip``:\n\n.. code-block:: sh\n\n  $ pip install djangorestframework_emailuser\n\nAdd ``'emailuser'`` to ``INSTALLED_APPS``:\n\n.. code-block:: Python\n\n  # mysite/settings.py\n  INSTALLED_APPS = [\n      ...\n      'emailuser',\n  ]\n\nAdd the following line to ``settings.py`` to override django's default User\nmodel with the 'EmailUser' model:\n\n.. code-block:: Python\n\n  # mysite/settings.py\n  AUTH_USER_MODEL = 'emailuser.EmailUser'\n\nAdd urls to url conf:\n\n.. code-block:: Python\n\n  # mysite/urls.py\n  from django.urls import path, include\n  urlpatterns = [\n    ...\n    path('accounts/', include('emailuser.urls')),\n  ]\n\nUsing\n-----\nTo create a user programatically:\n\n.. code-block:: Python\n\n  from django.contrib.auth import get_user_model\n\n  normal_user = get_user_model().objects.create_user(\n      email='me@example.com',\n      name='My Name',\n      password='MyPassword'\n  )\n\n  superuser = get_user_model().objects.create_superuser(\n      email='admin@example.com',\n      name='Super Name',\n      password='MySuperPassword'\n  )\n\nUsing Endpoints:\n~~~~~~~~~~~~~~~~\nAssuming emailuser urls were set to ``/accounts/``:\n\nCreating user\n?????????????\n``POST`` ``{\"email\": email, \"name\": name, \"password\": password}``\nto ``/accounts/users/register``\n\nUpdating User\n?????????????\n``PUT`` ``{\"email\": email, \"name\": name, \"password\": password}``\nto ``/accounts/users/<int:pk>/``\nor\n``PATCH`` the attribute you want to change\nto ``/accounts/users/<int:pk>/``\n\nReferencing User\n????????????????\nTo reference user object in your code as a string (As for foreign keys):\n\n.. code-block:: Python\n\n  from django.conf import settings\n\n  user_model = settings.AUTH_USER_MODEL\n\nTo reference the user class directly:\n\n.. code-block:: Python\n\n  from django.contrib.auth import get_user_model\n\n  user_model = get_user_model()\n\nSee `Django docs <https://docs.djangoproject.com/en/2.2/topics/auth/customizing/#referencing-the-user-model>`_  for more details.\n\nAttributes\n~~~~~~~~~~\nThe EmailUser model has the following attributes:\n\nemail\n  The email address used as the login username.\n\nname\n    A single field for the name of the user.\npassword\n  The password is hashed as set by the django settings.\n\nis_superuser\n  A boolean attribute that can only be set programatically.\n\nis_staff\n  A boolean attribute that can be set by the admin site or\n  programatically.\n\nEmailUser also subclasses ``django.contrib.auth.models.PermissionsMixin``.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A user for djangorestframework that uses an email as the username.",
    "version": "0.3.1.dev0",
    "project_urls": {
        "Source": "https://github.com/simlist/django-rest-framework-emailuser"
    },
    "split_keywords": [
        "django",
        "djangorestframework",
        "drf",
        "user",
        "emailuser"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "46275b8e3e5bec047087c51eadbab70f3444091735c57e3c96c5efc02b14f8bd",
                "md5": "8f733709e0868a19bd4cde505251111a",
                "sha256": "ac06df2088a3af660eade2e464165892351d4158640ea81fdf143b2d54ab15b9"
            },
            "downloads": -1,
            "filename": "djangorestframework_emailuser-0.3.1.dev0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8f733709e0868a19bd4cde505251111a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8524,
            "upload_time": "2023-07-11T15:04:27",
            "upload_time_iso_8601": "2023-07-11T15:04:27.321595Z",
            "url": "https://files.pythonhosted.org/packages/46/27/5b8e3e5bec047087c51eadbab70f3444091735c57e3c96c5efc02b14f8bd/djangorestframework_emailuser-0.3.1.dev0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4d0ea7e4377d691661c9c9ec3252e291a33c9a28782da4d50f50602541ba866d",
                "md5": "587cba65af0849b792c6260ad2135d9b",
                "sha256": "d1e3ac00711d11e17575a19c1d3d2e2ca86e62f83c90100fa6c8f1f7455fd23e"
            },
            "downloads": -1,
            "filename": "djangorestframework_emailuser-0.3.1.dev0.tar.gz",
            "has_sig": false,
            "md5_digest": "587cba65af0849b792c6260ad2135d9b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8033,
            "upload_time": "2023-07-11T15:04:33",
            "upload_time_iso_8601": "2023-07-11T15:04:33.941615Z",
            "url": "https://files.pythonhosted.org/packages/4d/0e/a7e4377d691661c9c9ec3252e291a33c9a28782da4d50f50602541ba866d/djangorestframework_emailuser-0.3.1.dev0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-11 15:04:33",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "simlist",
    "github_project": "django-rest-framework-emailuser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "djangorestframework_emailuser"
}
        
Elapsed time: 1.34336s