Maria
Ammar
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
Qwerty
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...
Qwerty
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
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?
C
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?
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
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.
Have you discovered 'Q' for complex querys yet? from django.db.models import Q
Vitaly
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
Vishnu
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?
##00
Hello everyone
How do I host a reactjs project with drf? Backend and frontend
Stanislav
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.
try this
Prefetch(
"marks",
queryset=lambda: Mark.objects.filter(student_id=OuterRef('pk')),
to_attr="student_marks"
)
amira
who have any idea about applying ACL based on a time restriction form from django to a firewall?
Vitaly
##00
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??
Khaled
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?
Mirco
M. Hossein
M. Hossein
M. Hossein
M. Hossein
Mirco
Mathew
Hii I have a doubt
Doragonsureiyā
Mathew
I am getting table already exists error
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
The Inspired
now gotta delete all the migrations, wipe the DB and rerun mingrations again
Maxim
Anonymous
I am going to give you simple ImageTransformationTool project. I want that it helps your work.
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
Charly
Acquaintance