Д
Hi all, how to do migration ( makemigration and migrate) when there are references in our app's models eg : Foriengnkey, one2one, m2m. What should be the order of commands execution?
makemigrations comes always first - the Models or Relationships between don't have anything to do with this. only whether you change them or not.
Doragonsureiyā
Thanks 👍
You're welcome! 😊
R@kesh
C:\djangoproject\fbvcrudproject>py populate.py File "C:\djangoproject\fbvcrudproject\populate.py", line 2 os.environ.setdefault('DJANGO_SETTINGS_MODULE','fbvcrudproject.settings') IndentationError: unexpected indent
R@kesh
What is this error ??
Sanji
What is this error ??
Give proper indentations
pavan
[15/04, 6:23 pm] Pavan: if something in list how to get other than something [15/04, 6:24 pm] Pavan: [a,b] [15/04, 6:24 pm] Pavan: if a i have how to get b
pavan
[a,b]
pavan
if a i have how to get other than a
pavan
without for loop
Д
if a i have how to get other than a
are you asking how to index the list? this is too basic of a question
pavan
index i know
pavan
b=a+b-a
pavan
it shows other thing
SHIVA DATHA
Can we develop SharePoint data to be displayed as visualization in django
SHIVA DATHA
I am new to this
SHIVA DATHA
Someone please guide
lubaskinc0de
around the world
SHIVA DATHA
Previously worked as automation developer
YUSUF CR
Can you share with your projects which created by django. It is interesting
Д
No
why not?
YUSUF CR
Why?
Д
where's the project sharing group - I want to see what I can learn from projects
Д
there's probably a github repository somewhere with tons of good django projects
Maxim
Be kind
be kind, refrain from offtopic
YUSUF CR
They say onemore reasons of learning django is it has a huge and good community. What a community is this!
Д
They say onemore reasons of learning django is it has a huge and good community. What a community is this!
this community is for solving technical problems. be the change you want to see in the world, and don't complain.
Эндейл
How can i make django app in which users approved by admin before accessing the home page
T
How can i make django app in which users approved by admin before accessing the home page
You can add a field to your custom user maybe. If the user has is True then you can authorise for the home page. Or you can use permissions.
ГуНиСе️
Hi, all! I've got a code that deletes all entries but three last. ours = SearchQuery.objects.filter(user_id=user.id).order_by('-updated_at').values_list('id') SearchQuery.objects.filter(id__in=ours[3:]).delete() It produces the following SQL (indenting is mine). DELETE FROM "appname_searchquery" WHERE "appname_searchquery"."id" IN ( SELECT V0."id" FROM "appname_searchquery" V0 WHERE V0."id" IN ( SELECT U0."id" FROM "appname_searchquery" U0 WHERE U0."user_id" = '0206f3bb-dd41-4226-9360-8f4943934137'::uuid ORDER BY U0."updated_at" DESC OFFSET 3 ) ) How do I optimize it and get rid of the nested redundant select from V0?
rishav
Anyone can give code for OTP based login
Ivan
How can i make django app in which users approved by admin before accessing the home page
yo can add a oneToOne relathinship to a new model Called profile, called, authorized for new users, later, create your custom loginrequired decorator, and used instead of default login_required recorator.
Harsh
Anyone can give code for OTP based login
Need email based authentication or Mobile number
Harsh
Email is free to use
Chirag
I got task to implement Google Calendar integration using django rest api and have to use oauth mechanism to get user calender access. Anybody know how to do this, please let me know, i have only 16hr left to submit the task.
Optimus
How to use StreamingHttpResponse using pandas dataframe as a CSV file?
Optimus
I got task to implement Google Calendar integration using django rest api and have to use oauth mechanism to get user calender access. Anybody know how to do this, please let me know, i have only 16hr left to submit the task.
Go to google console page ,create a project and your app and set your Oauth2.And get the South token, use Python library social-auth for authentication
lubaskinc0de
who knows the repo on github with the implementation of private messages on channels and django
Eslam
how can do like this in templates proudct.objects.filter(fk_Category__image='Accessories')
Eslam
{% for product in product.filte|fk_Category__image:'Accessories' %} i try but -_-
lubaskinc0de
how can do like this in templates proudct.objects.filter(fk_Category__image='Accessories')
#views.py def index(request): objects = #your filter return render(request,"your_app/your_template.html",context={"objects":objects})
lubaskinc0de
and #template.html {% for i in objects %} {{i}} {%endfor%}
RIP
thanks in advance, how to use django serializers.serialize("json", SomeModel.objects.all()) , if the SomeModel has a choice field, all question releated in google are with DRF not pure django, Can I do this by simple Django?
Altamash
Create a file name serializer.py
ГуНиСе️
RIP
so I need rewrite serializer function?
RIP
not use build in from django.core import serializers ?
RIP
It is far way hard for me
ГуНиСе️
thanks in advance, how to use django serializers.serialize("json", SomeModel.objects.all()) , if the SomeModel has a choice field, all question releated in google are with DRF not pure django, Can I do this by simple Django?
Basically, you can't convert easily an object to JSON. You need a procedure converting the object to a dict first. On the flip side, you can call the .values() method to directly retrieve dicts with QuerySet. But I don't imagine what a problem is with the choice field.
ГуНиСе️
It is far way hard for me
https://docs.djangoproject.com/en/3.2/ref/models/querysets/#values
ГуНиСе️
try to replace .all() with .values() and you don't need to call serializers.serialize
RIP
so I dont need to call serialize to output a json if I want some custom result for a queryset, right, I should handle the queryset at backend to Json dump or dictionary them then pass it to template?
RIP
I can not make it ,so I have to replace our my choice field to foreign key, it is so hard
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - https://dpaste.org - https://linkode.org - https://hastebin.com - https://bin.kv2.dev If you posted a wall of text, go back and delete it.
RIP
ok.
RIP
I will check and try to learn more
ГуНиСе️
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - https://dpaste.org - https://linkode.org - https://hastebin.com - https://bin.kv2.dev If you posted a wall of text, go back and delete it.
RIP, from the code you deleted here and I saw in a notification tray, you also need to convert the dicts to strings before emitting them in the template. I'd personally register a custom tag for this converting right in templates. But if you're new with Django, you can call to json.dumps in the view to pass ready strings through context.
ГуНиСе️
Oh well, Django already has a similar template tag, json_script. Which however additionally wraps JSON into <script> HTML tag.
RIP
someone told me I can make a var key value in JS and just translate it to what I needed. I believe it is a easy way I can understand.
Ли
Straight to the point: I uploaded the project to the virtual machine, runserver started working and everything seems to be fine Problem: It is necessary to make the project load at the domain address, I don’t know how to install, runserver works on port: 8000, but the page does not load, because I don’t know how to add port 8000 with the domain Please help, I checked everything on the Internet, it does not work I would be grateful if there is a link to the documentation, or just advice if you have configured the machine before ❤️
Ли
Sounds like you've got a firewall blocking connections to the port. Did you check the docs? There is a special section with examples about deployment.
Yes, all settings are specified settings.py it works normally, but the result is the same, I don't understand what the problem is, maybe I'm not specifying something correctly in the virtual machine?
Александр
Hello everyone. I am using "self" in a ForeignKey field. Is it bad? I'm a newbee, so I am not sure. I found references to "self" in the docs for ManyToMany field only.
ГуНиСе️
Yes, all settings are specified settings.py it works normally, but the result is the same, I don't understand what the problem is, maybe I'm not specifying something correctly in the virtual machine?
manage⁠.py runserver command is meant for local development. In production, on the VPS, you should use some web-server like Nginx or Apache.
Александр
are you having a problem?
I'm just not sure is it correct or not. Right now everything is working as expected, but what if there would be some problems which I can't see for now?
Александр
I think it's all right
I could not find any references in docs, where "self" is used in ForeignKey...
Akobir
I could not find any references in docs, where "self" is used in ForeignKey...
https://docs.djangoproject.com/en/4.0/topics/db/examples/many_to_one/
Александр