Skip to content

Latest commit

 

History

History
218 lines (175 loc) · 5.81 KB

README.md

File metadata and controls

218 lines (175 loc) · 5.81 KB

BlogMasterDjangoExercise

English | فارسی

Introduction

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.

Prerequisites

Ensure your system has:

  • Python 3.6 or higher
  • pip (Python package manager)
  • (Optional) virtualenv for isolated environments

Installation & Setup

1. Clone the Repository

Clone the source code from GitHub:

git clone https://github.com/YourUsername/YourProjectName.git
cd YourProjectName

2. Create a Virtual Environment (Optional but Recommended)

python -m venv venv

Activate the virtual environment:

  • Windows:
    venv\Scripts\activate
  • Linux/Mac:
    source venv/bin/activate

3. Install Dependencies

Install packages from requirements.txt:

pip install -r requirements.txt

4. Apply Migrations

Set up the database:

python manage.py migrate

5. Create a Superuser (Optional)

python manage.py createsuperuser

Follow the prompts to set up a username, email, and password.

6. Run the Development Server

python manage.py runserver

Visit http://127.0.0.1:8000 in your browser.

Project Structure

- mysite/            # Main project folder
  - settings.py      # Project settings
  - urls.py          # Main URL configurations
- blog/              # Blog app
  - admin.py         # Admin panel registration
  - models.py        # Database models (articles, categories)
  - templates/       # HTML templates
  - static/          # CSS, JS, images
  - migrations/      # Database migration files
- db.sqlite3         # Default SQLite database (development)
- manage.py          # Django management tool

Usage

View the Blog

Visit http://127.0.0.1:8000 to see the blog.

Access the Admin Panel

  1. Go to http://127.0.0.1:8000/admin.
  2. Log in with your superuser credentials.

Create/Edit Articles

  • Use the admin panel to manage articles.
  • Public pages display articles and their details.

Development Notes

Model Changes

After modifying models:

python manage.py makemigrations
python manage.py migrate

Static Files (Production)

python manage.py collectstatic

Environment Settings

Modify mysite/settings.py for database, email, etc.

License

MIT License

Contact


فارسی

مقدمه

این پروژه یک وبلاگ ساده و قدرتمند با استفاده از فریمورک Django است. هدف، ایجاد بستری برای تولید، ویرایش و نمایش مقالات با روش‌های بهینه جنگو می‌باشد. این فایل شامل مراحل نصب، راه‌اندازی، استفاده، تست و توسعه پروژه است.

پیش‌نیازها

  • پایتون 3.6 یا بالاتر
  • pip (مدیر بسته‌های پایتون)
  • (اختیاری) virtualenv برای محیط‌های مجزا

نصب و راه‌اندازی

1. کلون کردن مخزن

git clone https://github.com/YourUsername/YourProjectName.git
cd YourProjectName

2. ایجاد محیط مجازی (اختیاری)

python -m venv venv

فعالسازی محیط:

  • ویندوز:
    venv\Scripts\activate
  • لینوکس/مک:
    source venv/bin/activate

3. نصب بسته‌ها

pip install -r requirements.txt

4. اعمال مهاجرت‌ها

python manage.py migrate

5. ایجاد سوپر کاربر (اختیاری)

python manage.py createsuperuser

6. اجرای سرور توسعه

python manage.py runserver

به آدرس http://127.0.0.1:8000 مراجعه کنید.

ساختار پروژه

- mysite/            # پوشه اصلی پروژه
  - settings.py      # تنظیمات پروژه
  - urls.py          # تنظیمات URL اصلی
- blog/              # اپلیکیشن وبلاگ
  - admin.py         # ثبت مدل‌ها در پنل مدیریت
  - models.py        # مدل‌های پایگاه داده (مقالات، دسته‌بندی‌ها)
  - templates/       # قالب‌های HTML
  - static/          # فایل‌های استاتیک
  - migrations/      # فایل‌های مهاجرت
- db.sqlite3         # پایگاه داده پیش‌فرش SQLite
- manage.py          # ابزار مدیریت جنگو

نحوه استفاده

مشاهده وبلاگ

به آدرس http://127.0.0.1:8000 بروید.

پنل مدیریت

  1. آدرس http://127.0.0.1:8000/admin.
  2. با حساب سوپر کاربر وارد شوید.

مدیریت مقالات

  • از پنل مدیریت برای ایجاد یا ویرایش مقالات استفاده کنید.
  • صفحات عمومی، مقالات را نمایش می‌دهند.

نکات توسعه

تغییر مدل‌ها

پس از تغییر مدل‌ها:

python manage.py makemigrations
python manage.py migrate

فایل‌های استاتیک (محیط تولید)

python manage.py collectstatic

تنظیمات محیطی

ویرایش mysite/settings.py برای پایگاه داده، ایمیل و غیره.

مجوز

مجوز MIT

ارتباط با توسعه‌دهنده