Thursday, May 31, 2018

Re: href not working

my blog view.py is empty at the moment


Mysite url.py

from django.contrib import admin

from django.conf.urls import url, include

 

urlpatterns = [

    url(r'^admin/', admin.site.urls),

    url(r'^', include( 'hybridair.urls')),

    url(r'^blog/$', include( 'blog.urls')),

]

 

 

 

Hybrid Air url.py

from django.conf.urls import url, include

from . import views

urlpatterns = [

    url(r'^', views.index, name='index'),

    url(r'^contact/', views.contact, name='contact'),

]

 

 

Hybrid Air view.py

from django.shortcuts import render

 

def index(request):

    return render(request, 'hybridair/home.html')

 

def contact(request):

    return render(request, 'hybridair/basic.html' ('content' ['contact the team at''marcus@flymat21.com']))

 

def blog(request):

    return render(request, 'hybridair/header.html')

 

 

 

 

 

blog url.py

from django.conf.urls import url, include

from django.views.generic import ListView, DetailView

from blog.models import Post

 

urlpatterns = [

    url(r'^$', ListView.as_view(

    queryset=Post.objects.order_by('-date')[:25],

    template_name="blog/blog.html")),

 

    url(r'^(?P<pk>\d+)$', DetailView.as_view(model = Post,

    template_name='blog/post.html')),

    ]


Do you see what I need to change?

On Thursday, May 31, 2018 at 7:11:46 AM UTC-4, Mohammed Noor wrote:
I think the mistake is using a '/' before the name inside href. Try changing it from href= '/contact'/ to href= 'contact/' 

Have a great day 

On 31-May-2018, at 9:26 AM, Caleb Bryson <cbrys...@gmail.com> wrote:

So i am trying to create a directory with a Home,Blog,and Contact selection. But every time i click on one of them they all go back to the home page. How do i fix this, and here is the secton of code below. let me know if you need to see more

<div class="well bs-sidebar" id="sidebar" style="background-color:#fff">
       <ol class="nav nav-pills nav-stacked">
        <li><a href='/'>Home</a></li>
        <li><a href='/blog/'>Blog</a></li>
        <li><a href='/contact/'>Contact</a></li>
       </ol>
      </div>

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9dc7004b-4fff-412d-8560-6308f13db92c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/e7cc8fdf-03a2-4d4e-a8f6-1b949714fbc9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment