質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

0回答

1345閲覧

【Django Oscar】商品が表示されません。

ox8

総合スコア7

Django

DjangoはPythonで書かれた、オープンソースウェブアプリケーションのフレームワークです。複雑なデータベースを扱うウェブサイトを開発する際に必要な労力を減らす為にデザインされました。

MySQL

MySQL(マイエスキューエル)は、TCX DataKonsultAB社などが開発するRDBMS(リレーショナルデータベースの管理システム)です。世界で最も人気の高いシステムで、オープンソースで開発されています。MySQLデータベースサーバは、高速性と信頼性があり、Linux、UNIX、Windowsなどの複数のプラットフォームで動作することができます。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2018/02/01 11:25

Django Oscarを使ってサイトを作っているのですが、商品一覧が表示されません。
DBはMySQLを使っており、ダッシュボードやアドミンから商品データの登録・編集などを出来る状態なので表示させるためのコードが間違っていると思うのですが、どこが間違っているのかが分かりません。
また、商品個別のページも表示出来ています。
【商品一覧のページ】
商品一覧のページ

【商品一覧のテンプレート】

Python

1{% extends "layout_2_col.html" %} 2 3{% load basket_tags %} 4{% load promotion_tags %} 5{% load category_tags %} 6{% load product_tags %} 7{% load i18n %} 8 9{% block title %} 10 {% if summary %}{{ summary }} |{% endif %} {{ block.super }} 11{% endblock %} 12 13{% block headertext %}{{ summary }}{% endblock %} 14 15{% block breadcrumbs %} 16 <ul class="breadcrumb"> 17 <li> 18 <a href="{{ homepage_url }}">{% trans "Home" %}</a> 19 </li> 20 <li class="active">{{ summary }}</li> 21 </ul> 22{% endblock breadcrumbs %} 23 24 25{% block content %} 26 <form method="get" class="form-horizontal"> 27 {% for value in selected_facets %} 28 <input type="hidden" name="selected_facets" value="{{ value }}" /> 29 {% endfor %} 30 <input type="hidden" name="q" value="{{ search_form.q.value|default_if_none:"" }}" /> 31 32 {% if paginator.count %} 33 {% if paginator.num_pages > 1 %} 34 {% blocktrans with start=page_obj.start_index end=page_obj.end_index count num_results=paginator.count %} 35 <strong>{{ num_results }}</strong> result - showing <strong>{{ start }}</strong> to <strong>{{ end }}</strong>. 36 {% plural %} 37 <strong>{{ num_results }}</strong> results - showing <strong>{{ start }}</strong> to <strong>{{ end }}</strong>. 38 {% endblocktrans %} 39 {% else %} 40 {% blocktrans count num_results=paginator.count %} 41 <strong>{{ num_results }}</strong> result. 42 {% plural %} 43 <strong>{{ num_results }}</strong> results. 44 {% endblocktrans %} 45 {% endif %} 46 {% if form %} 47 <div class="pull-right"> 48 {% include "partials/form_field.html" with field=form.sort_by %} 49 </div> 50 {% endif %} 51 {% else %} 52 <p> 53 {% trans "<strong>0</strong> results." %} 54 </p> 55 {% endif %} 56 </form> 57 58 {% if products %} 59 <section> 60 <div> 61 <ol class="row"> 62 {% for product in products %} 63 <li class="col-xs-6 col-sm-4 col-md-3 col-lg-3">{% render_product product %}</li> 64 {% endfor %} 65 </ol> 66 {% include "partials/pagination.html" %} 67 </div> 68 </section> 69 {% else %} 70 <p class="nonefound">{% trans "No products found." %}</p> 71 {% endif %} 72 73 74{% endblock content %} 75 76{% block onbodyload %} 77 {{ block.super }} 78 oscar.search.init(); 79{% endblock %} 80

.
.

【product_tags.py】

Python

1from django import template 2from django.template.loader import select_template 3 4register = template.Library() 5 6 7 # Render a product snippet as you would see in a browsing display. 8 # This templatetag looks for different templates depending on the UPC and 9 # product class of the passed product. This allows alternative templates 10 # to be used for different product classes. 11 12@register.simple_tag(takes_context=True) 13def render_product(context, product): 14 if not product: 15 # Search index is returning products that don't exist in the database 16 return '' 17 18 names = ['catalogue/partials/product/upc-%s.html' % product.upc, 19 'catalogue/partials/product/class-%s.html' % product.get_product_class().slug, 20 'catalogue/partials/product.html'] 21 template_ = select_template(names) 22 context = context.flatten() 23 24 # Ensure the passed product is in the context as 'product' 25 context['product'] = product 26 return template_.render(context)

.
.
【product.html】

Python

1{% load reviews_tags %} 2{% load thumbnail %} 3{% load i18n %} 4{% load display_tags %} 5{% load staticfiles %} 6 7{% block product %} 8 <article class="product_pod"> 9 {% block product_image %} 10 <div class="image_container"> 11 {% with image=product.primary_image %} 12 {% thumbnail image.original "x155" upscale=False as thumb %} 13 <a href="{{ product.get_absolute_url }}"><img src="{{ thumb.url }}" alt="{{ product.get_title }}" class="thumbnail"></a> 14 {% endthumbnail %} 15 {% endwith %} 16 </div> 17 {% endblock %} 18 19 {% block product_review %} 20 {% iffeature "reviews" %} 21 <p class="star-rating {{ product.rating|as_stars }}"> 22 <i class="icon-star"></i> 23 <i class="icon-star"></i> 24 <i class="icon-star"></i> 25 <i class="icon-star"></i> 26 <i class="icon-star"></i> 27 </p> 28 {% endiffeature %} 29 {% endblock %} 30 31 {% block product_title %} 32 <h3><a href="{{ product.get_absolute_url }}" title="{{ product.get_title }}">{{ product.get_title|truncatewords:4 }}</a></h3> 33 {% endblock %} 34 35 {% block product_price %} 36 <div class="product_price"> 37 {% include "catalogue/partials/stock_record.html" %} 38 {% if not product.is_parent %} 39 {% include "catalogue/partials/add_to_basket_form_compact.html" %} 40 {% endif %} 41 </div> 42 {% endblock %} 43 </article> 44{% endblock %}

.
.
.
こちらが関係していると思われるファイルの記述です。
お手数をお掛け致しますが、御回答宜しくお願い致します。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問