[Fixed]-Designing my own list in django and bootstrap

1👍

Use a ListView. It will provide a context variable for your template called object_list that will contain your list. There is absolutely no need to copy the values from the model objects into some intermediary item class. There never is.

from django.views.generic.list import ListView

class UserListView(ListView):

    model = User  # your user model

By default this will use the template yourapp/user_list.html but you can override it by setting the class variable template_name in the UserListView class.

There’s not more to it. That’s why Django rocks. Many newcomers make mistakes and complicate things because they don’t realize how powerful Django really is and how little code you need to write.

Leave a comment