Skip to content

Joaxin/django-skeleton-cat

Repository files navigation

django-skeleton-cat

A template for launching new Django projects quickly.

Screenshots

main

sign_up

admin

Features

Comes with a complete user authentication flow, custom user model, and social authentication options via Gmail, Facebook, Twitter, etc.

For django-skeleton-cat-allauth:

  • Use django Social authentication via django-allauth
  • Support DRF(DjangoRestFramework)
  • An CRUD demo with DRF
  • Custom user model
  • Still building…..

For django-skeleton-cat-simple:

  • Use django built-in authentication system
  • Extended user model

For django-skeleton-cat-registration:

  • Use django-registration system
  • Still building…..

First-time setup

setup a virtualenv if needed

mkdir env
virtualenv dj
source dj/bin/activate
cd yourproject
pip install -r requirements.txt
python manage.py makemigrations users
python manage.py makemigrations images
python manage.py migrate

Create a superuser:

python manage.py createsuperuser
# A user with that username already exists.
test/test/[email protected] ==> test7...
luna/luna/[email protected]
luna2/luna2/[email protected]
luna3/...

Run:

python manage.py runserver

Load the site at http://127.0.0.1:8000.

Authentication URL

https://docs.djangoproject.com/en/3.1/topics/auth/default/

Defualt (django.contrib.auth.views)

urlpatterns = [
    path('users/', include('django.contrib.auth.urls')),
]

This will include the following URL patterns:

LoginView
users/ login/ [name='login']
Defaults to registration/login.html

LogoutView
users/ logout/ [name='logout']
Defaults to registration/logged_out.html.

PaswordChangeView
users/ password_change/ [name='password_change']
Defaults to registration/password_change_form.html

PasswordChangeDoneView
users/ password_change/done/ [name='password_change_done']
Defaults to registration/password_change_done.html

PasswordResetView
users/ password_reset/ [name='password_reset']
Defaults to registration/password_reset_form.html

PasswordResetDoneView
users/ password_reset/done/ [name='password_reset_done']
Defaults to registration/password_reset_done.html

PasswordResetConfirmView
users/ reset/<uidb64>/<token>/ [name='password_reset_confirm']
Defaults to registration/password_reset_confirm.html.

PasswordResetCompleteView
users/ reset/done/ [name='password_reset_complete']
Defaults to registration/password_reset_complete.html

If you want more control over your URLs, you can reference a specific view in your URLconf:

from django.contrib.auth import views as auth_views
urlpatterns = [
  path('login/',auth_views.LoginView.as_view(),name='login'),
    ...
]

The views have optional arguments you can use to alter the behavior of the view.

For example, if you want to change the template name a view uses, you can provide the template_name argument. A way to do this is to provide keyword arguments in the URLconf, these will be passed on to the view. For example:

path('logout/',
    auth_views.LogoutView.as_view(
        template_name='registration/logged_out.html',
        next_page=None
    ),
    name = 'logout'
)
urlpatterns = [
    path(
        'change-password/',
        auth_views.PasswordChangeView.as_view(template_name='registration/change-password.html'),
    ),
]

Django-allauth

accounts/ ^ ^signup/$ [name='account_signup']
accounts/ ^ ^login/$ [name='account_login']
accounts/ ^ ^logout/$ [name='account_logout']
accounts/ ^ ^password/change/$ [name='account_change_password']
accounts/ ^ ^password/set/$ [name='account_set_password']
accounts/ ^ ^inactive/$ [name='account_inactive']
accounts/ ^ ^email/$ [name='account_email']
accounts/ ^ ^confirm-email/$ [name='account_email_verification_sent']
accounts/ ^ ^confirm-email/(?P<key>[-:\w]+)/$ [name='account_confirm_email']
accounts/ ^ ^password/reset/$ [name='account_reset_password']
accounts/ ^ ^password/reset/done/$ [name='account_reset_password_done']
accounts/ ^ ^password/reset/key/(?P<uidb36>[0-9A-Za-z]+)-(?P<key>.+)/$ [name='account_reset_password_from_key']
accounts/ ^ ^password/reset/key/done/$ [name='account_reset_password_from_key_done']

Next Steps

Adding Social Authentication

Thanks to

About

A template for launching new Django projects quickly.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published