This project is a simple Login System built using Python and Django. It provides basic authentication features, allowing users to register, log in, and log out. The project is intended to serve as a starting point for building more complex web applications that require user authentication.
- User Registration: New users can sign up and create an account by providing a unique username and password.
- User Login: Registered users can log in with their credentials to access the authenticated portions of the application.
- User Logout: Authenticated users can log out to terminate their session.
To run the Login System locally, follow these steps:
- Clone the repository to your local machine:
git clone https://github.com/harshita-d/Login-System-with-Python-and-Django.git
- Change the working directory to the project folder:
cd Login-System-with-Python-and-Django
- VirtualBox: Ensure that VirtualBox is installed on your system. If not, download and install it from the official website: VirtualBox.
-
Run the command
vagrant init ubuntu/bionic64to initialize the Vagrantfile for the project. -
Start the Vagrant server using
vagrant up.
-
To create an SSH connection to the Vagrant server, run
vagrant ssh. To exit the SSH session, typeexit. -
Change to the Vagrant project directory with
cd /vagrant. -
To stop and destroy the Vagrant server, execute the command:
vagrant destroy. -
To gracefully exit the Vagrant server, use the command:
vagrant halt.
To run Python files within the Vagrant server, simply execute the following command:
python filename.py
-
Inside the project directory, run
vagrant sshto access the Vagrant server. -
Change to the
/vagrant/directory usingcd /vagrant/. -
Create the Python virtual environment in the Vagrant server:
python -m venv ~/env
Note: ~/env refers to the path where the virtual environment will be created.
- Activate the virtual environment:
source ~/env/bin/activate
To deactivate the virtual environment, run:
deactivate
- VirtualBox: Ensure that VirtualBox is installed on your system. If not, download and install it from the official website: VirtualBox.
-
Clone the Project:
git clone <project_repository_url> cd <project_folder> -
Start Virtual Machine:
vagrant up -
SSH into the Virtual Machine:
vagrant ssh -
Change Directory:
cd /vagrant -
Activate the Virtual Environment:
source ~/env/bin/activate -
Run the Server:
python manage.py runserver 0.0.0.0:8000The Django development server will now be running at
http://127.0.0.1:8000/.
To create migration files for the Django app, follow these steps:
-
Navigate to the project code directory:
cd source/...... (Replace the ellipsis with the path to the 'profiles-rest-api' folder) -
SSH into the Virtual Machine:
vagrant ssh -
Change Directory:
cd /vagrant -
Activate the Virtual Environment:
source ~/env/bin/activate -
Create Migration Files:
python manage.py makemigrations profiles_apiReplace
profiles_apiwith the name of the app for which you want to create migration files.
To apply the migration files to the database, follow these steps:
-
Navigate to the project code directory:
cd source/...... (Replace the ellipsis with the path to the 'profiles-rest-api' folder) -
SSH into the Virtual Machine:
vagrant ssh -
Change Directory:
cd /vagrant -
Activate the Virtual Environment:
source ~/env/bin/activate -
Run Migrations:
python manage.py migrate
That's it! The Django server should now be up and running, and the database should be up-to-date with the migrations.
To create a superuser, follow these steps:
-
Navigate to the project code directory:
cd source/...... (Replace the ellipsis with the path to the 'profiles-rest-api' folder) -
SSH into the Virtual Machine:
vagrant ssh -
Change Directory:
cd /vagrant -
Activate the Virtual Environment:
source ~/env/bin/activate -
Create Superuser:
python manage.py createsuperuser
Follow the prompts to set the username, email, and password for the superuser.