Welcome to the Online Course Platform! This platform is built using Django and provides a robust environment for creating and managing online courses.
Follow these steps to set up the Django project and implement user app registration, login, and logout.
-
Clone the repository:
git clone https://github.com/your-username/your-project.git
-
Navigate to the project directory:
cd your-project
-
Create a virtual environment (optional but recommended):
python -m venv venv
-
Activate the virtual environment:
-
On Windows:
.\venv\Scripts\activate
-
On macOS and Linux:
source venv/bin/activate
-
-
Install dependencies:
pip install -r requirements.txt
-
Inside your Django app directory, create a
static
folder.cd your_app_name mkdir static
-
Place your static files (CSS, JS, images, etc.) inside the
static
folder.
-
In your Django app, create a
registration
folder inside thetemplates
directory.cd your_app_name/templates mkdir registration
-
Create
registration/login.html
andregistration/logout.html
templates for login and logout views. -
Update your project's
urls.py
to include Django's built-in authentication views.# your_project_name/urls.py from django.contrib.auth import views as auth_views urlpatterns = [ # ... your other URL patterns path('accounts/login/', auth_views.LoginView.as_view(template_name='registration/login.html'), name='login'), path('accounts/logout/', auth_views.LogoutView.as_view(template_name='registration/logout.html'), name='logout'), # ... your other URL patterns ]
-
Ensure the
django.contrib.auth
app is included in yourINSTALLED_APPS
insettings.py
.# your_project_name/settings.py INSTALLED_APPS = [ # ... other apps 'django.contrib.auth', 'django.contrib.contenttypes', # ... other apps ]
-
Run migrations:
python manage.py makemigrations python manage.py migrate
-
Run the development server:
python manage.py runserver
-
Access the login page at http://localhost:8000/accounts/login/ and the logout page at http://localhost:8000/accounts/logout/.
Congratulations! You've completed the initial setup and implemented user app registration, login, and logout functionalities. Continue building your Online Course Platform by adding more features and functionalities as needed.