Re: Processing uploaded csv on the basis of user input

2015-01-15 Thread Jani Tiainen
Hi,

I do something similiar this way:


You could leverage Django (model)form to validate date and to normalize
it to proper data.

That way you would put design a contract between users that you state
which column names are matched to your internal data.

Then feed each row to (model)form if row is valid, you can save it, if
not you can log errors for showing them after import is done.

Another option is (what you're proposing) is to have such a dynamic
middle form to make mapping between columns frm csv and your model.
After that just map values from CSV to a dict, pass it to (model)form,
validate and save if valid.

As you see, Django (model)form is _very_ useful to validate user input
- even input is not directly from HTML form.

On Thu, 15 Jan 2015 18:54:13 -0800 (PST)
David Mutton  wrote:

> 
> 
> Please let me know if this is an inappropriate question. I feel it is
> a little broad.
> 
> I am fairly new to Django and coding an app for educational purposes.
> What I am trying to achieve is to allow users to upload a CSV and
> then populate a model by specifying that datatype that is in each
> column of the CSV. I’m fine with the first half (users can upload csv
> which are then processed into a PropertyQuery model but currently
> they would need to download a template CSV file and ensure they
> conform to it. I’d like them to be able to upload any CSV and then
> specify the column’s data.
> 
> I don’t need a step by step explanation on how to achieve this but
> after spending a fair chunk of time searching I could use a pointer.
> 
> I hope that my flowchart below explains it better.
> 
> Many 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
> http://groups.google.com/group/django-users. To view this discussion
> on the web visit
> https://groups.google.com/d/msgid/django-users/c5acdad9-eb00-438a-bf37-faf7a66a82a5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


-- 

Jani Tiainen

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20150116085438.0f3b4fec%40jns42-l.w2k.keypro.fi.
For more options, visit https://groups.google.com/d/optout.


Processing uploaded csv on the basis of user input

2015-01-15 Thread David Mutton


Please let me know if this is an inappropriate question. I feel it is a 
little broad.

I am fairly new to Django and coding an app for educational purposes. What 
I am trying to achieve is to allow users to upload a CSV and then populate 
a model by specifying that datatype that is in each column of the CSV. I’m 
fine with the first half (users can upload csv which are then processed 
into a PropertyQuery model but currently they would need to download a 
template CSV file and ensure they conform to it. I’d like them to be able 
to upload any CSV and then specify the column’s data.

I don’t need a step by step explanation on how to achieve this but after 
spending a fair chunk of time searching I could use a pointer.

I hope that my flowchart below explains it better.

Many 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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c5acdad9-eb00-438a-bf37-faf7a66a82a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: filter

2015-01-15 Thread sum abiut
i expect to see only the data that have
department_head_authorization="Approved"
and department="FMKD" showing but instead the data that the
department_head_authorization
is not Approved is also showing.



On Fri, Jan 16, 2015 at 11:58 AM, Vijay Khemlani  wrote:

> What are you expecting to see? What are you actually seeing?
>
> On Thu, Jan 15, 2015 at 9:48 PM, sum abiut  wrote:
>
>> Ok thanks,
>>
>> i just released that i have made a mistake. so basically here are my
>> template.html and view.py
>> i think there is a mistake in my view.py the display result is not what i
>> was looking for. can't seem to figure it out.
>>
>> template.html
>>
>> 
>> 
>> Select to approve leave
>>   First Name
>>   Last Name
>>   Position
>>   Department
>>   Leave Type
>>   Details
>>   Start Date
>>   End Date
>>   Total working days
>>   # of leave left
>>Department Head Authorization
>>   Authorize By
>>Remarks
>>   Authorized Date
>>
>> 
>> {%for a in new_leave%}
>> 
>> > onClick="parent.location='#'" >  
>> {{a.first_name}}
>>   {{a.last_name}}
>>   {{a.position}}
>>   {{a.department}}
>> {{a.leave_type}}
>>   {{a.specify_details}}
>>   {{a.start_date}}
>>   {{a.end_date}}
>>   {{a.total_working_days}}
>>   {{a.total_Leave_Left}}
>>{{a.department_head_authorization}}
>> {{a.authorized_by}}
>>  {{a.remarks}}
>>  {{a.authorization_date}}
>>
>>   
>> {%endfor%}
>> 
>>
>>
>>
>> view.py
>>
>>
>> def FMKD1_leave_to_authorize(request):
>> new_leave
>> =newleave.objects.filter(department_head_authorization="Approved" )
>> new_leave = newleave.objects.filter(department="FMKD")
>> if new_leave.exists() and new_leave.exists():
>> return render_to_response('FMKD1_display_approve_leave.html',
>> locals())
>>
>>
>>
>>
>>
>>
>> On Fri, Jan 16, 2015 at 10:52 AM, Vijay Khemlani 
>> wrote:
>>
>>> in your view new_leave and a are QuerySet objects, and then you are
>>> comparing them to a string ("True") not a bolean (True without quotes), so
>>> it's always False.
>>>
>>> Even if you change "True" to True it won't work, try it like this
>>>
>>> if new_leave.exists() and a.exists():
>>>   return ...
>>>
>>>
>>> On Thu, Jan 15, 2015 at 8:40 PM, sum abiut  wrote:
>>>


 Hi,
 I am trying to two column and display some result if two conditions are
 meet but i am getting this error:

 The view eLeave.views.FMKD1_leave_to_authorize didn't return an 
 HttpResponse object. It returned None instead.


 I can seems to figure out the issue, here is my view.py file

 def FMKD1_leave_to_authorize(request):
 new_leave
 =newleave.objects.filter(department_head_authorization="Approved" )
 a = newleave.objects.filter(department="FMKD")
 if new_leave=="True"and a =="True":
 return render_to_response('FMKD1_display_approve_leave.html',
 locals())

 --
 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 http://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAPCf-y7uRsM8Vx6Jj5QD4ZY%2BCk24SkgCHZv-xMGZr49icPrmrA%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+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CALn3ei0QaQbwb%3DvkGJ6%2B4DB19p2ZDjTzJb1fSmoAhWUGg_H5PA%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+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAPCf-y6MXc2tR5wBBv9358TMoy

Re: filter

2015-01-15 Thread Vijay Khemlani
What are you expecting to see? What are you actually seeing?

On Thu, Jan 15, 2015 at 9:48 PM, sum abiut  wrote:

> Ok thanks,
>
> i just released that i have made a mistake. so basically here are my
> template.html and view.py
> i think there is a mistake in my view.py the display result is not what i
> was looking for. can't seem to figure it out.
>
> template.html
>
> 
> 
> Select to approve leave
>   First Name
>   Last Name
>   Position
>   Department
>   Leave Type
>   Details
>   Start Date
>   End Date
>   Total working days
>   # of leave left
>Department Head Authorization
>   Authorize By
>Remarks
>   Authorized Date
>
> 
> {%for a in new_leave%}
> 
>  onClick="parent.location='#'" >  
> {{a.first_name}}
>   {{a.last_name}}
>   {{a.position}}
>   {{a.department}}
> {{a.leave_type}}
>   {{a.specify_details}}
>   {{a.start_date}}
>   {{a.end_date}}
>   {{a.total_working_days}}
>   {{a.total_Leave_Left}}
>{{a.department_head_authorization}}
> {{a.authorized_by}}
>  {{a.remarks}}
>  {{a.authorization_date}}
>
>   
> {%endfor%}
> 
>
>
>
> view.py
>
>
> def FMKD1_leave_to_authorize(request):
> new_leave
> =newleave.objects.filter(department_head_authorization="Approved" )
> new_leave = newleave.objects.filter(department="FMKD")
> if new_leave.exists() and new_leave.exists():
> return render_to_response('FMKD1_display_approve_leave.html',
> locals())
>
>
>
>
>
>
> On Fri, Jan 16, 2015 at 10:52 AM, Vijay Khemlani 
> wrote:
>
>> in your view new_leave and a are QuerySet objects, and then you are
>> comparing them to a string ("True") not a bolean (True without quotes), so
>> it's always False.
>>
>> Even if you change "True" to True it won't work, try it like this
>>
>> if new_leave.exists() and a.exists():
>>   return ...
>>
>>
>> On Thu, Jan 15, 2015 at 8:40 PM, sum abiut  wrote:
>>
>>>
>>>
>>> Hi,
>>> I am trying to two column and display some result if two conditions are
>>> meet but i am getting this error:
>>>
>>> The view eLeave.views.FMKD1_leave_to_authorize didn't return an 
>>> HttpResponse object. It returned None instead.
>>>
>>>
>>> I can seems to figure out the issue, here is my view.py file
>>>
>>> def FMKD1_leave_to_authorize(request):
>>> new_leave
>>> =newleave.objects.filter(department_head_authorization="Approved" )
>>> a = newleave.objects.filter(department="FMKD")
>>> if new_leave=="True"and a =="True":
>>> return render_to_response('FMKD1_display_approve_leave.html',
>>> locals())
>>>
>>> --
>>> 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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAPCf-y7uRsM8Vx6Jj5QD4ZY%2BCk24SkgCHZv-xMGZr49icPrmrA%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+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CALn3ei0QaQbwb%3DvkGJ6%2B4DB19p2ZDjTzJb1fSmoAhWUGg_H5PA%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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPCf-y6MXc2tR5wBBv9358TMoyBV5K5Ay8vHOSji104fBz1Ovg%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 receiv

Re: filter

2015-01-15 Thread sum abiut
Ok thanks,

i just released that i have made a mistake. so basically here are my
template.html and view.py
i think there is a mistake in my view.py the display result is not what i
was looking for. can't seem to figure it out.

template.html



Select to approve leave
  First Name
  Last Name
  Position
  Department
  Leave Type
  Details
  Start Date
  End Date
  Total working days
  # of leave left
   Department Head Authorization
  Authorize By
   Remarks
  Authorized Date


{%for a in new_leave%}

  
{{a.first_name}}
  {{a.last_name}}
  {{a.position}}
  {{a.department}}
{{a.leave_type}}
  {{a.specify_details}}
  {{a.start_date}}
  {{a.end_date}}
  {{a.total_working_days}}
  {{a.total_Leave_Left}}
   {{a.department_head_authorization}}
{{a.authorized_by}}
 {{a.remarks}}
 {{a.authorization_date}}

  
{%endfor%}




view.py


def FMKD1_leave_to_authorize(request):
new_leave
=newleave.objects.filter(department_head_authorization="Approved" )
new_leave = newleave.objects.filter(department="FMKD")
if new_leave.exists() and new_leave.exists():
return render_to_response('FMKD1_display_approve_leave.html',
locals())






On Fri, Jan 16, 2015 at 10:52 AM, Vijay Khemlani  wrote:

> in your view new_leave and a are QuerySet objects, and then you are
> comparing them to a string ("True") not a bolean (True without quotes), so
> it's always False.
>
> Even if you change "True" to True it won't work, try it like this
>
> if new_leave.exists() and a.exists():
>   return ...
>
>
> On Thu, Jan 15, 2015 at 8:40 PM, sum abiut  wrote:
>
>>
>>
>> Hi,
>> I am trying to two column and display some result if two conditions are
>> meet but i am getting this error:
>>
>> The view eLeave.views.FMKD1_leave_to_authorize didn't return an HttpResponse 
>> object. It returned None instead.
>>
>>
>> I can seems to figure out the issue, here is my view.py file
>>
>> def FMKD1_leave_to_authorize(request):
>> new_leave
>> =newleave.objects.filter(department_head_authorization="Approved" )
>> a = newleave.objects.filter(department="FMKD")
>> if new_leave=="True"and a =="True":
>> return render_to_response('FMKD1_display_approve_leave.html',
>> locals())
>>
>> --
>> 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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAPCf-y7uRsM8Vx6Jj5QD4ZY%2BCk24SkgCHZv-xMGZr49icPrmrA%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+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei0QaQbwb%3DvkGJ6%2B4DB19p2ZDjTzJb1fSmoAhWUGg_H5PA%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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y6MXc2tR5wBBv9358TMoyBV5K5Ay8vHOSji104fBz1Ovg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: filter

2015-01-15 Thread Vijay Khemlani
in your view new_leave and a are QuerySet objects, and then you are
comparing them to a string ("True") not a bolean (True without quotes), so
it's always False.

Even if you change "True" to True it won't work, try it like this

if new_leave.exists() and a.exists():
  return ...


On Thu, Jan 15, 2015 at 8:40 PM, sum abiut  wrote:

>
>
> Hi,
> I am trying to two column and display some result if two conditions are
> meet but i am getting this error:
>
> The view eLeave.views.FMKD1_leave_to_authorize didn't return an HttpResponse 
> object. It returned None instead.
>
>
> I can seems to figure out the issue, here is my view.py file
>
> def FMKD1_leave_to_authorize(request):
> new_leave
> =newleave.objects.filter(department_head_authorization="Approved" )
> a = newleave.objects.filter(department="FMKD")
> if new_leave=="True"and a =="True":
> return render_to_response('FMKD1_display_approve_leave.html',
> locals())
>
> --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAPCf-y7uRsM8Vx6Jj5QD4ZY%2BCk24SkgCHZv-xMGZr49icPrmrA%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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei0QaQbwb%3DvkGJ6%2B4DB19p2ZDjTzJb1fSmoAhWUGg_H5PA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


filter

2015-01-15 Thread sum abiut
Hi,
I am trying to two column and display some result if two conditions are
meet but i am getting this error:

The view eLeave.views.FMKD1_leave_to_authorize didn't return an
HttpResponse object. It returned None instead.


I can seems to figure out the issue, here is my view.py file

def FMKD1_leave_to_authorize(request):
new_leave
=newleave.objects.filter(department_head_authorization="Approved" )
a = newleave.objects.filter(department="FMKD")
if new_leave=="True"and a =="True":
return render_to_response('FMKD1_display_approve_leave.html',
locals())

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAPCf-y7uRsM8Vx6Jj5QD4ZY%2BCk24SkgCHZv-xMGZr49icPrmrA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Authenticate users with both username and email

2015-01-15 Thread Matt Cooper
Your if block in views.py is not well-formed. I haven't tested this but I'd 
write it more like this:

# try username
user = auth.authenticate(username=username, password=password)
if user is not None:
auth.login(request, user)
return HttpResponseRedirect('/')
# fall-through to email
user = auth.authenticate(email=username, password=password)
if user is not None:
auth.login(request, user)
return HttpResponseRedirect('/')
# ok, neither one worked
return HttpResponseRedirect('/accounts/invalid_login')


On Wednesday, January 14, 2015 at 10:07:29 PM UTC-8, Kakar Nyori wrote:

> I have extendted the *UserCreationForm* with email and other fields, so 
> that I could authenticate a user with both its username and email.
>
> forms.py:
>
>> class UserCreationForm(UserCreationForm):
>> class Meta:
>> model = User
>> fields = ('first_name', 'last_name', 'username', 'email',)
>
>
>  
> views.py:
>
> def auth_view(request):
>> username = request.POST.get('username','')
>> password = request.POST.get('password','')
>> user = auth.authenticate(username=username, password=password)
>> if user is not None:
>> auth.login(request, user)
>> return HttpResponseRedirect('/')
>> elif:
>> user = auth.authenticate(email=username, password=password)
>> if user is not None:
>> auth.login(request, user)
>> return HttpResponseRedirect('/')
>> else:
>> return HttpResponseRedirect('/accounts/invalid_login')
>
>
> html:
>
> 
>> {%csrf_token%}
>> Email or Username:
>> 
>> Password:
>> 
>> 
>> 
>
>
>
> In the views I tried giving both the *username* and *email *as input from 
> the form as *name*, and check to see if username and password 
> authenticate. If not then check whether email and password authenticate. 
> But its not working. How do I solve this problem? Please kindly help me. 
> Thank you.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/97740eb6-f826-4159-b770-20e66d917b20%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Use django rest framework with dynamoDB

2015-01-15 Thread victor . garcia
I need to create an api-rest with django-rest-framwork for bring data from 
a database DynamoDB.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f9ee519b-18a9-45a3-bd09-c34f9fdb6cc7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Canvas OAuth2 From Django View

2015-01-15 Thread Henry Versemann
First let me say that I haven't done a lot of stuff with either Python or 
Django, but I think I understand most of the basics. 
I am trying to get an access token back from the OAuth2 Web Application 
Flow of the Canvas' LMS API ( 
https://canvas.instructure.com/doc/api/file.oauth.html ). 
I have successfully sent the request in step 1 of the flow, and 
received back and extracted out of the response all of the data needed for 
step 3, which came back in step 2 of the flow.
So now in step 3 of the flow my problem is how to send a POST of the 
request needed, as described in step 3 of the flow, from a Django View.
I've not found anything definitive saying that I absolutely can't do a POST 
of a request, from a Django View, and have seen some  items which seem to 
indicate that I can do a POST from a view, but none of them seem to have 
detailed code examples or explanations of how to do it if it is possible. 
So far I've tried several ways of sending the POST within a 
returned HttpResponse and have not been successful, and if I understand 
things correctly HttpResponse doesn't allow it. 
I have also looked at all of the other Django Shortcut Functions 
documentation, and none of them seem to offer any obvious way of POSTing a 
request either. 
Can someone please point me to a good example of how to do it if it is 
possible, and if it is not maybe point me to one or more examples of how I 
might be able to successfully go through the Canvas OAuth2 Web Application 
Flow using some other module or package, that I can integrate into my 
Django application?
Thanks for the help.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/298a8f9d-3694-45f8-88c4-d9049a1e68d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How not to explicly write very very big json object when rendering page in django template ?

2015-01-15 Thread Matlau Issu
OK. AJAX is the solution.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6494c173-cc1d-43db-a914-8470f3019cbd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Need some advice on how to go about building a real time web app.

2015-01-15 Thread Shazwi Suwandi
Hi group,

I'm facing a very weird issue that causes a clash when I use swampdragon's 
*SelfPublishModel* and django's *models.Model*.
This is the current model that I'm using.

class Activity(SelfPublishModel, models.Model):
content = models.TextField()
dateTime = models.DateTimeField()
activityOwner = models.ForeignKey(User, related_name='activitiesOwned')
privacy = models.CharField()
participants = models.ManyToManyField(User)
event = models.ForeignKey(Event)

The activity model has a many to one relationship with the event model.
This works fine, but when an activity row gets added and points to an 
existing event, an error called "
*TypeError: 'NoneType' object is not callable".*
I found out that the error has something to do with this line residing at 
/swampdragon/models.py
*self._serializer = self.serializer_class(instance=self)*

I've tried all I could without touching /swampdragon/models.py but to no 
avail. Does anyone have a clue to point me somewhere to edit?



On Sunday, 4 January 2015 02:03:14 UTC+8, jonas hagstedt wrote:
>
> Yes I am the author of that article.
>
> Libraries does make life easier, as long as they are the right libraries 
> for the job.
>
> If you are unfamiliar with Angular I would actually recommend not using it.
>
> *  Angular 2.0 is supposedly not going to be backwards compatible (it 
> actually looks like a totally different framework).
> *  As you mentioned, you don't need to use Angular with SwampDragon.
> *  It's another layer of complexity.
> *  The blog post I linked to pretty much covers the basis for doing real 
> time notifications, and isn't using Angular, so you could more or less just 
> tweak that code and add it to your project.
>
>
> On Friday, January 2, 2015 4:12:10 PM UTC+1, Shazwi Suwandi wrote:
>>
>> Michiel: Ah, that's myopic on my part. Both sides are important. 
>>
>> Jonas: I see I see. I keep thinking that libraries will make my life a 
>> bit easier but maybe what I currently need now does not require the use of 
>> them. And are you the author of 
>> the article? (I'm assuming it's the same Jonas) Thank you so much for 
>> this link!! I'll go read it up. 
>>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1af4aabc-da9f-413f-8b95-5821d6f4a52d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ChoiceInline field giving name error

2015-01-15 Thread sanjeet kaur
>
> Are you following any tutorial? If yes, provide link.

Yes I was following tutorial of poll app and the error was solved by the
solution provided by vinayak

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO_JXR_kxNQo_kAZZOpHWA5UdxdJBbMYUArHECASzN4-07pyGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Authenticate users with both username and email

2015-01-15 Thread Kakar Nyori


I have extendted the *UserCreationForm* with email and other fields, so 
that I could authenticate a user with both its username and email.

forms.py:

> class UserCreationForm(UserCreationForm):
> class Meta:
> model = User
> fields = ('first_name', 'last_name', 'username', 'email',)


 
views.py:

def auth_view(request):
> username = request.POST.get('username','')
> password = request.POST.get('password','')
> user = auth.authenticate(username=username, password=password)
> if user is not None:
> auth.login(request, user)
> return HttpResponseRedirect('/')
> elif:
> user = auth.authenticate(email=username, password=password)
> if user is not None:
> auth.login(request, user)
> return HttpResponseRedirect('/')
> else:
> return HttpResponseRedirect('/accounts/invalid_login')


html:


> {%csrf_token%}
> Email or Username:
> 
> Password:
> 
> 
> 



In the views I tried giving both the *username* and *email *as input from 
the form as *name*, and check to see if username and password authenticate. 
If not then check whether email and password authenticate. But its not 
working. How do I solve this problem? Please kindly help me. Thank you.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0cb8e818-3145-4e91-a374-7b018092f4fd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Which 3rd Party (Social) Auth App should I use?

2015-01-15 Thread Tobias Dacoir
After more reading and experimenting I think I will use django-allauth. It 
allows local and social auth and signup. And I was able to customize the 
local signup form very easily (thanks to stackoverflow). 

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ad07bc1f-f1e0-4936-8bef-9a5fe3b94b2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ChoiceInline field giving name error

2015-01-15 Thread sanjeet kaur
On Jan 15, 2015 4:17 PM, "Kamal Kaur"  wrote:
>
> On Thu, Jan 15, 2015 at 4:08 PM, sanjeet kaur 
wrote:
> > Yes I tried but all that is correct.
>
> Are you following any tutorial? If yes, provide link.

Error solved

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAO_JXR-6DfGZrJVDhq2Up6WnQ5ngKeBvAdpi8BUTUj%3DUc4f0nQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ChoiceInline field giving name error

2015-01-15 Thread Kamal Kaur
On Thu, Jan 15, 2015 at 4:08 PM, sanjeet kaur  wrote:
> Yes I tried but all that is correct.

Are you following any tutorial? If yes, provide link.

-- 
Kamaljeet Kaur

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP8Q%2BxgZPbKt5H_96wdr3trC8SC1A6X2Vhds8cT%3D5e%2BBZSnKSg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ChoiceInline field giving name error

2015-01-15 Thread sanjeet kaur


>
>
> Have you tried this? 
>
> http://stackoverflow.com/questions/22768262/nameerror-not-defined 
>
> -- 
> Kamaljeet Kaur 
>
 

Yes I tried but all that is correct. 

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f36a6466-5cd5-476b-91e4-e18b47a0472f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.