在django中使用ListView,获取_uinit__;()只需要1个参数(给定2个)

在django中使用ListView,获取_uinit__;()只需要1个参数(给定2个),django,django-templates,django-views,django-class-based-views,Django,Django Templates,Django Views,Django Class Based Views,我是django的新手,我正在尝试显示数据库中的专辑列表。这是相册模型 class Album(models.Model): """Album model""" title = models.CharField(max_length=255) prefix = models.CharField(max_length=20, blank=True) subtitle = models.CharField(blank=True, max_length=255) slug = mode

我是django的新手,我正在尝试显示数据库中的专辑列表。这是相册模型

class Album(models.Model):
"""Album model"""
  title = models.CharField(max_length=255)
  prefix = models.CharField(max_length=20, blank=True)
  subtitle = models.CharField(blank=True, max_length=255)
  slug = models.SlugField()
  band = models.ForeignKey(Band, blank=True)
  label = models.ForeignKey(Label, blank=True)
  asin = models.CharField(max_length=14, blank=True)
  release_date = models.DateField(blank=True, null=True)
  cover = models.FileField(upload_to='albums', blank=True)
  review = models.TextField(blank=True)
  genre = models.ManyToManyField(Genre, blank=True)
  is_ep = models.BooleanField(default=False)
  is_compilation = models.BooleanField(default=False)

  class Meta:
    db_table = 'music_albums'
    ordering = ('title',)

  def __unicode__(self):
    return '%s' % self.full_title
我的观点是

    class album_list(ListView):
        template_name = "/music/album_list.html"
        context_object_name = 'list_of_albums'
       #paginate_by = '15'

        def get_queryset(self):
           return Album.objects.all()
我可以从管理界面添加相册,但在转到/albums/url显示它们时,我得到init()正好取1个参数(2个给定)错误

我正在使用的模板

    {% extends "music/base_music.html" %}

    {% block title %}Music Albums{% endblock %}
    {% block body_class %}{{ block.super }} music_albums{% endblock %}


    {% block content_title %}
      <h2>Music Albums</h2>
      {% include "music/_nav.html" %}
    {% endblock %}


    {% block content %}
     <table>
     <tr>
     <th>Band</th>
     <th>Album</th>
     </tr>
     {% for album in list_of_albums %}
      <tr class="{% cycle 'odd' 'even' %}">
      <td class="band"><a href="{{ album.band.get_absolute_url }}">{{ album.band }}</a>  </td>
      <td class="album"><a href="{{ album.get_absolute_url }}">{{ album.full_title }}</a></td>
      </tr>
      {% endfor %}

      </table>
      {% endblock %}
{%extensed“music/base_music.html”%}
{%block title%}音乐专辑{%endblock%}
{%block body_class%}{{block.super}}音乐专辑{%endblock%}
{%block content\u title%}
音乐专辑
{%include“music/_nav.html”%}
{%endblock%}
{%block content%}
乐队
专辑
{U相册%列表中的相册的%}
{%endfor%}
{%endblock%}

我已经阅读了这里已经提出的类似问题的答案,但无法让代码正常工作。

通常这是因为您忘记将
。as_view()
放在您的URL.py中:

而不是

(r"", 'SomeName.views.album_list'),


请记住更改
SomeName
:)

通常这是因为您忘记将
.as\u view()
放在URL.py中:

而不是

(r"", 'SomeName.views.album_list'),


记住更改
SomeName
:)

你能添加你的URL.py吗?你能添加你的URL.py吗?