mirror of
https://github.com/django-components/django-components.git
synced 2025-09-19 20:29:44 +00:00
parent
7e74831599
commit
2499126d1f
4 changed files with 14 additions and 3 deletions
|
@ -12,11 +12,15 @@
|
||||||
# settings.py
|
# settings.py
|
||||||
COMPONENTS = {
|
COMPONENTS = {
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"djc_ext_pydantic.PydanticExtension",
|
"djc_pydantic.PydanticExtension",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### Fix
|
||||||
|
|
||||||
|
- Make it possible to resolve URLs added by extensions by their names
|
||||||
|
|
||||||
## v0.135
|
## v0.135
|
||||||
|
|
||||||
#### Feat
|
#### Feat
|
||||||
|
|
|
@ -193,7 +193,7 @@ And add the extension to your project:
|
||||||
```py
|
```py
|
||||||
COMPONENTS = {
|
COMPONENTS = {
|
||||||
"extensions": [
|
"extensions": [
|
||||||
"djc_ext_pydantic.PydanticExtension",
|
"djc_pydantic.PydanticExtension",
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
|
@ -3,7 +3,7 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, List, NamedTuple, Tuple,
|
||||||
|
|
||||||
import django.urls
|
import django.urls
|
||||||
from django.template import Context
|
from django.template import Context
|
||||||
from django.urls import URLResolver
|
from django.urls import URLResolver, get_resolver, get_urlconf
|
||||||
|
|
||||||
from django_components.app_settings import app_settings
|
from django_components.app_settings import app_settings
|
||||||
from django_components.compat.django import routes_to_django
|
from django_components.compat.django import routes_to_django
|
||||||
|
@ -634,6 +634,11 @@ class ExtensionManager:
|
||||||
ext_url_resolver.urlconf_name = urls
|
ext_url_resolver.urlconf_name = urls
|
||||||
ext_url_resolver.url_patterns = urls
|
ext_url_resolver.url_patterns = urls
|
||||||
|
|
||||||
|
# Rebuild URL resolver cache to be able to resolve the new routes by their names.
|
||||||
|
urlconf = get_urlconf()
|
||||||
|
resolver = get_resolver(urlconf)
|
||||||
|
resolver._populate()
|
||||||
|
|
||||||
def get_extension(self, name: str) -> ComponentExtension:
|
def get_extension(self, name: str) -> ComponentExtension:
|
||||||
for extension in self.extensions:
|
for extension in self.extensions:
|
||||||
if extension.name == name:
|
if extension.name == name:
|
||||||
|
|
|
@ -75,6 +75,8 @@ COMPONENTS = {
|
||||||
"dirs": [Path(__file__).resolve().parent / "components"],
|
"dirs": [Path(__file__).resolve().parent / "components"],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
urlpatterns: list = []
|
||||||
|
|
||||||
|
|
||||||
class StaticFilesFinderTests(SimpleTestCase):
|
class StaticFilesFinderTests(SimpleTestCase):
|
||||||
@djc_test(
|
@djc_test(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue