I can help with this one. But I m not ready to write code over weekend. It is a nice to have used django auth model. You can extend it and this can cut a lot of your code. Early versions had a problem with correct author model but now situation is better. Try to catch me at the beginning of the week.
26 серп. 2016 18:03 "Neil Hunt" <[email protected]> пише: > I've read the tutorial but I didn't fully appreciate how useful CBV are. > Amazing as well that sometimes you can write almost no code. Thanks a lot > for explaining that. > > On Fri, Aug 26, 2016 at 3:29 PM, Andromeda Yelton < > [email protected]> wrote: > >> In my experience, CBVs are useful when the view you want to write is >> basically a create, read, update, or delete operation on a single database >> item, or a bunch of instances of the same model (...and it turns out a lot >> of web app pages are just that). And they're useful because they let you do >> that with almost no lines of code - they take care of all the things you'd >> have to write over and over, and let you focus on the things that are >> unique to your use case. >> >> The farther away your business logic is from that, the more you need to >> understand the actual methods available and the inheritance tree and so >> forth. It took me a while to get over this hurdle too, but now that I have >> I use CBVs exclusively. >> >> On Fri, Aug 26, 2016 at 10:13 AM, Neil Hunt <[email protected]> wrote: >> >>> heh heh. I don't fully appreciate the usefulness of CBV at the moment. >>> Getting a simple example working helps as much as reading the tutorial. >>> Thanks again for your help, >>> >>> Neil >>> >>> On Fri, Aug 26, 2016 at 2:24 PM, Sergiy Khohlov <[email protected]> >>> wrote: >>> >>>> Never mind. >>>> Few year ago I was thinking that moving to CBV is bad idea, but >>>> suddenly BUUUHHH !! in my head and everything was clear. >>>> >>>> Many thanks, >>>> >>>> Serge >>>> >>>> >>>> +380 636150445 >>>> skype: skhohlov >>>> >>>> On Fri, Aug 26, 2016 at 3:40 PM, Neil Hunt <[email protected]> wrote: >>>> >>>>> Hello Serge, >>>>> >>>>> I can't believe that's all I have to add to get the class based views >>>>> to work. It seems easier to get it to work than I thought it would be. Now >>>>> that you've explained it. Thank you so much for that. >>>>> >>>>> Kind regards, >>>>> >>>>> Neil >>>>> >>>>> On Fri, Aug 26, 2016 at 11:46 AM, Sergiy Khohlov <[email protected]> >>>>> wrote: >>>>> >>>>>> Hello Neil, >>>>>> >>>>>> It is nota problem to use Class based view. Could you please >>>>>> update your views.py with next code. >>>>>> Look like you would like to have detail of the deposit in this case >>>>>> add next string to the header >>>>>> >>>>>> from django.views.generic import DetailView >>>>>> from models import Account1, Person >>>>>> >>>>>> >>>>>> # next you should create a special view class for each Account1 >>>>>> >>>>>> >>>>>> class Deposit(DetailView): >>>>>> model = Account1 >>>>>> >>>>>> >>>>>> Of course function Deposit is useless >>>>>> >>>>>> thats all. >>>>>> >>>>>> >>>>>> P.S. Look like better way is adding auth and receive person using >>>>>> auth data. In this case every authorized person can connect to his >>>>>> account using auth info and account id >>>>>> >>>>>> Many thanks, >>>>>> >>>>>> Serge >>>>>> >>>>>> >>>>>> +380 636150445 >>>>>> skype: skhohlov >>>>>> >>>>>> On Thu, Aug 25, 2016 at 8:27 PM, Neil Hunt <[email protected]> >>>>>> wrote: >>>>>> >>>>>>> Thank you so much Andromeda. I didn't know you could use class based >>>>>>> views. I'll have a look at the documents. I don't know why I was trying >>>>>>> to >>>>>>> use them when I didn't need to. >>>>>>> >>>>>>> On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton < >>>>>>> [email protected]> wrote: >>>>>>> >>>>>>>> The stacktrace is helpful, thanks! >>>>>>>> >>>>>>>> The specific message with the AttributeError is helpful here: >>>>>>>> `AttributeError: 'module' object has no attribute 'DepositView'` >>>>>>>> >>>>>>>> The line above it is ` File >>>>>>>> "/home/soupdragon/DJapps/banking/mybank/banking/urls.py", >>>>>>>> line 8, in <module> >>>>>>>> url(r'^deposit/$', views.DepositView.as_view(), >>>>>>>> name='deposit'),` >>>>>>>> >>>>>>>> So I checked to see if your views.py contains anything named >>>>>>>> DepositView...and it does not. That's why the AttributeError is >>>>>>>> showing up. >>>>>>>> >>>>>>>> The `DepositView.as_view()` syntax is suitable for class-based >>>>>>>> views, which means I expect to see something in your views.py to the >>>>>>>> effect >>>>>>>> of: >>>>>>>> >>>>>>>> class DepositView(View): >>>>>>>> def post(self, request, *args, **kwargs): >>>>>>>> // the logic in your deposit() function actually belongs here >>>>>>>> >>>>>>>> Have a look at the class-based views documentation to see what the >>>>>>>> different classes are, and what options they provide you. >>>>>>>> >>>>>>>> Alternately, your urls.py could reference views.deposit (which does >>>>>>>> exist) instead of views.DepositView (which does not). >>>>>>>> >>>>>>>> Hope this helps! >>>>>>>> >>>>>>>> On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <[email protected]> >>>>>>>> wrote: >>>>>>>> >>>>>>>>> Thanks for your speedy reply, I've attached the stack trace >>>>>>>>> >>>>>>>>> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues >>>>>>>>> wrote: >>>>>>>>>> >>>>>>>>>> Could you share the full stack trace you get when trying to run >>>>>>>>>> the server ? >>>>>>>>>> The attribute error should come with a ton of information like >>>>>>>>>> the >>>>>>>>>> file and the line where the error occur. >>>>>>>>>> >>>>>>>>>> 2016-08-25 16:57 GMT+02:00 Neil Hunt <[email protected]>: >>>>>>>>>> > I've beem working on a simple banking app based on the Django >>>>>>>>>> tutorial. >>>>>>>>>> > Thanks to your help it almost works now. It was working using >>>>>>>>>> templates but >>>>>>>>>> > after making some changes to get HttpResponseRedirect to work I >>>>>>>>>> changed what >>>>>>>>>> > was in the urls file like it shows in the tutorial. Now, the >>>>>>>>>> server doesn't >>>>>>>>>> > run. It says there's an attribute error. I've temporarily left >>>>>>>>>> the user name >>>>>>>>>> > and password in at the moment. I had a look at their tutorial >>>>>>>>>> how to do a >>>>>>>>>> > use the Django authentication system (thanks for telling me >>>>>>>>>> about that) and >>>>>>>>>> > I'm going to change that after I understand what's going on >>>>>>>>>> here. It's >>>>>>>>>> > amazing how much you can do with Django. Do you think with time >>>>>>>>>> you get more >>>>>>>>>> > used to what different errors mean? The errors seem new and >>>>>>>>>> confusing to me >>>>>>>>>> > at the moment. Any help would be very much appreciated. Thanks >>>>>>>>>> in advnace. >>>>>>>>>> > >>>>>>>>>> > -- >>>>>>>>>> > 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 [email protected]. >>>>>>>>>> > To post to this group, send email to [email protected]. >>>>>>>>>> >>>>>>>>>> > Visit this group at https://groups.google.com/grou >>>>>>>>>> p/django-users. >>>>>>>>>> > To view this discussion on the web visit >>>>>>>>>> > https://groups.google.com/d/msgid/django-users/b30091ce-fcbf >>>>>>>>>> -461e-869e-bba72eb9dcfe%40googlegroups.com. >>>>>>>>>> > For more options, visit https://groups.google.com/d/optout. >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> >>>>>>>>>> -- >>>>>>>>>> >>>>>>>>>> Cordialement, Coues Ludovic >>>>>>>>>> +336 148 743 42 >>>>>>>>>> >>>>>>>>> -- >>>>>>>>> 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 [email protected]. >>>>>>>>> To post to this group, send email to [email protected] >>>>>>>>> . >>>>>>>>> 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/b9b247a9-830d >>>>>>>>> -4cc0-a441-5a8013899f13%40googlegroups.com >>>>>>>>> <https://groups.google.com/d/msgid/django-users/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>>>>>> . >>>>>>>>> >>>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> Andromeda Yelton >>>>>>>> Vice President/President-Elect, Library & Information Technology >>>>>>>> Association: http://www.lita.org >>>>>>>> http://andromedayelton.com >>>>>>>> @ThatAndromeda <http://twitter.com/ThatAndromeda> >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to a topic in >>>>>>>> the Google Groups "Django users" group. >>>>>>>> To unsubscribe from this topic, visit >>>>>>>> https://groups.google.com/d/topic/django-users/vXAou_bCuhE/u >>>>>>>> nsubscribe. >>>>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>>>> [email protected]. >>>>>>>> To post to this group, send email to [email protected]. >>>>>>>> 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/CAFE1XCbjKrqc >>>>>>>> XNmF2wUZottJLJr37SabJdq5ihZpWGiUiCLNDg%40mail.gmail.com >>>>>>>> <https://groups.google.com/d/msgid/django-users/CAFE1XCbjKrqcXNmF2wUZottJLJr37SabJdq5ihZpWGiUiCLNDg%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>>> . >>>>>>>> >>>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>>> >>>>>>> >>>>>>> -- >>>>>>> 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 [email protected]. >>>>>>> To post to this group, send email to [email protected]. >>>>>>> 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/CACaWuFRc4Ly_ >>>>>>> X-j1XVJoP4dxh-B7tbMcQvT_Je0u67rtczXRxQ%40mail.gmail.com >>>>>>> <https://groups.google.com/d/msgid/django-users/CACaWuFRc4Ly_X-j1XVJoP4dxh-B7tbMcQvT_Je0u67rtczXRxQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>>> . >>>>>>> >>>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>>> >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to a topic in >>>>>> the Google Groups "Django users" group. >>>>>> To unsubscribe from this topic, visit https://groups.google.com/d/to >>>>>> pic/django-users/vXAou_bCuhE/unsubscribe. >>>>>> To unsubscribe from this group and all its topics, send an email to >>>>>> [email protected]. >>>>>> To post to this group, send email to [email protected]. >>>>>> 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/CADTRxJNOByng >>>>>> hey%3DFi_%3DQzCJsviG%2BW0%3Du5VFaTSPwa9YQSjymA%40mail.gmail.com >>>>>> <https://groups.google.com/d/msgid/django-users/CADTRxJNOBynghey%3DFi_%3DQzCJsviG%2BW0%3Du5VFaTSPwa9YQSjymA%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>>> . >>>>>> >>>>>> For more options, visit https://groups.google.com/d/optout. >>>>>> >>>>> >>>>> -- >>>>> 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 [email protected]. >>>>> To post to this group, send email to [email protected]. >>>>> 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/CACaWuFSoMY7- >>>>> YThOCZ4PZVNqwv0Ug%2BLBLHvkVnBj%3Dvk68x-VkQ%40mail.gmail.com >>>>> <https://groups.google.com/d/msgid/django-users/CACaWuFSoMY7-YThOCZ4PZVNqwv0Ug%2BLBLHvkVnBj%3Dvk68x-VkQ%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>>> For more options, visit https://groups.google.com/d/optout. >>>>> >>>> >>>> -- >>>> You received this message because you are subscribed to a topic in the >>>> Google Groups "Django users" group. >>>> To unsubscribe from this topic, visit https://groups.google.com/d/to >>>> pic/django-users/vXAou_bCuhE/unsubscribe. >>>> To unsubscribe from this group and all its topics, send an email to >>>> [email protected]. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at https://groups.google.com/group/django-users. >>>> To view this discussion on the web visit https://groups.google.com/d/ms >>>> gid/django-users/CADTRxJP1epRoPA90fG24Jx%3DCc93W1HfonhrpDEZo >>>> R%2BAJx7m0Ow%40mail.gmail.com >>>> <https://groups.google.com/d/msgid/django-users/CADTRxJP1epRoPA90fG24Jx%3DCc93W1HfonhrpDEZoR%2BAJx7m0Ow%40mail.gmail.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- >>> 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 [email protected]. >>> To post to this group, send email to [email protected]. >>> Visit this group at https://groups.google.com/group/django-users. >>> To view this discussion on the web visit https://groups.google.com/d/ms >>> gid/django-users/CACaWuFS8rNk9n1fdZoTh7kYXUvatEUq6W7vPDv8h7u >>> 5nh725ew%40mail.gmail.com >>> <https://groups.google.com/d/msgid/django-users/CACaWuFS8rNk9n1fdZoTh7kYXUvatEUq6W7vPDv8h7u5nh725ew%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >>> For more options, visit https://groups.google.com/d/optout. >>> >> >> >> >> -- >> Andromeda Yelton >> Vice President/President-Elect, Library & Information Technology >> Association: http://www.lita.org >> http://andromedayelton.com >> @ThatAndromeda <http://twitter.com/ThatAndromeda> >> >> -- >> You received this message because you are subscribed to a topic in the >> Google Groups "Django users" group. >> To unsubscribe from this topic, visit https://groups.google.com/d/to >> pic/django-users/vXAou_bCuhE/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to >> [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit https://groups.google.com/d/ms >> gid/django-users/CAFE1XCZ4TqVtfpepWBcsLM_dj0T9x% >> 2BJ9RQTWH2FTJLne9p6a7Q%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAFE1XCZ4TqVtfpepWBcsLM_dj0T9x%2BJ9RQTWH2FTJLne9p6a7Q%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- > 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 [email protected]. > To post to this group, send email to [email protected]. > 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/CACaWuFSwE-48SLLngn4tdwqDWXmZX3TarhaR16Bu > 8pEe_5fBRg%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CACaWuFSwE-48SLLngn4tdwqDWXmZX3TarhaR16Bu8pEe_5fBRg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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 [email protected]. To post to this group, send email to [email protected]. 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/CADTRxJNXkpDM2qZ2%2BuCQBPB%2Ba3uVLi3DDe5OKOww%3D%3DEhXWSZMA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

