Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jvanderaa opened this issue Aug 30, 2021 · 1 comment · Fixed by #44
Closed

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

jvanderaa opened this issue Aug 30, 2021 · 1 comment · Fixed by #44

Comments

@jvanderaa
Copy link
Contributor

Environment

  • Python version: 3.9
  • Nautobot version: 1.1.2
  • nautobot-welcome-wizard version: 1.1.2

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 smk4664 changed the title Unable to Create Custom Field Due to AttributeError: 'function' object has no attribute 'view_class' Unable to add an object to a model in Django Admin view Aug 30, 2021
@smk4664
Copy link
Contributor

smk4664 commented Aug 30, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants