- Cloning the Repository
- Installation
- Project Creation
- Running the Program
- App Creation
- Setting Up the Local System Environment
To clone the repository, use:
git clone https://github.com/Akp-arvind/Django-FSD-lab
- Libraries: You can install the required libraries using pip. Open your terminal or command prompt and run the following command:
pip install -r requirements.txt
- Download and install the XAMPP server
https://www.apachefriends.org/download.html
OR
- Download and install WAMP server
https://sourceforge.net/projects/wampserver/files/latest/download
- For WAMP, many files will be missing and the system asks to install them. Hence download the files from this website:
https://wampserver.aviatechno.net/
(Last link ; chose second file after getting redirected ; Windows_64_bit)
Open the terminal and enter the following command:
django-admin startproject <project_name>
( e.g. - "lab" )
Observe that some files are generated.
Once you have installed the necessary libraries, and satisfied the program specific requirements, you can run the program by following these steps:
- Navigate to the project directory using the terminal or command prompt.
- Ensure that XAMPP/WAMP server is running (if required).
- Run the following command to start the Django server:
python manage.py runserver
- Open your web browser and enter the following URL:
http://localhost:8000
OR
http://127.0.0.1:8000
You should now be able to access the program.
You would have to enter the path manually this way.
To create an app, enter the following command in the terminal:
python manage.py startapp <app_name>
( e.g. - "ap2" )
In settings.py file, under TEMPLATES, set:
'DIRS':[os.path.join(BASE_DIR,'ap2/templates')],
This will ensure that the templates for the "ap2" app are accessible.
http://localhost:8000/cdt/
http://localhost:8000/fhb/
http://localhost:8000/fha/
http://localhost:8000/showlist/
- In settings.py, change the DIRS to ap3/templates, run the code and go to:
http://localhost:8000/home/
- Navigation can be done via clicking the links
- Observe the changes in URL after clicking
- In settings.py switch "ap3/templates" with "ap4/templates" under DIRS
- After successful installation of the server from Installation segment, start it and go to:
http://localhost/phpmyadmin
-
Create a new database - “studentreg” (db name)
-
In settings.py file:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'ap4', # added
]
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
# changed from sqlite3 default
'NAME': 'studentreg',
# changed for ap4
'USER': 'root',
'PASSWORD': '',
'HOST':'localhost',
'PORT':'3306',
}
}
STATIC_URL = 'static/'
STATICFILES_DIRS=[os.path.join(BASE_DIR, 'ap4/static')]
# added
- Make migrations to the db:
python manage.py makemigrations ap4
python manage.py migrate
- Add entities in the database tables (ap4_student and ap4_course)
Finally, for viewing the output, run the code and open your web browser to enter the followinbg URL:
http://localhost:8000/reg/
- Remember to stop the server once you're done.
http://localhost:8000/course_search/
-
Changes made to the code have been indicated in the comments.
-
Set the username and password by entering the following command in the terminal:
python manage.py createsuperuser
- Make changes to the db using the admin UI.
To login, enter the following URL in your web browser:
http://localhost:8000/admin/
- Perform migrations if required, run the app and go to:
http://localhost:8000/add_project/
- Add the indicated fields.
- The changes can be viewed here (ap4_project):
http://localhost/phpmyadmin
- Use the following paths for getting generic and detailed views (pre-registered students):
http://localhost:8000/student_list/
http://localhost:8000/student_detail/
- /<int: pk>/ (primary key, e.g. - "/2/") can be apppended here which will display the details of the corresponding student.
- Ensure that the data has been inserted beforehand.
- 9 A
http://localhost:8000/construct_csv_from_model/
- 9 B
http://localhost:8000/construct_pdf_from_model/
- Observe that the files get downloaded as soon as the path is entered.
- Ensure that "jquery.min.js" file is present in the static folder.
http://localhost:8000/regaj/
- Observe that the output is displayed on the same web page (reloading is not required, thanks to Ajax).
http://localhost:8000/course_search_ajax/
- Again, the partial output is loaded on the same page.
- Create a new folder for your project.
- Open the command prompt and navigate to the newly created folder.
- Enter the following command to create a virtual environment named "env":
python -m venv env
This will create a new virtual environment in the "env" folder.
- Activate the virtual environment by running the following command:
env\Scripts\activate
- You can now install the necessary libraries and run the program as mentioned in the previous instructions.
If you're using VS Code, go to View - Command Palette - Python: Select Interpreter - 3.11.1 ( 'env':venv )
Remember to deactivate the virtual environment when you're done by running the following command:
deactivate
This will ensure that your system environment is properly set up for the project.