Reputation: 808
there is a way to get full url from app_name ? like reverse('myapp:bio')
inside class ItemForm(forms.ModelForm)
from django.urls import include, path
app_name = 'myapp'
urlpatterns = [
path('index/', views.index, name='main-view'),
path('bio/<username>/', views.bio, name='bio'),
]
i'm tryng to use it in MyForm(ModelForm) but i get that error
File "D:\Development\SiteDJCentral\.venv\lib\site-packages\django\urls\resolvers.py", line 607, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf 'website.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
print( reverse('myapp:bio') )
my form where i try call it
class ItemForm(forms.ModelForm):
relase_date = forms.DateField(required=False, input_formats=settings.DATE_INPUT_FORMATS, help_text='opzionale formato yyyy-mm-dd')
tags = OdsTaggerMultipleChoiceField( queryset = None, required=True, json_url= HttpRequest.request.build_absolute_uri(reverse('myapp:bio' )) )
Upvotes: 0
Views: 134
Reputation: 6378
Simple:
from django.urls import reverse
reverse('main-view') == 'myapp/index/'
reverse('bio', kwargs={'username': UserObject.username}) == 'myapp/bio/<username>/'
Upvotes: 1