cc2e082d53d410e3b6114c9e5d69bf26fe3cc0e8
Zoneco ORG Backend API
A professional Django REST Framework backend for Zoneco ORG with PostgreSQL database.
Features
- Contact Us API: Handle contact form submissions with name, email/phone, description, and category
- Composition API: Manage compositions with name, description, and image
- Campaign API: Manage campaigns with name, description, start/end times, and image
- RESTful API: Full CRUD operations for all models
- CORS Enabled: Configured for frontend integration
- Image Upload: Support for image uploads with proper media handling
- Admin Panel: Django admin interface for managing data
Database Configuration
- Database Name: Zoneco_ORG
- User: postgres
- Password: postgres
- Host: localhost
- Port: 5432
Installation
-
Install Python dependencies:
pip install -r requirements.txt -
Create PostgreSQL database:
CREATE DATABASE "Zoneco_ORG"; -
Run migrations:
python manage.py makemigrations python manage.py migrate -
Create superuser (optional):
python manage.py createsuperuser -
Run development server:
python manage.py runserver
The API will be available at http://localhost:8000/api/
API Endpoints
Contact Us
GET /api/contact-us/- List all contactsPOST /api/contact-us/- Create new contact (public)GET /api/contact-us/{id}/- Get specific contactPUT /api/contact-us/{id}/- Update contact (authenticated)PATCH /api/contact-us/{id}/- Partial update (authenticated)DELETE /api/contact-us/{id}/- Delete contact (authenticated)GET /api/contact-us/by_category/?category={category}- Filter by category
Compositions
GET /api/compositions/- List all compositionsPOST /api/compositions/- Create new composition (authenticated)GET /api/compositions/{id}/- Get specific compositionPUT /api/compositions/{id}/- Update composition (authenticated)PATCH /api/compositions/{id}/- Partial update (authenticated)DELETE /api/compositions/{id}/- Delete composition (authenticated)
Campaigns
GET /api/campaigns/- List all campaignsPOST /api/campaigns/- Create new campaign (authenticated)GET /api/campaigns/{id}/- Get specific campaignPUT /api/campaigns/{id}/- Update campaign (authenticated)PATCH /api/campaigns/{id}/- Partial update (authenticated)DELETE /api/campaigns/{id}/- Delete campaign (authenticated)GET /api/campaigns/active/- Get active campaignsGET /api/campaigns/upcoming/- Get upcoming campaignsGET /api/campaigns/ended/- Get ended campaigns
Models
ContactUs
name(CharField): Name of the contactemail_or_phone(CharField): Email or phone numberdescription(TextField): Message descriptioncategory(CharField): Category (همکاری, فروش, پشتیبانی, درخواست مشاور, سایر)created_at(DateTimeField): Creation timestampupdated_at(DateTimeField): Last update timestamp
Composition
name(CharField): Name of the compositiondescription(TextField): Descriptionimage(ImageField): Composition imagecreated_at(DateTimeField): Creation timestampupdated_at(DateTimeField): Last update timestamp
Campaign
name(CharField): Campaign namedescription(TextField): Campaign descriptionstart_time(DateTimeField): Campaign start timeend_time(DateTimeField): Campaign end timeimage(ImageField): Campaign imagecreated_at(DateTimeField): Creation timestampupdated_at(DateTimeField): Last update timestamp
Admin Panel
Access the Django admin panel at http://localhost:8000/admin/ after creating a superuser.
CORS Configuration
CORS is configured to allow requests from:
http://localhost:5173(Vite default)http://localhost:3000http://127.0.0.1:5173http://127.0.0.1:3000
Media Files
Uploaded images are stored in the media/ directory:
- Composition images:
media/compositions/ - Campaign images:
media/campaigns/
Development Notes
- The backend uses Django REST Framework for API endpoints
- PostgreSQL is used as the database
- Image uploads are handled via multipart/form-data
- All models include proper indexing for performance
- Serializers include validation and proper error handling
- Viewsets provide both public read access and authenticated write access
Description
Languages
Python
90.4%
Shell
7.1%
Dockerfile
2.5%