Open ViggieM opened 1 year ago
Hi @movileanuv
You are missing django_view_decorator
from your INSTALLED_APPS
:)
Oh ok, my bad. Thank you! It doesn't say that in the README though :)
I tried now to adapt the settings to
INSTALLED_APPS=[
"django.contrib.auth",
"django.contrib.contenttypes",
"django_view_decorator",
"app"
],
I had to add the additional two apps "django.contrib.auth" and "django.contrib.contenttypes" because redirect_to_login
is imported in decorators.view
.
The view is still not found though :/
Hi @movileanuv
Sorry for not getting back to you! Did you figure it out?
I have the same issue but only with index
with others it is not happening, they are added with no issues.
I was able to get the same error with other views. Basically if I have multiple views doesn't find the others.
urlpatterns = [
path("", home.index, name='index'),
path("", include_view_urls()), # view-decorator
In this way I have the index but:
Reverse for 'comment_show' not found. 'comment_show' is not a valid view function or pattern name.
@require_GET
@view(
paths="comments/<int:lead_id>/",
name="comments_show",
)
def show(request: HtmxHttpRequest, comments_id) -> HttpResponse:
Removing the decorator require_GET
doesn't change the issue
A simple print in urls.py of include_view_urls shows that:
(<module 'django_view_decorator.urls' from '/home/www/project/.venv/lib/python3.11/site-packages/django_view_decorator/urls.py'>, None, None)
So my guess is that we are using the decorator but that data is not available somewhere when is needed. If I add a print on https://github.com/valberg/django-view-decorator/blob/4934a67eceed6414cc2e518438d0312240e6096c/django_view_decorator/apps.py#L42 of the paths variable I am not getting anything but just the crash before. Same thing for https://github.com/valberg/django-view-decorator/blob/4934a67eceed6414cc2e518438d0312240e6096c/django_view_decorator/decorators.py#L36 with the same variable and print, I am not getting anything.
Maybe the decorator are executed after that part so those functions are not executed with runserver
?
I have the app enabled in django:
INSTALLED_APPS = [
"unfold",
"unfold.contrib.filters", # optional, if special filters are needed
"unfold.contrib.forms", # optional, if special form elements are needed
"django.contrib.admin", # required
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.sessions",
"django.contrib.messages",
"django.contrib.staticfiles",
"django_htmx",
"tailwind",
"django_select2",
"django_view_decorator",
"portal",
]
Running the CLI command just find only one view:
(name: index, view: portal.views.home.index)
Maybe django requires to load all the views for any request to get all the info? Because adding some print in the app code I see that the decorator is just executed for index but not also for the other views.
So I was able to find the issue. As I have views in different files inside the views.py folder the library doesn't load them.
In urls.py I did:
path("", include_view_urls(extra_modules=["portal.views.comments"])),
So probably need to support a folder and loop the files inside.
Hi, I am trying out your package, and I think it's an awesome idea. I was playing around with this idea of putting an entire django app into one file, like this:
And in the folder
app
, I have aviews.py
file with following view:But when I start the app with
python main.py runserver
, the view is not detected and I only see the django startproject view with the rocket. Why is that? Is there a setting I am missing?my directory structure looks like this:
This are my package versions: