swappsco / django-wordpress-api

MIT License
22 stars 9 forks source link

Single posts not working #12

Closed Capitancacho closed 3 years ago

Capitancacho commented 3 years ago

Description

The problem occurs when I enter in a single post, although I pass the post slug to it, it always returns the same entry. I use the default urls. Everything works ok but the problem is that the single post always retrieve the same post.

What I Did

uls.py

from django.urls import path, re_path, include
from django.conf import settings
from django.conf.urls.static import static
from django.conf.urls import url
from django.contrib import admin
from django.views.generic import TemplateView
from django.conf.urls.i18n import i18n_patterns

urlpatterns = [
    path('admin/', admin.site.urls),
]

urlpatterns += i18n_patterns(
    path('accounts/', include('django.contrib.auth.urls')),
    re_path('', include('apps.users.urls')),
    re_path('', include('apps.pages.urls')),
    re_path('', include('apps.artistas.urls')),
    re_path('', include('apps.exposicioneslab.urls')),
    re_path('', include('apps.obras.urls')),
    re_path('', include('apps.projects.urls')),
    url(r'^news/', include('wordpress_api.urls')),
    prefix_default_language=True,
) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

blog_list.html

<h3><a href="{% url 'wordpress_api_blog_detail' blog.slug %}">{{ blog.title.rendered | striptags | safe }}</a></h3>

To check it you can go to: http://167.172.104.202/news/

Capitancacho commented 3 years ago

I have found a solution just chenging BlogView:

wp_api['wp_filter'] = {'slug': str(kwargs.get('slug'))}