You're after get_model in django.db.models:

    model_class = get_model(*model_string.split('.'))

See James Bennet's post in this topic:

http://www.b-list.org/weblog/2007/nov/03/working-models/

Regards
Scott


On May 27, 12:13 am, Jeffrey Taggarty <jtagga...@gmail.com> wrote:
> Hey Guys,
>
> I am trying to build this app so we ca re-use it throughout all of the
> projects we build.
>
> The re-usable app has it's own model and a FK to a specific model that
> it is related to, this is required. Right now I have a setting in my
> project settings.py that uses the re-usable that has this:
> APP_RELATED_MODEL = 'officesupplies.Supply' where officesupplies is
> the appname and Supply is the model it is related to, then in my re-
> usable app I just have ForeignKey(settings.APP_RELATED_MODEL) which
> works fine.
>
> The real problem lies in my import statements in the reusable app, I
> have right now this:
>
> from officesupplies.models import Supply # this is hardcoded, need to
> dynamically load the app/model from the settings.APP_RELATED_MODEL
>
> How can I load up the APP_RELATED_MODEL settings into my import so I
> can do my DB queries etc?
>
> Jeff

-- 
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=en.

Reply via email to