Notes![what is notes.io? What is notes.io?](/theme/images/whatisnotesio.png)
![]() ![]() Notes - notes.io |
from django.conf import settings
from django.utils.timezone import now, timedelta
class Story(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, related_name='stories')
image = models.ImageField(upload_to='stories/')
created_at = models.DateTimeField(auto_now_add=True)
caption = models.TextField(blank=True, null=True)
def is_active(self):
"""Check if the story is still within the 24-hour timeframe."""
return now() <= self.created_at + timedelta(hours=24)
class Meta:
ordering = ['-created_at']
def __str__(self):
return f"Story by {self.user.username} at {self.created_at}"
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from .models import Story
@login_required
def upload_story(request):
if request.method == 'POST':
image = request.FILES.get('image')
caption = request.POST.get('caption', '')
if image:
Story.objects.create(user=request.user, image=image, caption=caption)
return redirect('story_feed') # Redirect to story feed
return render(request, 'stories/upload_story.html')
from django.utils.timezone import now, timedelta
@login_required
def story_feed(request):
# Filter stories for all users that are still active (within 24 hours)
stories = Story.objects.filter(
created_at__gte=now() - timedelta(hours=24)
).exclude(user=request.user) # Optionally exclude the user's own stories
user_stories = request.user.stories.filter(
created_at__gte=now() - timedelta(hours=24)
) # Current user's stories
return render(request, 'stories/story_feed.html', {'stories': stories, 'user_stories': user_stories})
<form method="post" enctype="multipart/form-data">
{% csrf_token %}
<label for="image">Upload Story:</label>
<input type="file" name="image" id="image" required>
<textarea name="caption" placeholder="Add a caption (optional)"></textarea>
<button type="submit">Post Story</button>
</form>
<h2>Your Stories</h2>
<div class="user-stories">
{% for story in user_stories %}
<img src="{{ story.image.url }}" alt="Story">
<p>{{ story.caption }}</p>
{% endfor %}
</div>
<h2>All Active Stories</h2>
<div class="all-stories">
{% for story in stories %}
<p><b>{{ story.user.username }}</b></p>
<img src="{{ story.image.url }}" alt="Story">
<p>{{ story.caption }}</p>
{% endfor %}
</div>
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team