Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » generic views + new admin templates [RSS Feed]

#1 Nov. 27, 2005 12:24:58

s.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

generic views + new admin templates


I'm trying to use generic views together with the newly separated admin
templates, but it's failing miserably.

I specify the generic view I want to use in url.py:
countries = {
'app_label': 'ttime',
'module_name': 'countries',
}
urlpatterns = patterns('',
(r'^countries/$',
'django.views.generic.list_detail.object_list', countries),
(r'^countries/add/$',
'django.views.generic.create_update.create_object', countries),
)

I've copied django/contrib/admin/templates/admin/change_list.html to my
own template directory (no changes yet).

All I get for my efforts is:
AttributeError at /countries/
'str' object has no attribute 'result_count'
Request Method: GET
Request URL:http://localhost:8000/countries/Exception Type: AttributeError
Exception Value: 'str' object has no attribute 'result_count'
Exception Location:

/usr/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_list.py
in search_form, line 264

And the (nice and pretty but still) error message points to the line
containing the {% search_form cl %} tag.

I must be missing something fundamental here.

Anyone?

/LarS

Offline

#2 Nov. 27, 2005 13:55:47

Robert W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

generic views + new admin templates


stava wrote:
> I'm trying to use generic views together with the newly separated admin
> templates, but it's failing miserably.
>
> I specify the generic view I want to use in url.py:
> countries = {
> 'app_label': 'ttime',
> 'module_name': 'countries',
> }
> urlpatterns = patterns('',
> (r'^countries/$',
> 'django.views.generic.list_detail.object_list', countries),
> (r'^countries/add/$',
> 'django.views.generic.create_update.create_object', countries),
> )
>
> I've copied django/contrib/admin/templates/admin/change_list.html to my
> own template directory (no changes yet).
>
> All I get for my efforts is:
> AttributeError at /countries/
> 'str' object has no attribute 'result_count'
> Request Method: GET
> Request URL:http://localhost:8000/countries/> Exception Type: AttributeError
> Exception Value: 'str' object has no attribute 'result_count'
> Exception Location:
>
> /usr/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_list.py
> in search_form, line 264
>
> And the (nice and pretty but still) error message points to the line
> containing the {% search_form cl %} tag.
>
> I must be missing something fundamental here.
>
> Anyone?
>
> /LarS
>
>

Erm, the generic views do not provide a reasonable context for the
changelist.

If you want to make something like the changelist in the admin, you
should probably start off with a copy of the view function from the admin.

Offline

#3 Nov. 27, 2005 17:55:21

s.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

generic views + new admin templates


I just don't get it (newbie:). Isn't there a way of using generic views
together with the recently separated admin templates? In order to
learn/understand: I'm taking a small part of my model, the Country()
class with two fields (country_code and country_name); I copy the
appropriate templates (change_list and change_form) to my project
environment, and try to access/edit the database items. Are you saying
this is not possible? I've done this by sort of "reverse engineering"
(with the help of Adrian) in previous versions (prior to new-admin
being merged into trunk) to get the templates being created on-the-fly.
I would have thought that the separation of the admin templates into
files instead of being created on the fly was aimed at this type of
thing.

/LarS

Offline

Board footer

Moderator control

Enjoy the 23rd of April
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support