Harsh
Harsh

Reputation: 45

Django : Problem with Django-allauth urls

I just started with a Django project using django-allauth, I configured the basic settings, without using any 3rd party provider. I have set up the urls.py of my project and urls.py of my app.

But on going to http://localhost:8000, I am getting to 'home.html' but how do I remove the navigation of allauth

enter image description here

The following is the urls.py of my project :

from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    path('admin/', admin.site.urls),
   path('accounts/', include('allauth.urls')),
    path('ckeditor/',include('ckeditor_uploader.urls')),
    path('',include('blog.urls')),
]


if settings.DEBUG:
    urlpatterns += static(settings.STATIC_URL,
                          document_root=settings.STATIC_ROOT)
    urlpatterns += static(settings.MEDIA_URL,
                          document_root=settings.MEDIA_ROOT)

And this my urls.py of app :

from django.urls import path, include 
from . import views
urlpatterns = [

    path("", views.PostListView.as_view(), name = 'post_list'),
    path("post/add", views.CreatePostView.as_view(), name = "create_new_post"),

]

views.py

from django.shortcuts import render
from django.views.generic import ListView, View
# Create your views here.
from .forms import PostForm, CommentForm
from .models import Post, Comment

class PostListView(ListView):
   queryset = Post.objects.filter(is_published=True)
   template_name = 'home.html'

class CreatePostView(View):
   form_class = PostForm()
   template_name = 'create_post.html'
   model = Post

home.html

{% extends 'base.html' %}

{% block content %}

    <h1>Hello World</h1>
    {% for post in post_list %}

    <h1>{{post.post_title}}</h1>
    <p>{{post.post_body|safe}}</p>

    {% endfor %}

{% endblock %}

Upvotes: 0

Views: 283

Answers (3)

aNup
aNup

Reputation: 381

the extended base.html file may contain the navigation. make changes there to remove or simply remove it

{% extends 'base.html' %}

Upvotes: 1

unknown
unknown

Reputation: 332

your global urls.py:

path('',include('blog.urls')),

add something in your app urls.py:

path('test/',views.PostListView.as_view()),

after adding this to your urls.py, run your app again

Upvotes: 1

bmons
bmons

Reputation: 3392

 path("post/add/", views.CreatePostView.as_view(), name = "create_new_post"),

add trailing slash to your url

Upvotes: 2

Related Questions