displaying the gallery in template

140 views
Skip to first unread message

Mateusz Zarzycki

unread,
Aug 19, 2016, 4:15:02 AM8/19/16
to Django Photologue
what I need to change in order to view the gallery in the template? I can add pictures, galleries in the admin panel but can not see them on the site. because I do not know what is wrong so I threw the entire project on github - https://github.com/MateuszsuetaM/strona_szkoly 
 I've seen similar questions but none of the candidates do not work in my case, or simply I can not use them, please help :)

P.S sorry for my bad spelling :(

Richard Barran

unread,
Aug 23, 2016, 3:22:17 PM8/23/16
to Django Photologue
Hi,

Thanks for uploading your source code - I can see that you have added the Photologue urls at https://github.com/MateuszsuetaM/strona_szkoly/blob/master/psp/urls.py#L44

So, when you are running your website locally, the Photologue pages should be at http://localhost:8000/photologue/

Hope to help,
Richard

Mateusz Zarzycki

unread,
Sep 6, 2016, 2:46:44 AM9/6/16
to Django Photologue
Yes, now I can see galleries! Thank you very much! :) But it's not all. I want to have gallery in every article.
 for example:
I have article about festival and gallery with photos for this event, now i want to have it all on one site, like in attachment. 
In joomla you need only to insert gallery_name between gallery tags:
{gallery} gallery_name {/gallery}
Is it possibly to do in django? :)
problem.png

Richard Barran

unread,
Sep 6, 2016, 3:32:29 PM9/6/16
to django-p...@googlegroups.com
Hello,

You’ll need to change the View for the article detail, so that the required Gallery instance is added to the RequestContext.

And then you will have to edit your template so that it displays the photos from that gallery; the code will be very similar to Django’s own template code at https://github.com/jdriscoll/django-photologue/blob/master/photologue/templates/photologue/gallery_detail.html

For example, this could work:


{% for photo in gallery.public %}
<a href="{{ photo.get_absolute_url }}">
<img src="{{ photo.get_thumbnail_url }}" alt="{{ photo.title }}">
</a>
{% endfor %}

--
You received this message because you are subscribed to the Google Groups "Django Photologue" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-photolo...@googlegroups.com.
To post to this group, send email to django-p...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-photologue.
For more options, visit https://groups.google.com/d/optout.
<problem.png>

Mateusz Zarzycki

unread,
Sep 7, 2016, 3:17:44 AM9/7/16
to Django Photologue
I added gallery to View but it's not working. Could You help me with this trouble? :)

I planned that gallery title have the same title like Article (Artykul.tytul)

def artykul(request, pk, title):
    artykul = get_object_or_404(Artykul, pk=pk)
    zdjecia = Gallery.objects.get(title=Artykul.tytul).public()
    context = {'artykul': artykul, 'zdjecia': zdjecia}
    return render(request, 'artykul/category_detail.html', context)

 

Richard Barran

unread,
Sep 7, 2016, 3:25:59 AM9/7/16
to django-p...@googlegroups.com
In my example I assumed that you would call the Gallery variable ‘gallery’.

I see that you’ve called the Gallery variable ‘zdjecia’ - have you also changed the template code and renamed ‘gallery’ to ‘zdjecia’?

Mateusz Zarzycki

unread,
Sep 13, 2016, 3:03:09 AM9/13/16
to Django Photologue
I have one more problem, the code below is not working

    zdjecia = Gallery.objects.get(title=Artykul.tytul).public()

It's my Models:

class Artykul(models.Model):
    tytul = models.CharField(max_length=30, null=False, blank=False)

and it's photologue models:

class Gallery(models.Model):
    date_added = models.DateTimeField(_('date published'),
                                      default=now)
    title = models.CharField(_('title'),
                             max_length=250,
                             unique=True) 


I imported in Views:

from photologue.models import Gallery

but it's still wrong:

issue #1:
type object 'Artykul' has no attribute 'tytul'

I add apostrophes like that:  'Artykul.tytul' 

issue #2

Gallery matching query does not exist.

but i have article (Artykul) named jol and gallery with the same name 

Gallery.title=Artykul.tytul giving issue #3:

File "/home/mateusz/projekt/artykul/views.py", line 25
    zdjecia = Gallery.objects.get(Gallery.title=Artykul.tytul).public()
                                     ^
SyntaxError: keyword can't be an expression


Reply all
Reply to author
Forward
0 new messages