Python / Django - creating a photo gallery - get pics' names instead of pics themself -


i have following issue result of lack of experience: don't photos in gallery page.

the main idea create pretty simple photo gallery (with bootstrap in future). know there couple of useful libraries purpose (like prologue, imagekit etc.), have great understand beginning. why use django.

as result of of efforts following (getting photos' names instead of photos themself):

enter image description here

now have next:

settings.py

media_url = '/media/' media_root = os.path.join(os.path.dirname(base_dir), 'static_in_dev', 'media_root') 

models.py

class gallerycupsmodel(models.model):     photo = models.imagefield(upload_to='cups/%y/%m/%d') 

admin.py

class gallerycupsadmin(admin.modeladmin):     list_display = ['photo']  admin.site.register(gallerycupsmodel, gallerycupsadmin) 

also uploaded 3 images via admin panel (file1, file2, file3, names of see in first figure).

view.py

def cups(request):     context = {         'context_cups': gallerycupsmodel.objects.all()     }      return render(request, 'cups.html', context) 

url.py

urlpatterns = [     url(r"^cups/all/$", "gallery_cups.views.cups", name="cups"), ]  if settings.debug:     urlpatterns += static(settings.static_url, document_root=settings.static_root)     urlpatterns += static(settings.media_url, document_root=settings.media_root) 

cups.html

... {% cup in context_cups %}    {{ cup.photo }} {% endfor %} ... 

here folder tree:

├── gallery_cups │   ├── migrations │   │   └── __pycache__ │   └── __pycache__ ├── lc │   └── __pycache__ ├── static_in_dev │   ├── media │   ├── media_root │   ├── my_static │   │   ├── css │   │   ├── img │   │   └── js │   └── static_root │       ├── admin │       │   ├── css │       │   ├── fonts │       │   ├── img │       │   │   └── gis │       │   └── js │       │       ├── admin │       │       └── vendor │       │           ├── jquery │       │           └── xregexp │       ├── css │       ├── img │       │   ├── header │       │   └── portfolio │       └── js └── templates 

the problem is result 1 can see in first figure instead of getting real photos. looks miss smth crucial. can not miss.

p.s. not see files, uploaded in admin panel, in static_in_dev/media/cups. looks don't adequately understand how media works..

p.p.s. maybe efforts monkey job?) , using existing libraries better choice in learning django?

to render imagefield template, need:

<img src="{{ cup.photo }}" /> 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -