asifpy / django-crudbuilder

Generic CRUD implementation in Django
https://django-crudbuilder.readthedocs.org/en/latest/index.html
Apache License 2.0
193 stars 67 forks source link

Empty registered cruds list #52

Open pavelber opened 6 years ago

pavelber commented 6 years ago

I tried to resemble your example with Person and PersonCrud but I get empty registered cruds list.

Should I explicitly register a crud in some way?

catherinedevlin commented 6 years ago

I am seeing the same problem.

asifpy commented 6 years ago

Where did you define your crud config classes?

jorgehatccrma commented 6 years ago

I know this is closed, but the solution didn't solve the problem for me. I've checked that my app is in settings.INSTALLED_APPS and I've created my CRUD classes in myapp/crud.py. Anything else I should check?

jorgehatccrma commented 6 years ago

Digging into crudbuilder's source code, I think I found a possible cause. Apparently when using the Application Configuration features (see this SO post), crudbuilder can't find the app's path (in crudbuilder.registry.import_crud(app).

In my case, instead of declaring the raw name for my app (e.g. myapp) in INSTALLED_APPS, I have myapp.apps.MyappConfig (the default created by django 1.11 when following the tutorial). In other words:

INSTALLED_APPS = [
    # 'myapp',                  # I think this is what CRUDbuilder is expecting
    'myapp.apps.MyappConfig',   # This is what django automatically generates, but crudbuilder can't find the path in this case 
    ...
]

If I use the raw app name instead of the autogenerated line, then I see the registered cruds. It seems to me that, since the Application Configuration feature seems to be the prefered way to declare apps, crudbuilder should add support for this feature as well.