-
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- The `compatibility` argument on `reactpy_django.components.view_to_component` is deprecated. - Using `reactpy_django.components.view_to_component` as a decorator is deprecated. - `reactpy_django.utils.register_iframe` function has been added. - `reactpy_django.components.view_to_iframe` component has been added - It is now recommended to call `as_view()` when using `view_to_component` or `view_to_iframe` with Class Based Views. - Thread sensitivity has been enabled in all locations where ORM queries are possible.
- Loading branch information
1 parent
67dc1eb
commit 6f79c4c
Showing
48 changed files
with
814 additions
and
416 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.apps import AppConfig | ||
from reactpy_django.utils import register_iframe | ||
|
||
from . import views | ||
|
||
|
||
class ExampleAppConfig(AppConfig): | ||
name = "example" | ||
|
||
def ready(self): | ||
register_iframe(views.HelloWorld) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django.apps import AppConfig | ||
from reactpy_django.utils import register_iframe | ||
|
||
from . import views | ||
|
||
|
||
class ExampleAppConfig(AppConfig): | ||
name = "example" | ||
|
||
def ready(self): | ||
register_iframe(views.hello_world) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.http import HttpResponse | ||
|
||
|
||
def hello_world(request, arg1, arg2, kwarg1=None, kwarg2=None): | ||
return HttpResponse(f"Hello World! {arg1} {arg2} {kwarg1} {kwarg2}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.http import HttpResponse | ||
from django.views import View | ||
|
||
|
||
class HelloWorld(View): | ||
def get(self, request): | ||
return HttpResponse("Hello World!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.http import HttpResponse | ||
|
||
|
||
def hello_world(request): | ||
return HttpResponse("Hello World!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.http import HttpResponse | ||
|
||
|
||
def hello_world(request): | ||
return HttpResponse('<div id="hello-world"> Hello World! </div>') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from .hello_world_cbv import HelloWorld | ||
from .hello_world_fbv import hello_world | ||
|
||
__all__ = [ | ||
"HelloWorld", | ||
"hello_world", | ||
] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from django.http import HttpRequest | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_component | ||
|
||
from . import views | ||
|
||
hello_world_component = view_to_component(views.hello_world) | ||
|
||
|
||
@component | ||
def my_component(): | ||
request = HttpRequest() | ||
request.method = "GET" | ||
|
||
return html.div( | ||
hello_world_component( | ||
request, # This request object is optional. | ||
"value_1", | ||
"value_2", | ||
kwarg1="abc", | ||
kwarg2="123", | ||
), | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,13 @@ | ||
from django.http import HttpResponse | ||
from django.views import View | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_component | ||
|
||
from . import views | ||
|
||
class HelloWorldView(View): | ||
def get(self, request): | ||
return HttpResponse("Hello World!") | ||
|
||
|
||
vtc = view_to_component(HelloWorldView) | ||
hello_world_component = view_to_component(views.HelloWorld.as_view()) | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
vtc(), | ||
hello_world_component(), | ||
) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
from django.http import HttpResponse | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_component | ||
|
||
from . import views | ||
|
||
@view_to_component(strict_parsing=False) | ||
def hello_world_view(request): | ||
return HttpResponse("<my-tag> Hello World </my-tag>") | ||
hello_world_component = view_to_component(views.hello_world) | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
hello_world_view(), | ||
hello_world_component(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
from django.http import HttpResponse | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_component | ||
|
||
from . import views | ||
|
||
|
||
def example_transform(vdom): | ||
attributes = vdom.get("attributes") | ||
if attributes and attributes.get("id") == "hello-world": | ||
vdom["children"][0] = "Good Bye World!" | ||
vdom["children"][0] = "Farewell World!" | ||
|
||
|
||
@view_to_component(transforms=[example_transform]) | ||
def hello_world_view(request): | ||
return HttpResponse("<div id='hello-world'> Hello World! <div>") | ||
hello_world_component = view_to_component( | ||
views.hello_world, transforms=[example_transform] | ||
) | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
hello_world_view(), | ||
hello_world_component(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
from django.http import HttpResponse | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_component | ||
|
||
from . import views | ||
|
||
@view_to_component | ||
def hello_world_view(request): | ||
return HttpResponse("Hello World!") | ||
hello_world_component = view_to_component(views.hello_world) | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
hello_world_view(), | ||
hello_world_component(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_iframe | ||
|
||
from . import views | ||
|
||
hello_world_iframe = view_to_iframe( | ||
views.hello_world, | ||
) | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
hello_world_iframe( | ||
"value_1", | ||
"value_2", | ||
kwarg1="abc", | ||
kwarg2="123", | ||
), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_iframe | ||
|
||
from . import views | ||
|
||
hello_world_iframe = view_to_iframe(views.HelloWorld.as_view()) | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
hello_world_iframe(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_iframe | ||
|
||
from . import views | ||
|
||
hello_world_iframe = view_to_iframe( | ||
views.hello_world, extra_props={"title": "Hello World!"} | ||
) | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
hello_world_iframe(), | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from reactpy import component, html | ||
from reactpy_django.components import view_to_iframe | ||
|
||
from . import views | ||
|
||
hello_world_iframe = view_to_iframe(views.hello_world) | ||
|
||
|
||
@component | ||
def my_component(): | ||
return html.div( | ||
hello_world_iframe(), | ||
) |
Oops, something went wrong.