how to add plugin

503 views
Skip to first unread message

renu gautam

unread,
Nov 9, 2020, 6:07:50 AM11/9/20
to NetBox
hello every one,

I have created one django app and I want to add this app inside the netbox . But I'm getting an error :
----------------------------------------------------------------------------------------------

A database programming error was detected while processing this request. Common causes include the following:

Database migrations missing - When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You can run migrations manually by executing python3 manage.py migrate from the command line.

 Unsupported PostgreSQL version - Ensure that PostgreSQL version 9.6 or higher is in use. You can check this by connecting to the database using NetBox's credentials and issuing a query for SELECT VERSION().

The complete exception is provided below:

<class 'django.db.utils.ProgrammingError'>
relation "reportview_reportviewmodel" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "reportview_reportviewmode... ^  

----------------------------------------------------------------------------------------------------------------------------------


I have followed https://netbox.readthedocs.io/en/stable/plugins/development/ this link for creations of plugins(django app)

Please find the attached django app (plugins) 


thanks in advance I'm waiting for response 

reportview.rar

Brian Candler

unread,
Nov 9, 2020, 6:20:42 AM11/9/20
to NetBox
On Monday, 9 November 2020 11:07:50 UTC, renu gautam wrote:

relation "reportview_reportviewmodel" does not exist LINE 1: SELECT COUNT(*) AS "__count" FROM "reportview_reportviewmode... ^  


"relation" means "table".  i.e. you haven't created the table in your database yet.

"Migrations" are bits of Python code which create or update database tables.  For simple cases like creating a new model, the code can be generated automatically for you.


"Once you have defined the model(s) for your plugin, you'll need to create the database schema migrations.
...
Next, we can apply the migration to the database with the migrate command"

renu gautam

unread,
Nov 9, 2020, 7:17:52 AM11/9/20
to NetBox

I also fallowed this link https://netbox.readthedocs.io/en/stable/plugins/development/#database-models
I have created model.py file for table. could you please check the attached rar file. 

Brian Candler

unread,
Nov 9, 2020, 7:28:43 AM11/9/20
to NetBox
You didn't attach a rar file (which in any case is a proprietary format - it suggests you are developing under Windows??)

What you need to show is:
- the content of your models.py
- the output when you run the command "manage.py makemigrations ...etc"
- the migration file which was created (e.g. migrations/0001_initial.py)
- the output when you run the command "manage.py migrate ...etc"

It might be helpful to start with the actual animal_sounds plugin and get that to work, before developing your own.

renu gautam

unread,
Nov 9, 2020, 7:43:38 AM11/9/20
to NetBox

model.py

from django.db import models

# Create your models here.
class ReportviewModel(models.Model):
    url = models.URLField(null=False,max_length=300)
    width = models.IntegerField(default=300)
    height = models.IntegerField(default=200)
    name = models.CharField(max_length = 50)
    def __str__(self):
       return self.name
    class Meta:
        ordering = ['name']
...................................................................................

no /0001_initial.py file created
output of makemigrations command

output of migrate command


models.py

renu gautam

unread,
Nov 9, 2020, 7:48:08 AM11/9/20
to NetBox
output of makemigrations command 
------------------------------------------------ 
CommandError: This command is available for development purposes only. It will
NOT resolve any issues with missing or unapplied migrations. For assistance,
please post to the NetBox mailing list:
---------------------------------------------
output of migrate command 
------------------------------------------------
Operations to perform:
  Apply all migrations: admin, auth, circuits, contenttypes, dcim, extras, ipam, lifecycles, netbox_licences, netbox_onboarding, netbox_vcenter, secrets, sessions, taggit, tenancy, users, virtualization
Running migrations:
  No migrations to apply. 
------------------------------------------------
no /0001_initial.py file created  

Brian Candler

unread,
Nov 9, 2020, 8:38:11 AM11/9/20
to NetBox
On Monday, 9 November 2020 12:48:08 UTC, renu gautam wrote:
output of makemigrations command 
------------------------------------------------ 
CommandError: This command is available for development purposes only.

$ grep -2hR "This command is available for development purposes only." .
        if not settings.DEVELOPER:
            raise CommandError(
                "This command is available for development purposes only. It will\n"
                "NOT resolve any issues with missing or unapplied migrations. For assistance,\n"
                "please post to the NetBox mailing list:\n"

In other words: you need to set DEVELOPER=True in your settings.py before you can make migrations.

(maybe it should be mentioned in the plugins development section too)

renu gautam

unread,
Nov 9, 2020, 8:39:17 AM11/9/20
to NetBox
I have to create the table manually??is it ?

renu gautam

unread,
Nov 9, 2020, 8:51:26 AM11/9/20
to NetBox
thank you so much I'm able to create the migrate file  0001_initial.py . But the problem not yet solved. 
inside the admin page I got same error.

 Server Error

A database programming error was detected while processing this request. Common causes include the following:

 Database migrations missing - When upgrading to a new NetBox release, the upgrade script must be run to apply any new database migrations. You can run migrations manually by executing python3 manage.py migrate from the command line.

 Unsupported PostgreSQL version - Ensure that PostgreSQL version 9.6 or higher is in use. You can check this by connecting to the database using NetBox's credentials and issuing a query for SELECT VERSION().

The complete exception is provided below:

<class 'django.db.utils.ProgrammingError'>
relation "reportview_reportviewmodel" does not exist LINE 1: SELECT (1) AS "a" FROM "reportview_reportviewmodel" WHERE "r...

renu gautam

unread,
Nov 9, 2020, 8:59:12 AM11/9/20
to NetBox
now it's solved .......thank youuuuuuuuuuuuuuuuuu sooooooooo much 

renu gautam

unread,
Nov 17, 2020, 5:28:05 AM11/17/20
to NetBox
hello ,

I have created new plugins and installed it using python setup.py develop command. I have followed https://netbox.readthedocs.io/en/stable/plugins/development/ for installations and creations. 
but now i found the error 

NoReverseMatch at /

'reportriew' is not a registered namespace inside 'plugins'

9 <li>
10 {% if menu_item.buttons %}
11 <div class="buttons pull-right">
12 {% for button in menu_item.buttons %}
13 {% if not button.permissions or request.user|has_perms:button.permissions %}
14 <a href="{% url button.link %}" class="btn btn-xs btn-{{ button.color }}" title="{{ button.title }}"><i class="{{ button.icon_class }}"></i></a>
15 {% endif %}
16 {% endfor %}
17 </div>
18 {% endif %}
19 <a href="{% url menu_item.link %}">{{ menu_item.link_text }}</a>
20 </li>
21 {% else %}
22 <li class="disabled"><a href="#">{{ menu_item.link_text }}</a></li>
23 {% endif %}
24 {% endfor %}
25 {% if not forloop.last %}
26 <li class="divider"></li>
27 {% endif %}
28 {% endfor %}
29 </ul>

--
You received this message because you are subscribed to the Google Groups "NetBox" group.
To unsubscribe from this group and stop receiving emails from it, send an email to netbox-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/netbox-discuss/e673f637-db00-43bd-8fef-bddfd2490869n%40googlegroups.com.

Brian Candler

unread,
Nov 19, 2020, 10:14:37 AM11/19/20
to NetBox
> 'reportriew' is not a registered namespace inside 'plugins'

The full backtrace should show it.  My guess is that somewhere in your code, or in configuration.py, you have written "reportriew" instead of "reportview"

Reply all
Reply to author
Forward
0 new messages