John
John
use signal
i doesn't have any idea about that did u have any example
John
and i use django for rest api only so is its work for that ?
international
Can anybody help me
007
How to dynamically set 'DJANGO_SETTINGS_MODULE' in celery.py , Based on different django settings
Harsh
what is that
In your model class Override the default save model and call the superclass's save method at the end. Lemme send you an example
Harsh
In your model class Override the default save model and call the superclass's save method at the end. Lemme send you an example
https://github.com/infinity-plus/django-url-shortener-api/blob/c8a6f3e8d6e539c736d6048db154608e64bf9791/api/models.py#L24
Jerome
How to dynamically set 'DJANGO_SETTINGS_MODULE' in celery.py , Based on different django settings
Look at the Django CookieCutter project, it is an extremely well made boilerplate, you'll find how they manage that
Salesforce
Any one needs python rest api django full course by durga sir ping me.
Python - ERP
Sequence of Path matters? urlpatterns = [ path('meetups/', views.meetups,name="all-meetups"), path('meetups/success',views.confirm_registration,name="confirm-registration"), path('meetups/<slug:meetup_slug>',views.meetupDetails,name="meetup-detail"), ]
Nayan
Hi can someone help me !! I have 5 groups , each group have different permission which i have assign to them Now how can i use this groups in views.py with function based so that the views will behave based on group permission also i think i need to check which user is associated to which group ?? I am confused please help !!!
Damilola
Hi can someone help me !! I have 5 groups , each group have different permission which i have assign to them Now how can i use this groups in views.py with function based so that the views will behave based on group permission also i think i need to check which user is associated to which group ?? I am confused please help !!!
CBVs allow you group related logic, it also help maintain the Django DRY principle. You can create an abstract CBV with permission mixins as your want, name each CBV a permission mixin similar to the group, then reuse it anywhere you want.
Nayan
I saw some examples with cbv and fbv but one could not able to get it in both the cases how to use it with 5 groups , the example are available only with 1 group Ex for fbv Def somegroup(user) If user: Return user.group.filter(name='student').count() == 0 What if user belongs with 2 groups at the same time or it refers to some other group ... It is confusing me up.
Nayan
The decorator we use here is @user_passes_test(some group)
Nayan
Sure will do it .
Inuk
@boiyelove sorry, mistake in spam protection, i'll look into it
Damilola
@boiyelove sorry, mistake in spam protection, i'll look into it
Thanks. Sadly I lost all the info I typed in response to Nayan detailing how to help solve his problem. Thanks again for the unban
Inuk
Sure will do it .
this is what @boiyelove said: https://docs.djangoproject.com/en/3.2/topics/auth/default/#permissions-and-authorization Use custom logic for texting user has the right perm https://docs.djangoproject.com/en/3.2/topics/auth/default/#django.contrib.auth.mixins.UserPassesTestMixin This is the permission required decorator for FBV; https://docs.djangoproject.com/en/3.2/topics/auth/default/#the-permission-required-decorator This is the mixin for CBV https://docs.djangoproject.com/en/3.2/topics/auth/default/#the-permissionrequiredmixin-mixin If you're worried your user belongs to multiple groups (although I'm unsure why this is a problem), you can 1. create group such that permission 1 belongs to group a but not group b OR 2. Do your permission checks based on "permissions" directly and not based on groups.
Nayan
Great. Glad you were about to recover it. Nayan please read this for context.
Yes let me figure it out tomorrow if it did not work i will represent what i am trying to do .
Abdalwhab
How create form like Google forms in Django I need add field without add it in models file
Anonymous
How create form like Google forms in Django I need add field without add it in models file
You can create a form not related to models. create a class inherited from djanfo.forms.Form
James
Hellow. Any one who can help me best site or youtube chanel that is good for integrating django with angular js
Neeraj
Yes I want..will you please share to me?
https://youtube.com/c/FeelFreeToCode
Neeraj
Or use geeky show chanel also for this
Enes
https://www.hizliresim.com/1wdkwhi
Enes
please help guys i have a modal which is get data with ajax for product but when i try to use imagefield in this modal it says that you need to serialize
Enes
$('.add-quick-view').click(function(){ var catid; catid = $(this).attr("data-productid"); $.ajax( { type:"GET", url: "/getproduct/", data:{ product_id: catid }, success: function( data ) { document.getElementById("prdct_title").innerHTML = data.product_name; document.getElementById("prdct_price").innerHTML = data.product_price+'$'; document.getElementById("prdct_details").innerHTML = data.product_details; document.getElementById("prdct_photo").innerHTML = data.product_photo; document.getElementById("prdct_title").innerHTML = data.product_name; console.log(data) } }) });
Enes
def get_product_info(request): if request.is_ajax and request.method == "GET": product_id = request.GET['product_id'] print(product_id) obj = Product.objects.get(id=product_id) product_name = getattr(obj, 'name') product_photo = getattr(obj, 'photo') product_price = getattr(obj, 'price') product_details = getattr(obj, 'details') return JsonResponse({"product_name":product_name,'product_price':product_price,'product_photo':product_photo,'product_details':product_details}, status = 200) else: return JsonResponse({}, status = 400)
Enes
**url path('getproduct/', views.get_product_info, name='get-product-info'),
Enes
the error on browser console TypeError at /getproduct/ Object of type ImageFieldFile is not JSON serializable Request Method: GET Request URL: http://127.0.0.1:8000/getproduct/?product_id=2
Enes
the problem is in there; in views : product_photo = obj.photo.url in js: document.getElementById("prdct_photo").src= data.product_photo;
Chikal
Excuse me.. I have a question.. #ask how to submit data from form <form>, and fill the link with its data from form using javascript ? example, I have a code: <script type="text/javascript"> function showInput() { document.getElementById('display').innerHTML = document.getElementById("name").value; } </script> the form is: <form> <input name="name" type="text" id="name"> <input type="submit"> </form> <button onclick="showInput()"></button> <span id='display'></span> then there is a link : <a href='https://api.whatsapp.com/send?phone=6281909555392&text=Halo%20Iam%20--I want full fill this part with the data from input name--%20wanna%20ask"> how to do it ? is it possible? If I click the showInput button, the name display by span id=display, but inside the link its not appear, how to do it ?
Anonymous
Hi all, I need help. How to start learning Django? Can you please share any ideas guy's.
Jerome
Hi all, I need help. How to start learning Django? Can you please share any ideas guy's.
You can take a first step with the William S. Vincent book for beginners then try to find good tutorials that seems good for you
Anonymous
You can take a first step with the William S. Vincent book for beginners then try to find good tutorials that seems good for you
Hi Jerome, Thank you for your information. I need another one help. Can you please share django with jwt api authentication tutorial or blog or link.
Anshu
Hi all, I need help. How to start learning Django? Can you please share any ideas guy's.
There's a course of Jose portilla on Udemy which basically I used, the course is designed basically for beginners Ping me if you need YouTube tutorial also
Swati
Hey.. Can django be integrated wd ai software.. I want to make a project for my final yr engineering.. Can someone suggest mr ideas n how to do that?
khairul
Sahil
Hello guys, I don't have web development knowledge at all but I kNow Python. Then how to start learning django ?
Sahil
Any very basic tutorial for it ?
Sahil
Also do we need to learn rest api along with django ?
Sahil
Django + Database + Rest ??
NOV
Django + Database + Rest ??
Django&rest+vue+postgres+
Anshu
Hey.. Can django be integrated wd ai software.. I want to make a project for my final yr engineering.. Can someone suggest mr ideas n how to do that?
Yeah, you can follow this tutorial it's awesome https://youtube.com/playlist?list=PLgjw1dR712jqPLCDvJK6uCNCTHSfgAS8b
William
While implementing on views you need to import the permission classes and use it permission_classes list
Anonymous
hello, what's the problem here, error message 'ItemAdmin' object has no attribute 'urls', https://pastebin.com/Wtfz3hMN, https://pastebin.com/ci8pxb5W
Jaya
Hello, can anyone tell me how to filter many to many fields, i want to get only that field which contains some of the user present in that many to many field
luna
filter many to many with user__in=[User.objects.filter(**kwargs))]
Jaya
See i have a class with a field group users which is many to many field and a field group id and i want to get the group from the group id and name of users present in group users
William
See i have a class with a field group users which is many to many field and a field group id and i want to get the group from the group id and name of users present in group users
Give us more detail. Give us some examples. In which table ManyToMany field is there and to which model/table it is referring.
Jaya
Ok
Jaya
class groupchat(models.Model): groupusers=models.ManyToManyField(User,blank=True) groupid=models.Foreignkey(Group,on_delete=cascade) groupname=models.CharField(max_length=255) This is the model and i have group id and name of two users now i want to fetch the group name with the help of data i have
Jaya
Hope you get my question or do i need to explain it again😅
William
Use prefetch_related on the group users field.
William
Can you please write the code
GroupChat.objects.prefetch_related(Prefetch('groupusers', queryset=User.objects.filter()))
rtg
Hi! How can i upload image (imageField) to static/img/installation/ folder?
rtg
Is this correct:
Mani
What's easiest way to redirect to the page back after login was attemped, in @login_required pages ?