Re: Attribute error, with a very basic banking app

2016-08-26 Thread Sergiy Khohlov
 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  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 <
> andromeda.yel...@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 
>> 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  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 :
 > 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+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/ms
>>> gid/django-users/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com
>>> 
>>> .
>>>
>>> For more options,

Re: Hi. i'm new to django, i have lot of doubts about AD

2016-08-26 Thread rajeshkmr9583
i'm trying to login with gmail account in django admin login page... i 
don't know how to write script... send me any in-build script available for 
learning

On Thursday, 25 August 2016 19:27:35 UTC+5:30, M Hashmi wrote:
>
> What is your code and what you are trying to achieve?
>
> On Thu, Aug 25, 2016 at 5:18 AM, rajeshkmr9583  > wrote:
>
>> Hi guys,
>> i'm new to django framework and now my doubt id how to create AD for 
>> login page
>>
>> Thanks
>>
>> -- 
>> 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/b866-4026-4f3d-9b0f-1840ab90a57a%40googlegroups.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+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/4d1a031b-2659-4dda-bf16-63830ad927f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hi. i'm new to django, i have lot of doubts about AD

2016-08-26 Thread Rafael E. Ferrero
you can use the AllAuth app for accomplish gmail login

Cheers!!


Rafael E. Ferrero

2016-08-26 2:27 GMT-03:00 rajeshkmr9583 :

> i'm trying to login with gmail account in django admin login page... i
> don't know how to write script... send me any in-build script available for
> learning
>
> On Thursday, 25 August 2016 19:27:35 UTC+5:30, M Hashmi wrote:
>>
>> What is your code and what you are trying to achieve?
>>
>> On Thu, Aug 25, 2016 at 5:18 AM, rajeshkmr9583 
>> wrote:
>>
>>> Hi guys,
>>> i'm new to django framework and now my doubt id how to create AD for
>>> login page
>>>
>>> Thanks
>>>
>>> --
>>> 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/ms
>>> gid/django-users/b866-4026-4f3d-9b0f-1840ab90a57a%40googlegroups.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+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/4d1a031b-2659-4dda-bf16-63830ad927f4%40googlegroups.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+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/CAJJc_8UqB8%3DquW%2BZQvoBv%2B5Kt0zZz9YRqh-QudDBN9CSYUPZ1g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Neil Hunt
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  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  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 <
>> andromeda.yel...@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 
>>> 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  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 :
> > 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+unsubscr...@googlegroups.com.
 To post to this gro

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Sergiy Khohlov
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  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 
> 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  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 <
>>> andromeda.yel...@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 
 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 
 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 :
>> > 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.g

Django template iterating through two dictionaries/variables

2016-08-26 Thread Aaron Weisberg
I didn't really know how to label this question, but I think it's an 
interesting concept and I haven't seen a resolution anywhere else.

I currently have two different dictionaries as context for a template:

Enter code here...context ={
 'person':person,
 'scores':scores,
   }


Each of these dictionaries has a common key (person.Number), 
(scores.Number), however the person dictionary is based off of a model in 
my django database, while scores comes from a json feed that I parse 
through:

I currently run through a table in a template that looks like this:

Enter code here...
  
  
  Person
Person Number
First Name
Last Name 
 City  
 Score 
  
  
  
   {% for person in persons %}
  
  {{ person.Number }}
  {{ person.firstName }}
  
{{ person.lastName }}
  
{{ person.city }}
  
??'''scores.score1 goes here'''
 
 {% endfor %}

  

What I'm trying to figure out to do is figure out how to get that final 
detail loaded into the table where we would find the score specific to that 
person.Number.  In other words how to go through my scores dictionary in 
this template and find the corresponding score1 using the person.Number 
from the other dictionary as the value.


Let me know if you have any ideas.

Thanks.


-- 
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/d05c8fc4-706b-422b-bc11-b656f1950dea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to set up a form from an existing view

2016-08-26 Thread Aaron Weisberg
Good morning,

I have been working on an app displaying some analytics and I want to 
incorporate some user feedback and I am having trouble figuring out how:

I have a detail view:

Enter code here...

#views.py
def detail(request, game_id):
games = Game.objects.get(pk=game_id)
context = {
'games':games}
return render(request,'myapp/detail.html',context)

