• 19-03-2022, 16:56:43
    #1
    from django.http import HttpResponse
    from django.shortcuts import render
    from matplotlib.style import context
    
    data = {
        "blogs": [
            {
                "id": 1,
                "title": "Başlık 1",
                "image": "python.jpg",
                "is_active": True,
                "is_blog": True,
                "description": "bu bir açıklamadır 1"
            }
        ]
    },
    
    # Create your views here.
    def index(request):
        context= {
            "blogs": data["blogs"]
        }
        return render(request, "index.html", context)
    
    def blog(request):
        context= {
            "blogs": data["blogs"]
        }
        return render(request, "blog.html", context)
    
    def blog_details(request, id):
        return render(request, "blog-detail.html", {
            "id": id
        })


    sürekli bir hata alıyorum nedeni nedir ve doğru olanı nasıl yaparım destek olur musunuz?


    aldığım hata :
    Type Eror

    tuple indices must be integers or slices, not str
  • 19-03-2022, 17:05:50
    #2
    Python Coder
    16.satırdaki virgülü silip dener misiniz hocam
  • 19-03-2022, 17:10:57
    #3
    Wp den ulaşın hocam halledelim, data["blogs"] diye değilde data[0] diye kullanımı deneyin
  • 19-03-2022, 17:13:31
    #4
    keremyagan adlı üyeden alıntı: mesajı görüntüle
    16.satırdaki virgülü silip dener misiniz hocam
    eyvallah hocam gözden kaçmış , çaylaklık işte. Düzeldi sağolun.
  • 19-03-2022, 17:14:18
    #5
    kmprens adlı üyeden alıntı: mesajı görüntüle
    Wp den ulaşın hocam halledelim, data["blogs"] diye değilde data[0] diye kullanımı deneyin
    sağolun hocam hallettik, tek bir virgül bile her şeyi değiştiriyor
  • 11-02-2023, 21:38:44
    #6
    kmprens adlı üyeden alıntı: mesajı görüntüle
    Wp den ulaşın hocam halledelim, data["blogs"] diye değilde data[0] diye kullanımı deneyin
    Geceyim mi wp den iletişime