-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Thank you for library, I have some questions #13
Comments
Hi, all good! let's see...
class User:
pass
class Boat:
users = models.ManyToManyField(User, related_name='boats') if you have a user with ID 1, associated to a boat with id 2.... u = User.objects.get(id=1)
u.save() Will trigger the following messages, depending on how did you configure auto-broadcast:
In the code of your component you can do **I think I need to write proper documentation about this and the live cycles of the component.
I will use your feedback to improve the documentation and as always, sorry for my broken English. Happy hacking! |
Hello Eddy, sorry for late response.
So, i have <p>
<a href="{% url 'psy-user-profile-update' psy.id %}">{{ psy.username }}</a>
</p> Then in <form method="post" enctype="multipart/form-data">{% csrf_token %}
<div class="form-group">
{{ form.email|as_crispy_field }}
</div>
...
{{ profile.management_form }}
{% for form in profile.forms %}
{% component 'dynamic-component' form=form profile=user.profile %}
{% endfor %}
</form> And <div class="form-group">
{{ form.statuses|as_crispy_field }}
</div>
<a href="{% url 'psy-status-create'%}" target="_blank" class="non-color-link">
<i class="fa fa-plus-square"></i>
</a> ** {% component 'dynamic-component' form=form profile_forms=profile.forms profile=user.profile %} But then when I try to generate a token in the component template {% csrf_token %}, the token is not generated, I don't understand the reason for this. ** {% component 'component-name' state=state %} But, I tried to do something like your example with <div is="dymanic-component" id="{{ this.id }}" state="{{ this.serialize|tojson }}"> I thought that this is how you can use a component and render it implicitly, but ran into a problem how to pass the state correctly, tried to do it differently:
and so on) Finally the code of my component: from psychologists.models import PsychologistStatus, PsychologistUserProfile
from reactor.component import Component
class DynamicComponent(Component):
template_name = 'cadmin/psychologists/psy_user_profile_update_dynamic.html'
def mount(self, form, profile, **kwargs):
self.form = form
self.profile = profile
self.subscribe(f"psychologistuserprofile.{profile.id}.statuses")
def serialize(self):
return dict(
form=self.form,
profile=self.profile,
) Also added to settings: AUTO_BROADCAST = {
# model_a
# model_a.del
# model_a.new
'MODEL': True,
# model_a.1234
'MODEL_PK': True,
# model_b.1234.model_a_set
# model_b.1234.model_a_set.new
# model_b.1234.model_a_set.del
'RELATED': True,
# model_b.1234.model_a_set
# model_a.1234.model_b_set
'M2M': True,
}
CHANNEL_LAYERS = {
"default": {
"BACKEND": "channels_redis.core.RedisChannelLayer",
"CONFIG": {
"hosts": [("127.0.0.1", 6379)],
},
},
} I may have missed something or don't understand it, but it doesn't work yet(statuses are not updated after adding).
It will be perfectly and solve misunderstandings. Sorry that I did not immediately describe all the problems I encountered. |
First of all, I need to write proper documentation and examples, that's for sure, and that's what you are missing here. From a quick look the The data returned by Also instead of: |
Thank you for the quick response!
I missed
This will lead to endless recursion.
Ok, I'll wait for your examples, thank you in advance! |
Hello Eddy, thank you for the library!
I am not a very experienced developer and I have several questions and problems with the library:
send_redirect
method takes url as django url name or it is string?Thanks again for work you've done!
Waiting for your reply
The text was updated successfully, but these errors were encountered: