Soil-Carbon-Coalition / atlasbiowork

App framework based on wq for entering georeferenced data about landscape function
4 stars 2 forks source link

admin site trouble #1

Closed managingwholes closed 8 years ago

managingwholes commented 8 years ago

I've begun configuring admin, wanting to be able to edit data and data types from admin, and added an admin.py to obs directory as follows:

from django.contrib import admin
from .models import Site, Observation, ObservationType

admin.site.register(Site)
admin.site.register(Observation)
admin.site.register(ObservationType)

I also modified urls.py as recommended here https://docs.djangoproject.com/en/1.9/ref/contrib/admin/#hooking-adminsite-instances-into-your-urlconf (note that in Django 1.9 the include statement is not needed):

When I ran migrate I got the following error, and the admin interface did not include links to Sites, Observations, or ObservationTypes:

pdonovan@atlasbiowork:/var/www/atlasbiowork/db$ ./manage.py migrate

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.p
y", line 353, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/__init__.p
y", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py",
line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py",
line 398, in execute
    self.check()
  File "/usr/local/lib/python3.4/dist-packages/django/core/management/base.py",
line 426, in check
    include_deployment_checks=include_deployment_checks,
  File "/usr/local/lib/python3.4/dist-packages/django/core/checks/registry.py",
line 75, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/usr/local/lib/python3.4/dist-packages/django/core/checks/urls.py", line
 10, in check_url_config
    return check_resolver(resolver)
  File "/usr/local/lib/python3.4/dist-packages/django/core/checks/urls.py", line
 19, in check_resolver
    for pattern in resolver.url_patterns:
  File "/usr/local/lib/python3.4/dist-packages/django/utils/functional.py", line
 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py", lin
e 417, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/usr/local/lib/python3.4/dist-packages/django/utils/functional.py", line
 33, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/usr/local/lib/python3.4/dist-packages/django/core/urlresolvers.py", lin
e 410, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python3.4/importlib/__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "/var/www/atlasbiowork/db/atlasbiowork/urls.py", line 19, in <module>
    url(r'^', rest.router.urls)
  File "/usr/local/lib/python3.4/dist-packages/django/conf/urls/__init__.py", li
ne 99, in url
    urlconf_module, app_name, namespace = view
ValueError: too many values to unpack (expected 3)
sheppard commented 8 years ago

It looks like rest.router.urls still doesn't support use without the include statement. It doesn't hurt to have it there, but it would be nice to be consistent with the new admin usage. I made a note in wq/wq.db#55.