Are you ready to dive into the world of Django and SQL? Setting up a simple Django project is a great way to start! In this article, we’ll walk you through the installation and configuration process step by step, ensuring you have everything you need to get your project up and running smoothly. Let’s embark on this coding adventure!
Installation Steps
To successfully set up your simple Django project, you will need to follow these prerequisites.
1. Install Python
First things first, ensure you have Python installed. You will need Python 3.7.2 and python-pip. Follow the steps from the reference document based on your operating system:
2. Install MySQL
Next, install MySQL 8.0.15. Again, follow the steps according to your operating system:
3. Setup Virtual Environment
A virtual environment is essential to manage dependencies effectively:
bash
# Install virtual environment
sudo pip install virtualenv
# Make a directory
mkdir envs
# Create virtual environment
virtualenv .envs
# Activate virtual environment
source envs/bin/activate
4. Clone Git Repository
Clone the project repository from GitHub:
bash
git clone https://github.com/Manisha-Bayyas/simple-django-project.git
5. Install Requirements
Next, navigate to your cloned repository and install the required packages:
bash
cd simple-django-project
pip install -r requirements.txt
6. Load Sample Data into MySQL
Open your MySQL bash and load the sample data:
bash
# Open MySQL bash
mysql -u mysql-user -p
# Give the absolute path of the file
mysql> source ~simple-django-project/world.sql;
# Exit MySQL
mysql> exit;
7. Edit Project Settings
Now, edit your project settings to configure the database and email settings:
bash
# Open settings file
vim panorbit/settings.py
# Edit Database configurations
# Search for DATABASES section
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'world',
'USER': 'mysql-user',
'PASSWORD': 'mysql-password',
'HOST': 'mysql-host',
'PORT': 'mysql-port',
}
}
# Edit email configurations
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'your-email'
EMAIL_HOST_PASSWORD = 'your-email-password'
EMAIL_PORT = 587
# Save the file
8. Run the Server
Your final setup step involves running the server:
bash
# Make migrations
python manage.py makemigrations
python manage.py migrate
# For search feature we need to index certain tables to the haystack
python manage.py rebuild_index
# Run the server
python manage.py runserver 0:8001
Your server is now live on port 8001. Try opening http://localhost:8001 in your browser!
9. Explore the URLs
Now that your server is running, you can explore various functionalities:
- Signup: http://localhost:8001/signup
- Login: http://localhost:8001/login
- Home for Search: http://localhost:8001
- Country Page: http://localhost:8001/country/kenya
- Logout: http://localhost:8001/logout
Troubleshooting
If you encounter issues during the setup, consider the following troubleshooting tips:
- Ensure all prerequisites are installed correctly before proceeding.
- Check the database configurations and ensure MySQL is running.
- If you face issues while activating the virtual environment, double-check your shell commands.
- For any dependency errors, verify the packages in requirements.txt.
For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.
Final Words
At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

