WebFaction
Community site: login faq

I want to know if its posible to create new forms and models in an already django application, for example that the admin could create another model and forms and views without the need of coding and modifying the sourcecode.

I was thinking in saving the new models and fields in tables but still is unclear to me.

Thanks for your help

This question is marked "community wiki".

asked 30 Jun '11, 19:29

Rene Paredes
32
accept rate: 0%


A model and a form is source code. There is no way to make the Django admin write more source code or create new models and forms unless you wrote python code that told it to do that.

Basically models and forms are made with source code and have to be built by a person in the first place, in theory you could write an app that did this for you, but that app would have to be written to do such, it is not something Django has built in.

You can of course add and remove apps and code to your Django app, but you must synchronize the database to match the new code. You would have to use an app like south to assist with this.

All in all there is likely a better solution to what your end result is, what are you trying to do exactly?

Have you looked into using Foreign Keys?

Something like this in the model,

model = models.ForeignKey('OtherModel')
permanent link

answered 30 Jun '11, 19:57

johns
5.4k312
accept rate: 23%

edited 30 Jun '11, 19:58

You may want to look at Model Inheritance: https://docs.djangoproject.com/en/dev/topics/db/models/#model-inheritance

If you really want to add to an existing application and associated tables, I would create a new app that inherits from the existing one.

permanent link

answered 01 Jul '11, 05:45

Rupe
411814
accept rate: 0%

Thanks for your help, I wasn't sure if it could be done, and thanks about Model Inheritance.

permanent link

answered 01 Jul '11, 18:39

Rene Paredes
32
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×7
×3

question asked: 30 Jun '11, 19:29

question was seen: 2,294 times

last updated: 01 Jul '11, 18:39

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM