Thanks a lot! get _model works. Only one thing, I've been reading the code in te file django/db/models/ loading.py and I don't understand how it works, and now I need to know or I won't sleep :-)
What should I do to reference stuff? app = __import__('app_name',{},{},['models']) mods = getattr(app,'models') module = getattr(mods,'ModuleIWant') This actually works, but I'm not sure if it's the right way or the "python way". Thanks. On 16 nov, 20:56, Doug B <[EMAIL PROTECTED]> wrote: > I'd love to know if there is a better method, but this is the best I > could come up with... pretty much the same thing you are doing, but > forcing the view functions to call 'import_feed' which can only load a > restricted set of modules. > > AVAILABLE_FEEDS = > {'columbia':'columbia.search','glvar':'glvar.search'} > > def import_feed(name): > if name in AVAILABLE_FEEDS: > return __import__(AVAILABLE_FEEDS[name]) > else: > return None > > That only gets me the app, so if I do > feed=import_feed('columbia') > I still have to reference stuff like feed.search.myfunction() instead > of feed.myfunction() > > Hmm.. now that I reread your post, I might have confused module with > model. If so you might want to take a look at: > from django.db.models.get_model > > m=get_model(appname,modelname) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---