Thursday, August 25, 2016

Re: Attribute error, with a very basic banking app

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 <andromeda.yelton@gmail.com> 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 <hunt.neil@gmail.com> 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 <hunt...@gmail.com>:
> 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 django-users...@googlegroups.com.
> To post to this group, send email to django...@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/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 django-users+unsubscribe@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/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology Association: http://www.lita.org

--
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/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users+unsubscribe@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/CAFE1XCbjKrqcXNmF2wUZottJLJr37SabJdq5ihZpWGiUiCLNDg%40mail.gmail.com.

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 django-users+unsubscribe@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/CACaWuFRc4Ly_X-j1XVJoP4dxh-B7tbMcQvT_Je0u67rtczXRxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment