1

I am following the tutorial on plugin development at https://netbox.readthedocs.io/en/stable/plugins/development/

I have gone as far as creating the models and want to make migrations...

However, the manage.py is not found in the root of my plugin folder.

Where is it expected that manage.py is?

tread
  • 10,133
  • 17
  • 95
  • 170
  • The pluggings are supposed to be [reusable Django apps](https://docs.djangoproject.com/en/3.2/intro/reusable-apps/), which doesn't have `manage.py`. – JPG Nov 25 '21 at 13:08

2 Answers2

1

The manage.pyis part of the Django application (= website). It is located in the Django root folder, see e.g. Django tutorial.

So, a plugin never has got its own manage.py, but it may have got a set of migration files that are used by the Django app when python manage.py migrate is invoked and the plugin has been installed and defined as being a part of the Django app (within settings.py).

Nechoj
  • 1,512
  • 1
  • 8
  • 18
  • I agree. But the question is what `manage.py` file am I supposed to use to create the migrations in the plugin? Am I to use the `django-admin` binary with `django-admin makemigrations my_plugin_plugin`? Trying that I set `django.core.exceptions.ImproperlyConfigured: Requested setting STATIC_URL, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.` – tread Nov 25 '21 at 13:43
  • 1
    I would suggest to create a Django app using the `django-admin startproject mysite` command. This will be an empty app initially. Then install your plugin, include it in the `settings.py` of the created app and then run `makemigrations`. This will create the migration files that you can then use as part of your plugin package. – Nechoj Nov 25 '21 at 13:59
0

Assuming you've followed the installation instructions and installed Netbox in /opt/netbox, the manage.py file you need to use is located in /opt/netbox/netbox/ folder.

Don't forget to activate the virtual environment in /opt/netbox/venv and to set DEVELOP to True in /opt/netbox/netbox/netbox/configuration.py

tread
  • 10,133
  • 17
  • 95
  • 170
Barnebyte
  • 161
  • 5