On 07/04/2012 10:27 PM, Mariano DAngelo wrote:
> Hi I'm trying to create a class from a string
> This is my code, but is not working
It would be helpful if you posted an error message. Then, we could know
what's actually going on.
> 'myshop.models.base'
> module_name, class_name = model
On Wed, 04 Jul 2012 13:27:29 -0700, Mariano DAngelo wrote:
> Hi I'm trying to create a class from a string This is my code, but
> is not working
>
> 'myshop.models.base'
> module_name, class_name = model.rsplit(".", 1)
> module = importlib.import_module(module_name)
> class_ = getattr(m
Hi I'm trying to create a class from a string
This is my code, but is not working
'myshop.models.base'
module_name, class_name = model.rsplit(".", 1)
module = importlib.import_module(module_name)
class_ = getattr(module, class_name)()
Anyone know what I'm doing wrong or another way?