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 %}
Add a Comment


{% csrf_token %}
{{ form.as_p }}



{% endblock %}

-- 
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://groups.google.com/d/msgid/django-users/493eaf33-0918-4f6c-9dcb-59465ff2c616%40googlegroups.com.


Re: Associating comments with images

2020-04-01 Thread Andréas Kühne
Yeah ok - so you should use the pictures variable to iterate over to get
the pictures and you should be fine!

Regards,

Andréas


Den ons 1 apr. 2020 kl 15:26 skrev 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
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/944c9708-34f5-497a-a877-ecd66cd0fbca%40googlegroups.com
> .
>

-- 
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://groups.google.com/d/msgid/django-users/CAK4qSCecVxhDbs8H0vqOg_O7hdeFb60JnsSfdbhjF5zd6_J-6Q%40mail.gmail.com.


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 email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/944c9708-34f5-497a-a877-ecd66cd0fbca%40googlegroups.com.


Re: Associating comments with images

2020-04-01 Thread Andréas Kühne
Ok - so you are not really doing this correctly - I am guessing now.

Can you send the code for your view as well. Because I am guessing that you
aren't sending anything to the context variable "pictures".

I think the other things are more or less correct (even though there are
some issues with the html as well)

But if we start with the context variable:
{% if pictures %}

This means that you need to send a variable called pictures with the
pictures you want to display on the page. This should be populated in
your view with the pictures you want to display. The reason I don't think
this is done, is because you then use the following for loop:
 {% for p in Picture.objects.all %}

You shouldn't use the models in the templates that way - but it would be
better to do:
 {% for p in pictures %} (if you have set the variable) :)

Other than that - you have a ul tag there that seems a bit out of place :)

Regards,

Andréas


Den ons 1 apr. 2020 kl 13:43 skrev 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/base.html' %}
> {% block body_block %}
> 
> 
> {% if pictures %}
> 
> {% for p in Picture.objects.all %}
> 
>   
> 
> 
>
>   
> 
>
> 
> 
>
>   
> {{
> p.title }}
>   
> {{ p.when_added }}
> 
> 
>
>   
> 
> 
> 
> 
> 
> 
>
>   
> 
> 
>
>   
> {{
> p.description }}
>   
>  aria-expanded="false" aria-controls="collapseContent">Click for
> description
> 
> 
>
> 
> 
> 
> 
> comments
> {% if not p.comments %}
> No comments
> {% endif %}
> {% for x in p.comment %}
> 
> 
> Comment by {{ x.user }}
> 
> {{ x.created_on }}
> 
> 
> {{ x.body | linebreaks }}
> 
> {% endfor %}
> 
> 
> {% if new_comment %}
> Your comment has been posted.
> {% else %}
> Leave a comment
> 
> {{ comment_form.as_p }}
> {% csrf_token %}
> Submit
> {% endif %}
> 
> 
>   
> 
> 
> {% endfor %}
> 
> {% else %}
> There are no photographs present.
> {% endif %}
>
> {% endblock %}
>
>
> Thanks
>
> Jeff
>
> --
> 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://groups.google.com/d/msgid/django-users/7a56b57b-42e9-42be-bc9f-3ed8714cf444%40googlegroups.com
> .
>

-- 
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://groups.google.com/d/msgid/django-users/CAK4qSCfY878xRaOLbODrp1%2BoY60exZC3BZ8h%3DDkQmsS5LB4NkA%40mail.gmail.com.


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/base.html' %}
{% block body_block %}


{% if pictures %}

{% for p in Picture.objects.all %}

  



  





  
{{ p.title 
}}
  
{{ 
p.when_added }}



  







  



  
{{ 
p.description }}
  
Click for description







comments
{% if not p.comments %}
No comments
{% endif %}
{% for x in p.comment %}


Comment by {{ x.user }}

{{ x.created_on }}


{{ x.body | linebreaks }}

{% endfor %}


{% if new_comment %}
Your comment has been posted.
{% else %}
Leave a comment

{{ comment_form.as_p }}
{% csrf_token %}
Submit
{% endif %}


  


{% endfor %}

{% else %}
There are no photographs present.
{% endif %}

{% endblock %}


Thanks

Jeff

-- 
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://groups.google.com/d/msgid/django-users/7a56b57b-42e9-42be-bc9f-3ed8714cf444%40googlegroups.com.


Re: Associating comments with images

2020-03-31 Thread Andréas Kühne
Add the photo id to the url - so instead of having the form like this:


you add it like this:
 

and make sure that the photo_id variable is in the current context and that
the comment view accepts an id.

Regards,

Andréas


Den tis 31 mars 2020 kl 16:58 skrev 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 comments %}
> No comments
> {% endif %}
> {% for x in comment %}
> 
> 
> Comment by {{ x.user }}
> 
> {{ x.created_on }}
> 
> 
> {{ x.body | linebreaks }}
> 
> {% endfor %}
> 
> 
> {% if new_comment %}
> Your comment has been posted.
> {% else %}
> Leave a comment
>  method="POST">
> {{ comment_form.as_p }}
> {% csrf_token %}
> Submit
> {% endif %}
>
> How do you suggest I overcome this problem, please?
>
> Thanks
>
> Jeff
>
> --
> 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://groups.google.com/d/msgid/django-users/cabe2b94-bf00-4394-b699-8a15d48247d2%40googlegroups.com
> .
>

-- 
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://groups.google.com/d/msgid/django-users/CAK4qSCcYWsEjhdP%3DxLOMUeUPmeH6RssocH48L7v%3DMhHJf11-3g%40mail.gmail.com.


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 comments %}
No comments
{% endif %}
{% for x in comment %}


Comment by {{ x.user }}

{{ x.created_on }}


{{ x.body | linebreaks }}

{% endfor %}


{% if new_comment %}
Your comment has been posted.
{% else %}
Leave a comment

{{ comment_form.as_p }}
{% csrf_token %}
Submit
{% endif %}

How do you suggest I overcome this problem, please?

Thanks

Jeff

-- 
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://groups.google.com/d/msgid/django-users/cabe2b94-bf00-4394-b699-8a15d48247d2%40googlegroups.com.