Ammar
Thanks for the solution.
try it first 😅
Shahid
Iam using swagger 1.21 it just allows me http but i wanna https anyone can help please
Priyanshu Pratap
Hey is anyone uses postgresql as database in django?..i need help regarding postgresql
Priyanshu Pratap
I am using psql to import a .sql file when i am importing the file using \i path/to/sql/file then it says permission denined i check out few solutions on internet and did those things but error doesn't resolve..i change the permission as well as ownership of file using chmod and chown...postgres is username in my case...
Priyanshu Pratap
\i /home/kali/Downloads/Mock_Data.sql i am using this command and then it shows permission denined
Qwerty
psql -d yourdatabase -f pathtoyourfile
Priyanshu Pratap
Again it shows permission denined
Qwerty
Again it shows permission denined
Try to move your file to the another directory and show, to the desktop for example
Qwerty
And show the file access
Priyanshu Pratap
It worked i just changed the directory and change the ownership....thank you so much bro 🙌
RZ
Hello, does anyone know how to show in the details view in the django administration (when you cannot edit, only see) how to show the content of a ManyToMany separated into lines or at least not show it in a pile?
Rajul
It is done to give permission only read not to edit
Rajul
It is work
Siddhali
File "C:\Python311\Lib\tomllib\_parser.py", line 366, in parse_key_value_pair raise suffixed_err(src, pos, "Expected '=' after a key in a key/value pair") tomllib.TOMLDecodeError: Expected '=' after a key in a key/value pair (at line 1, column 5)
s
Did anyone competed python I need some guidance regarding it Since I am done with basics and oops After this which path should i follow whether projects, Django,libraries or anything else Please I am confused by seeing lot of roadmaps and suggestion But want to know from person who had done and give me correct advice I really want geniue and honest mentor to gudie
M. Hossein
Whenever I try to close connection in the django channels aysnc consumer I get this runtime error: RuntimeError: Expected ASGI message 'websocket.http.response.body' but got 'websocket.close'. What should I do? Here is my code: class DeviceDataConsumer(AsyncWebsocketConsumer): """Consumer for sending real-time data to clients.""" async def connect(self: Self): user = self.scope["user"] if not user.is_authenticated: await self.close()
C
Greetings everyone 👋. please who has a free udemy course on Django?
Raymond
Greetings everyone 👋. please who has a free udemy course on Django?
Try logging in and search. I think I remember seeing some courses that were free there. Otherwise, please try YouTube
hadi
Hello friends. I have a WordPress site with CPanel and I want to add a Django site next to it, so that I can enter the Django app by following the site address, for example, mysite.com/django. It is possible?
Levitybot
Hello friends. I have a WordPress site with CPanel and I want to add a Django site next to it, so that I can enter the Django app by following the site address, for example, mysite.com/django. It is possible?
Not sure what you mean by 'next to it'. WordPress is going to be running in php on an Apache or Nginx server, Django will be running in a completely different python environment. The best thing I could think of here is setting up a 301 redirect in your .htaccess file to the other server running Django for anything matching your mysite.com/django route. Never tried it, but I guess it should work. Sub domain would be more natural django.mysite.com
Vitaly
Got classes of Student, StudentGroup, Pair(double lesson), Mark and a queryset: class Student(models.Model): student_group = models.ForeignKey("StudentGroup", ...) ... class StudentGroup(models.Model): ... class Pair(models.Model): pair_time = models.TimeField(...) pair_date = models.DateField(...) student_group = models.ForeignKey("StudentGroup", ...) ... class Mark(models.Model): student = models.ForeignKey("Student", ...) pair = models.ForeignKey("Pair", ...) queryset = ( Student.objects .select_related("student_group") .prefetch_related( Prefetch( "student_group__pairs", queryset=( Pair.objects .order_by("-pair_date", "pair_time") .select_related("subject") .prefetch_related( Prefetch( "marks", # This is what I need to filter. queryset=Mark.objects.filter(student_id=**???**), to_attr="student_marks" ) ) .all() ), to_attr="student_pairs" ) ) .all() ) I need to filter marks by student_id. How can I do it? Tried F, Q, Subquery, but I can't get how to use'em.
Levitybot
nope, that's why I'm asking
I'm not totally sure what your asking, but if you want to do complex queries check out Q
A
Hello guys, a quick question I have made a drop down menu in html and even if I'm selecting an option in it, it's not getting selected and not showing in the terminal while every other input in any other form like textboxes are getting displayed. What is the possible way to correct it ?
Pandu
is name attribute correct
Vishnu
I tried to visualize it using chart.js but it just displays an empty space in the website I couldn't find a way to display the charts and data
Please read the official documentation of chart js and if you still face issues with that, please let me know. I can help you with sample code.
Vishnu
Hello guys, a quick question I have made a drop down menu in html and even if I'm selecting an option in it, it's not getting selected and not showing in the terminal while every other input in any other form like textboxes are getting displayed. What is the possible way to correct it ?
Are you using html with css classes. If yes, it may work with the help of some javascript code. So, you need to add the script as well. To confirm the same, use just html select and option tags and take the value of the select tag. And pass required values to option tags.
shais
How to sign up for telegram initially?
Doragonsureiyā
How to sign up for telegram initially?
This is not a Django specific question, please delete your offtopic message. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
Koen de
Something like; Children.objects.filter(master_id=Master.pk) Where “master_id” is your IntegerField This returns a queryset with zero or more records, the queryset is iterable like an array. In any other case… share your code and errors
Soheyl Taheri
Hi guys What’s difference between DefaultRouters and SimpleRouters in Django?
Mosihere
Hi guys What’s difference between DefaultRouters and SimpleRouters in Django?
If you're using DefaultRouter, the API root will automatically be included. The API root is an endpoint that returns a response containing hyperlinks to all the list views. (Unlike DefaultRouter , SimpleRouter doesn't include the API root.)
##00
Hello everyone How do I host a reactjs project with drf? Backend and frontend
Koen de
Hello everyone How do I host a reactjs project with drf? Backend and frontend
The question is very generic. There are several ways to do so. VPS, docker, etc The question has been asked a lot of times, here, stackoverflow, reddit, etc One of them; https://www.reddit.com/r/django/comments/139epka/what_is_the_best_way_of_deploying_django_rest/
amira
who have any idea about applying ACL based on a time restriction form from django to a firewall?
Creator🇺🇦
Creator🇺🇦, [5 мая 2024 г., 20:11:33 (5 мая 2024 г., 20:14:26)]: I don’t understand why it doesn’t display data in {% for post2 in similar_posts %} returns similar_posts Creator🇺🇦, [5 мая 2024 г., 20:15:36]: <h2>Similar posts</h2> {% for post2 in similar_posts %} <p> <a href="{{ post.get_absolute_url }}">{{ post2 }}</a> </p> {% empty %} There are no similar posts yet. {% endfor %} Creator🇺🇦, [5 мая 2024 г., 20:15:48]: def post_detail(request, year, month, day, post): post = get_object_or_404(Post, status=Post.Status.PUBLISHED, slug=post, publish__year=year, publish__month=month, publish__day=day) # List of active comments for this post comments = post.comments.filter(active=True) # Форма для комментирования пользователями form = CommentForm() post_tags_ids = post.tags.values_list('id', flat=True) similar_posts = Post.published.filter(tags__in=post_tags_ids).exclude(id=post.id) similar_posts = similar_posts.annotate(same_tags=Count('tags')).order_by('-same_tags', '-publish')[:4] return render(request, 'blog/post/detail.html', {'post': post, 'comments': comments, 'form': form, ' similar_posts': similar_posts})
Koen de
Happy to share your solution for any of us?
Myworld@vz
Hello everyone,How can we apply angularjs code inside the django templates??
The Inspired
Hello everyone,How can we apply angularjs code inside the django templates??
Nope. Pure Django Templates support only vanilla HTML-CSS (and HTMX prolly). If you want to use Angular, you have to use Django REST framework in the backend
Khaled
Hello everyone,How can we apply angularjs code inside the django templates??
with django templates you can use jquery or alpine.js instead
Zion
Hello everyone,How can we apply angularjs code inside the django templates??
why you want to do that? just create a rest Api and work with it, Django Orm is superb for manage entities in the rest framework this action will "decouple" your front and back parts, more responsibilities but more flexibility when you want to add more "technology" inside
Zion
btw then is an option, connect a react JSX in Django template as a fake-vanilla
M. Hossein
In my django project I have overriden the model manager create method to log whenever a new object is created. The thing is when I create a model from admin page it looks like the create method of the manager isn't called. How does it create the object?
M. Hossein
Why doing this ? Instead of manager you could just put the log into save method by overriding it
I just said log as an example. It actually sends something to websocket
Mirco
I just said log as an example. It actually sends something to websocket
It's the same Model manager is not the best suit for that goal Override save method or use a post save signal First opt is preferred
M. Hossein
It's the same Model manager is not the best suit for that goal Override save method or use a post save signal First opt is preferred
So the thing is if I put the logic in the save method, will it work if I create an object using save method?
Mirco
So the thing is if I put the logic in the save method, will it work if I create an object using save method?
Save method is called by Django when you create or update objects Only when using bulk creation, the internal logic is different
Mirco
I am avoiding signals
So use the save method
Mirco
Mathew
Hii I have a doubt
Doragonsureiyā
Mathew
I am getting table already exists error
Doragonsureiyā
I am getting table already exists error
Impossible to help without details. Read this please: http://www.catb.org/~esr/faqs/smart-questions.html
Alex
I am getting table already exists error
are you running any automation script for migrations?
Mathew
At first the error was the table does not exist then I actually deleted the app migration rows from django_migration table Now it's says table already exists
The Inspired
now gotta delete all the migrations, wipe the DB and rerun mingrations again
michael
now gotta delete all the migrations, wipe the DB and rerun mingrations again
I've ran into this issue a while back but I don't think wiping the DB did good, deleting the migrations did but it was stubborn for a while... The table already exists is truely RIP lol
Anonymous
I am going to give you simple ImageTransformationTool project. I want that it helps your work.
Doragonsureiyā
I am going to give you simple ImageTransformationTool project. I want that it helps your work.
Rule 5️⃣: Never post walls of text or screen photos. Use paste bins like https://nekobin.com, https://dpaste.org (or your favorite one)
M. Hossein
SELECT time as timestamp, value as value, %s as device_id FROM unnest((SELECT lttb(timestamp, value, %s) FROM core_devicedata Can I do this with django? I don't wanna use raw sql (already tried). I need to get results as query set
Blue
django def str(self) for int
Habib
Hey there, I have a question regarding Django signals
Habib
@receiver(post_save,sender=Order) def user_item_interactions(sender,instance,created,**kwargs): if created: print(instance) print(instance.payment_method) customer_order = instance.orderproduct_set.all() print(customer_order,'is customer ordder')
Habib
Output: fahim12 Cash on Delivery <QuerySet []> is customer ordder
Habib
fahim12 is just str() for instance The question Why instance.orderproduct_set.all() gives me empty query set I tested using manage.py shell --- it correctly returns orderproduct instance
Acquaintance
fahim12 is just str() for instance The question Why instance.orderproduct_set.all() gives me empty query set I tested using manage.py shell --- it correctly returns orderproduct instance
Maybe you're saving the order and then making relations (ForeignKey) for orderproduct So when it's not related yet you're getting nothing