The Inspired
Hello everyone.
Please, I need some help.😬
I'm working with Django DRF and I'm implementing my front-end with ReactJS.
So, I'm rebuilding a blog I've already built sometimes ago (then with only Django and Ajax) with ReactJS this time.
I've been able to serialize and retrieve my posts and display post detail in React front-end.
But the issue is that I'm trying to get all the comments for each post detail and all the replies for those comments on a post. And I want to serialize them so that I can consume them in my ReactJS front-end.
I have three models: Post, Comments, and Replies.
I've made research and I've tried everything I saw, none is giving me what I want. I don't know whether I'm the one missing out on something.
This is what I'm trying to achieve:
post = {'post_title': '...',
'post_body' : '...',
'author': '...',
comments: [
{'id': 3, 'Name': '...',
'comment': '...',
replies : [
{'id': 2, 'reply': '...', 'user': '...'}, {'id': 3, 'reply': '...', 'user': '...'} ]
]
Please help me out. Thanks.
What you need is a nested serializer.
show your PostSerializer class
Alexey
Hello everyone.
Please, I need some help.😬
I'm working with Django DRF and I'm implementing my front-end with ReactJS.
So, I'm rebuilding a blog I've already built sometimes ago (then with only Django and Ajax) with ReactJS this time.
I've been able to serialize and retrieve my posts and display post detail in React front-end.
But the issue is that I'm trying to get all the comments for each post detail and all the replies for those comments on a post. And I want to serialize them so that I can consume them in my ReactJS front-end.
I have three models: Post, Comments, and Replies.
I've made research and I've tried everything I saw, none is giving me what I want. I don't know whether I'm the one missing out on something.
This is what I'm trying to achieve:
post = {'post_title': '...',
'post_body' : '...',
'author': '...',
comments: [
{'id': 3, 'Name': '...',
'comment': '...',
replies : [
{'id': 2, 'reply': '...', 'user': '...'}, {'id': 3, 'reply': '...', 'user': '...'} ]
]
Please help me out. Thanks.
This is what u want. What u retrieve now?
Anonymous
I need to create a site and place an order
Doragonsureiyā
I need to create a site and place an order
We're not here to do your job for you.
This group is to help you on specific issues you have in YOUR code, so you have to show the code you wrote by yourself and explain where and why you are stuck... as simple as that. 🤷🏻♂️
Anonymous
I understand thank you
bhzad
Hello I can't import six What is the problem?
from django.utils import six
Error: cloud not be resolved from source
Hermitoid
hello, i'm quite unfamilliar with django, how should i proceed to create clickable links that would then define a datasearch and display filtered results (categories filters for a e shop)? i already managed to do this with checkboxes list for sizes, but those aren't clickable links
Charly
bhzad
To register with email confirmation And from version 4.1.5
Charly
Charly
bhzad
I can not send photos
Doragonsureiyā
I can not send photos
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://linkode.org, https://nekobin.com (or your favorite one)
bhzad
What?
bhzad
no send photo
Maxim
Hermitoid
is it possible to filter data in jinja template? like for example i have a dataset and in would like to do something like this {% for category in data WHERE gender = woman %}
Hermitoid
then display all products {{ product.category }}
Максим
You can create your own filters in django, idk about jinja
Shivani
How can I get radio button in html page using forms. Py and crispy forms
SaNjU
مريم خالد
when i try to update admin dashboard using dj-rest-auth i got that error Code Details 401 Undocumented Error: Unauthorized Response body Download { "detail" : "The user is invalid" }
مريم خالد
https://linkode.org/#7hIxmxj6cgW6qniVGn2u
مريم خالد
that is my code
amirhosein
I would like my code to run every 5 seconds from 9 to 15 on Saturdays, Sundays, Mondays, Tuesdays, and Wednesdays using celery. I would appreciate it if someone could guide me on how to set up this "schedule": crontab(hour="9-15", minute="*/5", day_of_week="0-2,4-5").
Shivam
If we get the desire from django queries , but after passing through serializers we get difference results
Should we need to write custom logic to convert the query set results into json , or we can do it by doing modification in serializers
The Inspired
The Inspired
The Inspired
that is my code
Did you run migrations and migrate before creating this user model?
Venkat
Django is used widely what will be the scope of adoption of this framework
amirhosein
Maxim
cj
Goodness
please i need help implementing the oauth 1.0a three legged authentication flow for twitter
is there anyone who has worked on something similar please
Дмитрий
Hi all! I have a very unusual question: I dynamically generated migrations for the database, but there is an error "the relation "name" already exists", the string is not displayed completely, so I decided to try to shorten the string. And it worked as it should. The question is how to bypass the string length limitation for name.
.
Unluncky
I need help how to write django api in forgot password
Shamnad
лил
No module named 'crm.apps.py'; 'crm.apps' is not a package
лил
why?
🧚♂️
Hi, Don't you know why swagger shows "No operations defined in spec!”?
zmod
anyone has a sample code for django admin sites customization
HOOMAN
HOOMAN
🧚♂️
HOOMAN
I did it
Send you.r code in group
🧚♂️
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
schema_view = get_schema_view(
openapi.Info(
title='Cooking Blog',
description='Cook with love!',
default_version='v1',
),
public=True
)
urlpatterns = [
path('admin/', admin.site.urls),
path('swagger/', schema_view.with_ui('swagger')),
path('cooking/', include('main.urls'))
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
🧚♂️
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'drf_yasg',
'main',
'account'
]
Omar
I did it
Run migrations after adding to installed app
Doragonsureiyā
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
schema_view = get_schema_view(
openapi.Info(
title='Cooking Blog',
description='Cook with love!',
default_version='v1',
),
public=True
)
urlpatterns = [
path('admin/', admin.site.urls),
path('swagger/', schema_view.with_ui('swagger')),
path('cooking/', include('main.urls'))
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like:
- https://dpaste.org
- https://linkode.org
- https://hastebin.com
- https://bin.kv2.dev
If you posted a wall of text, go back and delete it.
HOOMAN
from drf_yasg import openapi
from drf_yasg.views import get_schema_view
schema_view = get_schema_view(
openapi.Info(
title='Cooking Blog',
description='Cook with love!',
default_version='v1',
),
public=True
)
urlpatterns = [
path('admin/', admin.site.urls),
path('swagger/', schema_view.with_ui('swagger')),
path('cooking/', include('main.urls'))
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Use swagger
🧚♂️
🧚♂️
HOOMAN
??
Search swagger drf docyoument
Patrick
Has anyone tried saelor?
Is it possible to get whole setup with frontend?
I am trying but its not providing the frontend.
It is open source...
@h_llary
Omar
Omar
Saelor has a storefront as well. You can check it out
Anton
Hi, how do I display images on my website?
Adorilson
Anuj
s
Anuj
The MEDIA_URL and STATIC_URL settings must have different values4
Anuj
facing this issue
Lord
а
Lord
What steps would you take if a user told you that an API 500 error was being returned?
I received such a question from a senior and I need to answer competently in order to get this job, but the only thing that comes to my mind is to shoot the logs. could you help?
Doragonsureiyā
Maxim
Lord
but I'm not a scammer, I don't understand the procedure.
I need to ask the user to pass all error data. Make sure DEBUG mode is enabled in Django. Replay the user's request using tools like Postman or Curl. View logs. If the error is caused by the code, fix it and test it. But am I missing something in this? I know what I'm missing but I don't know what
Bandar
Hello friends I got questions
Bandar
Now when you build your project what are the Vulnerabilities you should check for in code level?
Maxim