python - Django template not getting view data -


im trying make own app called services, have been following django tutorial on how make own app.

i making app in django cms, want app contain templates can insert pages of cms via includes tag.

i have made models, views, urls , template. template isn't receiving data view. able create new service objects in backend know model working how want , i'm not getting template error when including it.

here models, views, url file , template. suspect either how setup view or how i'm pulling view in urls file.

currently output in template "no services available" set output when there no service_list view.

models.py

from django.db import models djangocms_text_ckeditor.fields import htmlfield import filer.fields.image django_extensions.db.fields import autoslugfield colorfield.fields import colorfield   class service(models.model):   title = models.charfield(max_length=200,default="")   slug = autoslugfield(max_length=50, populate_from='title')   color = colorfield(default='#ffffff')   tab_content = htmlfield(blank=true,help_text='describe service offer , how might benfit people.')   page_content = htmlfield(blank=true,help_text='describe service offer , how might benfit people.')   quote = models.charfield(max_length=200,default="")   icon = filer.fields.image.filerimagefield(verbose_name='image',blank=false,null=true,on_delete=models.set_null,related_name='+',)    def __str__(self):     return self.title 

views.py

from django.shortcuts import render django.http import httpresponse django.template import loader django.views.generic import view, listview, detailview, templateview  .models import service   #create views here. def tabs(request):   services_list = service.objects.all()[:5]   context = {'services_list': services_list,}   return render(request,'service_tabs.html', context) 

urls.py

from django.conf.urls import url  . import views  urlpatterns = [   url(r'^$', views.tabs, name='service tabs'), ] 

template

{% load cms_tags staticfiles sekizai_tags %} {% block content %} {% if services_list %}   <!-- nav tabs -->   <div id="services" class="container">     <ul id="services_list" class="nav nav-tabs" role="tablist">         {% service in services_list %}          <p>{{ service.title }}</p>        {% endfor %}      </ul>   </div>   <!-- end of: nav tabs --> {% else %}  <p>no services available</p> {% endif %} {% endblock %} 


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -