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
Maxim
Campusx Channel on YouTube (in hindi)
rule 1 also applies to materials and documentation
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???
ГуНиСе️
How can I retrive the data from db???
which data? use QuerySet as usual: YourModel.objects.all()
Алекс
http://localhost:8000/?q=test how to get q value, in self.kwargs?
ГуНиСе️
http://localhost:8000/?q=test how to get q value, in self.kwargs?
I think you should rely on request.GET dict. However, you can copy the value to the kwargs before processing the request. view.kwargs['q'] = reqeuest.GET['q']
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
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.
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"
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?
Vice
Hi First makenewmigration And then migrate
That's the code I have been running but still I get the same error sir
Vice
Please send a pic from your error
Thanks it worked I had missed an a comma at the settings.
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() ???
Ivan
I could give you the answer but that would be boring. I will pose you another question: how would you test this?
I'm writing my unit tests, and my unit tests working done, but, I have the doubt, because maybe my object is saving in memory and it not going to work how I spec when I create the UI
Д
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()
Д
Ok, that's all I need it, thank you.
what happens btw if you try to resave it? do you get duplicate ID error?
Д
UNIQUE constraint failed or something
Ivan
what happens btw if you try to resave it? do you get duplicate ID error?
no, not failed, just it saved like you are updating object without changes, I guess
Ivan
because my unit tests working
Д
no, not failed, just it saved like you are updating object without changes, I guess
right, because the Object is still pointing to the same, so it's just an update
Д
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?
Kenechi
What is difference between Django and Django Rest Framework?
The Django rest framework is for building restful APIs.. This APIs can work as the backend of web applications and mobile apps.. Helps in renders data in json format easily
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
Кодиров
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 ???
Кодиров
this question has no answer without reference to a specific model code
class Person(models.Model): fl_name = models.CharField(max_length=100) room = models.CharField(max_length=3) phone = models.CharField(max_length=10) internal_address = models.CharField(max_length=8) section = models.CharField(max_length=100)
Кодиров
where is apiview_api table here ?
class Person(models.Model):
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
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???
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
Prathmesh
Hello where can I get beginners Django projects with source codes
https://youtube.com/playlist?list=PLu0W_9lII9ah7DDtYtflgwMwpT3xmjXY9
Prathmesh
Means I have written 'shop.apps.ShopConfig' in setting.py
Mirco
Means I have written 'shop.apps.ShopConfig' in setting.py
Yup, you forgot to create that class in apps.py
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?