OisinWrites / Byte

A Restaurant Booking Page
0 stars 2 forks source link

E7, User Story 1: Utilise and implement django's Allauth library for all user account operations. #49

Open OisinWrites opened 1 year ago

OisinWrites commented 1 year ago

Task 1: Install Django Allauth

  1. Open a terminal or command prompt.
  2. Navigate to the root directory of your Django project.
  3. Activate your virtual environment (if you are using one).
  4. Run the following command to install Django Allauth:
    pip install django-allauth

Task 2: Configure Django Allauth in Settings

  1. Open your Django project's settings file (settings.py).
  2. Add 'allauth' and 'allauth.account' to the INSTALLED_APPS list:
    INSTALLED_APPS = [
       ...
       'allauth',
       'allauth.account',
       ...
    ]
  3. Configure the authentication backends by adding the following line to the settings:
    AUTHENTICATION_BACKENDS = [
       'django.contrib.auth.backends.ModelBackend',
       'allauth.account.auth_backends.AuthenticationBackend',
    ]

    This ensures that Allauth is used for authentication.

Task 3: URL Configuration

  1. Open your Django project's URL configuration file (urls.py).
  2. Import the necessary modules:
    from django.urls import include
  3. Add the URL patterns for Allauth views by including the following line in the urlpatterns list:
    urlpatterns = [
       ...
       path('accounts/', include('allauth.urls')),
       ...
    ]

    This sets up the URL patterns for Allauth's views.

Task 4: Database Migration

  1. In the terminal or command prompt, navigate to the root directory of your Django project.
  2. Run the following command to create the necessary database migrations:
    python manage.py makemigrations
  3. Apply the migrations by running the following command:
    python manage.py migrate

    This will create the required database tables for Allauth.

Task 5: Static Files Configuration

  1. In your project's settings file, make sure you have properly configured static files handling. Example:
    STATIC_URL = '/static/'
    STATIC_ROOT = os.path.join(BASE_DIR, 'static')
  2. Run the following command to collect the static files required by Allauth:
    python manage.py collectstatic