Re: Re-using CreateView, UpdateView & friendship

2018-04-30 Thread subhani shaik
Hi
can you please share me any django project.for the  practicing purpose .

On Mon, Apr 30, 2018 at 10:15 AM, Mikkel Kromann 
wrote:

> Hmmm. It might be my question 3 after all.
> After a good night's sleep, I re-read the Figure 8.1 on Function vs Class
> Based Views in Two Scoops of Django ...
>
> 1) No generic view match closely what I have in mind (I think?)
> 2) I don't think I need to subclass my view
> 3) I suspect my CBV will need to process a lot of slightly different forms
>
> So, I should make 4 function based views for create, read, update and
> delete that can handle my many quite similar Models.
> Have I understood the difference between FBV and CBV correctly?
>
> thanks, Mikkel
>
>
>
> søndag den 29. april 2018 kl. 22.06.01 UTC+2 skrev Mikkel Kromann:
>>
>> Dear Django users.
>>
>> I'm testing whether Django is a good choice for a web based application
>> that I need to handle (create, read, update, delete) a lot of data tables.
>> I've discovered the built-in Class Based View, which are going to save me
>> from a lot of repetitive code lines - yay!
>>
>> Now, I've got an awful lot of models for my data tables (well, around
>> 20-30 ...) and looking at my code so far, it strikes me that it will
>> quickly become a bit repetitive, which I agree is a bad thing.
>>
>> From urls.py:
>>
>>
>> urlpatterns = [
>> # Urls for truck forms & actions
>> path('data/trucks/list/',views.TruckListView.as_view(), name=
>> 'truck_list'),
>> path('data/trucks/create/',views.TruckCreateView.as_view(), name=
>> 'truck_create'),
>> path('data/trucks/update//',views.TruckUpdateView.as_view(), name
>> ='truck_update'),
>> path('data/trucks/delete//',views.TruckDeleteView.as_view(), name
>> ='truck_delete'),
>>
>> # Urls for container forms & actions
>> path('data/containers/list/',views.ContainersListView.as_view(), name
>> ='containers_list'),
>> path('data/containers/create/',views.ContainersCreateView.as_view(),
>> name='containers_create'),
>> path('data/containers/update//',views.ContainersUpdateView.
>> as_view(), name='containers_update'),
>> path('data/containers/delete//',views.ContainersDeleteView.
>> as_view(), name='containers_delete'),
>>
>> # Urls for destination forms & actions
>> # ... guess what will come here ...
>>
>> ]
>>
>> From views.py
>>
>> # Create views
>> class TruckCreateView(CreateView):
>> model = Truck
>> fields = ['label', 'description', 'max_speed', 'max_weight',
>> 'max_volume' ]
>>
>> def get_success_url(self):
>> return reverse("truck_list")
>>
>> class ContainerCreateView(CreateView):
>> model = Container
>> fields = ['label', 'description', 'max_weight', 'max_volume' ]
>>
>> def get_success_url(self):
>> return reverse("container_list")
>>
>> # ... drum-whirl ... what is next? ...
>>
>>
>> I suppose my task at hand may be a bit unusual, but I aIso think I can't
>> be the first facing this problem.
>> Basically, I want to do more or less the same with all my models (maybe
>> in 2 or 3 variations). So,
>>
>> 1) did someone perhaps already make a nice package of Class Based Views
>> which can take an Model name as argument, with the model capable of
>> providing the necessary data, e.g. field list?
>> 2) How advisable / possible would it be to take the object name from the
>> url and pass that on to the generic class based view?
>> 3) Did I miss something very obvious? :)
>>
>>
>> Thanks for your help, Mikkel
>>
> --
> 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 post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/3e6e5850-0afc-4b8c-af49-17ba467a540f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Thanks,

Subhani Shaik
8897630945

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGytu6DQnZh-uDaARoeB__a%3Dh%3DbviFaiLcVo8ZAxR0jSkkHP7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Re-using CreateView, UpdateView & friendship

2018-04-29 Thread Mikkel Kromann
Hmmm. It might be my question 3 after all.
After a good night's sleep, I re-read the Figure 8.1 on Function vs Class 
Based Views in Two Scoops of Django ...

1) No generic view match closely what I have in mind (I think?)
2) I don't think I need to subclass my view
3) I suspect my CBV will need to process a lot of slightly different forms

So, I should make 4 function based views for create, read, update and 
delete that can handle my many quite similar Models.
Have I understood the difference between FBV and CBV correctly?

thanks, Mikkel