Very simple with no form activity as of yet.

My template currently shows a comparison between two properties set up like:

#detail.html






{{ games.roadTeam }}
{{ games.roadTeamWins}} - {{ 
games.roadTeamLosses}} 
 
   


{{games.homeTeam }}
{{ games.HomeTeamWins}} - {{ 
games.HomeTeamLosses}}
 




I would like to work backwards and turn this template into a form.  Would I 
be able to make it a form by adding a third div to each one of these that 
is a button which sends the value of the variable back to the view?  and 
then how would I be able to process that in the view?
Enter code here...


{% csrf_token %}




I am not an expert when it comes to forms, so your assistance would be 
greatly appreciated.

Thanks.

-- 
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/0569cc00-30c1-4b14-b521-107e37149340%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Neil Hunt
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  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  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 
>> 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  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 <
 andromeda.yel...@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 
> 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 
> 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 :
>>> > 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-user

AWS ElasticBeanstalk update without modifying Django wsgi.conf

2016-08-26 Thread Ronaldo Bahia


I have a django app deployed in AWS EB using autoscaling. This app uses 
Django Rest with Token Authentication. In order for this to work, I have to 
add the following lines in etc/httpd/conf.d/wsgi.conf file:

RewriteEngine onRewriteCond %{HTTP:Authorization} ^(.*)RewriteRule .* - 
[e=HTTP_AUTHORIZATION:%1]
WSGIPassAuthorization On

The problem is: when AWS do an autoscale or ElasticBeanstalk environment 
upgrade, the wsgi.conf file is updated and the custom settings are deleted.

How can I avoid that?

Thanks in advance


Stackoverflow 
thread: 
http://stackoverflow.com/questions/39168351/aws-elasticbeanstalk-update-without-modifing-django-wsgi-conf

-- 
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/e1670544-ce4b-4c5a-9361-7b52d13da752%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Andromeda Yelton
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  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 
> 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  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 
>>> 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  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 <
> andromeda.yel...@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 
>> 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 
>> 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 :
 > 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

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Michal Petrucha
On Fri, Aug 26, 2016 at 10:29:16AM -0400, Andromeda Yelton 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.

I'll just chime in with a reference to http://ccbv.co.uk/, which is an
invaluable resource whenever you're doing anything with CBVs that
involves more than setting the ``template_name`` and ``model``
attributes. In my opinion, CCBV makes a lot of the pain involved in
dealing with CBVs go away.

Cheers,

Michal

-- 
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/20160826144853.GA6601%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Neil Hunt
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 <
andromeda.yel...@gmail.com> 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  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 
>> 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  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 
 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 
> 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 <
>> andromeda.yel...@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 
>>> 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 
>>> 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.
>
>>

Re: How to set up a form from an existing view

2016-08-26 Thread ludovic coues
First, your html is invalid. You can't put a whole form in a link. Nor
a button. You can remove the  element and put the shiny class on
the input[type=submit]

About your input[type=submit], I have some doubts about cross brother
compatibility of what you are trying to achieve. It would be either to
add an input[type=hidden] which the value {{games.roadTeam}}. This
will prevent you some headache if your code don't work under IE or Fx
or chrome or whatnot.

About your question,
you can use the request argument, like this:

if request.method == "POST":
request.POST.get("variable", "default_value")

If you want to do something more complex than simply find which team
is chosen, you should create a form class. This will simplify data
handling.

That being said, you are on a good start :)

