On Fri, 2008-07-04 at 09:28 -0700, mwebs wrote:
> Hello,
> 
> I am trying to generate models at runtime. For this purpose I am using
> the method create_model() provided at
> http://code.djangoproject.com/wiki/DynamicModels
> 
> create_model(name, fields, module='app.models' )
> 
> When I am doing like this i get a keyError '__module__'
> 
> then I tried to pass the whole path:
> 
> create_model(name, fields, module='project.src.app.models' )
> 
> Still got an keyError, but this time it looked like this: keyError
> 'project.src.app.models'
> 
> Any ideas what I am doing wrong.

Quite seriously, if you're not able to debug this sort of error
yourself, given the source code for create_model() and the internals of
Django it calls, then you probably shouldn't be creating dynamic models.
Creating models at runtime is a very advanced piece of functionality and
certainly not recommended (models in Django are backed by database
tables almost always, so runtime creation hardly ever makes sense).

We can't really help anyway, since you don't tell us where you get the
KeyError. However, you can work through it fairly easily. Looking at the
traceback you see, you should be able to work out which line in
create_model() is the jumping off point for the problem, then work out
what might have changed in the Django core code it's calling. It will
take some time, but you will learn stuff about Django's internals whilst
doing it.

Regards,
Malcolm



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