Ask Your Question
1

Changing a form on Horizon [closed]

asked 2014-05-21 04:52:07 -0600

iceman gravatar image

updated 2014-05-22 01:58:57 -0600

*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 flag offensive 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

2 answers

Sort by ยป oldest newest most voted
0

answered 2014-05-28 07:07:43 -0600

iceman gravatar image

updated 2014-05-28 07:11:12 -0600

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.

edit flag offensive delete link more

Comments

Sweet, glad it worked!

jpichon gravatar imagejpichon ( 2014-05-28 09:52:44 -0600 )edit
0

answered 2014-05-21 07:20:44 -0600

jpichon gravatar image

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.

In any case, code examples would help to help you better!

edit flag offensive delete link more

Comments

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?

iceman gravatar imageiceman ( 2014-05-22 01:59:21 -0600 )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.

iceman gravatar imageiceman ( 2014-05-22 02:06:20 -0600 )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.

jpichon gravatar imagejpichon ( 2014-05-27 08:22:31 -0600 )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!

jpichon gravatar imagejpichon ( 2014-05-27 08:24:29 -0600 )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.

iceman gravatar imageiceman ( 2014-05-28 00:57:11 -0600 )edit

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2014-05-21 04:52:07 -0600

Seen: 173 times

Last updated: May 28 '14