# News Portal - Quick Setup Guide

## ✅ Installation Complete!

Your Django News Portal has been successfully set up with the following configuration:

## Database Information
- **Database Name**: httpskitenepal_newsportal
- **Database Type**: MySQL (via XAMPP)
- **Host**: localhost
- **Port**: 3306
- **Username**: httpskitenepal_newsportal
- **Password**: (Pythondeveloper!)

## Admin Account
- **Username**: admin
- **Email**: admin@newsportal.com
- **Password**: You need to set this! (See below)

## Next Steps

### 1. Set Admin Password
Run this command to set the admin password:
```bash
python manage.py changepassword admin
```
Or use Python shell:
```bash
python manage.py shell
```
Then run:
```python
from django.contrib.auth.models import User
user = User.objects.get(username='admin')
user.set_password('your_password_here')
user.save()
exit()
```

### 2. Start the Development Server
```bash
python manage.py runserver
```

### 3. Access the Application
- **Frontend**: http://localhost:8000/
- **Admin Panel**: http://localhost:8000/admin/

### 4. Configure Your Site (Important!)

After logging into the admin panel:

1. **Go to Site Settings**
   - Add your site name
   - Upload logo and favicon
   - Add contact information
   - Add social media links
   - Configure footer text

2. **Create Categories**
   - Go to Categories → Add Category
   - Create news categories (e.g., Politics, Sports, Technology, Entertainment)

3. **Create Your First News Article**
   - Go to News Articles → Add News Article
   - Fill in all required fields
   - Upload featured image
   - Set status to "Published"
   - Check "Is Featured" for homepage display

4. **Add Tags** (Optional)
   - Create tags for better content organization

5. **Add Advertisements** (Optional)
   - Upload ad images
   - Select positions (header, sidebar, footer, content)

## Features Overview

### Admin Features
✅ Complete news management (create, edit, delete)
✅ Category management with images
✅ Tag system
✅ Multiple images per article (gallery)
✅ Comment moderation
✅ Advertisement management
✅ Site-wide settings control
✅ SEO controls (meta descriptions, keywords)
✅ User management

### Frontend Features
✅ Responsive design
✅ Featured news section
✅ Breaking news ticker
✅ Category browsing
✅ Search functionality
✅ Tag filtering
✅ Comment system
✅ Related news
✅ Pagination
✅ Advertisement display

## File Structure

```
newsportal/
├── manage.py
├── README.md
├── SETUP_INSTRUCTIONS.md
├── newsportal_project/
│   ├── settings.py          # Django settings
│   ├── urls.py               # URL configuration
│   └── db_backend/           # Custom MySQL backend for XAMPP compatibility
├── news/
│   ├── models.py             # Database models
│   ├── views.py              # View functions
│   ├── admin.py              # Admin interface
│   └── urls.py               # App URLs
├── templates/                # HTML templates
├── static/                   # CSS, JS, images
└── media/                    # Uploaded files
```

## Important Notes

### XAMPP Compatibility
- This project uses a custom database backend to work with XAMPP's older MariaDB version (10.4.32)
- The custom backend is located in `newsportal_project/db_backend/`

### Media Files
- All uploaded images are stored in the `media/` folder
- Make sure this folder has write permissions

### Static Files
- CSS and other static files are in the `static/` folder
- For production, run: `python manage.py collectstatic`

## Common Tasks

### Add a New News Article
1. Login to admin panel
2. Go to "News Articles" → "Add News Article"
3. Fill in title, category, content, and upload image
4. Set status to "Published"
5. Optionally mark as "Featured" or "Breaking"
6. Save

### Moderate Comments
1. Go to "Comments" in admin panel
2. Review pending comments
3. Check "Is Approved" to publish
4. Save

### Manage Advertisements
1. Go to "Advertisements"
2. Add new advertisement with image
3. Select position (header, sidebar, etc.)
4. Set active/inactive status
5. Save

## Troubleshooting

### Can't access admin panel?
- Make sure you've set the admin password
- Ensure the server is running: `python manage.py runserver`

### Images not uploading?
- Check that the `media/` folder exists and has write permissions

### Database connection error?
- Ensure XAMPP MySQL is running
- Check database credentials in `newsportal_project/settings.py`

### CSS not loading?
- Run: `python manage.py collectstatic`
- Make sure DEBUG = True in settings.py for development

## Security Reminders

For production deployment:
1. Change SECRET_KEY in settings.py
2. Set DEBUG = False
3. Configure ALLOWED_HOSTS
4. Use a strong database password
5. Enable HTTPS
6. Configure proper file upload limits
7. Set up regular backups

## Support

Refer to Django documentation: https://docs.djangoproject.com/

---

**Congratulations! Your News Portal is ready to use!** 🎉

Start by setting your admin password, then login to the admin panel to configure your site and add content.
