|
I don't know that I'll live long enough to retire from coding, though i may retire from doing it professionally. I've always loved it. I suspect I always will.
Real programmers use butterflies
|
|
|
|
|
"Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems." - Jamie Zawinski
|
|
|
|
|
They're not that bad, Sander. Where's your sense of adventure?
Real programmers use butterflies
|
|
|
|
|
It can be quite intimidating at first. I found that Regex 101[^] is a great tool for learning to use regex, and I still use it to validate my regex for projects that I am working on.
Regards,
Thomas Stockwell
|
|
|
|
|
not afraid, but when you only need to make some regex once a year or less, It generally takes a bit to remember the all rules correctly to get the desired results. long regex's can be very cryptic, so I generally tend to break it down with lots of notes about each section for the future me that might have to modify it.
|
|
|
|
|
So i have a project called star social project this project is similar to a socail media that you can post and create group but this project you can only post when you are in a group. So i get an error message that is not familiar to me which is on the title, i tried to search on google and get some result but when i implement it to my project it does not work. So why im getting this error is because i'm trying to create a comment section and when i click the add comment that's when i get the error message. So i'm here to ask someone to help me because i'm not really familiar on this error and i'm just learning django for about 2 months now.
models.py
##########################
## POSTS MODELS.PY FILE ##
##########################
from django.contrib.auth import get_user_model
from django.db import models
from groups.models import Group
from misaka import html
from django.urls import reverse
from django.utils import timezone
User = get_user_model()
class Post(models.Model):
user = models.ForeignKey(User, related_name='posts', on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now=True)
message = models.TextField()
message_html = models.TextField(editable=False)
group = models.ForeignKey(Group, related_name='posts', null=True, blank=True, on_delete=models.CASCADE)
def __str__(self):
return self.message
def save(self, *args, **kwargs):
self.message_html = html(self.message)
super().save(*args, **kwargs)
def get_absolute_url(self):
return reverse(
'posts:single',
kwargs={
'username': self.user.username,
'pk': self.pk
}
)
class Meta:
ordering = ['-created_at']
class Comment(models.Model):
post = models.ForeignKey(Post, related_name='comments', on_delete=models.CASCADE)
username = models.CharField(max_length=50)
text = models.TextField()
created = models.DateTimeField(auto_now_add=True)
approved = models.BooleanField(default=False)
def __str__(self):
return self.text
def approved(self):
self.approved = True
self.save()
views.py
class AddComment(LoginRequiredMixin, generic.CreateView):
model = Comment
fields = ('username', 'text')
def form_valid(self, form):
post = get_object_or_404(Post, pk=self.kwargs.get('pk'))
self.object = form.save(commit=False)
self.object.post = post
self.object.save()
return super().form_valid(form)
urls.py
########################
## POSTS URLS.PY FILE ##
########################
from django.urls import path
from posts import views
app_name = 'posts'
urlpatterns = [
path('', views.PostList.as_view(), name='all'),
path('by/<username>/', views.UserPost.as_view(), name='for_user'),
path('by/<username>/<int:pk>/', views.PostDetail.as_view(), name='single'),
path('new/', views.CreatePost.as_view(), name='create'),
path('delete/<int:pk>/', views.DeletePost.as_view(), name='delete'),
path('post/comment/', views.AddComment.as_view(), name='add_comment'),
]
comment_form.html
{% extends 'posts/post_base.html' %}
{% load bootstrap4 %}
{% block prepost %}
<h4>Add New Comment</h4>
<form id="commentForm" action="{% url 'posts:add_comment' %}" method="POST">
{% csrf_token %}
{% bootstrap_form form %}
{% buttons %}
<button type="submit" class="btn btn-large btn-primary">Add Comment</button>
{% endbuttons %}
</form>
{% endblock %}
_post.html
<div class="media">
<h3 class="mr-5"><a href="{% url 'posts:for_user' username=post.user.username %}">@{{ post.user.username }}</a></h3>
<div class="media-body">
{{ post.user.username }}
<h5>{{ post.message_html|safe }}
<time class="time"><a href="{% url 'posts:single' username=post.user.username pk=post.pk %}">{{ post.created_at }}</a></time>
{% if post.group %}
in <a href="#">{{ post.group.name }}</a>
{% endif %}
</h5>
<hr>
{% if user.is_authenticated %}
<a class="btn btn-primary btn-comment" href="{% url 'posts:add_comment' %}">Add Comment</a>
{% endif %}
<div class="container">
{% for comment in comment_list %}
<br>
{{ comment.created }}
<p>{{ comment.text|safe|linebreaks }}</p>
<p>Posted By: {{ comment.username }}</p>
{% endfor %}
</div>
<div class="media-footer">
{% if user.is_authenticated and post.user == user and not hide_delete %}
<a class="btn btn-simple" href="{% url 'posts:delete' pk=post.pk %}" title="delete">Delete</a>
{% endif %}
</div>
</div>
</div>
|
|
|
|
|
Read the red text in the upper-right corner of the page.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
Wrong place to post this, try here: Ask a Question[^]
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
A for Asymptomatic
B for Blood Test
C for Corona
D for Dispensing
E for Epidemic
F for Flattening the Curve
G for "Go Corona Go"
H for Handwash
I for Incubation Period
J for Jobless
K for Kit (Immunity Kit)
L for Lockdown
M for Mask
N for Negative Report
O for Online
P for Pandemic
Q for Quarantine
R for Respirator
S for Sanitizer
T for Tracing
U for Unlock
V for Vaccine
W for Work From Home
X for ?
Y for Yellow Zone
Z for Zoom Call
(Again from WhatsApp)
modified 2-Jan-21 21:25pm.
|
|
|
|
|
Amarnath S wrote: X for ?
"X for "XXXXing virus!"
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
X for xenophobia - fear of the unknown, which we've all been experiencing to some degree or other
|
|
|
|
|
A certain site beginning with x and ending in videos for when you are bored perhaps?
|
|
|
|
|
X is for X-ray to look at the damage in yer lungs.
|
|
|
|
|
1920 x 1080
Last year was 800 x 640
|
|
|
|
|
I've upgraded my resolution from 40 columns to 80 columns.
|
|
|
|
|
I went from 1920 x 1200 to 7680 x 2160.
It might get to 11520 x 2160 by the end of the year, IF nVidia ever makes enough RTX3000 cards to fill demand.
|
|
|
|
|
that seems... decadent.
Real programmers use butterflies
|
|
|
|
|
7680 is the maximum horizontal resolution for most video cards and the maximum vertically is usually 4320 or 4x 1080. Actually, it works out the maximum is 4x4 times HD resolution.
"They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"
|
|
|
|
|
That limit is "per DisplayPort", not the limit for the entire card.
I'm already running 3 monitors at 3840, 3840, and 1920 on a GTX 1080. The 1920 is being replaced with another 3840.
|
|
|
|
|
jsc42 wrote: Last year was 800 x 640
What was last year, 1997?
|
|
|
|
|
To you and yours.
The Healthy part is particularly important to us old guys.
Still Young at heart.
|
|
|
|
|
Thank you. Happy New Year to you as well.
Health is especially important to those of us older than you.
Lou
If you can keep your head while those about you are losing theirs, perhaps you don't understand the situation.
|
|
|
|
|
True, the elderly are pre-disposed to harsher times with COVID, but there are a considerable amount of "youngins" dying from COVID related illnesses each day, too.
to be fair, I think in this day and age, health is important to everyone on planet earth....and the space station.
|
|
|
|
|
I agree whole heartedly. I just wish everybody Young and Old would wear a mask in public.
Covid-19 is not a hoax!
|
|
|
|
|
I wasn't sure there was anyone older than me left in this pandemic.
Seriously congratulations.
We all need to stick together.
|
|
|
|