|
| 1 | +# BlogMasterDjangoExercise |
| 2 | + |
| 3 | +**English** | [فارسی](#فارسی) |
| 4 | + |
| 5 | +## Introduction |
| 6 | +This project is a simple yet powerful blog built using the Django framework. The goal is to provide a platform for creating, editing, and displaying articles using Django best practices. This README includes complete steps for installation, setup, usage, testing, and development. |
| 7 | + |
| 8 | +## Prerequisites |
| 9 | +Ensure your system has: |
| 10 | +- **Python 3.6** or higher |
| 11 | +- **pip** (Python package manager) |
| 12 | +- (Optional) **virtualenv** for isolated environments |
| 13 | + |
| 14 | +## Installation & Setup |
| 15 | + |
| 16 | +### 1. Clone the Repository |
| 17 | +Clone the source code from GitHub: |
| 18 | +```bash |
| 19 | +git clone https://github.com/YourUsername/YourProjectName.git |
| 20 | +cd YourProjectName |
| 21 | +``` |
| 22 | + |
| 23 | +### 2. Create a Virtual Environment (Optional but Recommended) |
| 24 | +```bash |
| 25 | +python -m venv venv |
| 26 | +``` |
| 27 | +Activate the virtual environment: |
| 28 | +- **Windows:** |
| 29 | + ```bash |
| 30 | + venv\Scripts\activate |
| 31 | + ``` |
| 32 | +- **Linux/Mac:** |
| 33 | + ```bash |
| 34 | + source venv/bin/activate |
| 35 | + ``` |
| 36 | + |
| 37 | +### 3. Install Dependencies |
| 38 | +Install packages from `requirements.txt`: |
| 39 | +```bash |
| 40 | +pip install -r requirements.txt |
| 41 | +``` |
| 42 | + |
| 43 | +### 4. Apply Migrations |
| 44 | +Set up the database: |
| 45 | +```bash |
| 46 | +python manage.py migrate |
| 47 | +``` |
| 48 | + |
| 49 | +### 5. Create a Superuser (Optional) |
| 50 | +```bash |
| 51 | +python manage.py createsuperuser |
| 52 | +``` |
| 53 | +Follow the prompts to set up a username, email, and password. |
| 54 | + |
| 55 | +### 6. Run the Development Server |
| 56 | +```bash |
| 57 | +python manage.py runserver |
| 58 | +``` |
| 59 | +Visit [http://127.0.0.1:8000](http://127.0.0.1:8000) in your browser. |
| 60 | + |
| 61 | +## Project Structure |
| 62 | +``` |
| 63 | +- mysite/ # Main project folder |
| 64 | + - settings.py # Project settings |
| 65 | + - urls.py # Main URL configurations |
| 66 | +- blog/ # Blog app |
| 67 | + - admin.py # Admin panel registration |
| 68 | + - models.py # Database models (articles, categories) |
| 69 | + - templates/ # HTML templates |
| 70 | + - static/ # CSS, JS, images |
| 71 | + - migrations/ # Database migration files |
| 72 | +- db.sqlite3 # Default SQLite database (development) |
| 73 | +- manage.py # Django management tool |
| 74 | +``` |
| 75 | + |
| 76 | +## Usage |
| 77 | + |
| 78 | +### View the Blog |
| 79 | +Visit [http://127.0.0.1:8000](http://127.0.0.1:8000) to see the blog. |
| 80 | + |
| 81 | +### Access the Admin Panel |
| 82 | +1. Go to [http://127.0.0.1:8000/admin](http://127.0.0.1:8000/admin). |
| 83 | +2. Log in with your superuser credentials. |
| 84 | + |
| 85 | +### Create/Edit Articles |
| 86 | +- Use the admin panel to manage articles. |
| 87 | +- Public pages display articles and their details. |
| 88 | + |
| 89 | +## Development Notes |
| 90 | + |
| 91 | +### Model Changes |
| 92 | +After modifying models: |
| 93 | +```bash |
| 94 | +python manage.py makemigrations |
| 95 | +python manage.py migrate |
| 96 | +``` |
| 97 | + |
| 98 | +### Static Files (Production) |
| 99 | +```bash |
| 100 | +python manage.py collectstatic |
| 101 | +``` |
| 102 | + |
| 103 | +### Environment Settings |
| 104 | +Modify `mysite/settings.py` for database, email, etc. |
| 105 | + |
| 106 | +## License |
| 107 | +MIT License |
| 108 | + |
| 109 | +## Contact |
| 110 | +- Created with ❤️ by [Sorna](https://github.com/sorna-fast) |
| 111 | +- Email: masudpythongit@gmail.com |
| 112 | + |
| 113 | +--- |
| 114 | + |
| 115 | +# فارسی |
| 116 | + |
| 117 | +## مقدمه |
| 118 | +این پروژه یک وبلاگ ساده و قدرتمند با استفاده از فریمورک Django است. هدف، ایجاد بستری برای تولید، ویرایش و نمایش مقالات با روشهای بهینه جنگو میباشد. این فایل شامل مراحل نصب، راهاندازی، استفاده، تست و توسعه پروژه است. |
| 119 | + |
| 120 | +## پیشنیازها |
| 121 | +- **پایتون 3.6** یا بالاتر |
| 122 | +- **pip** (مدیر بستههای پایتون) |
| 123 | +- (اختیاری) **virtualenv** برای محیطهای مجزا |
| 124 | + |
| 125 | +## نصب و راهاندازی |
| 126 | + |
| 127 | +### 1. کلون کردن مخزن |
| 128 | +```bash |
| 129 | +git clone https://github.com/YourUsername/YourProjectName.git |
| 130 | +cd YourProjectName |
| 131 | +``` |
| 132 | + |
| 133 | +### 2. ایجاد محیط مجازی (اختیاری) |
| 134 | +```bash |
| 135 | +python -m venv venv |
| 136 | +``` |
| 137 | +فعالسازی محیط: |
| 138 | +- **ویندوز:** |
| 139 | + ```bash |
| 140 | + venv\Scripts\activate |
| 141 | + ``` |
| 142 | +- **لینوکس/مک:** |
| 143 | + ```bash |
| 144 | + source venv/bin/activate |
| 145 | + ``` |
| 146 | + |
| 147 | +### 3. نصب بستهها |
| 148 | +```bash |
| 149 | +pip install -r requirements.txt |
| 150 | +``` |
| 151 | + |
| 152 | +### 4. اعمال مهاجرتها |
| 153 | +```bash |
| 154 | +python manage.py migrate |
| 155 | +``` |
| 156 | + |
| 157 | +### 5. ایجاد سوپر کاربر (اختیاری) |
| 158 | +```bash |
| 159 | +python manage.py createsuperuser |
| 160 | +``` |
| 161 | + |
| 162 | +### 6. اجرای سرور توسعه |
| 163 | +```bash |
| 164 | +python manage.py runserver |
| 165 | +``` |
| 166 | +به آدرس [http://127.0.0.1:8000](http://127.0.0.1:8000) مراجعه کنید. |
| 167 | + |
| 168 | +## ساختار پروژه |
| 169 | +``` |
| 170 | +- mysite/ # پوشه اصلی پروژه |
| 171 | + - settings.py # تنظیمات پروژه |
| 172 | + - urls.py # تنظیمات URL اصلی |
| 173 | +- blog/ # اپلیکیشن وبلاگ |
| 174 | + - admin.py # ثبت مدلها در پنل مدیریت |
| 175 | + - models.py # مدلهای پایگاه داده (مقالات، دستهبندیها) |
| 176 | + - templates/ # قالبهای HTML |
| 177 | + - static/ # فایلهای استاتیک |
| 178 | + - migrations/ # فایلهای مهاجرت |
| 179 | +- db.sqlite3 # پایگاه داده پیشفرش SQLite |
| 180 | +- manage.py # ابزار مدیریت جنگو |
| 181 | +``` |
| 182 | + |
| 183 | +## نحوه استفاده |
| 184 | + |
| 185 | +### مشاهده وبلاگ |
| 186 | +به آدرس [http://127.0.0.1:8000](http://127.0.0.1:8000) بروید. |
| 187 | + |
| 188 | +### پنل مدیریت |
| 189 | +1. آدرس [http://127.0.0.1:8000/admin](http://127.0.0.1:8000/admin). |
| 190 | +2. با حساب سوپر کاربر وارد شوید. |
| 191 | + |
| 192 | +### مدیریت مقالات |
| 193 | +- از پنل مدیریت برای ایجاد یا ویرایش مقالات استفاده کنید. |
| 194 | +- صفحات عمومی، مقالات را نمایش میدهند. |
| 195 | + |
| 196 | +## نکات توسعه |
| 197 | + |
| 198 | +### تغییر مدلها |
| 199 | +پس از تغییر مدلها: |
| 200 | +```bash |
| 201 | +python manage.py makemigrations |
| 202 | +python manage.py migrate |
| 203 | +``` |
| 204 | + |
| 205 | +### فایلهای استاتیک (محیط تولید) |
| 206 | +```bash |
| 207 | +python manage.py collectstatic |
| 208 | +``` |
| 209 | + |
| 210 | +### تنظیمات محیطی |
| 211 | +ویرایش `mysite/settings.py` برای پایگاه داده، ایمیل و غیره. |
| 212 | + |
| 213 | +## مجوز |
| 214 | +مجوز MIT |
| 215 | + |
| 216 | +## ارتباط با توسعهدهنده |
| 217 | +- ساخته شده با ❤️ توسط [Sorna](https://github.com/sorna-fast) |
| 218 | +- ایمیل: masudpythongit@gmail.com |
0 commit comments