i found out maybe because my url did not declare correctly, i mean the 
format for example the following works:

urlpatterns = patterns("",
    url("^techspec/(?P<slug>.*)", views.tsmodeldetail, name="tsmodeldetail"
),
)


as long as "techspec/(?P<slug>.*)"  without "/", it will work. 

But then, why this happen, can't understand what cause this problem.


On Wednesday, January 28, 2015 at 12:00:47 AM UTC+8, Josh Cartmell wrote:
>
> I would add some print statements or breakpoints around this line:
>
> tsmodel = get_object_or_404(tsmodels, slug=slug)
>
> I would print the slug before that line and verify that slug actually 
> exists in the database.  My guess is that line is producing the 404 because 
> it isn't finding an object.
>
> On Tue, Jan 27, 2015 at 12:09 AM, S.C. <[email protected] <javascript:>> 
> wrote:
>
>> it show page not found (404)...
>>
>> On Tuesday, January 27, 2015 at 12:16:18 AM UTC+8, Josh Cartmell wrote:
>>>
>>> What happened when you tried what you posted above?
>>>
>>> I don't think this has anything to do with using Displayable (I don't 
>>> think Displayable does anything to templates) and more likely has to do 
>>> with the view.
>>>
>>> On Mon, Jan 26, 2015 at 5:16 AM, S.C. <[email protected]> wrote:
>>>
>>>> I was unable to link up template for the Displayable's Model, i follow 
>>>> the example in the source code but failed to link to the template. 
>>>>
>>>> The app name "*TechSpec*", and the template name for the models "
>>>> *tsmodel.html*" (path: templates/techspec/tsmodel.html)
>>>>
>>>> *Models:*
>>>> class TSModel(Displayable, RichText):
>>>>     order = models.IntegerField(_("Ordering"), default=0)
>>>>     title = models.charField(_("Title"), max_length=50)
>>>>
>>>>     class Meta:
>>>>         verbose_name = _("TS Model")
>>>>         verbose_name_plural = _("TS Models")
>>>>         ordering = ("order", )
>>>>
>>>>
>>>>     @models.permalink
>>>>     def get_absolute_url(self):
>>>>         return ("techspec_model", (), {"slug": self.slug})
>>>>
>>>> *Views:*
>>>> from models import TSModel
>>>>
>>>> def tsmodelview(request, slug, template="techspec/tsmodel.html"):
>>>>     tsmodels = TSModel.objects.all()
>>>>
>>>>     tsmodel = get_object_or_404(tsmodels, slug=slug)
>>>>     context = {"tsmodel": tsmodel}
>>>>     templates = [u"techspec/%s.html" % str(slug), template]
>>>>     return render(request, templates, context)
>>>>
>>>> *Urls:*
>>>> from views import tsmodelview
>>>>
>>>> urlpatterns = patterns("",
>>>>     url("^techspec/(?P<slug>.*)%s$" % _slash, tsmodelview, name=
>>>> "techspec_model"),
>>>> )
>>>>
>>>> Thank you in advance.
>>>>
>>>> -- 
>>>> 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] <javascript:>.
>> 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