Form not being published

2020-03-29 Thread Jeff Waters
I am creating a website using Django. I'd like to give users the chance to comment on pictures they have posted. I have created a comment model and a comment form, and put the following code into the HTML document for the photo gallery: Leave a comment {{ comment_fo

Form not displaying

2020-03-29 Thread Jeff Waters
Apologies if I'm posting this twice - my original message isn't displayed in the list of messages. I am creating a website using Django. I'd like to give users the chance to comment on pictures they have posted. I have created a comment model and a comment form, and put the following code into

Re: Form not displaying

2020-03-30 Thread Jeff Waters
Sure. It's as follows: @login_required def add_comment(request, image_id): template_name = 'add_comment.html' image = get_object_or_404(Picture, id=image_id) comments = image.comments.filter(active=True) new_comment = None # Comment posted if request.method == 'POST':

Re: Form not displaying

2020-03-30 Thread Jeff Waters
Thanks Ernest. I'm not sure I follow (forgive me, I am very new to Django). Given that template_name is defined earlier in the method as 'add_comment.html', surely what I've written is equivalent to: return render(request, add_comment.html, {'image': image,

Re: Form not displaying

2020-03-30 Thread Jeff Waters
Will do, thanks -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://grou

HTML code not being read

2020-03-30 Thread Jeff Waters
Hi I have written some code that allows users of a website to comment on photos in a picture gallery, using a form. However, when I test the code, no comments are displayed. It would appear that Django is not processing the following code (from my HTML file for the photo gallery), given that '

Re: HTML code not being read

2020-03-30 Thread Jeff Waters
Hi Thanks for getting back to me. This is from my views.py: @login_required def add_comment(request, image_id): new_comment = None template_name = 'add_comment.html' image = get_object_or_404(Picture, id=image_id) comment = image.comment.filter(active=True) new_comment = Non

Re: HTML code not being read

2020-03-30 Thread Jeff Waters
Hi I'm not sure what you mean by 'Have you all ready use a content that define your content'. I'm new to Django, so am not familiar with all of the terminology yet. Can you elaborate please? Thanks Jeff -- You received this message because you are subscribed to the Google Groups "Django u

Re: HTML code not being read

2020-03-30 Thread Jeff Waters
Thanks guys I previously had 'comments' in the plural in views.py, but had the same problem. Am I right in thinking that Django recognises that 'comments' is the plural of 'comment', so if it knows from the view what a comment is, it knows what comments are? Thanks, Jeff -- You received t

Re: HTML code not being read

2020-03-30 Thread Jeff Waters
I've modified my code a bit to try (unsuccessfully!) to get this working. My views.py is now as follows: @login_required def add_comment(request, image_id): new_comment = None template_name = 'add_comment.html' image = get_object_or_404(Picture, id=image_id) comment = image.commen

NoReverseMatch error message - Please help

2020-03-31 Thread Jeff Waters
I am putting together a website which has a photo gallery where users can add comments. When I go to the photo gallery page, I get the following error message: NoReverseMatch at /photo_feed/ Reverse for 'add_comment' with arguments '('',)' not found. 1 pattern(s) tried: ['add_comment/$'] The c

Associating comments with images

2020-03-31 Thread Jeff Waters
I am creating a website where users can comment on photos in a gallery. The challenge I currently have is that Django is not able to determine which of the photos the comment 'submit' button relates to. This is my HTML code for the photo gallery: comments {% if not comm

Re: NoReverseMatch error message - Please help

2020-03-31 Thread Jeff Waters
Thanks Ryan. I've just tried that, but I still get an error message. By the way, is it definitely .id and not _id? I've seen both, and Django docs says: 'Behind the scenes, Django appends "_id" to the field name to create its database column name, which makes me wonder if it might be _id. Inc

Re: Associating comments with images

2020-04-01 Thread Jeff Waters
Thanks Andreas I think that one of the mistakes I'd made previously was to not associate particular comments with particular pictures. I've tried to rectify that using the code below. However, when I do this, the page I get is empty. Any advice would be appreciated: {% extends 'nowandthen/b

Re: Associating comments with images

2020-04-01 Thread Jeff Waters
Thank you Andreas. This is the views.py - https://github.com/EmilyQuimby/my_now_and_then/blob/master/nowandthen/views.py -- 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

Re: Associating comments with images

2020-04-01 Thread Jeff Waters
Thanks Andreas When I do that, I get an error message: NoReverseMatch at /photo_feed/ Could the problem be with my add_comment.html? The code for that is as follows: {% extends 'nowandthen/base.html' %} {% load staticfiles %} {% block title_block %} Add self {% endblock %} {% block body_block %

Populate script not working

2020-04-01 Thread Jeff Waters
I've created a population script to test my website - please see below - but I get the following error message: django.contrib.auth.models.DoesNotExist: User matching query does not exist. Given that I've created a hypothetical user, I'm not sure why this is? Any suggestions would much apprecia