2016-08-26 16:00 GMT+02:00 Aaron Weisberg :
> Good morning,
>
> I have been working on an app displaying some analytics and I want to
> incorporate some user feedback and I am having trouble figuring out how:
>
> I have a detail view:
>
> Enter code here...
>
> #views.py
> def detail(request, game_id):
> games = Game.objects.get(pk=game_id)
> context = {
> 'games':games}
> return render(request,'myapp/detail.html',context)
>
> Very simple with no form activity as of yet.
>
> My template currently shows a comparison between two properties set up like:
>
> #detail.html
>
> 
> 
> 
> 
> 
> {{ games.roadTeam }}
> {{ games.roadTeamWins}} - {{
> games.roadTeamLosses}}
>
>
> 
> 
> {{games.homeTeam }}
> {{ games.HomeTeamWins}} - {{
> games.HomeTeamLosses}}
>
>
> 
>
>
> I would like to work backwards and turn this template into a form.  Would I
> be able to make it a form by adding a third div to each one of these that is
> a button which sends the value of the variable back to the view?  and then
> how would I be able to process that in the view?
> Enter code here...
>
> 
> {%
> csrf_token %}
> 
>  style="width 100%">
> 
>
> I am not an expert when it comes to forms, so your assistance would be
> greatly appreciated.
>
> Thanks.
>
> --
> 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/0569cc00-30c1-4b14-b521-107e37149340%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+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/CAEuG%2BTZtE_QP3uq473HkW%2BRmYNtPrHV3XO%2B09PubC4sp5k-H0A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django template iterating through two dictionaries/variables

2016-08-26 Thread ludovic coues
You could write a filter [1]. It would be used like {{
scores|from_player:person }} and look like that:

def from_player (scores, player):
return scores[player.Number]

You might want to adjust to your actual code, check that you got the
right arguments and that kind of things.

[1] https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/

2016-08-26 15:50 GMT+02:00 Aaron Weisberg :
> I didn't really know how to label this question, but I think it's an
> interesting concept and I haven't seen a resolution anywhere else.
>
> I currently have two different dictionaries as context for a template:
>
> Enter code here...context ={
>  'person':person,
>  'scores':scores,
>}
>
>
> Each of these dictionaries has a common key (person.Number),
> (scores.Number), however the person dictionary is based off of a model in my
> django database, while scores comes from a json feed that I parse through:
>
> I currently run through a table in a template that looks like this:
>
> Enter code here...
>   
>   
>   Person
> Person Number
> First Name
> Last Name 
>  City 
>  Score
>   
>   
>   
>{% for person in persons %}
>   
>   {{ person.Number }}
>   {{ person.firstName }}
>   {{
> person.lastName }}
>   {{
> person.city }}
>
> ??'''scores.score1 goes here'''
>
>  {% endfor %}
>
>   
>
> What I'm trying to figure out to do is figure out how to get that final
> detail loaded into the table where we would find the score specific to that
> person.Number.  In other words how to go through my scores dictionary in
> this template and find the corresponding score1 using the person.Number from
> the other dictionary as the value.
>
>
> Let me know if you have any ideas.
>
> Thanks.
>
>
> --
> 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/d05c8fc4-706b-422b-bc11-b656f1950dea%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+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/CAEuG%2BTatGSwstRkfEDpZdeB6yMv2BobiaQ_Zb3CEL7ZXr5kE-g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


is it possible to manipulate image in PIL after uploading directly by its "request.FILES.GETLIST(FORMFIELD)" address not the saved picture on hard disk

2016-08-26 Thread ali Eblice
Hello Friends
is it possible to manipulate image in PIL after uploading directly by its "
*request.FILES.GETLIST(FORMFIELD)*"  address not the saved picture on hard 
disk?

I wrote a function for manipulating  but its only working with  " 
*Image.open('a.jpg')* " but i don't want to save image after uploading and 
then opening it for manipulating , is it possible to manipulate image with 
its "request.FILES" object address?

-- 
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/9b6734c8-4530-42b3-b791-99bbce020b32%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: is it possible to manipulate image in PIL after uploading directly by its "request.FILES.GETLIST(FORMFIELD)" address not the saved picture on hard disk

2016-08-26 Thread Asad Jibran Ahmed
Hi,
 Every object in `request.FILES` is actually a file *liike* object that you
can use for processing. I guess you can use something like
`PIL.Image.frombytes` with the `request.FILES[filename].read()` data.

Django Doc for the `request.FILES`:
https://docs.djangoproject.com/en/1.10/ref/files/uploads/#django.core.files.uploadedfile.UploadedFile
Pillow (PIL Fork) documentation for the `frombytes` method:
https://pillow.readthedocs.io/en/3.3.x/reference/Image.html#PIL.Image.frombytes

Hope that helps.
Regards,

Asad Jibran Ahmed 
http://blog.asadjb.com

On Fri, Aug 26, 2016 at 7:46 PM, ali Eblice  wrote:

