Dear Ivan, it sounds like we are closer to the solution, still not got
it though.

Ivan Sagalaev wrote:
[...]
> > http://dpaste.com/72639/
> 
> Oy! I've found it :-). It has nothing to do with model_view decorator or 
> anything that we're talking here about. It's in urls.py, on line 30:
> 
>      (r'^$', 'current_datetime')
> 
> You pass a string instead of a function. Django tries to import this 
> name, fails and tries to call it as a function. Then you get this error 
> because strings are not callable.

Right! I promptly removed the " and now no more problems at
http://localhost:8000/.

> > and finally the traceback I get at http://localhost:8000/manufacturer/:
> > 
> > http://dpaste.com/72637/
> 
> Ok... I've finally managed to actually check what I has "invented" and 
> it seems I was on crack... Sorry for the confusion. I've messed up 
> building model_classes dict in two places but it doesn't matter because 
> it can be done simpler.
> 
>      from django.db.models import get_model
> 
>      def model_view(func):
>          def wrapper(request, *args, **kwargs):
>              model = get_model('arteak', kwargs.pop('model'))
>              kwargs['queryset'] = model.objects.all()
>              return func(request, *args, **kwargs)
>          return wrapper
> 
> It happens that Django already has a registry of all models and 
> get_model can, well, get a model from it by an app_name ('arteak') and a 
> model_name which is passed in kwargs right out of urlconf.
> 
> And model_classes code can be just thrown away.

I had actually had a few tries with get_model on my own a few days
ago. The point is that I get this error:

AttributeError at /manufacturer
'NoneType' object has no attribute 'objects'

along with this full traceback: http://dpaste.com/72673/.

This is how my urls.py looks like at last: http://dpaste.com/72674/.

For the sake of clarity, my django project is named arteak, the models
we are using belong to an app called "management".

Fabio.

-- 
Fabio Natali


--~--~---------~--~----~------------~-------~--~----~
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