Sleeping
File "C:\Users\hp\AppData\Local\Programs\Python\Python310\lib\site-packages\django\utils\_os.py", line 29, in safe_join
raise SuspiciousFileOperation(
django.core.exceptions.SuspiciousFileOperation: The joined path (S:\cdn.jsdelivr.net\npm\bootstrap-icons@1.5.0\font\bootstrap-icons.css) is located outside of the base path component (C:\Users\hp\Desktop\sqlite\project\static)
[14/Apr/2022 13:40:23] "GET /static/assets/https%3A/cdn.jsdelivr.net/npm/bootstrap-icons%401.5.0/font/bootstrap-icons.css HTTP/1.1" 500 59
Not Found: /{% static 'assets/images/icons/favicon.ico
[14/Apr/2022 13:40:24] "GET /%7B%%20static%20'assets/images/icons/favicon.ico HTTP/1.1" 404 4380
Sleeping
In terminal this error occurred
RedPilledRebels
@aaxxios the error was occurring because I was logged in as admin while simultaneously trying to browser the host.
This was creating a conflict because the authticated Users(where admin automatically goes) and Customers(where normal users should go)
Your wish of Goodluck really helped me out bro
Kinder #pupu
Hi.
Maybe someone knows how to build an orm query to get a list of objects and their number?
Example: <QuerySet [{'company__campaign__activecampaign': [objects], 'total': 1}]>
Vikash
How to use cache in apiview ? For filter in django rest framework
N.P
How can I retrive the data from db???
Алекс
http://localhost:8000/?q=test
how to get q value,
in self.kwargs?
ravi
Hello guys..
I have face some problem
When foreign key use in many more model so .. call one model by api..all related model call asynchronous..that data loading process slowing..
How to solve..
Дмитрий Борисов
Zhaks
Problem:
There are records in the database where some fields have null value
Question:
How can these values be replaced with others in the serializer for this model?
Malik
Hello guys! What problem CORS blocked?
CORS_ALLOWED_ORIGINS = [
"http://localhost:3000",
"https://greenwich.netlify.app"
]
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_CREDENTIALS = True
CORS_ALLOW_METHODS = [
'DELETE',
'GET',
'OPTIONS',
'PATCH',
'POST',
'PUT',
]
CORS_ALLOW_HEADERS = [
'accept',
'accept-encoding',
'authorization',
'content-type',
'dnt',
'origin',
'user-agent',
'x-csrftoken',
'x-requested-with',
]
Anonymous
# template.html
{% for obj in object_list %}
<td>{{ obj.model_method }}</td>
{% endfor %}
# models.py
class Foo(models.Model):
...
def model_method(self):
qs = self.get_descendants(include_self=True).prefetch_related('outlines').aggregate(**obj)
return qs
Hello
. Here I have identical requests (similar), how can I access the method only once in forloop and rename it (the method) to a new variable in order to access a local variable (similar to as)
If there are other tips for implementation, I will be glad :)
UPD*
Found how to implement
using builtin method in templates used
{% with aggregate=obj.model_method %}
{{aggregate.field}}
...
{% endwith %}
Thus, the model method is called only once in the for loop. Now similar queries have become 10 times smaller)) but they exist
Harry gorilla
from cart.forms import CartAddProductForm
def product_detail(request, id, slug):
product = get_object_or_404(Product, id=id,slug=slug,available=True)
cart_product_form = CartAddProductForm()
return render(request,'shop/product/detail.html',{'product': product,'cart_product_form': cart_product_form})
How can i convert this into class based view? I have tried this
class DetailView(DetailView):
model = Product
template_name = "shop/product/detail.html"
Any additionals to add to make my class based views complete?
Harry gorilla
from cart.forms import CartAddProductForm
def product_detail(request, id, slug):
product = get_object_or_404(Product, id=id,slug=slug,available=True)
cart_product_form = CartAddProductForm()
return render(request,'shop/product/detail.html',{'product': product,'cart_product_form': cart_product_form})
How can i convert this into class based view? I have tried this
class DetailView(DetailView):
model = Product
template_name = "shop/product/detail.html"
Any additionals to add to make my class based views complete?
The tutorial am using just introduced from cart.forms import CartAddProductForm, cart_product_form = CartAddProductForm() and 'cart_product_form': cart_product_form. My class based view was just working well before, but now am confused on how i can make it work again after the tutorial introduced those new stuff
Harry gorilla
I love class based views, but unfortunately, most tutorials in the internet use function based views. As am still a newbie, converting function based view is quite a challenge for me.
cj
Ruzan
Function is way more simple than class based view
Ruzan
Check cbv.co.uk for class based views
Ruzan
ccbv.co.uk
Harry gorilla
Function is way more simple than class based view
meeh, in class based, i just write 3 lines of code and i have done so much which if i would have used function based, it can even go upto 10 lines of code. So i find class based view to be easy
cj
Function is way more simple than class based view
until you know how to use CBV in the proper way ¯\_(ツ)_/¯
but it all depends on the view requirements, there are edge cases where a FBV would be straightforward to be used, still CBV are way easier to write —and read— and understand how they work
Ruzan
Yes
Harry gorilla
Here is an example of class based view that does the same thing as function based view
# def product_list(request, category_slug=None):
# category = None
# categories = Category.objects.all()
# products = Product.objects.filter(available=True)
# if category_slug:
# category = get_object_or_404(Category, slug=category_slug)
# products = products.filter(category=category)
# return render(request,
# 'shop/product/list.html',
# {'category': category,
# 'categories': categories,
# 'products': products})
class ListView(ListView):
model = Product
template_name = "shop/product/list.html"
Doragonsureiyā
Vice
Hello am new here
Still a novice with Django
Questions is am trying to update the sql db
But I get this error 'modelnotfound' how do I resolve it?
ire
ire
Ivan
Hi, I have a question, when in a model I run the next code:
mymodelinstance = Model.objects.create(params)
mymodelinstance is it have an id ?? .... or I need to do mymodelinstance.save() ???
Д
Д
Д
how do you make sure that the object would be in the database?
Milad
Hi!
Ivan
so, you say you can look at the ID from the object itself?
Just I want to know if I write a code like this, It's going to work fine.
PrecioMayoreo.objects.create(
producto=producto,
cantidad=datos_mayoreo.get('cantidad'),
precio=datos_mayoreo.get('precio')
)
I want to know, if it's sufficient to save the object, or I need to save it later like this
precio = PrecioMayoreo.objects.create(
producto=producto,
cantidad=datos_mayoreo.get('cantidad'),
precio=datos_mayoreo.get('precio')
)
precio.save()
Д
Ivan
Д
UNIQUE constraint failed or something
Ivan
because my unit tests working
Д
but you could have solved it by looking at the ID of the object and then doing a new query from the DB with that precise ID
Д
if the object is returned properly, it's in the DB
Ivan
right, because the Object is still pointing to the same, so it's just an update
that's right, thank you, the problem was, every you run
python manage.py test
django create a test database, run migrations, run your unit tests, and later, drop that database, I could not see ID 😅
Д
Ivan
unless the object reference itself has .id
yes, except when I have this code
PrecioMayoreo.objects.create(
producto=producto,
cantidad=datos_mayoreo.get('cantidad'),
precio=datos_mayoreo.get('precio')
)
well, It was simple, Just I had a doubt.
YUSUF CR
What is difference between Django and Django Rest Framework?
YUSUF CR
Will it be easy after I learn Django well?
Anonymous
Guys i need good resource for building learning management system by django..
Yves le Curseur
Django Allauth Customized Login Template Not Working - Stack Overflow
https://stackoverflow.com/questions/69029008/django-allauth-customized-login-template-not-working
Yves le Curseur
Кодиров
SELECT *
from apiview_api
where room in (
select room as r
from apiview_api
where fl_name like "%513%" OR
internal_address like "%512%") how this query is written in Django ???
Maxim
Maxim
Кодиров
neruslvn
Hello, when creating a post model, I added a category, when creating a post by the user, I want to give him the opportunity to choose a category. how to do it?
simran
anybody have geekyshows django ppt
Arham
Doragonsureiyā
Check inbox
We know the rules are quite long, but read them, because on average, hundreds of users are banned from this network every week. Reading the rules will help in avoiding this pitiful fate.
Bekzhan
select *
from (select distinct on (t1.id) t1.company_name, t1.messages , t1.from_whom , t1.for_whom, t1.create_time , t1.update_time
from tbl_vacancy_response t1
order by t1.id , t1.create_time desc ) v
order by update_time ,can you help write a request for Django ORM
Amit
Can anyone apply password validation in signup form???
Vaibhav
Rohan
Doragonsureiyā
Can anyone apply password validation in signup form???
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
Ruzan
!meta
Doragonsureiyā
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
Vice
Hello where can I get beginners Django projects with source codes
Prathmesh
Hello what should I do here.
shop.apps not contain shopconfig class
Mirco
Prathmesh
Means I have written 'shop.apps.ShopConfig' in setting.py
Mirco
k
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?