nautobot / nautobot-app-welcome-wizard

Magic and wonder UI wizard that simplifies getting started with Nautobot.
https://docs.nautobot.com/projects/welcome-wizard/en/latest/
Other
13 stars 7 forks source link

Unable to add an object to a model in Django Admin view #43

Closed jvanderaa closed 3 years ago

jvanderaa commented 3 years ago

Environment

Expected Behavior

Able to create a custom field

Observed Behavior

Received the error when trying to create a new custom field:

18:45:00.307 ERROR   django.request :
  Internal Server Error: /admin/extras/customfield/add/
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 171, in _get_response
    response = middleware_method(request, callback, callback_args, callback_kwargs)
  File "/opt/nautobot/.local/lib/python3.9/site-packages/welcome_wizard/middleware.py", line 34, in process_view
    base_fields = view_func.view_class.model_form.base_fields
AttributeError: 'function' object has no attribute 'view_class'
[pid: 45|app: 0|req: 193/923] 172.26.0.7 () {60 vars in 1393 bytes} [Mon Aug 30 18:45:00 2021] GET /admin/extras/customfield/add/ => generated 1846 bytes in 7 msecs (HTTP/1.0 500) 6 headers in 214 bytes (1 switches on core 0)

Steps to Reproduce

  1. Install Welcome Wizard Plugin
  2. Go to admin panel
  3. Select Custom Fields
  4. Select create custom field
  5. Receive the error
smk4664 commented 3 years ago

The middleware currently looks for /add/ in the request path, to find the associated model_fields. This code is expecting the request path to be for a Nautobot form, not a Django Admin form. I will have a fix coming soon.