I'm
I'm
Ankit Sharma
raise AppRegistryNotReady("Apps aren't loaded yet.")django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Paritosh
Paritosh
The directory which doesn't contains settings.py is your app
Charly
Lucifer
Database main column missing error kinda arha hai hey anyone know faced these type of issue in django
Charly
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ā
Charly
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
‹m›Javad‹/n›
park seo joon
You have been asking questions all those while
()
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
Charly
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
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
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
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
Alex
Василь
Did anyone faced the 521 error, when project was deployed with cloudflare domain?
C&E&H
C&E&H
Василь
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
Charly
MarKo
Thinking
Can i take a picture? Sorry, my english is very basic
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
Charly
Thinking
Many parameters. Please Charly explain to me.
Charly
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.
Charly
Jimmies San
Thinking
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
Miracle
It’s
Miracle
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?
Jimmies San