Re: View "functions" that are callables?

2024-05-15 Thread Anthony Flury
I can't see why not - as far as Python is concerned a callable is a
callable.

There is a deep in the weeds way for a caller to determine if a callable is
a __call__ method on a class, but I really doubt Django does anything close
to that - what would be the benefit.

On Wed, May 15, 2024 at 8:39 PM Christophe Pettus  wrote:

> Hi,
>
> I'm surprised I don't know this, but: Can a view "function" in a urlconf
> be a callable that is not actually a function, such as a class with a
> __call__ method?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/F70DCB4E-1307-42C2-AC62-CA2DC98DCD5B%40thebuild.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN0Bb7fx5t1FC5WKRwkE31%3DYvnTVRoSi_hYqDB%2B%3DZG2-7zonzg%40mail.gmail.com.


Cascading drop down list

2024-05-15 Thread kateregga julius
Hi. I need help on implementing
Cascading drop downlist in django using functional based views and manual
forms.
*​**Kateregga Julius*
*Email: julikats2...@gmail.com *
*Kampala-Uganda*

*Skype: Katslog*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMVv_-FTK1YbmT2tz4DnvyOy_eHjT%3DBTGSky0Q%3DzzKJcy8kFOg%40mail.gmail.com.


Re: View "functions" that are callables?

2024-05-15 Thread Faisal Mahmood
Yes, in Django, a view function in a URLconf can indeed be a callable that
is not necessarily a function. You can use classes with a `__call__` method
as views, often referred to as class-based views (CBVs).

Class-based views offer more flexibility and organization than
function-based views in some cases. They allow you to group related
functionality together more easily, provide better code reuse through
inheritance, and offer built-in methods for common HTTP operations like
GET, POST, PUT, etc.

Here's a basic example of a class-based view:

```python
from django.http import HttpResponse
from django.views import View

class MyView(View):
def get(self, request, *args, **kwargs):
return HttpResponse("This is a GET request")

def post(self, request, *args, **kwargs):
return HttpResponse("This is a POST request")
```

You can then include this class-based view in your URLconf like this:

```python
from django.urls import path
from .views import MyView

urlpatterns = [
path('myview/', MyView.as_view(), name='my-view'),
]
```

In this example, `MyView` is a class-based view with `get()` and `post()`
methods, which handle GET and POST requests, respectively. When included in
the URLconf using `.as_view()`, Django will internally call the `__call__`
method of the class to handle the request.

On Thu, May 16, 2024, 12:38 AM Christophe Pettus  wrote:

> Hi,
>
> I'm surprised I don't know this, but: Can a view "function" in a urlconf
> be a callable that is not actually a function, such as a class with a
> __call__ method?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/F70DCB4E-1307-42C2-AC62-CA2DC98DCD5B%40thebuild.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP3eejziJxgJR6UQZ4%2B7pUH_12rwez7yJYEp%3DwjD2%3D%3DXvhdGzw%40mail.gmail.com.


Re: View "functions" that are callables?

2024-05-15 Thread Abdulfarid Olakunle
Yes, in Django, a view function in a URLconf can indeed be a callable that
is not necessarily a function. It can be a class-based view where the class
has a `__call__` method, effectively making it callable. This is a common
practice and allows for more flexibility and organization in your code.


On Wed, May 15, 2024 at 20:39 Christophe Pettus  wrote:

> Hi,
>
> I'm surprised I don't know this, but: Can a view "function" in a urlconf
> be a callable that is not actually a function, such as a class with a
> __call__ method?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/F70DCB4E-1307-42C2-AC62-CA2DC98DCD5B%40thebuild.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BccuR3mM0-Q9MUk8h0jck4%3DNr2YyovWWFVDPMO6mGtFYpx0-g%40mail.gmail.com.


View "functions" that are callables?

2024-05-15 Thread Christophe Pettus
Hi,

I'm surprised I don't know this, but: Can a view "function" in a urlconf be a 
callable that is not actually a function, such as a class with a __call__ 
method?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/F70DCB4E-1307-42C2-AC62-CA2DC98DCD5B%40thebuild.com.


Creating live streaming app

2024-05-15 Thread Anshuman Thakur
Hi Teams,

how can we create live streaming application when we are using react.js in 
frontend and django rest framework in baackend

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2af2a9d5-c856-4127-8f51-cb1f4edbcd74n%40googlegroups.com.