2010-07-18 23 views
9

Continuo a ricevere questo errore sulle mie visualizzazioni. Non riesco a risolverlo perché il codice è simile al tutorial di djangos semplicemente cambiando il nome degli oggetti. Ecco il codice per il mio views.py:L'oggetto "Manager" non è richiamabile

from django.http import HttpResponse   
from django.template import Context, loader 
from django.shortcuts import render_to_response 
from astonomyStuff.attendance.models import Member 
from astonomyStuff.attendance.models import Non_Member 
from astonomyStuff.attendance.models import Talk 
from astonomyStuff.attendance.models import Event_Attendance  


# Create your views here.  
def talksIndex(request): 
latest_talk = Talk.objects().all() 
return render_to_response('talks/index.html', {'latest_talk': latest_talk}) 

def viewMembers(request): 
members_List = Member.objects().all() 
return render_to_response('members/index.html', {'members_List': members_List}) 

Poi il mio urls.py assomiglia a questo:

urlpatterns = patterns('', 
# Example: 
# (r'^astonomyStuff/', include('astonomyStuff.foo.urls')), 

# Uncomment the admin/doc line below and add 'django.contrib.admindocs' 
# to INSTALLED_APPS to enable admin documentation: 
# (r'^admin/doc/', include('django.contrib.admindocs.urls')), 

# Uncomment the next line to enable the admin: 
(r'^admin/', include(admin.site.urls)), 
(r'^attendance/$', 'astonomyStuff.attendance.views.talksIndex'), 
(r'^members/$', 'astonomyStuff.attendance.views.viewMembers'), 
) 

Ha uno ha ottenuto tutte le idee perché questo errore sta accadendo come ho fatto in precedenza avuto il parla per funzionare bene. Posso pubblicare più codice se necessario.

risposta

22

objects non è richiamabile (è un attributo).

  • Talk.objects() ->non sarà lavoro

  • Talk.objects ->volontà lavoro

Così, invece di cercare di chiamare in questo modo:

# Create your views here.  
def talksIndex(request): 
    latest_talk = Talk.objects().all() 
    return render_to_response('talks/index.html', {'latest_talk': latest_talk}) 
.210

Prova questo:

# Create your views here.  
def talksIndex(request): 
    latest_talk = Talk.objects.all() 
    return render_to_response('talks/index.html', {'latest_talk': latest_talk}) 

E lo stesso con gli altri esempi

+0

Che cosa hai cambiato? – Dean

+7

'Talk.objects(). All()' a 'Talk.objects.all()' – sdolan

+1

Grazie non è stato possibile vedere il cambiamento :) – Dean

Problemi correlati