2017-10-27 23 views
2

これは非常に問題ではありますが、このエラーで返された商品テンプレートをレンダリングしようとすると、最初の2ページは約というように正しくレンダリングされます私はの製品ページのために別のアプリを追加しようとしましたが、それは読み込まれませんでした。htmlテンプレートはPython djangoでレンダリングされません

#THE ERROR 
Page not found (404) 
Request Method: GET 
Request URL: http://localhost:8000/%7B%25%20url%20'products'%7D 
Using the URLconf defined in trydjango.urls, Django tried these URL 
patterns, in this order: 
1. ^admin/ 
2. ^$ [name='home'] 
3. ^about/$ [name='about'] 
4. ^products/$ [name='products'] 
5. ^contact/$ [name='contact'] 
6. ^accounts/ 
7.^static\/(?P<path>.*)$ 
8.^static\/(?P<path>.*)$ 

The current URL, {% url 'products'}, did not match any of these. 

#This is the structure 
src 
>> contact 
>> products 
    >> migrations 
    >> templates 
     >> products.html 
>> profiles 
>> migrations 
>> templates 
    >> about.html 
    >> base.html 
    >> home.html 
    >> navbar.html 

#from the products app this is the views.py 

def products(request): 
    context = {} 
    template = 'products.html' 
    return render(request, template,context) 

#This is the config for urls 


from profiles import views as profiles_views 
from contact import views as contact_views 
from products import views as products_views 

urlpatterns = [ 
url(r'^admin/', admin.site.urls), 
url(r'^$', profiles_views.home, name='home'), 
url(r'^about/$', profiles_views.about, name='about'), 
url(r'^products/$', products_views.products, name='products'), 
url(r'^contact/$', contact_views.contact, name='contact'), 
url(r'^accounts/', include('allauth.urls')), 

] 

#and this is where I called it in navbar 
<li class="nav-item"> 
     <a class="nav-link js-scroll-trigger" href="{%url'products'}">Products</a> 
</li> 

答えて

1

ますリンクテンプレートタグの終了 '%'が表示されないようです。

<a class="nav-link js-scroll-trigger" href="{% url 'products' %}">Products</a> 
2

それはそれはのURLに移動し、追加を行うに、含まれている場合は、URLを名前を付けないでください:

app_name='products' 
urlpatterns = [ 
    url(r'^$', your_view.path, name='home'), 

] 

をし、それを参照してください。

{% url 'products:home' %} 
関連する問題