views:

44

answers:

1

Think of this:

You create a CMS of some sort, which asks you for an application name and a csv file for that application. Then it automatically creates that app on the fly, creates the required model.py based on the csv columns, activates the admin page for it and allows only you to have the full permission to this new table via django admin, then it inserts the the app into the url.py and creates the view.py for it as well.

Then all you'd have to do is upload a csv, name your app and whola!, you have an admin page to play with.

Now, is there anyway to create an app or at least a model.py out of a csv file in django or is there any django-app that can do this?

Note: Look beyond (./manage.py inspectdb > models.py)

A: 

While this does not involve creating an actual models.py and application, you may want to look into dynamically creating Model classes at runtime. You could have "meta" models that store the information on the dynamic models, and then have your CSV view import the data into those models, create the classes, and register them with the admin. Or something like that.

Creating an actual application directory, with models.py, views.py, and so on, is fairly easy (just create the directory, create the files, and write formatted strings to them based on the CSV data). Editing the project's settings.py and urls.py, and reloading the modules, wouldn't be too difficult either. But, I wouldn't trust automatically generated Django applications without first looking at them.

Joseph Spiros