A modern, feature-rich online newspaper platform built with Django. This application allows users to read news articles, rate them, and provides an editorial system for content management.
- News Articles: Browse and read news articles organized by categories
- Rating System: Users can rate articles (0-4 stars) with comments
- Category Management: News organized by different categories
- User Authentication: Registration, login, and profile management
- Editorial System: Special editor accounts for content creation
- Responsive Design: Mobile-friendly interface using Bootstrap 5
- General Users: Can read articles, rate them, and manage their profiles
- Editors: Can create, edit, and publish news articles
- Administrators: Full access to manage users, categories, and content
- Article Views Tracking: Monitor article popularity
- Editor Performance: Track editor statistics and ratings
- Image Upload: Support for article images
- Search & Filter: Browse articles by category
- Admin Dashboard: Comprehensive admin interface
- Backend: Django 4.2.5
- Frontend: HTML5, CSS3, Bootstrap 5, JavaScript
- Database: SQLite (default) / PostgreSQL (production ready)
- Forms: Django Crispy Forms with Bootstrap 5
- Image Processing: Pillow
- Styling: Custom CSS + Bootstrap 5
- Python 3.7 or higher
- pip (Python package installer)
- Git (for cloning the repository)
-
Clone the repository
git clone <repository-url> cd django-online-newspaper-main
-
Run the setup script
python setup.py
-
Start the server
python run.py
-
Clone and navigate to the project
git clone <repository-url> cd django-online-newspaper-main
-
Create a virtual environment (recommended)
python -m venv newspaper_env source newspaper_env/bin/activate # On Windows: newspaper_env\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Run database migrations
python manage.py makemigrations python manage.py migrate
-
Collect static files
python manage.py collectstatic
-
Create a superuser account
python manage.py createsuperuser
-
Start the development server
python manage.py runserver
- Main Website: http://127.0.0.1:8000
- Admin Panel: http://127.0.0.1:8000/admin
- User Accounts: http://127.0.0.1:8000/accounts/
- Posts Management: http://127.0.0.1:8000/posts/
django-online-newspaper-main/
βββ π accounts/ # User management app
β βββ π migrations/ # Database migrations
β βββ π templates/ # Account-related templates
β βββ models.py # User and Editor models
β βββ views.py # Account views
β βββ forms.py # User forms
β βββ urls.py # Account URLs
βββ π posts/ # News articles app
β βββ π migrations/ # Database migrations
β βββ π templates/ # Post-related templates
β βββ models.py # Post, Category, Rating models
β βββ views.py # Post views
β βββ forms.py # Post forms
β βββ urls.py # Post URLs
βββ π Newspaper_Site/ # Main project settings
β βββ settings.py # Django settings
β βββ urls.py # Main URL configuration
β βββ views.py # Main views
β βββ wsgi.py # WSGI configuration
βββ π templates/ # Global templates
βββ π static/ # Static files (CSS, JS, images)
βββ π media/ # User uploaded files
βββ π staticfiles/ # Collected static files
βββ db.sqlite3 # SQLite database
βββ manage.py # Django management script
βββ requirements.txt # Python dependencies
βββ setup.py # Automated setup script
βββ run.py # Quick run script
βββ README.md # This file
- Registration: Create an account at
/accounts/register/ - Login: Access your account at
/accounts/login/ - Browse News: View articles on the homepage organized by categories
- Rate Articles: Click "Give Rating" on any article to rate and comment
- View Details: Click "Details" to read the full article
- Profile Management: Update your profile information
- Apply for Editor Role: Submit an application through the accounts section
- Wait for Approval: Admin needs to approve your editor application
- Create Articles: Once approved, create and publish news articles
- Manage Content: Edit your published articles
- Track Performance: View your editor statistics and ratings
- Access Admin Panel: Visit
/admin/with superuser credentials - Manage Users: Approve editor applications, manage user accounts
- Content Management: Oversee all articles and categories
- System Monitoring: Track site statistics and user activity
Create a .env file based on .env.example:
cp .env.example .envEdit the .env file with your specific configuration:
SECRET_KEY=your-secret-key-here
DEBUG=True
ALLOWED_HOSTS=localhost,127.0.0.1SQLite (Default)
- No additional configuration needed
- Database file:
db.sqlite3
PostgreSQL (Production)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'newspaper_db',
'USER': 'your_username',
'PASSWORD': 'your_password',
'HOST': 'localhost',
'PORT': '5432',
}
}- ApplicationsForEditors: Editor application requests
- EditorsProfile: Editor profile information
- User: Django's built-in user model (extended)
- Category: News categories (Sports, Politics, Technology, etc.)
- Post: News articles with metadata
- Rating: User ratings and comments for articles
- Main CSS:
static/css/style.css - Bootstrap 5 integration
- Responsive design for mobile devices
- Base template:
templates/base.html - Account templates:
accounts/templates/ - Post templates:
posts/templates/
python manage.py runserver- Set
DEBUG = False - Configure proper database (PostgreSQL recommended)
- Set up static file serving
- Configure email backend
- Set up proper logging
- Use environment variables for sensitive data
- Set up SSL/HTTPS
- Configure allowed hosts
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
Migration Errors
python manage.py makemigrations --empty accounts
python manage.py makemigrations --empty posts
python manage.py migrateStatic Files Not Loading
python manage.py collectstatic --clearPermission Errors
chmod +x setup.py run.py- Check the Django documentation: https://docs.djangoproject.com/
- Review the error logs in the console
- Ensure all dependencies are installed correctly
For support and questions:
- Create an issue in the repository
- Check existing documentation
- Review the troubleshooting section
Happy Coding! π
Built with β€οΈ using Django and Bootstrap