-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
55 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,71 @@ | ||
# learnDjango | ||
```md | ||
# learnDjango 🌐 | ||
|
||
1) add your .cnf file for adding <b>mysql</b> as <b>database</b> | ||
2) cnf file format : | ||
 | ||
 | ||
 | ||
 | ||
|
||
<code>[client] | ||
--- | ||
|
||
## 🛠️ **Project Setup** | ||
|
||
This guide will walk you through configuring MySQL as your database using a secure `.cnf` file for sensitive credentials. | ||
|
||
### **Step 1: Add MySQL Configuration File** | ||
|
||
- Create a `.cnf` file that contains the necessary database connection information. | ||
|
||
#### **Sample `my.cnf` File Format**: | ||
|
||
```ini | ||
[client] | ||
database = DB_NAME | ||
host = localhost | ||
user = DB_USER | ||
password = DB_PASSWORD | ||
default-character-set = utf8</code> | ||
default-character-set = utf8 | ||
``` | ||
|
||
> ⚠️ **Note:** Never hardcode personal or sensitive information in your project's codebase. Use the `.cnf` file to protect your credentials. | ||
--- | ||
|
||
3) <b>update</b> the <b>settings.py</b> with <b>path</b> to .cnf file: | ||
### **Step 2: Update `settings.py` to Include `.cnf` File** | ||
|
||
<code>DATABASES = { | ||
In your Django project's `settings.py`, update the `DATABASES` configuration to use the `.cnf` file for database credentials: | ||
|
||
```python | ||
DATABASES = { | ||
'default': { | ||
'ENGINE': 'django.db.backends.mysql', | ||
'OPTIONS': { | ||
'read_default_file': '/path/to/my.cnf', | ||
}, | ||
} | ||
}</code> | ||
} | ||
``` | ||
|
||
- Replace `/path/to/my.cnf` with the actual file path to your `.cnf` file. | ||
|
||
--- | ||
|
||
## 📸 **Screenshots** | ||
|
||
<div align="center"> | ||
<img src="./project_images/1.png" alt="Setup Screenshot" width="300" /> | ||
<img src="./project_images/2.png" alt="CNF File Screenshot" width="300" /> | ||
<img src="./project_images/3.png" alt="CNF File Screenshot" width="300" /> | ||
</div> | ||
|
||
--- | ||
|
||
## 🤝 **Contributing** | ||
|
||
- Fork this repository | ||
- Create a new branch: `git checkout -b feature/<branch_name>` | ||
- Commit your changes: `git commit -m '<commit_message>'` | ||
- Push to the branch: `git push origin feature/<branch_name>` | ||
- Open a pull request | ||
|
||
<h3>for security purposes we need .cnf file not to directly hardcode the personal info.</h3> | ||
--- |