**
Good day, please am new to Django and am facing some challenges which have tried to resolve but am not yet resolve please i need your help.
**
the error are below
Page not found (404)
Request Method: GET
Request URL: https://mydomain/pages/index.php**
Using the URLconf defined in dcitygate.urls, Django tried these URL patterns, in this order:
admin/
[name='index']
blog/ [name='blog']
audio_messages/ [name='audio_messages']
imgc/ [name='imgc']
imgc/<int:id> [name='imgc_detail']
tsc/ [name='tsc']
tsc/<int:id> [name='tsc_detail']
word_prayer/ [name='word_prayer']
word_prayer/<int:id> [name='word_prayer_detail']
video_messages/ [name='video_messages']
contact_us/ [name='contact_us']
couple_meeting/ [name='couple_meeting']
kcc/ [name='kcc']
kcc/<int:id> [name='kcc_detail']
pages/streaming/ [name='streaming']
watchlive/ [name='watchlive']
<int:id> [name='audio_streaming_detail']
listenlive/ [name='listenlive']
blogs/
audio_msg/
^media/(?P<path>.*)$'''
*The current path, index.php, didn’t match any of these*
my Project.url
from django.contrib import admin
from django.urls import path, include
from django.conf.urls.static import static
from django.conf import settings
from django.conf.urls import url
urlpatterns = [
path('admin/',admin.site.urls),
path('', include('pages.urls')),
path('blogs/', include('blogs.urls')),
path('audio_msg/', include('audio_msg.urls')),
] static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
MyApp.url
from django.urls import path, re_path
from django.conf.urls import url
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('blog/',views.blog, name='blog'),
path('audio_messages/', views.audio_messages, name='audio_messages'),
path('imgc/', views.imgc, name='imgc'),
path('imgc/<int:id>', views.imgc_detail, name='imgc_detail'),
path('tsc/', views.tsc, name='tsc'),
path('tsc/<int:id>', views.tsc_detail, name='tsc_detail'),
path('word_prayer/', views.word_prayer, name='word_prayer'),
path('word_prayer/<int:id>', views.word_prayer_detail, name='word_prayer_detail'),
path('video_messages/', views.video_messages, name='video_messages'),
path('contact_us/', views.contact_us, name='contact_us'),
path('couple_meeting/', views.couple_meeting, name='couple_meeting'),
path('kcc/', views.kcc, name='kcc'),
path('kcc/<int:id>', views.kcc_detail, name='kcc_detail'),
path('pages/streaming/', views.streaming, name='streaming'),
path('watchlive/', views.watchlive, name='watchlive'),
path('<int:id>', views.audio_streaming_detail, name='audio_streaming_detail'),
path('listenlive/', views.listenlive, name='listenlive'),
]
my view
from django.shortcuts import render, get_object_or_404
from blogs.models import Blog
from audio_msg.models import Audio_msg
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
# Create your views here.
def index(request):
blog_data = Blog.objects.order_by('-created_date')
audio_data = Audio_msg.objects.order_by('-created_date')
data = {
'blog_data': blog_data,
'audio_data': audio_data,
}
return render(request, 'pages/home.html', data)
def blog(request):
return render(request, 'pages/blog.html')
def audio_messages(request):
return render(request, 'pages/audio_messages.html')
def imgc(request):
blog_data = Blog.objects.order_by('-created_date').filter(category='IMGC')
paginator = Paginator(blog_data, 9)
page = request.GET.get('page')
paged_blog = paginator.get_page(page)
data = {
'blog_data': paged_blog,
}
return render(request, 'pages/imgc.html', data)
def imgc_detail(request, id):
blog_detail = get_object_or_404(Blog, pk=id)
data = {
'blog_detail': blog_detail,
}
return render(request, 'pages/imgc_detail.html', data)
def tsc(request):
blog_data = Blog.objects.order_by('-created_date').filter(category='TSC')
paginator = Paginator(blog_data, 9)
page = request.GET.get('page')
paged_blog = paginator.get_page(page)
data = {
'blog_data': paged_blog,
}
return render(request, 'pages/tsc.html', data)
def tsc_detail(request, id):
blog_detail = get_object_or_404(Blog, pk=id)
data = {
'blog_detail': blog_detail,
}
return render(request, 'pages/tsc_detail.html', data)
def word_prayer(request):
blog_data = Blog.objects.order_by('-created_date').filter(category='WAP')
paginator = Paginator(blog_data, 9)
page = request.GET.get('page')
paged_blog = paginator.get_page(page)
data = {
'blog_data': paged_blog,
}
return render(request, 'pages/word_prayer.html', data)
def word_prayer_detail(request, id):
blog_detail = get_object_or_404(Blog, pk=id)
data = {
'blog_detail': blog_detail,
}
return render(request, 'pages/word_prayer_detail.html', data)
def video_messages(request):
return render(request, 'pages/video_messages.html')
def audio_messages(request):
return render(request, 'pages/audio_messages.html')
def contact_us(request):
return render(request, 'pages/contact_us.html')
def couple_meeting(request):
return render(request, 'pages/couple_meeting.html')
def kcc(request):
blog_data = Blog.objects.order_by('-created_date').filter(category='KCC')
data = {
'blog_data': blog_data,
}
return render(request, 'pages/kcc.html', data)
def kcc_detail(request, id):
blog_detail = get_object_or_404(Blog, pk=id)
data = {
'blog_detail': blog_detail,
}
return render(request, 'pages/kcc_detail.html', data)
def streaming(request):
return render(request, 'pages/streaming.html')
def watchlive(request):
return render(request, 'pages/watchlive.html')
def listenlive(request):
return render(request, 'pages/listenlive.html')
def audio_msg(request):
audio_data = Audio_msg.objects.order_by('-created_date')
data = {
'audio_data': audio_data,
}
return render(request, 'pages/audio_msg.html', data)
def audio_streaming_detail(request, id):
audio_data = get_object_or_404(Audio_msg, pk=id)
data = {
'audio_data': audio_data,
}
**return render(request, 'pages/audio_streaming_detail.html', data)
please help**
CodePudding user response:
I don't see any pages/index.php
anywhere, and you shouldn't use .php
on Django projects, it's not PHP
If you're trying to get to: path('', views.index, name='index')
just try http://127.0.0.1:8000/
If you are trying to get to another view, what view?- ti should be in a urls.py
CodePudding user response:
Thank you for this platform and everyone that have contributed to this question. my solution to the problem was removing the default redirect code in .htaccess and use this code below.
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION BEGIN
PassengerAppRoot "/home2/thecity2/church-project"
PassengerBaseURI "/"
PassengerPython "/home2/thecity2/virtualenv/church-project/3.9/bin/python"
# DO NOT REMOVE. CLOUDLINUX PASSENGER CONFIGURATION END
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION BEGIN
<IfModule Litespeed>
</IfModule>
# DO NOT REMOVE OR MODIFY. CLOUDLINUX ENV VARS CONFIGURATION END