‹m›Javad‹/n›
Search on YouTube.
Do you know a good channel?
Ankit Sharma
raise AppRegistryNotReady("Apps aren't loaded yet.")django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Paritosh
The directory which doesn't contains settings.py is your app
Lucifer
Database main column missing error kinda arha hai hey anyone know faced these type of issue in django
Dullah
Hello everyone I’m moving from sqlite3 to postgresql, i have successfully dumped the data buy i keep getting the error: psycopg2.errors.CannotCoerce: cannot cast type time without time zone to timestamp with time zone LINE1:…ted” TYPE timestamp with time zone USING “created”::timestam… The above exception was the direct cause of the following exception: … django.db.utils.ProgrammingError: cannot cast type time without time zone to timestamp with time zone LINE1:…ted” TYPE timestamp with time zone USING “created”::timestam… i am using psycopg2-binary v2.9.9
kasra
Hi A site for removing html slider codes
Doragonsureiyā
Hi A site for removing html slider codes
What are you talking about?
kasra
What are you talking about?
I want a site for html ready codes
Charly
I want a site for html ready codes
So, nothing to do with django?
Doragonsureiyā
I want a site for html ready codes
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.
kasra
So, nothing to do with django?
I'm a Django user myself, but I need HTML codes
park seo joon
Guys, someone has the views code. To show a post and its comment and send a comment? can you send🥲
It's depends on your model instead of using a models subclass alone why not using custom models along and you can use model manager for display the time and filter what ever you want
park seo joon
I din't notice
What kind of app are you building
park seo joon
You have been asking questions all those while
Ankit Sharma
What exactly are you doing ?
Trying to implement django-channels
Charly
Trying to implement django-channels
More specifically to get that error
Lucifer
Did you make and run migrations?
Yeah but when running migration giving error
()
Anyone give django book
()
Free book django book
Doragonsureiyā
Anyone give django book
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Lia
Hi, i'm doing a project, about ads, following Django for everybody, from Dr. Chuck's course on coursera. So I'm in the last part of the series, and I'm having some issues. So for context, this is an app, Ads, CRUD, it has, title, text, prices, pictures, as well as comments and favorite, unfavorite. So the last part is, adding a search bar, that one works, added tags, works as well. But I'm having one single error, when I use the search bar, it's getting some duplicated ads. And is suggesting using the distinct(): Test completed: Found menu bar at the top of the page Found more than one ad when searching for 'HHGTTG_42 1717626368'. You probably need to add distinct() after select_related().distinct() ... in your views.py so it shouldn't find more than one ad with that....
Lia
You probably need to add distinct() after select_related().distinct() ... in your views.py
Lia
how to use select_related.distinct() ? it's a SQL database
Lia
lol is a MySQL db
Charly
how to use select_related.distinct() ? it's a SQL database
like that just call that function on your query set
Lia
let me show you, is a get request, to show: class AdListView(ListView): model = Ad # Specify the model you're working with template_name = "ads/ad_list.html" def get(self, request): strval = request.GET.get("search", False) if strval: query = Q(title__icontains=strval) query.add(Q(text__icontains=strval), Q.OR) ad_list = Ad.objects.filter(query).select_related().distinct().order_by('-updated_at') else: ad_list = Ad.objects.all().select_related().distinct().order_by('-updated_at') # Apply distinct() explicitly ad_list = ad_list.distinct() if request.user.is_authenticated: favorites = list(request.user.favorite_ads.values_list('id', flat=True)) else: favorites = [] for obj in ad_list: obj.natural_updated = naturaltime(obj.updated_at) ctx = {'ad_list': ad_list, 'favorites': favorites, 'search': strval} return render(request, self.template_name, ctx)
Lia
model = Ad # Specify the model you're working with template_name = "ads/ad_list.html" def get(self, request): strval = request.GET.get("search", False) if strval: query = Q(title__icontains=strval) query.add(Q(text__icontains=strval), Q.OR) ad_list = Ad.objects.filter(query).select_related().distinct().order_by('-updated_at') else: ad_list = Ad.objects.all().select_related().distinct().order_by('-updated_at') # Apply distinct() explicitly ad_list = ad_list.distinct() if request.user.is_authenticated: favorites = list(request.user.favorite_ads.values_list('id', flat=True)) else: favorites = [] for obj in ad_list: obj.natural_updated = naturaltime(obj.updated_at) ctx = {'ad_list': ad_list, 'favorites': favorites, 'search': strval} return render(request, self.template_name, ctx)
Lia
these are some references: # References https://docs.djangoproject.com/en/4.2/topics/db/queries/#one-to-many-relationships # Note that the select_related() QuerySet method recursively prepopulates the# cache of all one-to-many relationships ahead of time. # sql “LIKE” equivalent in django query https://stackoverflow.com/questions/18140838/sql-like-equivalent-in-django-query # How do I do an OR filter in a Django query?# https://stackoverflow.com/questions/739776/how-do-i-do-an-or-filter-in-a-django-query https://stackoverflow.com/questions/1074212/how-can-i-see-the-raw-sql-queries-django-is-running
ERS1N
How to make search system in the website ?
Charly
How to make search system in the website ?
It is basically write a view where you get the search terms and write querysets for it
Lia
It is basically write a view where you get the search terms and write querysets for it
yes, in this case, just making something else, is like a get request inside of a view that's already inside... the assignment is asking for me to make use a get request, instead of creating another view...
Lia
well then do it 👍
lol, 3 days in, will share resuls once I figure it out... it's complaining due to duplicated stuff 😭 so idk something will pop up
Greiberth P.
Yo folks good morning, have anyone used django q2?
Doragonsureiyā
Yo folks good morning, have anyone used django q2?
Please don't ask meta questions like: - Any user of $x here? - Anyone used technology $y? - Hello, I need help on $z! Just ask about your problem directly! If you don't know what to ask, please read: http://catb.org/~esr/faqs/smart-questions.html
Haya
I have two project in one domain can get fk from one to another it's project not an app
Greiberth P.
How would you hadle a task using django q2 to excecute after anotherone (we need the params of the previous one) To run in specific time, like example every 1st day of the month
Mirco
like Celery, Django Q has chain feature
Abraham
while trying to use channels am getting not to know my asgi file i tried so many approaches but it doesnt work here is the error log mw_instance = middleware(adapted_handler) TypeError: init() takes 1 positional argument but 2 were given and here was my asgi file import os from channels.routing import ProtocolTypeRouter, URLRouter from django.core.asgi import get_asgi_application from channels.auth import AuthMiddlewareStack from apps.products import routing as products_routing os.environ.setdefault("DJANGO_SETTINGS_MODULE", "conf.settings") application = ProtocolTypeRouter({ "http": get_asgi_application(), "websocket": AuthMiddlewareStack( URLRouter( products_routing.websocket_urlpatterns ) ), })
nizzer
Can I get help on how to assign permission to a specific group or user in html view
Василь
Did anyone faced the 521 error, when project was deployed with cloudflare domain?
Charly
Did anyone faced the 521 error, when project was deployed with cloudflare domain?
Maybe but that doesn't mean it will be the same issue as you. So as this not django but your deployment, ask in the offtopic group and provide all details along with logs.
Василь
thanks, I already understood that I forgot to change allowed hosts
Thinking
Hello. I am working on an academic project in which I am asked to create a solution to support the database. After several tests with pg dump, pipe and popen the db is downloaded empty. By the system command, the download goes well but in python it gives me several errors. Can you help me with this? thank you
Thinking
Can i take a picture? Sorry, my english is very basic
Charly
Can i take a picture? Sorry, my english is very basic
No, images are forbidden here. And the errors are text. You can read rule 5 to know how to share it
Doragonsureiyā
Can i take a picture? Sorry, my english is very basic
Python groups in other languages (⚠️Not managed by us ‼️) Amharic @python_amharic Arabic @arabipython Azerbaijani @azepug Chinese @pythonzh French @python_francais German @pythonde Hebrew @pythonisrael Hindi @pyhindi Tamil @pythontamilcommunity Indonesian @pythonid Italian @python_ita @pythonita Kazakh @python_kz Malaysia @pythonmalaysia Persian @pyfarsi Portuguese @pythonbr Russian @ru_python_beginners @ru_python @python_scripts Spanish @PythonEsp Swahili @python_eafrica Turkish @python_tr Uzbek @python_uz If you have an active and well managed group that you want to be listed there, ask in the Meta group, link in the rules page.
Thinking
No, images are forbidden here. And the errors are text. You can read rule 5 to know how to share it
View.py def backup(request): command = ['pg_dump'] process = subprocess.Popen(command, stdout=subprocess.PIPE) output, error = process.communicate() response = HttpResponse(content=output, content_type='application/sql') response['Content-Disposition'] = 'attachment; filename=backup.sql' return response And the db dowload with 0 tables and the content say None. I dont know if this problem is with the configuration of postgres in settings.py
Thinking
Many parameters. Please Charly explain to me.
Thinking
Like the database
The first thing I did was create db.py where I save the postgres config, then in settings call databases = db.postgres. I did the migrations and checked that they were successful. Then I started testing with this config that I showed you. Excuse me Charlie, I'm starting now with django and there are things that I don't understand well. That's why I told you to explain to me.
Thinking
If you run pg_dump it has nothing to do with Django's config. You need to pass all the parameters as if you called pg_dump from terminal
you're right. and from the system command it works very well. Now as part of the project, I need to create a link so that when the system administrator clicks, I can backup the database. And it's crazy, because I haven't found the solution yet.
Thinking
Just replicate the system command in your python subprocess code. Did you try?
Type error, backup() missing required positional arguments. Before def backup(request): After def backup():
It’s
I can host my project in Cpanel, my database is mysql. Now, how can i bata backup system doing?
It’s
Batabase backup?
Charly
Eben
If I set DEBUG to True. Static files are served but media files(files from database) disappear. How can I fix this.
Sam
am i allowed to ask questions about DRF?