detail view cant find pk
Question: Fairly new to Django and Python, I am trying to build a detail view and a list
view for a bunch of pictures I have uploaded. My list view works and shows all
the pictures I have but I cannot figure out how to create a detailview that
would let me look at only one picture.

In my "mysite" directory I have a url.py containing

    
    
    urlpatterns = patterns('',
    url(r'^photo/', include('photo.urls', namespace = "photo")),
    )
    

Then in my "photo" directory I have

from photo import views

    
    
    urlpatterns = patterns('',
        url(r'$', views.ListImage.as_view(),name ='Photo-List',),
        url(r'^/image/(?P<pk>\d+)/$', views.ImageView.as_view(),name='image-view',),
    
    ) 
    

I have uploaded a bunch of pictures and I can see them when I visit my local
website 800local../photo. But if I want to see one picture only, the address
../photo/image/1 returns a 404.

My Folder can be found at <https://github.com/henrigeek/Django>


Answer: List view will return object_list and Detail view return object.

    
    
    {% if object %}
    {{object.title}}
    ................
    {% else %}
    {% for img_obj in object_list %}
    {{ img_obj.title }}
    ................
    {% empty %}
    No images found
    {% endfor %}
    {% endif %}
    

You can refer here [Class based
view](https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-
display/)

