0
0 комментариев

Не могу понять в чем проблема.

Traceback
Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/articles/get/1/

Django Version: 1.6.1
Python Version: 2.7.6
Installe

d Applications:
('django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'article')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware')
 
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
  114.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)
 
Exception Type: TypeError at /articles/get/1/
Exception Value: articles() got an unexpected keyword argument 'article_id'

Содержание файла views.py :

from django.shortcuts import render
from django.http.response import HttpResponse
from django.template.loader import get_template
from django.template import Context
from django.shortcuts import render_to_response
from article.models import Article, Comments
 
 urls
 
def articles(request):
    return render_to_response('articles.html', {'articles': Article.objects.all()})
 
def article(request, article=0):
    return render_to_response('article.html',       {'article':Article.objects.get(id=article_id), 'comments':Comments.objects.filter(comments_article_id=article_id)})

urls

from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
    url(r'^articles/all/$', 'article.views.articles'),
    url(r'^articles/get/(?P<article_id>\d+)/$', 'article.views.articles'),

)


Добавить комментарий