I am trying to create a copy of the built in blog app so I can customize
the fields in it. I have copied and renamed everything I can find in the
files. I can get the mediablog to open up in the admin screen to add a new
post. But when I click save, it saves it in the database and then gets the
following error.
Error during template rendering
In template
C:\django\web\lib\site-packages\grappelli_safe\templates\admin\change_list.html,
error at line
*105*Reverse for 'mediablog_post_detail' with arguments '()' and keyword
arguments '{'slug': 'test-mediablog-2'}' not found. 0 pattern(s) tried: []
I have looked at other threads with the same problems and I still cannot
figure out what is causing it. Here is the information that was asked for
in the other threads. I am changing the text color for the areas, I think
are involved.
Part of model.py
def get_absolute_url(self):
URLs for mediablog posts can either be just their slug, or prefixed
with a portion of the post's publish date, controlled by the
setting ``mediablog_URLS_DATE_FORMAT``, which can contain the value
``year``, ``month``, or ``day``. Each of these maps to the name
of the corresponding urlpattern, and if defined, we loop through
each of these and build up the kwargs for the correct urlpattern.
The order which we loop through them is important, since the
order goes from least granualr (just year) to most granular
(year/month/day).
url_name = mediablog_post_detail
kwargs = {slug: self.slug}
date_parts = (year, month, day)
if settings.mediablog_URLS_DATE_FORMAT in date_parts:
url_name = mediablog_post_detail_%s %
settings.mediablog_URLS_DATE_FORMAT
for date_part in date_parts:
date_value = str(getattr(self.publish_date, date_part))
if len(date_value) == 1:
date_value = 0%s % date_value
kwargs[date_part] = date_value
if date_part == settings.mediablog_URLS_DATE_FORMAT:
break
return reverse(url_name, kwargs=kwargs)
Part of my urls.py:
# mediablog patterns.
urlpatterns = patterns(.views,
url(^%sfeeds/(?Pformat.*)%s$ % _slashes,
mediablog_post_feed, name=mediablog_post_feed),
url(^%stag/(?Ptag.*)/feeds/(?Pformat.*)%s$ % _slashes,
mediablog_post_feed, name=mediablog_post_feed_tag),
url(^%stag/(?Ptag.*)%s$ % _slashes, mediablog_post_list,
name=mediablog_post_list_tag),
url(^%scategory/(?Pcategory.*)/feeds/(?Pformat.*)%s$ % _slashes,
mediablog_post_feed, name=mediablog_post_feed_category),
url(^%scategory/(?Pcategory.*)%s$ % _slashes,
mediablog_post_list, name=mediablog_post_list_category),
url(^%sauthor/(?Pusername.*)/feeds/(?Pformat.*)%s$ % _slashes,
mediablog_post_feed, name=mediablog_post_feed_author),
url(^%sauthor/(?Pusername.*)%s$ % _slashes,
mediablog_post_list, name=mediablog_post_list_author),
url(^%sarchive/(?Pyear\d{4})/(?Pmonth\d{1,2})%s$ % _slashes,
mediablog_post_list, name=mediablog_post_list_month),
url(^%sarchive/(?Pyear\d{4})%s$ % _slashes,
mediablog_post_list, name=mediablog_post_list_year),
url(^%s(?Pyear\d{4})/(?Pmonth\d{1,2})/(?Pday\d{1,2})/
(?Pslug.*)%s$ % _slashes,
mediablog_post_detail, name=mediablog_post_detail_day),
url(^%s(?Pyear\d{4})/(?Pmonth\d{1,2})/(?Pslug.*)%s$ % _slashes,
mediablog_post_detail, name=mediablog_post_detail_month),
url(^%s(?Pyear\d{4})/(?Pslug.*)%s$ % _slashes,
mediablog_post_detail, name=mediablog_post_detail_year),
url(^%s(?Pslug.*)%s$ % _slashes, mediablog_post_detail,
name=mediablog_post_detail),
url(^%s$ % _slashes[1], mediablog_post_list,
name=mediablog_post_list),
)
Part of my views.py:
def mediablog_post_detail(request, slug, year=None, month=None, day=None,
template=mediablog/mediablog_post_detail.html):
. Custom templates are checked for using the name
``mediablog/mediablog_post_detail_XXX.html`` where ``XXX`` is the
mediablog
posts's slug.
mediablog_posts = mediablogPost.objects.published(
for_user=request.user).select_related()
mediablog_post = get_object_or_404(mediablog_posts, slug=slug)
context = {mediablog_post: mediablog_post, editable_obj:
mediablog_post}
templates = [umediablog/mediablog_post_detail_%s.html % str(slug),
template]
return render(request, templates, context)
I have the template mediablog_post_detail.html in the
/mediablog/tempates/mediablog/ folder and in the root directory
/templates/mediablog/ folder.
I have deleted all the url patterns above the one highlighted above and
still get the same error.
Here is