Just solved this 404 issue, such a stupid mistake! Was using (now 
deprecated) `urlpatterns = patterns()`, just switch out patterns for a 
simple `urlpatterns = []` and all works as expected.

Have also successfully reversed the blog's views enough to return data!

Thanks for the help Eduardo, just enough of a push to get going.

On Sunday, July 9, 2017 at 10:00:23 AM UTC-7, [email protected] wrote:
>
> Currently they are before the catch-all
> url("^", include("mezzanine.urls")),
>
> but after the redirect to index
> url("^$", direct_to_template, {"template": "index.html"}, name="home"),
>
> In the same pattern
> urlpatterns += []
>
> Trying to get debug statements into both the app's urlconf and views, but 
> the requests don't seem to be making it there. Also tried commenting out 
> Mezzanine's default 404 and 500 handlers, with no luck.
>
>
>
> On Saturday, July 8, 2017 at 3:46:53 PM UTC-7, Eduardo Rivas wrote:
>>
>> Have you included your url patterns before Mezzanine's catch-all in the 
>> root conf? 
>>
>> On Jul 7, 2017 1:37 PM, <[email protected]> wrote:
>>
>> Solved that, and have been constantly 404'ing since. Saw another of your 
>> posts Eduardo about i18n and middleware causing 404's on pages that don't 
>> exist, but have disabled i18n and am still running into issue. It's almost 
>> like the urls.py is not updating. 
>>
>> Here is the root url pattern I am using:
>> url("^news/", include("kdi.urls")),
>>
>> And the urls.py for kdi:
>> url(r"^$", "kdi.views.newstest", name="newstest"),
>>
>> And the `newstest` view:
>> def newstest(request, slug):
>>     print "called!"
>>     return HttpResponse('Test')
>>
>>
>> Expected behavior should be that navigation to domain/news will send the 
>> request to `kdi.urls`, where it will accept any string (^$) and call the 
>> `newstest` view to return the super simple response of "test". 404's every 
>> time.
>>
>>
>>
>>
>> On Friday, July 7, 2017 at 11:11:38 AM UTC-7, [email protected] 
>> wrote:
>>>
>>> Have solved the fully qualified path issue, but now throwing `'unicode' 
>>> object has no attribute 'regex'` error. This one is more difficult to 
>>> traceback.
>>>
>>> On Thursday, July 6, 2017 at 8:12:00 PM UTC-7, [email protected] 
>>> wrote:
>>>>
>>>> Hi, thanks for such a great resource! I have googled around for a few 
>>>> days and have made some headway this problem, but have hit a wall. I'm 
>>>> trying to use the Displayable model to create an easy way to add news 
>>>> stories and have them displayed as a simple list view, which is very 
>>>> similar behavior to the blog app. If there is a better solution using a 
>>>> ForeignKey, please point me in the right direction!
>>>>
>>>> I read an older post 
>>>> <https://groups.google.com/forum/#!msg/mezzanine-users/HmNGXkf4m4k/FDJ1Rd-h1KsJ>
>>>>  about 
>>>> creating a new Displayable, and have used Mezzanine's source code to 
>>>> successfully extend the Displayable model and have it appear correctly in 
>>>> the admin. The issue now is that I can't seem to get the views (views.py) 
>>>> and url patterns to work. When clicked "view on site" from the admin, the 
>>>> url seems to grab the model's slug ("news"), but ends up linking to 
>>>> http://localhost:8000/en/admin/<myapp>/news/%28u/, and doesn't work 
>>>> linking directly to the actual item's slug. Exploring the source code for 
>>>> Mezzanine's blog's urls and views, I'm unsure how to correctly refactor. I 
>>>> understand that I will need to create my own templates to act as 
>>>> blog_post_list.html 
>>>> and blog_post_detail.html, but don't know how to create the super 
>>>> basic views to point to them.
>>>>
>>>> models.py:
>>>> class News(Displayable, RichText):
>>>>
>>>>     pagetitle = models.CharField('Title', max_length=255, blank=True)
>>>>     url = models.CharField('Link', max_length=255, blank=True)
>>>>     summary = models.CharField('Summary', max_length=255, blank=True)
>>>>     date = models.DateField(_("Date"), default=datetime.date.today)
>>>>     categories = models.ManyToManyField("NewsCategory",
>>>>                                         verbose_name=_("Categories 
>>>> (Magazine, Award, etc.)"),
>>>>                                         blank=True, 
>>>> related_name="newsitems")
>>>>     related_news = models.ManyToManyField("self",
>>>>                                  verbose_name=_("Related News"), 
>>>> blank=True)
>>>>
>>>>     class Meta:
>>>>         verbose_name = _("News Item")
>>>>         verbose_name_plural = _("News Items")
>>>>
>>>>     def get_absolute_url(self):
>>>>         url_name = 'news'
>>>>         kwargs = {
>>>>             'slug': self.slug,
>>>>         }
>>>>         return (url_name, (), kwargs)
>>>>
>>>>
>>>> class NewsCategory(Slugged):
>>>>     """
>>>>     A category for grouping news items into a series.
>>>>     """
>>>>
>>>>     class Meta:
>>>>         verbose_name = _("News Category")
>>>>         verbose_name_plural = _("News Categories")
>>>>         ordering = ("title",)
>>>>
>>>>     @models.permalink
>>>>     def get_absolute_url(self):
>>>>         return ("news_item_list_category", (), {"category": self.slug})
>>>>
>>>> admin.py
>>>> news_fieldsets = deepcopy(DisplayableAdmin.fieldsets)
>>>> news_fieldsets[0][1]["fields"].insert(1, "categories")
>>>> news_fieldsets[0][1]["fields"].extend(["pagetitle", "url", "summary", 
>>>> "date"])
>>>> news_fieldsets = list(news_fieldsets)
>>>> news_fieldsets.insert(1, (_("Other News"), {
>>>>     "classes": ("collapse-closed",),
>>>>     "fields": ("related_news",)}))
>>>> news_list_filter = deepcopy(DisplayableAdmin.list_filter) + 
>>>> ("categories",)
>>>>
>>>>
>>>> class NewsAdmin(DisplayableAdmin):
>>>>     """
>>>>     Admin class for news posts.
>>>>     """
>>>>
>>>>     fieldsets = news_fieldsets
>>>>     # list_display = news_list_display
>>>>     list_filter = news_list_filter
>>>>     filter_horizontal = ("categories", "related_news",)
>>>>
>>>>     def save_form(self, request, form, change):
>>>>         """
>>>>         Super class ordering is important here - user must get saved 
>>>> first.
>>>>         """
>>>>         DisplayableAdmin.save_form(self, request, form, change)
>>>>         return DisplayableAdmin.save_form(self, request, form, change)
>>>>
>>>> class NewsCategoryAdmin(BaseTranslationModelAdmin):
>>>>     """
>>>>     Admin class for blog categories. Hides itself from the admin menu
>>>>     unless explicitly specified.
>>>>     """
>>>>
>>>>     fieldsets = ((None, {"fields": ("title",)}),)
>>>>
>>>>     def has_module_permission(self, request):
>>>>         """
>>>>         Hide from the admin menu unless explicitly set in 
>>>> ``ADMIN_MENU_ORDER``.
>>>>         """
>>>>         for (name, items) in settings.ADMIN_MENU_ORDER:
>>>>             if "blog.BlogCategory" in items:
>>>>                 return True
>>>>         return False
>>>>
>>>>
>>>> admin.site.register(News, NewsAdmin)
>>>> admin.site.register(NewsCategory, NewsCategoryAdmin)
>>>>
>>>> urls.py:
>>>> from .models import News
>>>> import .views
>>>>
>>>> _slashes = (
>>>>     "/" if settings.BLOG_SLUG else "",
>>>>     "/" if settings.APPEND_SLASH else "",
>>>> )
>>>>
>>>> urlpatterns = patterns(
>>>>     'news.views',
>>>>     url("^%s(?P<slug>.*)%s$" % _slashes, "news", name="news"),
>>>> )
>>>>
>>>> views.py:
>>>> from django.shortcuts import render
>>>>
>>>> def news(request, slug):
>>>>     return HttpResponse('Test')
>>>>
>>>> The view is currently not even returning "Test." Any direction at all 
>>>> would be appreciated!
>>>>
>>>>
>>>> -- 
>> 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/d/optout.
>>
>>
>>

-- 
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/d/optout.

Reply via email to