Thanks Karen but I'm just getting a 'NoneType' object has no attribute
'objects' with this code:

def search(request):
    query = request.GET.get('q', '')
    model = request.GET.get('models', '')
    model_class = get_model(blog, model)
    results = []
    if query:
        results = model_class.objects.filter(content__icontains=query)
    return render_to_response('search/search.html',
                                { 'query': query, 'results':
results })

On Nov 18, 6:29 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Wed, Nov 18, 2009 at 9:09 PM, neridaj <neri...@gmail.com> wrote:
> > Hello,
>
> > I have a select menu which I would like to use as a model selector in
> > a view but I keep getting 'unicode' object has no attribute 'objects'
> > because I need to cast this to type Model or something similar. How do
> > I go about doing that.
>
> Undocumented internal routine, but unlikely to change:
>
> from django.db.models import get_model
> model_class = get_model(app_name, model_name)
>
> Karen

--

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


Reply via email to