mmcardle / django_builder

Django Builder Site
MIT License
608 stars 124 forks source link

django_builder get "NoReverseMatch at /htmx/" #178

Closed KongNan closed 1 year ago

KongNan commented 1 year ago

I get "NoReverseMatch at /htmx/" when using django builder.

I use the model in django tutorial :

from django.db import models

class Question(models.Model):
    question_text = models.CharField(max_length=200)
    pub_date = models.DateTimeField('date published')

class Choice(models.Model):
    question = models.ForeignKey(Question, on_delete=models.CASCADE)
    choice_text = models.CharField(max_length=200)
    votes = models.IntegerField(default=0)

I create venv, pip install -r, makemigrations, migrate, runserver, and the "generic" urls works ok. but when I try htmx the following error occurs:

NoReverseMatch at /htmx/
Reverse for 'app_Question_htmx_create' not found. 'app_Question_htmx_create' is not a valid view function or pattern name.
Request Method: GET
Request URL:    http://127.0.0.1:8000/htmx/
Django Version: 3.2.18
Exception Type: NoReverseMatch
Exception Value:    
Reverse for 'app_Question_htmx_create' not found. 'app_Question_htmx_create' is not a valid view function or pattern name.
Exception Location: ...\venv\lib\site-packages\django\urls\resolvers.py, line 698, in _reverse_with_prefix
Python Executable:  ...\venv\Scripts\python.exe
Python Version: 3.9.0

I tried django 4 or 3 but the error still there. I don't know how to fix them , please tell me how to fix that , thanks!

sorry for my English.

mmcardle commented 1 year ago

Hi @KongNan

That looks like a Django issue.

What does your urls.py file look like, it should have the line

path("app/htmx/Question/create/", htmx.HTMXQuestionCreateView.as_view(), name="app_Question_htmx_create"),
KongNan commented 1 year ago

My urls.py contains the following: path("polls/htmx/Question/create/", htmx.HTMXQuestionCreateView.as_view(), name="polls_Question_htmx_create"),

If it's a Django issue, just let time cure it . :)

mmcardle commented 1 year ago

This issue should now be fixed and deployed to djangobuilder.io