a
first of all, no code walls secondly, rephrase your question
Марк
1) to explain I need to use a photo, if possible I can send examples in private messages 2) how else can I post code to explain the whole problem?
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - https://dpaste.org - https://hastebin.com - https://bin.kv2.dev If you posted a wall of text, go back and delete it.
Марк
Good day to all) Help me solve the problem with a huge number of sql queries when opening an object in the django admin panel. The problem is that my model has many other models associated with it and when I open this object in the admin panel, many sql queries are called, to get data about all the relationships with the object, I need to configure admin.py so that all this data django received for a small number of sql queries https://dpaste.org/vhM0y To administer the django database, I use 'django.contrib.admin'. Let's say I want to fix one of the objects of the Review model in the django admin panel, when clicking on the django object, it hangs due to its attempt to download all data from ForeignKey, that is, data about all related objects, which is why it does this suboptimally and sends several thousand sql queries, so I can't even open the page with the object in the admin panels, how can this be fixed so that django gets all the information without executing a huge number of sql queries
Марк
2
Марк
https://*/api/admin/catalog/review/19/change/ here is a link that generates thousands of sql queries
a
https://*/api/admin/catalog/review/19/change/ here is a link that generates thousands of sql queries
the review object has only 4 foreign fields. have you tried tracking the queries using django debug toolbar?
Марк
the review object has only 4 foreign fields. have you tried tracking the queries using django debug toolbar?
to track queries, I use silk, which shows the query, all sql queries generated by it, their type and execution time
a
to track queries, I use silk, which shows the query, all sql queries generated by it, their type and execution time
not actually sure how to help you there, but i suppose you could try using raw_id_fields or autocomplete_fields for the foreign key fields
a
raw_id_fields autocomplete_fields
Марк
I think ModelAdmin is suitable for a temporary solution.readonly_fields
a
I think ModelAdmin is suitable for a temporary solution.readonly_fields
did the above not work? they seem to be your case
Марк
your suggestion, I haven't tested it, they don't sound exactly like a solution to the problem, but I'll try
kim
How can I leave a message to the user after the data is successfully sent to the database
@
Any one does know mechine learning i has doubts please clarify
Abhi
Is there any other service for sending SMS in Django besides Twilio
Raj
Anyone looking backdoor jobs, please reach out to me personally, we have openings in Hyderabad and Bangalore locations in CMM LEVEL 5 COMPANY...
KAKASHI
Hello friends Why doesn't the static files link correctly? I have linked them with static but nothing change I have setup the settings.py and I'm still getting nothing
Surya
Hy I'm new in group Anyone can tell me how can i learn django anyone know about learning materials or resources
Surya
It's a website
Juan J
👋 Hi, Django community! 🚀 I want to share with you my new open-source project: Graphene Django Cruddals 🛠️. If you use Django and GraphQL, this might interest you! 🚀 🔹 What does it do? It simplifies and speeds up CRUD creation in Django using GraphQL. It's easy to use and customizable. 🔗 GitHub Repo: [Graphene Django Cruddals](https://github.com/juanjcardona13/graphene_django_cruddals) 🔗 PyPI: [graphene-django-cruddals](https://pypi.org/project/graphene-django-cruddals/) Your feedback and contributions are more than welcome. I hope you find it useful! 🙌 📬 Feel free to message me on Telegram: @juanjcardona13
Ashok
https://datascienceproject.in/jdbc
john
Hello, I'm implementing a e-commerce website and using djoser library which is a authentication library of django. and for registering (Sign Up) users, I use JWT which stands for Json Web Token. I used signals because I want each user that sign up, have a record in database as a customer. but when I want to create a new user I get this message in browsable API: [ "Unable to create account." ] I was wondering if someone can help me to fix this issue. Thanks a lot. signals.py: from django.db.models.signals import post_save from django.dispatch import receiver from django.conf import settings from .models import Buyyer @receiver(post_save, sender=settings.AUTH_USER_MODEL) def create_customer_for_new_user(sender, **kwargs): if kwargs['created']: Buyyer.objects.create(user=kwargs['instance']) apps.py from django.apps import AppConfig class ShopConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'shop' def ready(self) -> None: import shop.signals
a
It might make sense to ask Django questions here and discuss frameworks in off-topic.
drf is a superset of django. are you implying that drf is offtopic?
clouded
drf is a superset of django. are you implying that drf is offtopic?
No, fastapi is. Even more so if more frameworks are to be discussed.
The Inspired
It might give some better error messages
The Inspired
which will help in better debugging.
ȺʍìɾⱮօհąʍʍąժ
Hello, I am working on a project, and I need to implement an API for user password reset. The problem is that when the user clicks on the link (the link is sent by the back-end), I should display an html webpage, but before showing the webpage, the client should send me a request so that I cofirm the link. But there is a problem, How should the url structure be ? Should the client  send me the base url in order that I add the token to the link ? Or is there a better way to implement this ? (When there is no API, I can implement that easily because the domain was obvious, but now I need to forward the user to the webpage, I need the domain, and the client should send me a request for verification)
luckyDev777
Hi everyone, can someone give a link to good public GitHub repo Django + Kafka app implemented as microservice?
Yagi
Quick question: With QuerySets, you technically don't need to understand how SQL statements work because the API will handle that side of things?
a
Quick question: With QuerySets, you technically don't need to understand how SQL statements work because the API will handle that side of things?
django orm handles sql for you, but understanding what your queries do under the hood is recommended so that you write optimized queries (quick example - prefetch & select_related)
Yagi
django orm handles sql for you, but understanding what your queries do under the hood is recommended so that you write optimized queries (quick example - prefetch & select_related)
yes i agree, I'm asking because I'm coming from a background of where I would have to handcraft the SQL statements myself, so knowing Querysets does it all for me, it's cool! but it also lazy LOL So those SQL statements are being converted into python methods? such as filter(), save() etc
a
some people call orms an anti pattern tho
a
this one for example https://www.yegor256.com/2014/12/01/orm-offensive-anti-pattern.html
Yagi
I'm still new to the technology but thanks for confirming my suspicion!!! and I'll give the link a read!, Thanks !
Abdullo
ValueError at /addcourse The view blogapp.views.Contact_Page_View didn't return an HttpResponse object. It returned None instead. I am stuck with this problem My view looks like this: def AddCourse(request): if request.method == 'POST': form = CourseForm(request.POST) if form.is_valid(): form.save() return redirect("index") else: form = CourseForm() return render(request, 'addcourse.html', {'form': form})
Abdullah
You are not returning any value
Abdullah
Write the last return statement as a function returning not in else block
ishaan
can we make APIs in django without using serializers? just returning as json response
ishaan
yes
then why we use serializers? I mean what's the benifit
ishaan
And is it good to use jsonresponse for api in big project?
Hrishi S Vijayan
then why we use serializers? I mean what's the benifit
Good for validation of data and reusability
Hrishi S Vijayan
The Inspired
then why we use serializers? I mean what's the benifit
why do you use django instead of Spring? for ease of use and automatic features, right? same is the case with serializers. Why would you write your own data validation logic and repeat yourself when serializers do that for free for you?
The Inspired
And is it good to use jsonresponse for api in big project?
You can use it, but if you are using DRF, it is highly recommended to use the Response object. Refer to the introductory (first 4 )paragraphs mentioned here:- https://www.django-rest-framework.org/api-guide/responses/ In simple words, don't use JsonResponse unless you are forced to
Mohsen
Hey guys 👋 I'm almost finishing my project and I'm starting to write my unit tests I found out I need to have about 300 test methods overall and I am the only developer here You think it's necessary to write my unit tests by myself or I can use AI at this point?
乇PIPHANY❦▧▧❄️
good day folks can I Iink an internal page from django using a urlfield using the admin page?! for more clarity I'm trying to provide a link on  the homepage where users can access the destination page from and I want the super user or admin to be the one who provides those destination links to the pages when he wants but it seems the urlfield can only take https:// links and since the website isn't online what can I do about it or urlfield just won't work if so what will?
Mehdi
HI . i created model with blank and nul = true and use it as value in html but when user signup and try to use form it doesnt show html placeholder instead show None As Value , is there way to put blank and null = to nothing i mean ("") this not ("None")
Yagi
why does Django not accept Null values within a database?
️امیر
why does Django not accept Null values within a database?
Because you should implement null=True and blank=True in your model declaration
m
Hi, How much does real-time programming increase resource consumption compared to the non real time? Is FastAPI better for this purpose than Django Channels?
a
fastapi is an api lib, django channels is a protocol extension lib for django
kaka
Hello everyone, I'm new to Django. I'm developing a Library information management system, I created a form for the users of the Library details. But then, when I enter use details, it doesn't save in my website, even in the Django admin interface, the informations I entered three doesn't save in my website. ANY HELP PLEASE 🥺
彡 اميہر
Can you source the Django project code for visual viewing and feeding?
Charly
Can you source the Django project code for visual viewing and feeding?
Can you rephrase and explain what you want to accomplish ?
M. Hossein
What's the best way to get objects based on year in django? I need to get articles based on year (don't wanna use archive view) Something like queryset[2034].first()
M. Hossein
.get(year=2034) Where year = your model date field
That's not what I'm looking for Look I wanna show something like archive Output I am looking for (just for example) is a dict Each key is a year Each value is a queryset or list of articles in that year
M. Hossein
Share your model for a better answer 😁
Way simple 😁 created_at = DateTimeField(auto_now_add=True) title = CharField()
Mirco
So you just need to use annotate() on created_at field and use values() to have a query dict
Mirco
You can see inside Django doc how it works But basically you need a group by year
m
what are you talking about
websocket from fastapi or django channels? which is better? How much is the resource consumption?
cj
websocket from fastapi or django channels? which is better? How much is the resource consumption?
you should create an example using FastAPI and Django, and measure it yourself
John
The latest version of Channels does not support the ASGI development mode in runserver. What steps should I take?
t
hi everyone i want to deploy django with docker on production and have problems with static files load can anyone help me?