Git Product home page Git Product logo

Comments (3)

kmmbvnr avatar kmmbvnr commented on July 19, 2024
-    path('ui/', include('ui.urls')),
     path('ui/', include(frontend_urls)),

the first line seems redundant. Frontend perform modules app configs auto-discovery

from django-material.

djjudas21 avatar djjudas21 commented on July 19, 2024

Thanks for your response. I'm still stuck on this issue. I've tried various combinations of configs but at the moment my global urls.py is

urlpatterns = [
    path('', include('ui.urls')),
#    path('', include('schema.urls')),
    path('', include(frontend_urls)),
    ]

and the UI module urls.py is

urlpatterns = [
    path('', generic.RedirectView.as_view(url='./cameramodel/', permanent=False), name="index"),
    path('cameramodel/', include(views.CameraModelViewSet().urls)),
]

If I hit /ui/cameramodel/ I get

NoReverseMatch at /ui/cameramodel/
Reverse for 'cameramodel_add' not found. 'cameramodel_add' is not a valid view function or pattern name.

I still don't understand why cameramodel_add can't be found. My views.py is

from material.frontend.views import ModelViewSet
from schema import models

class CameraModelViewSet(ModelViewSet):
    model = models.CameraModel

Thanks

from django-material.

djjudas21 avatar djjudas21 commented on July 19, 2024

I abandoned work on my project because of this blocker, but I've returned to it and I've started trying to reimplement a UI with django-material again from scratch. I'm running into the same error again 😞

  • the parent app is camerahub
  • the app which contains an existing models.py is schema
  • the app which contains a skeleton Material project is ui

The schema app used to contain a bunch of views I wrote myself, but I have now deleted everything apart from models.py.

# camerahub/urls.py

from django.contrib import admin
from django.urls import include, path
from material.frontend import urls as frontend_urls

urlpatterns = [
    path('', include(frontend_urls)),
    path('', include('schema.urls')),
    path('api/', include('api.urls')),
    path('admin/', admin.site.urls),
    path('accounts/', include('django_registration.backends.activation.urls')),
    path('accounts/', include('django.contrib.auth.urls')),
    path('', include('django_prometheus.urls')),
    path('ratings/', include('star_ratings.urls', namespace='ratings')),
    path('health/', include('health_check.urls')),
]
# ui/urls.py

from unicodedata import name
from django.urls import path, include
from django.views import generic

from . import views


urlpatterns = [
    path('', generic.RedirectView.as_view(url='./cameramodel/'), name="index"),
    path('cameramodel/', include(views.CameraModelViewSet().urls)),
]
# ui/views.py

from material.frontend.views import ModelViewSet

from schema import models

# class MyModelViewSet(ModelViewSet):
#    model = models.MyModel

class CameraModelViewSet(ModelViewSet):
    model = models.CameraModel

Trying to browse to http://127.0.0.1:8000/ui/cameramodel/ I get

Internal Server Error: /ui/cameramodel/
Traceback (most recent call last):
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/django/views/generic/base.py", line 70, in view
    return self.dispatch(request, *args, **kwargs)
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/django/utils/decorators.py", line 43, in _wrapper
    return bound_method(*args, **kwargs)
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
    return view_func(request, *args, **kwargs)
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/material/frontend/views/list.py", line 531, in dispatch
    return super(ListModelView, self).dispatch(request, *args, **kwargs)
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/material/frontend/views/list.py", line 357, in dispatch
    return handler(request, *args, **kwargs)
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/material/frontend/views/list.py", line 315, in get
    context = self.get_context_data()
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/material/frontend/views/list.py", line 521, in get_context_data
    kwargs['add_url'] = reverse('{}:{}_add'.format(opts.app_label, opts.model_name))
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/django/urls/base.py", line 86, in reverse
    return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
  File "/home/jonathan/.cache/pypoetry/virtualenvs/camerahub-FNy4MBnC-py3.10/lib/python3.10/site-packages/django/urls/resolvers.py", line 698, in _reverse_with_prefix
    raise NoReverseMatch(msg)
django.urls.exceptions.NoReverseMatch: Reverse for 'cameramodel_add' not found. 'cameramodel_add' is not a valid view function or pattern name.
"GET /ui/cameramodel/ HTTP/1.1" 500 117163

from django-material.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.