I am not sure my first reply worked, but here it goes again. Your template is using {{ post.NAME }} when I believe it should be using {{ customer.NAME }}. The context name that is used in the template is obtained by default from the model and in your case, you are using model= Customer. If you want to rename so that you can use {{ post.Name }}, you will have to use 'context_object_name = post'. But I suggest you edit your template.
url(r'^(?P<pk>\d+)$', DetailView.as_view( model = Customer, template_name="customer.html", context_object_name='post')),# Do this only if you want to use {{ post.NAME }} get_context_object_name(*obj*)<https://docs.djangoproject.com/en/1.6/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.get_context_object_name> Return the context variable name that will be used to contain the data that this view is manipulating. If context_object_name<https://docs.djangoproject.com/en/1.6/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.context_object_name>is not set, the context name will be constructed from themodel_name of the model that the queryset is composed from. For example, the model Article would have context object named 'article'. Ref: https://docs.djangoproject.com/en/1.6/ref/class-based-views/mixins-single-object/#django.views.generic.detail.SingleObjectMixin.get_context_object_name hope that works. On Tuesday, May 6, 2014 4:24:07 PM UTC-7, G Z wrote: > > repost easier to read > > So I'm using DetailView to associate a Customer ID with customer > information but due to my lack of knowledge im not entirely sure what the > issue is. It will go to the page but it won't load the unique customer > data. The data exist at domain/customers/ however when you click the link > which takes you to domain/customers/id it wont show the data its just a > blank page with a title. > > Here is my urls.py > > from django.conf.urls import patterns, include, url > from django.views.generic.list import ListView > from django.views.generic.detail import DetailView > from vmware.models import Customer > > urlpatterns = patterns('', > url(r'^$', ListView.as_view( > queryset=Customer.objects.all().order_by("-id")[:100], > template_name="vms.html")), > > url(r'^(?P<pk>\d+)$', DetailView.as_view( > model = Customer, > template_name="customer.html")), > > ) > > Here is the html output for it > > {% extends "base.html" %} > {% block content %} > <h2><a href="/customers/{{ post.id }}"> {{ post.NAME }} </a> </h2> > <div class = "post_meta"> > {{ post.id }} > </div> > <div class = "post_name"> > {{ post.NAME }} > </div> > <div class = "post_name"> > {{ post.WEBSITE }} > </div> > <div class = "post_name"> > {{ post.PHONE }} > </div> > <div class = "post_name"> > {{ post.EMAIL }} > </div> > <div class = "post_name"> > {{ post.ADDRESS }} > </div> > <div class = "post_name"> > {{ post.VMIDS }} > </div> > {% endblock %} > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/31ef4781-37b7-4d03-980c-3bc63aa4d382%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.