drf-forms/drf-schema-adapter

:bug: An Adapter with required_fields=True and works_with='viewset' crashes export command

Closed this issue · 1 comments

Traceback (most recent call last):
  File "./manage.py", line 9, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/joakim/Envs/drf-schema/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/Users/joakim/Envs/drf-schema/lib/python2.7/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/joakim/Envs/drf-schema/lib/python2.7/site-packages/django/core/management/base.py", line 294, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/joakim/Envs/drf-schema/lib/python2.7/site-packages/django/core/management/base.py", line 345, in execute
    output = self.handle(*args, **options)
  File "/Users/joakim/ProReNataJournal/drf-schema-adapter/export_app/management/commands/export.py", line 64, in handle
    fields, rels = self.get_fields_for_model(model, serializer_instance, adapter,
UnboundLocalError: local variable 'model' referenced before assignment

I'm not sure exactly what the fix would be so I'm making this an issue instead of a PR.

Sorry for the late reply.
Field information is provided from a serializer so an adapter that requires field information has to either work with serializer or both in order to have access to that information.
I will add an assert to make that clear