fizban wrote:
>
> On 14 Apr, 16:54, "Norman Harman" <[EMAIL PROTECTED]> wrote:
>   
>> Why don't you use the extra_context parameter to generic views?  Or am I
>> misunderstanding what you are trying to do?
>>
>> def myview(request):
>>    context = dict()
>>    context["my_custom_var"] = "wwgd"
>>    return generic_view(request, extra_context = context, bla=blah,...)
>>     
>
> I have just tried setting it up but it is returning a 404 when I try
> to load the page (and it obviously works with date_based.object_detail
> and/or my custom "entry_detail")
>
> This is the view I tried to setup:
>
> def myview(request, year, month, day, queryset, date_field,
> month_format, slug, template_object_name):
>       context = dict()
>       context['year'] = year
>       context['month'] = month
>       context['day'] = day
>
>       return date_based.object_detail(
>               request, year, month, day, queryset, date_field, month_format, 
> slug,
> template_object_name, extra_context=context,
>       )
>
> As far as I understood your suggestion and the docs I found it should
> work, shouldn't it?
>
> The urlconf, beside the from ... import statements is the following:
>
>
> entry_info_dict = {
>       'queryset': Entry.live.all(),
>       'date_field': 'pub_date',
> }
>
> urlpatterns = patterns('django.views.generic.date_based',
>       (r'(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[\w\d\-]
> +)/$', myview, dict(entry_info_dict, month_format='%m',
> template_object_name='entry')),
> )
>
> (I'm using django.views.generic.date_based there since it's needed by
> the other patterns, I didn't include them since they are relevant --
> however it won't work even if I snip it out)
>
>   

myview should be in the views.py of your app.  The urlpatterns above is 
pointing to some django views file.  You shouldn't edit the django 
source if you can avoid it.

urlpatterns = patterns('',
        (r'(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[\w\d\-]
+)/$', "myapp.views.myview", dict(entry_info_dict, month_format='%m', 
template_object_name='entry')),
)


Not sure if that caused your 404.  They are usually caused by missing 
data (if you used incorrect slug in url), or if regex in urlpatterns is 
wrong.  Turning debug=True in your settings.py should give you more 
information on why there is 404's.

-- 
Norman J. Harman Jr.  512 912-5939
Technology Solutions Group, Austin American-Statesman

___________________________________________________________________________
Get out and about this spring with the Statesman! In print and online,
the Statesman has the area's Best Bets and recreation events.
Pick up your copy today or go to statesman.com 24/7.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to