A custom Django authentication module
Project description
Here is a sample README.md file for your Django authentication package. This file includes instructions for installing the package, using it, and overriding components like the User model and views.
# Django Accounts Package
A reusable Django authentication package providing customizable user authentication views and models.
## Installation
Install the package via pip:
```bash
pip install ns-django-custom-auth
Basic Setup
After installation, add accounts to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
...
'accounts',
...
]
Include the authentication URLs in your project's urls.py:
from django.urls import path, include
urlpatterns = [
path('api/auth/', include('accounts.urls')),
...
]
Usage
Importing Views and User Model
To use the default views and user model, you can import them as follows:
from accounts import SignupApiView, LoginApiView, User
Basic Usage Example
In your urls.py, you can include the views provided by the package:
from django.urls import path
from accounts import SignupApiView, LoginApiView
urlpatterns = [
path('signup/', SignupApiView.as_view(), name='signup'),
path('login/', LoginApiView.as_view(), name='login'),
]
Customizing the User Model
To use a custom user model, define it in your app and set AUTH_USER_MODEL in settings.py:
# custom_app/models.py
from django.contrib.auth.models import AbstractUser
from django.db import models
class CustomUser(AbstractUser):
mobile_no = models.CharField(max_length=15, unique=True)
gender = models.CharField(max_length=10, null=True, blank=True)
In your settings.py:
AUTH_USER_MODEL = 'custom_app.CustomUser'
Overriding Signup and Login Views
To customize the SignupApiView and LoginApiView, subclass them and override methods as needed:
# custom_app/views.py
from accounts.views import SignupApiView, LoginApiView
from .models import CustomUser
from .serializers import CustomUserSerializer
class CustomSignupApiView(SignupApiView):
def post(self, request, *args, **kwargs):
# Custom logic for user registration
class CustomLoginApiView(LoginApiView):
def post(self, request, *args, **kwargs):
# Custom logic for user login
In your urls.py:
# custom_app/urls.py
from django.urls import path
from .views import CustomSignupApiView, CustomLoginApiView
urlpatterns = [
path('signup/', CustomSignupApiView.as_view(), name='custom_signup'),
path('login/', CustomLoginApiView.as_view(), name='custom_login'),
]
License
This package is licensed under the MIT License.
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
Contact
For any questions or support, please contact ns848410#gmail.com.
### Summary
- **Installation Instructions:** Details on how to install the package.
- **Basic Usage:** How to include the default views and model.
- **Customization:** Instructions for overriding the `User` model and views.
- **License and Contribution Information:** Details on licensing and how to contribute.
This `README.md` provides clear instructions for using your package and customizing it according to project needs.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ns-django-custom-auth-0.2.tar.gz.
File metadata
- Download URL: ns-django-custom-auth-0.2.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83f8f2169014493f81637b7c5d956ffc5233a9e75598b1e817774d879e98cd53
|
|
| MD5 |
8e8e2400078cfc414923f6873be3b210
|
|
| BLAKE2b-256 |
e6c6f309fb930bf455bb93c4896e6eb30011ed53866c32078a22db20ca0df967
|
File details
Details for the file ns_django_custom_auth-0.2-py3-none-any.whl.
File metadata
- Download URL: ns_django_custom_auth-0.2-py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4ab14f88a2d1f3f9e1f625a0429de0d3dd71e9a29f2dd4bed1b9288cdf5483f
|
|
| MD5 |
a9f9d9239e0187757090a1f98a444f64
|
|
| BLAKE2b-256 |
5332c06d0945a3c7d99f5d9a8dd28d012c25d8e6aa61fc43ce30156bc6d1b5b1
|