> Hello Friends
> is it possible to manipulate image in PIL after uploading directly by its "
> *request.FILES.GETLIST(FORMFIELD)*"  address not the saved picture on
> hard disk?
>
> I wrote a function for manipulating  but its only working with  "
> *Image.open('a.jpg')* " but i don't want to save image after uploading
> and then opening it for manipulating , is it possible to manipulate image
> with its "request.FILES" object address?
>
> --
> 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/9b6734c8-4530-42b3-b791-99bbce020b32%40googlegroups.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+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/CA%2BYYaWeTsyGvKeZ8uo_veyg_YrzQtR3y1Hsr8q37GGhXvGEcPg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Rest Framework inside of Django Project

2016-08-26 Thread Sylvain Dégué
Hi,

I am building a mobile application and I need a Rest API and a web version 
of my app. So I was wondering if I could make a website with Django Rest 
Framework or if I have create a Django project for my website and a Django 
Rest Framwork for my API

-- 
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/8cea6e27-d16f-4225-84c7-944b0963eabe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Sergiy Khohlov
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"  пише:

> 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 <
> andromeda.yel...@gmail.com> 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  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 
>>> 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  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 
> 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 
>> 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 <
>>> andromeda.yel...@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 
 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!

>>

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Neil Hunt
Thanks for that Michal, I see what you mean. I've bookmarked it. Thanks to
everyone for all the detailed replies it really helps make sense of CBV :)

On Fri, Aug 26, 2016 at 3:48 PM, Michal Petrucha <
michal.petru...@konk.org> wrote:

> On Fri, Aug 26, 2016 at 10:29:16AM -0400, Andromeda Yelton 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.
>
> I'll just chime in with a reference to http://ccbv.co.uk/, which is an
> invaluable resource whenever you're doing anything with CBVs that
> involves more than setting the ``template_name`` and ``model``
> attributes. In my opinion, CCBV makes a lot of the pain involved in
> dealing with CBVs go away.
>
> Cheers,
>
> Michal
>
> --
> 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+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/20160826144853.GA6601%40konk.org.
> 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+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/CACaWuFT1cL7jmsUbmj3g%3Dskp9HK5VtunWxSx8i9M8%2BAqOF2yzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Rest Framework inside of Django Project

2016-08-26 Thread John
Sylvain,

It is your choice. You can have views which return HTML and views which
form a REST interface concurrently within the same project. You can
choose to implement your non-mobile website using a javascript UI. Or
you can use frameworks like React.js and do everything with one set of
JS. To get a REST interface for an existing (non-REST) project is easy;
check out http://www.django-rest-framework.org/.

John

On 26/08/16 17:07, Sylvain Dégué wrote:
> Hi,
>
> I am building a mobile application and I need a Rest API and a web
> version of my app. So I was wondering if I could make a website with
> Django Rest Framework or if I have create a Django project for my
> website and a Django Rest Framwork for my API
> -- 
> 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/8cea6e27-d16f-4225-84c7-944b0963eabe%40googlegroups.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+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/533dadd1-57b1-83b0-0eb6-04f5e7c2c4aa%40martinhome.org.uk.
For more options, visit https://groups.google.com/d/optout.


Format of arrays in multipart forms?

2016-08-26 Thread ggilley
I'm trying to create an iOS app that can post multipart forms to Django. 
(JSON is trivial, wish it worked with file uploads. :-)

What is the proper format for the HTTP request when passing arrays of 
values? (Strings is all I care about at the moment)

I think PHP has the follow style. What is the Django equivalent? I tried 
reading through the sources, but it wasn't obvious.

Thanks,

 Greg

*--Boundary-56A500AE-D543-43BD-93F0-6A1721A73F70*

*Content-Disposition: form-data; name="array[]"*


*one*

*--Boundary-56A500AE-D543-43BD-93F0-6A1721A73F70*

*Content-Disposition: form-data; name="array[]"*


*two*

*--Boundary-56A500AE-D543-43BD-93F0-6A1721A73F70*

*Content-Disposition: form-data; name="array[]"*


*three*

*--Boundary-56A500AE-D543-43BD-93F0-6A1721A73F70*


-- 
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/4d999852-b1eb-4b39-bbb3-46606a77d0c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.