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/(?P<format>.*)%s$" % _slashes,
"mediablog_post_feed", name="mediablog_post_feed"),
url("^%stag/(?P<tag>.*)/feeds/(?P<format>.*)%s$" % _slashes,
"mediablog_post_feed", name="mediablog_post_feed_tag"),
url("^%stag/(?P<tag>.*)%s$" % _slashes, "mediablog_post_list",
name="mediablog_post_list_tag"),
url("^%scategory/(?P<category>.*)/feeds/(?P<format>.*)%s$" % _slashes,
"mediablog_post_feed", name="mediablog_post_feed_category"),
url("^%scategory/(?P<category>.*)%s$" % _slashes,
"mediablog_post_list", name="mediablog_post_list_category"),
url("^%sauthor/(?P<username>.*)/feeds/(?P<format>.*)%s$" % _slashes,
"mediablog_post_feed", name="mediablog_post_feed_author"),
url("^%sauthor/(?P<username>.*)%s$" % _slashes,
"mediablog_post_list", name="mediablog_post_list_author"),
url("^%sarchive/(?P<year>\d{4})/(?P<month>\d{1,2})%s$" % _slashes,
"mediablog_post_list", name="mediablog_post_list_month"),
url("^%sarchive/(?P<year>\d{4})%s$" % _slashes,
"mediablog_post_list", name="mediablog_post_list_year"),
url("^%s(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/"
"(?P<slug>.*)%s$" % _slashes,
"mediablog_post_detail", name="mediablog_post_detail_day"),
url("^%s(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<slug>.*)%s$" % _slashes,
"mediablog_post_detail", name="mediablog_post_detail_month"),
url("^%s(?P<year>\d{4})/(?P<slug>.*)%s$" % _slashes,
"mediablog_post_detail", name="mediablog_post_detail_year"),
url("^%s(?P<slug>.*)%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 = [u"mediablog/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 the lower parts of the traceback:
> - C:\django\web\website\mediablog\models.py in get_absolute_url
> 1.
>
> return reverse(url_name, kwargs=kwargs)
>
> ...
> ▼ Local vars <http://127.0.0.1:8000/admin/mediablog/mediablogpost/#>
> VariableValueurl_name
>
> 'mediablog_post_detail'
>
> date_parts
>
> ('year', 'month', 'day')
>
> self
>
> <mediablogPost: test mediablog>
>
> kwargs
>
> {'slug': 'test-mediablog-2'}
>
> - C:\django\web\lib\site-packages\django\core\urlresolvers.py in
> reverse
> 1.
>
> return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
> *args, **kwargs))
>
> ...
> ▼ Local vars <http://127.0.0.1:8000/admin/mediablog/mediablogpost/#>
> VariableValueargs
>
> []
>
> resolved_path
>
> []
>
> path
>
> []
>
> viewname
>
> 'mediablog_post_detail'
>
> current_app
>
> None
>
> prefix
>
> '/'
>
> kwargs
>
> {'slug': 'test-mediablog-2'}
>
> view
>
> 'mediablog_post_detail'
>
> urlconf
>
> 'website.urls'
>
> resolver
>
> <RegexURLResolver 'website.urls' (None:None) ^/>
>
> ns_pattern
>
> ''
>
> parts
>
> ['mediablog_post_detail']
>
> - C:\django\web\lib\site-packages\django\core\urlresolvers.py in
> _reverse_with_prefix
> 1.
>
> (lookup_view_s, args, kwargs,
> len(patterns), patterns))
>
> ...
> ▼ Local vars <http://127.0.0.1:8000/admin/mediablog/mediablogpost/#>
> VariableValueargs
>
> ()
>
> text_kwargs
>
> {'slug': 'test-mediablog-2'}
>
> _prefix
>
> '/'
>
> lookup_view_s
>
> 'mediablog_post_detail'
>
> n
>
> None
>
> kwargs
>
> {'slug': 'test-mediablog-2'}
>
> m
>
> None
>
> possibilities
>
> []
>
> prefix_args
>
> []
>
> self
>
> <RegexURLResolver 'website.urls' (None:None) ^/>
>
> text_args
>
> []
>
> lookup_view
>
> 'mediablog_post_detail'
>
> prefix_norm
>
> '/'
>
> patterns
>
> []
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Mezzanine Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.