Friday, April 26, 2019

Re: Comment Form Related issue

its pretty much the same, you can check on class based view where you have CreateView and UpdateView and so on

and i would recomend to add the following to models.py:
updated_at = models.DateTimeField(null=True)
updated_by = models.ForeignKey(get_user_model(), on_delete=models.CASCADE, null=True)

cheers mate

Den fre 26 apr. 2019 kl 14:05 skrev Soumen Khatua <soumenkhatua258@gmail.com>:
Okay,Could you tell me If any user want to update their comment it later the process is same or different?

Thank You


On Fri, Apr 26, 2019 at 5:31 PM Robin Riis <riis.somfan@gmail.com> wrote:
class Comment(models.Model): <--- in models.py

class CommentForm(forms.ModelForm): <--- in forms.py

def CommentVideo(request, pk): <--- in views.py

and the video is another model i used since you said like youtube. :)

Den fre 26 apr. 2019 kl 13:33 skrev Soumen Khatua <soumenkhatua258@gmail.com>:
yes,I'm new to django so let me check once.
Thank You for your response.

On Fri, Apr 26, 2019 at 4:36 PM Robin Riis <riis.somfan@gmail.com> wrote:
class Comment(models.Model):
message = models.TextField()
video = models.ForeignKey(Video, related_name='comments', on_delete=models.CASCADE)
created_at = models.DateTimeField(auto_now_add=True)
created_by = models.ForeignKey(get_user_model(), related_name='comments', on_delete=models.CASCADE)

class CommentForm(forms.ModelForm):
class Meta:
model = Comment
fields = ['message',]

def CommentVideo(request, pk):
video = get_object_or_404(Video, pk=pk)
if request.method == 'POST':
form = CommentForm(request.POST)
if form.is_valid():
comment = form.save(commit=False)
comment.video = video
comment.created_by = request.user
comment.save()
return reverse_lazy('my_cool_place')
else:
form = CommentForm()
return render(request, 'path/to/html/file.html', {'video': video, 'form': form})

something like that?

Den fre 26 apr. 2019 kl 12:34 skrev Soumen Khatua <soumenkhatua258@gmail.com>:
Hi Folks,
I want to show one textarea where only logged in users can comment otherwise if they are click the textareabox redirect them to login page just like youutbe comnet box. If anyone have any source code related to this please share.

Thank You.


Regards,
Soumen

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WadmH6vfXBrpSfNdGrMRgVoBAV-DZfGbJkoO%2B1tVuWyfw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPLZMbMsH-55Z_KK3byho-BqMDHaXWmWQcwnmn1ZDuKHUB56eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WbCeF%2BUuQVfOBoNEzM1vZo9dheKTQYoMz%3DQXfQmtgeTSQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPLZMbOxPsNjD%2BDX6t36i3WZEwXLRXJW-qO7e%2BGeV5m%3DhXss-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPUw6WYuJDfXxELqoaCHMNrcGPeucZHN-i8r_kS3KhBU93bzRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPLZMbM8EdsC%2B9-fi78BqOTsJNms7O-wY3X07Dcz70mdox91ZA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment