Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
i I'm beginner in learning Django, I got this error when i try to runserver:
__init__() takes 1 positional argument but 2 were given
the urls:
from django.contrib import admin
from django.urls import path
from users import views as user_views
from main.views import about, ListView
from django.contrib.auth import views as auth_views
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
path('admin/', admin.site.urls),
path('register/', user_views.register, name='register'),
path('profile/', user_views.profile, name='profile'),
path('about/', about, name='about'),
path('', ListView, name='PostListViews'),
path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
here is my views:
from django.shortcuts import render
from .models import Post
from django.views.generic import ListView
def blog(request):
context = {
'posts': Post.objects.all()
return render(request=request,
template_name='main/blog.html',
context=context)
class PostListViews(ListView):
model = Post
template_name = 'main/blog.html'
def about(request):
return render(request=request,
template_name='main/about.html')
i don't know where the error comes from please explain to me and Thank you in advance :)
–
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.