søndag den 29. april 2018 kl. 22.06.01 UTC+2 skrev Mikkel Kromann:
>
> Dear Django users.
>
> I'm testing whether Django is a good choice for a web based application 
> that I need to handle (create, read, update, delete) a lot of data tables.
> I've discovered the built-in Class Based View, which are going to save me 
> from a lot of repetitive code lines - yay! 
>
> Now, I've got an awful lot of models for my data tables (well, around 
> 20-30 ...) and looking at my code so far, it strikes me that it will 
> quickly become a bit repetitive, which I agree is a bad thing.
>
> From urls.py:
>
>
> urlpatterns = [
> # Urls for truck forms & actions
> path('data/trucks/list/',views.TruckListView.as_view(), name=
> 'truck_list'),
> path('data/trucks/create/',views.TruckCreateView.as_view(), name=
> 'truck_create'),
> path('data/trucks/update//',views.TruckUpdateView.as_view(), name=
> 'truck_update'),
> path('data/trucks/delete//',views.TruckDeleteView.as_view(), name=
> 'truck_delete'),
>
> # Urls for container forms & actions
> path('data/containers/list/',views.ContainersListView.as_view(), name=
> 'containers_list'),
> path('data/containers/create/',views.ContainersCreateView.as_view(), 
> name='containers_create'),
> path('data/containers/update//',views.ContainersUpdateView.as_view
> (), name='containers_update'),
> path('data/containers/delete//',views.ContainersDeleteView.as_view
> (), name='containers_delete'),
>
> # Urls for destination forms & actions
> # ... guess what will come here ...
>
> ]
>
> From views.py
>
> # Create views
> class TruckCreateView(CreateView):
> model = Truck
> fields = ['label', 'description', 'max_speed', 'max_weight', 
> 'max_volume' ]
>
> def get_success_url(self):
> return reverse("truck_list")
>
> class ContainerCreateView(CreateView):
> model = Container
> fields = ['label', 'description', 'max_weight', 'max_volume' ]
>
> def get_success_url(self):
> return reverse("container_list")
>
> # ... drum-whirl ... what is next? ... 
>
>
> I suppose my task at hand may be a bit unusual, but I aIso think I can't 
> be the first facing this problem.
> Basically, I want to do more or less the same with all my models (maybe in 
> 2 or 3 variations). So, 
>
> 1) did someone perhaps already make a nice package of Class Based Views 
> which can take an Model name as argument, with the model capable of 
> providing the necessary data, e.g. field list?
> 2) How advisable / possible would it be to take the object name from the 
> url and pass that on to the generic class based view?
> 3) Did I miss something very obvious? :)
>
>
> Thanks for your help, Mikkel
>

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/3e6e5850-0afc-4b8c-af49-17ba467a540f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re-using CreateView, UpdateView & friendship

2018-04-29 Thread Mikkel Kromann
Dear Django users.

I'm testing whether Django is a good choice for a web based application 
that I need to handle (create, read, update, delete) a lot of data tables.
I've discovered the built-in Class Based View, which are going to save me 
from a lot of repetitive code lines - yay! 

Now, I've got an awful lot of models for my data tables (well, around 20-30 
...) and looking at my code so far, it strikes me that it will quickly 
become a bit repetitive, which I agree is a bad thing.

>From urls.py:


urlpatterns = [
# Urls for truck forms & actions
path('data/trucks/list/',views.TruckListView.as_view(), name=
'truck_list'),
path('data/trucks/create/',views.TruckCreateView.as_view(), name=
'truck_create'),
path('data/trucks/update//',views.TruckUpdateView.as_view(), name=
'truck_update'),
path('data/trucks/delete//',views.TruckDeleteView.as_view(), name=
'truck_delete'),

# Urls for container forms & actions
path('data/containers/list/',views.ContainersListView.as_view(), name=
'containers_list'),
path('data/containers/create/',views.ContainersCreateView.as_view(), 
name='containers_create'),
path('data/containers/update//',views.ContainersUpdateView.as_view
(), name='containers_update'),
path('data/containers/delete//',views.ContainersDeleteView.as_view
(), name='containers_delete'),

# Urls for destination forms & actions
# ... guess what will come here ...

]

>From views.py

# Create views
class TruckCreateView(CreateView):
model = Truck
fields = ['label', 'description', 'max_speed', 'max_weight', 
'max_volume' ]

def get_success_url(self):
return reverse("truck_list")

class ContainerCreateView(CreateView):
model = Container
fields = ['label', 'description', 'max_weight', 'max_volume' ]

def get_success_url(self):
return reverse("container_list")

# ... drum-whirl ... what is next? ... 


I suppose my task at hand may be a bit unusual, but I aIso think I can't be 
the first facing this problem.
Basically, I want to do more or less the same with all my models (maybe in 
2 or 3 variations). So, 

1) did someone perhaps already make a nice package of Class Based Views 
which can take an Model name as argument, with the model capable of 
providing the necessary data, e.g. field list?
2) How advisable / possible would it be to take the object name from the 
url and pass that on to the generic class based view?
3) Did I miss something very obvious? :)


Thanks for your help, Mikkel

-- 
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 post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/80559ac3-bb8b-429b-9395-7bd09870e636%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.