A Django-based web application for sharing and enjoying dad jokes! This platform allows users to create, share, like, and comment on dad jokes with customizable styling and social authentication.
- 🎭 Create & Share Jokes: Post your best dad jokes with custom styling
- ❤️ Like System: Like your favorite jokes and see what others enjoy
- 💬 Comments: Engage with the community through joke comments
- 👤 User Profiles: Personalized profiles with profile pictures and about sections
- 🔐 Authentication: Email-based registration with account activation
- 🌐 Google OAuth: Quick sign-in with Google authentication
- 🎨 Custom Styling: Personalize jokes with:
- Background colors
- Text colors
- Font types (Arial, Times New Roman, Comic Sans MS, and more)
- 🔀 Random Shuffle: Jokes are shuffled for a fresh experience every time
- ✉️ Email Verification: Secure account activation via email
- 🔑 Password Reset: Easy password recovery system
- 📝 Profile Editing: Update your profile information and picture
- Django 5.2.5: Python web framework
- Python 3.x: Programming language
- SQLite3: Database (default)
- HTML/CSS/JavaScript: Core web technologies
- Django Templates: Server-side rendering
- social-auth-app-django: Google OAuth integration
- Pillow: Image processing for profile pictures
- django-phonenumber-field: Phone number validation
- django-widget-tweaks: Enhanced form rendering
- django-browser-reload: Development hot-reload
- Python 3.8 or higher
- pip (Python package manager)
- Virtual environment (recommended)
-
Clone the repository
git clone https://github.com/gcl140/dadjokes.git cd dadjokes -
Create and activate virtual environment
python -m venv venv # On Windows venv\Scripts\activate # On macOS/Linux source venv/bin/activate
-
Install dependencies
pip install -r req.txt
-
Configure environment variables Create a
.envfile in the root directory:GOOGLE_OAUTH2_KEY=your_google_oauth_key GOOGLE_OAUTH2_SECRET=your_google_oauth_secret
-
Run migrations
python manage.py migrate
-
Create superuser (optional)
python manage.py createsuperuser
-
Run the development server
python manage.py runserver
-
Access the application Open your browser and navigate to
http://127.0.0.1:8000/
The application uses Gmail SMTP for sending activation emails. Update the following in dadjokes/settings.py:
EMAIL_HOST_USER = 'your-email@gmail.com'
EMAIL_HOST_PASSWORD = 'your-app-password'Note: Use an App Password for Gmail, not your regular password.
- Go to Google Cloud Console
- Create a new project or select existing one
- Enable Google+ API
- Create OAuth 2.0 credentials
- Add authorized redirect URIs:
http://127.0.0.1:8000/oauth/complete/google-oauth2/http://localhost:8000/oauth/complete/google-oauth2/
- Add the credentials to your
.envfile
For production, collect static files:
python manage.py collectstatic- Click on "Register" from the landing page
- Fill in your details (username, email, password)
- Check your email for the activation link
- Click the activation link to activate your account
- Log in with your credentials
- Log in to your account
- Navigate to "Create Joke"
- Enter your joke content
- Customize the appearance (colors, font)
- Add an optional description
- Submit the joke
- Like: Click the heart icon to like a joke
- Comment: Click the comment icon and add your thoughts
- Delete: Remove your own jokes or comments (only your own)
- Click on your username to view your profile
- See all your posted jokes
- Edit your profile information and picture
- View statistics (jokes posted, likes received)
dadjokes/
├── content/ # Jokes app
│ ├── migrations/ # Database migrations
│ ├── templates/ # Content templates
│ ├── models.py # Joke, JokeLike, JokeComment models
│ ├── views.py # Joke-related views
│ ├── urls.py # Content URL patterns
│ └── forms.py # Joke forms
├── yuzzaz/ # User authentication app
│ ├── migrations/ # Database migrations
│ ├── templates/ # Auth templates
│ ├── models.py # CustomUser model
│ ├── views.py # Auth views
│ ├── urls.py # Auth URL patterns
│ ├── forms.py # User forms
│ └── tokens.py # Email verification tokens
├── dadjokes/ # Project settings
│ ├── settings.py # Django settings
│ ├── urls.py # Root URL configuration
│ ├── wsgi.py # WSGI config
│ └── asgi.py # ASGI config
├── static/ # Static files (CSS, JS, images)
│ ├── css/
│ ├── js/
│ └── images/
├── media/ # User-uploaded files
├── manage.py # Django management script
└── req.txt # Python dependencies
GET /- Home page with joke feedGET /api/jokes/- Fetch all jokes (JSON)GET /api/jokes/<id>/- Fetch specific joke (JSON)POST /create-joke/- Create a new joke (requires login)DELETE /delete-joke/<id>/- Delete a joke (requires login)POST /toggle-like/<id>/- Like/unlike a joke (requires login)GET /fetch-comments/<id>/- Fetch comments for a jokePOST /post-comment/<id>/- Post a comment (requires login)DELETE /delete-comment/<id>/- Delete a comment (requires login)
GET /accounts/login/- Login pagePOST /accounts/login/- Process loginGET /accounts/register/- Registration pagePOST /accounts/register/- Process registrationGET /accounts/logout/- LogoutGET /accounts/activate/<uidb64>/<token>/- Email activationGET /accounts/password-reset/- Password reset requestGET /oauth/login/google-oauth2/- Google OAuth login
GET /accounts/profile/<user_id>/- View user profilePOST /accounts/edit-profile/- Edit profile (requires login)
- Extends Django's AbstractUser
- Fields: username, email, profile_picture, about
- Unique email and username
- content (TextField): The joke text
- description (TextField): Optional description
- bg_color (CharField): Background color (hex)
- text_color (CharField): Text color (hex)
- font_type (CharField): Font family
- bg_music (CharField): Background music URL
- joke_by (ForeignKey): User who created the joke
- created_at (DateTimeField): Creation timestamp
- likers (ManyToManyField): Users who liked the joke
- user (ForeignKey): User who liked
- joke (ForeignKey): Joke that was liked
- created_at (DateTimeField): Like timestamp
- Unique constraint: (user, joke)
- user (ForeignKey): User who commented
- joke (ForeignKey): Joke being commented on
- comment_text (TextField): Comment content
- created_at (DateTimeField): Comment timestamp
python manage.py testpython manage.py makemigrations
python manage.py migrate- Create a superuser (if not already done)
- Navigate to
http://127.0.0.1:8000/admyn/ - Log in with superuser credentials
The project runs in DEBUG mode by default. For production:
- Set
DEBUG = Falsein settings.py - Configure
ALLOWED_HOSTS - Use a production-grade database (PostgreSQL, MySQL)
- Set up proper static file serving (nginx, WhiteNoise)
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow PEP 8 for Python code
- Use meaningful variable and function names
- Add comments for complex logic
- Write tests for new features
- Never commit the
.envfile or sensitive credentials - Change the
SECRET_KEYin production - Use environment variables for sensitive data
- Keep dependencies updated regularly
- Disable DEBUG mode in production
- Use HTTPS in production
- Implement rate limiting for API endpoints
This project is open source and available under the MIT License.
- GitHub: @gcl140
- Repository: https://github.com/gcl140/dadjokes
- Django community for the excellent framework
- Contributors and users of this project
- All the dad joke enthusiasts out there! 🎉
Made with ❤️ for spreading laughter, one dad joke at a time!