Fixed edit always being invalid due to always failing form validation

This commit is contained in:
Matthew Smith
2019-10-05 15:07:41 +01:00
parent 3aa3498d3a
commit 1d253aa452
2 changed files with 1 additions and 4 deletions

View File

@@ -46,7 +46,7 @@
{% if duplicate %}
{% render_field form.asset_id|add_class:'form-control' value=object.asset_id %}
{% elif object.asset_id %}
{% render_field form.asset_id|attr:'readonly disabled'|add_class:'disabled_input form-control' value=object.asset_id %}
{% render_field form.asset_id|attr:'readonly'|add_class:'disabled_input form-control' value=object.asset_id %}
{% else %}
{% render_field form.asset_id|add_class:'form-control' %}
{% endif %}

View File

@@ -60,8 +60,6 @@ class AssetEdit(LoginRequiredMixin, generic.UpdateView):
def get_context_data(self, **kwargs):
context = super(AssetEdit, self).get_context_data(**kwargs)
if self.kwargs:
context['object'] = get_object_or_404(models.Asset, pk=self.kwargs['pk'])
context['form'] = forms.AssetForm
# context['asset_names'] = models.Asset.objects.values_list('asset_id', 'description').order_by('-date_acquired')[]
@@ -70,7 +68,6 @@ class AssetEdit(LoginRequiredMixin, generic.UpdateView):
return context
def form_invalid(self, form):
print(form.errors)
return super().form_invalid(form)
def get_success_url(self):