This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The issue is: when the form_action in my _create.html is specified this way: {% block form_action %}{% url 'workloads_panel:create' %}{% endblock %} - I get NoReverseMatch: u'workloads_panel' is not a registered namespace; "GET /mydashboard/workloads_panel/create/ HTTP/1.1" 500 35672 | |
Here is my directory structure under openstack_dashboard/dashboards/mydashboard: | |
. | |
├── blueprints_panel | |
│ ├── __init__.py | |
│ ├── __init__.pyc | |
│ ├── models.py | |
│ ├── models.pyc | |
│ ├── panel.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tables.py: | |
class UpdateWorkload(tables.LinkAction): | |
name = "update" | |
verbose_name = _("Edit Workload") | |
url = "horizon:mydashboard:workload_panel:update" | |
classes = ("ajax-modal",) | |
icon = "pencil" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UpdateView(forms.ModalFormView): | |
form_class = project_forms.UpdateWorkload | |
template_name = 'update_workload.html' | |
context_object_name = 'workload' | |
success_url = reverse_lazy('index') | |
def get_context_data(self, **kwargs): | |
context = super(UpdateView, self).get_context_data(**kwargs) | |
context["id"] = self.kwargs['id'] | |
return context |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UpdateWorkload(tables.LinkAction): | |
name = "update" | |
verbose_name = _("Edit Workload") | |
url = "horizon:mydashboard:workloads_panel:update" | |
classes = ("ajax-modal",) | |
icon = "pencil" | |
class WorkloadsTable(tables.DataTable): | |
name = tables.Column("name", verbose_name=_("Name")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
views.py: | |
class UpdateView(forms.ModalFormView): | |
form_class = project_forms.UpdateWorkload | |
template_name = 'update_workload.html' | |
context_object_name = 'workload' | |
success_url = reverse_lazy('index') | |
def get_context_data(self, **kwargs): | |
context = super(UpdateView, self).get_context_data(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ERRORS: | |
Internal Server Error: /mydashboard/workloads_panel/3/update | |
Traceback (most recent call last): | |
File "/home/eugene/dev/horizon/.venv/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 137, in get_response | |
response = response.render() | |
File "/home/eugene/dev/horizon/.venv/local/lib/python2.7/site-packages/django/template/response.py", line 105, in render | |
self.content = self.rendered_content | |
File "/home/eugene/dev/horizon/.venv/local/lib/python2.7/site-packages/django/template/response.py", line 82, in rendered_content | |
content = template.render(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% extends "horizon/common/_modal_form.html" %} | |
{% load i18n %} | |
{% load url from future %} | |
{% block form_id %}update_workload_form{% endblock %} | |
{% block form_action %}{% url 'horizon:mydashboard:workloads_panel:update' %}{% endblock %} | |
{% block modal_id %}update_workload_modal{% endblock %} | |
{% block modal-header %}{% trans "Update Workload" %}{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I need to assign the value to the 'initial' attributes for the images and flavors fields. | |
Here is how I do it currently. | |
No errors, the print shows that assignment took, but in the actual html form, I still have my default choice list, with no item selected, as desired | |
forms.py: | |
class UpdateWorkload(forms.SelfHandlingForm): | |
name = forms.CharField(max_length="255", label=_("Workload Name")) | |
description = forms.CharField(widget=forms.Textarea, | |
label=_("Description"), required=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resources: | |
class BlueprintResource(ModelResource): | |
# workloads = ManyToManyField(Workload, 'workloads') | |
workloads = fields.ManyToManyField('catalog.api.WorkloadResource', attribute='workloads', | |
full=True, null=True) | |
def obj_create(self, bundle, request=None, **kwargs): | |
return super(BlueprintResource, self).obj_create(bundle, request) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
models: | |
class Blueprint(models.Model): | |
id = models.AutoField(primary_key=True) | |
name = models.CharField(max_length=120) | |
description = models.TextField() | |
# workloads = models.ManyToManyField('Workload', db_constraint=False) | |
# workloads = models.ManyToManyField('self', null=True) | |
class Meta: |
OlderNewer