Hobeal
Hello, I just want to know best practices for Django staticfiles. It's better to user root folder or app folders ?
Jerome
Hello, I just want to know best practices for Django staticfiles. It's better to user root folder or app folders ?
different approches... i mostly use root because it's cool as my projects are not over extended. Add whitenoise pkg, all fine )
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
Jerome
Also you save space because you don't duplicate statics right?
you got a copy if you "collectstatic" no matter what, but still managable
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
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?
I use the layout from cookiecutter, why? because it has almost everything I use in the projects I work on
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
عبد الله
(⌐■-■)
AttributeError: partially initialized module 'pygame' has no attribute 'color' (most likely due to a circular import) I am getting this error when importing pygame
You can also refer to following link. https://stackoverflow.com/questions/7336802/how-to-avoid-circular-imports-in-python
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); } } }); }) });
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
𝕬𝖒𝖎𝖗-𝕸𝖔𝖍𝖆𝖒𝖒𝖆𝖉
Anonymous
pip install django :/
Have to do this on anaconda prompt?
Anonymous
Have to do this on anaconda prompt?
Open terminal, run python3 -m pip install django
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
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
Doragonsureiyā
If it is allowed, I can paste my models.py file
To share code or error tracebacks, use a pasting service, like: - https://linkode.org - https://dpaste.org
Mohd
Hi all, how can I restrict non-logged users to access my static files in django?
Charly
Is it possible to use django google maps without google api ?
What do you mean with "without google api"?
Diction10
https://linkode.org/#LuttphvUYOay5DleYKJVL2
Hee is the code Please do check it out
Alik
What do you mean with "without google api"?
In the documentation of the django google maps they say you have to add your GOOGLE_MAPS_API_KEY
Alik
and whats the issue whit that?
The problem is that i dont have an api key and i dont know how to get it and i guess it is not free
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 ?
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?
mr y
While showing the image in my html doc, it is not loading
https://learndjango.com/tutorials/django-file-and-image-uploads-tutorial
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
Shafquet
It gives html 404 error
Shafquet
suman
rakshit
Did you rendered something?
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)
rakshit
Yes, I got an image in that folder
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.
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!