Waff
Hobeal
Hello, I just want to know best practices for Django staticfiles. It's better to user root folder or app folders ?
Dhruva
AttributeError: partially initialized module 'pygame' has no attribute 'color' (most likely due to a circular import) I am getting this error when importing pygame
Hobeal
AZ
Hi guys. Do you guys use the default project layout from Django or do you use a different layout? What layout is it and why?
cj
AZ
Bug_23¶
You can use celery beat
Talking of celery beat. I have a python script that fetches ping results from a timeseries database, serializes the results and sends as an alert to a webhook. I want to cache the data and only send an alarm if it does not exist in cache. Which is the best way to deploy this workflow?
Sunken
Anonymous
Anyone can give me basic idea how to use generic forigenkey relationship between
class LikeComment(TimeAt):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, null=True)
story = models.ForeignKey(Story, on_delete=models.CASCADE, null=True)
reels = models.ForeignKey(Reels, on_delete=models.CASCADE)
like = models.IntegerField(default=0)
comment = models.TextField(max_length=500)
def str(self):
return '{} - {}'.format(self.user, self.like, self.comment)
Брат
how I can create a model in create method in serializers
Брат
class ClientSerializer(serializers.ModelSerializer):
friends = FriendSerializer(many=True)
chats = ChatSerializer(many=True, read_only=True)
offer_to_user = OffersSerializer(many=True)
class Meta:
model = Client
fields = ['slug', 'user_subscription', 'friends', 'chats', 'offer_to_user']
def create(self, validated_data):
obj = Client.objects.create(**validated_data)
Searchfriend.objects.create(user_model = obj)
return obj
Брат
عبد الله
(⌐■-■)
Maxim
(⌐■-■)
Anonymous
hello i have a challange to get anchor data from a django template to view by using ajax here is my template <div class="dropdown-menu dropdown-menu-right" >
{% for classinfo in classinfo %}
<a href="#c{{ classinfo.id }}" class="dropdown-item" data-toggle="tab" id="getclass" name="select_class">{{ classinfo.classname }}</a>
{% endfor %}
</div>
Anonymous
and here is my view def get_class(request):
select_class=request.GET.getlist('select_class[]')
data = list(Subject.objects.filter(class_info_id__classname=select_class))
print(data)
print(select_class)
return JsonResponse(data,safe=False)
Anonymous
and here is my script $(document).ready(function() {
$("#getclass").click(function () {
var select_class = $(this).val();
$.ajax({
url: "{% url 'get_class' %}",
data: {
'select_class': select_class
},
dataType: "json",
csrfmiddlewaretoken: '{{ csrf_token }}',
success: function (data) {
if (data) {
alert(data);
}
}
});
})
});
rtg
Anonymous
How to install django Anyone pls help me?
rtg
I have an error: https://pastebin.com/LKQ16Eu9
rtg
( NameError: name 'account_activation_sent' is not defined ) Why?
Anonymous
𝕬𝖒𝖎𝖗-𝕸𝖔𝖍𝖆𝖒𝖒𝖆𝖉
German
help me pls with view action decorator patch method
i need do this route
/imports/$import_id/citizens/$citizen_id
i don't get how can i add citizen_id here
btw import_id and citizen_id in difference tables
Rahul
I want to create a game like this https://agar.io/ and I am going to use django for backend and unity for ui but I don't know what are the things that I need to do in django
Rahul
Alik
Is it possible to use django google maps without google api ?
Diction10
Good day everyone,
Please I need your help. 🙏🏿
I am trying to use django signals to automatically create Employee as soon as a user registers.
The problem is , the Employee instance is created but the Choice fields are not created.
How can I make this work?
Diction10
If it is allowed, I can paste my models.py file
Mohd
Hi all, how can I restrict non-logged users to access my static files in django?
Charly
Diction10
Diction10
Charly
Anonymous
How to resolve circular error when model import ?
Adams
Hello guys I want to create a system in Django which works with microtik where a user can automatically pay for internet when it has finished, any hint please
Hamouda
Hello guys, now maybe this is not the right place to ask this question, but i really would appreciate an answer, i was working as a Django/ Angular dev and now my company moved me to another position to do QA including doing tests and stuff like this, do you think it's a better job for the future or dev is way better ?
Doragonsureiyā
Ai
How to i deploy my django app in aws or azure
Doragonsureiyā
How to i deploy my django app in aws or azure
Step 1: Open a browser
Step 2: Write down https://google.com or https://duck.com and press Enter
Step 3: In the search box, write down the same words you asked here
Step 4: Read the first results
(⌐■-■)
Use request.FILES to fetch files uploaded into ur views.py function. And keep input type as file in html
(⌐■-■)
Example:
<input type="file" class="form-control" id="filename" name="filename">
def file_to_db(request):
    if request.method == "POST":
        try:
            files = request.FILES["filename"]
            df = pd.read_csv(files, encoding='unicode-escape')
Adhin
class delete(APIView):
def delete(self,request,id):
data = person.objects.get(id=id)
if data is not None:
print("user endee")
data.delete()
return Response({"message":"user deleted succesfully"})
else:
return Response("user not found")
Adhin
when i pass a valid data to backend it not working what is the problem
rakshit
Hey actually I am stuck in an project
rakshit
I am building an web
rakshit
In which I created a model which uploads the image in media folder
rakshit
While showing the image in my html doc, it is not loading
rakshit
Can anyone help?
rakshit
I just checked the console and it show GET http://127.0.0.1:8000/media/shop/images/610e0SrwacL._SL1500 127.0.0.1/:6
png 404 (Not Found)
Julio Cezar
Does anyone use django with multi-db or multi-schemas?
Doragonsureiyā
Does anyone use django with multi-db or multi-schemas?
Don't ask meta questions like:
"Any user of $x here?"
"Anyone used technology $y?"
"Hello, I need help on $z!"
Just ask directly! The better you are at explaining the problem, the more likely you are to get help.
Asking smart questions
Shafquet
Why the link generated after running manag.py is showing error in my browser
rakshit
Shafquet
It gives html 404 error
Shafquet
suman
rakshit
Did you rendered something?
Maxim
William
rakshit
Yup i did
rakshit
I console it is showing GET http://127.0.0.1:8000/media/shop/images/610e0SrwacL._SL1500 127.0.0.1/:6
png 404 (Not Found)
William
rakshit
Yes, I got an image in that folder
William
rakshit
Yes they are same
William
Yes they are same
Check with other image file as well.
Copy 1 image to the app media folder and pass the image name in url.
Anshu
Messi
Hey guys, I’m trying to create a timed email reminder. Basically user enters a date and then the code would send out an email to the user 3 months prior to the date entered. I used the send_mail function to send out a mail
but I’m not sure how to implement the 3 months prior to the code. Thanks!
rakshit