# Changing a form on Horizon [closed]

*I want to change the Create Volume form in Horizon, i.e. i want to add a new field to the already existing ones.

*I have typed in a separate python script for it because i dont want to change the existing Horizon code.

*Added a 'customization-module' field in local_settings.py as follows:

'customization_module': 'openstack_dashboard.dashboards.project.volume.myfilename.overrides'

and added the path of my file to WSGIDaemonProcess in Apache's Horizon Config file just like it is stated in http://docs.openstack.org/developer/horizon/topics/customizing.html (http://docs.openstack.org/developer/h...) .

*Is this all that i need to do? coz i cant see the changes, seems like iv missed out on something or am i doing it the wrong way? Would really appreciate it if someone can guide me through.

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by iceman close date 2014-05-28 07:08:49.000547

Sort by » oldest newest most voted

thanks a ton @jpichon. i managed to override the "create volume" form as well. you're right, the call to a form does go through "views.py". what i did was i created a separate file for my form and just made the following changes in "override.py":

from openstack_dashboard.dashboards.project.volumes.mycreateform import CreateForm as ProjectCreateForm

from openstack_dashboard.dashboards.project.volumes.views import CreateView as xyz

xyz.form_class=ProjectCreateForm

These 3 lines did it. "CreateForm" is my class in the file "mycreateform.py" file. I dont know if this the correct way to do it, but for now it works pretty good.

more

( 2014-05-28 09:52:44 -0500 )edit

You might want to update the question to include pieces of code and paths. Where did you put your 'overrides' file? (Note that in this case it means the file name is "overrides.py". If you called it "myfilename.py" or something else this is what you should include instead).

Looking at the Customisation documentation at http://docs.openstack.org/developer/h... , I would pay particular attention to the way it advises getting to the existing panels (e.g. settings.get_panel("user")) in order to make sure you're overriding the existing panels rather than redefining elements without actually hooking the new code into the existing dashboards/panels.

more

The overrides.py file was exactly what i was confused about. I was under the impression that its a file that is required and that i havn't created it. If not required, il change the dotted path in 'customization-module' as you mentioned, till just my filename. And if required, what should be in it?

( 2014-05-22 01:59:21 -0500 )edit

And about overriding the existing panels, I really dont require all of it. I mainly need to change the 'create volume' form that appears. Isnt there a way to just do that? Like, creating my own python script for the form, overriding the existing one, without having to change any other components.

( 2014-05-22 02:06:20 -0500 )edit
1

The overrides.py file does not need to be called that or be placed in "my_project". Just make sure the path to the script in "customization_module" is set properly. I think the top level in that path should be one of the dashboards that is imported in the INSTALLED_APPS or the plug-in system.

( 2014-05-27 08:22:31 -0500 )edit

You can of course only overrides as much or as little as you need, all the panel customisation pieces in the documentation are only there to serve as helpful examples. Good luck!

( 2014-05-27 08:24:29 -0500 )edit

@jpichon thanks a lot julie. i figured out the problem. i hadnt created an "overrides.py" file at all. i created one and changed the paths in "customization_module" to it. so overriding now works fine for a few examples. but my objective of overriding the create-form remains. trying to figure that.

( 2014-05-28 00:57:11 -0500 )edit

# Get to know Ask OpenStack

Resources for moderators