session is missing on httpresponse redirect to google oauth

2013-11-19 Thread Aswani Kumar
here is my code @login_required def gpconnect(request): if 'code' in request.REQUEST: # insert google data to db return render_to_response('social/google.html') else: rty="https://accounts.google.com/o/oauth2/auth?client_id="+G

How to test django app

2013-11-19 Thread Harjot Mann
To test my django app I got unittest module in Django but what I am notiing that it needs to create tests for the functions in views.py file. So I need to do lot of coding. Is there any another way to do testing or this is the only best way to do it? Is anyone using it or can he/she share their exp

Re: Exception Value: column user_id is not unique

2013-11-19 Thread tim
Did you have unique=True when you created the database with south? If not, I cannot any reason for the discrepancy you are describing. south does treat apps that have migrations separately from the rest, but that doesn't seem to be related to the issue you had. On Tuesday, November 19, 2013 7:5

Re: Exception Value: column user_id is not unique

2013-11-19 Thread HannesP
Thanks for tip tim. Actually I have noticed a weird thing. Hope you can explain why it happened: Initially, I had installed south. when I created a fresh sqlite database, the module that I created always came separate form others. That is .manage.py syncdb resulted in Not synced (use migrations

Re: Filter ForeignKey values in model's admin view

2013-11-19 Thread tim
I don't see an easy way to do this offhand. Filtering the ForeignKey queryset using ModelAdmin.formfield_for_foreignkey [1] seems close, but I don't think there's any way to incorporate the values from the M2M field in your filtering. Have you considered writing some JavaScript to do the filter

Re: Exception Value: column user_id is not unique

2013-11-19 Thread tim
If you first run syncdb with the UserPic.user field unique=True, it's not enough just to change unique=False. You'll also need to remove the database unique constraint. Do you have the problem on a fresh syncdb if unique=False? If so, it would be helpful to include the full traceback of the err

Exception Value: column user_id is not unique

2013-11-19 Thread HannesP
I'm Django noob so please bear with me. I am trying to make a simple gallery for usres so that they can upload pics to their profile. Here are the relevant parts: models.py def get_uplaod_file_name(instance,filename): return 'uploaded_files/%s_%s' % (str(time()).replace('.','_'), filenam

Re: Filter ForeignKey values in model's admin view

2013-11-19 Thread Michal Ludvig
On 19/11/13 17:10, Michal Ludvig wrote: > > Hi > > I've got two Django models: Contact and Group, where Group has two > fields: contact and contact_primary linked to Contact. Like this: > > |class Group(models.Model): > name = models.CharField(max_length=200) > contacts = models.ManyToManyF

Re: Error: XXX is not JSON serializable

2013-11-19 Thread Lee Hinde
Thanks; I'm almost positive. I'll double check. I've worked around the problem by converting first. On Tue, Nov 19, 2013 at 12:58 PM, tim wrote: > Are you sure have the list() cast in the deployed version of the code? > Trying to serialize a ValuesListQuerySet directly would give the error you

Re: Error: XXX is not JSON serializable

2013-11-19 Thread tim
Are you sure have the list() cast in the deployed version of the code? Trying to serialize a ValuesListQuerySet directly would give the error you mention since repr() of a ValuesListQuerySet looks like a list. On Tuesday, November 19, 2013 12:28:11 PM UTC-5, Lee Hinde wrote: > > I have an app I'

Django Admin Error: pop-up entry form

2013-11-19 Thread Derek
Hi I am using Django 1.5.5. This error happens while running the dev server. If I click on the "+" button so I can use the pop-up form to add a new entry to a drop-down list (i.e. FK to another model), I get the following error trace when trying to save that form. File "/home/derek/.virtualenvs/

getting html form data into django class based view

2013-11-19 Thread Nikunj Aggarwal
I have created a Class view in `views.py` of the django application. class HelloTemplate(TemplateView): template_name = "index.html" def get_context_data(self, **kwargs): context = super(HelloTemplate, self).get_context_data(**kwargs) return context

Error: XXX is not JSON serializable

2013-11-19 Thread Lee Hinde
I have an app I'm moving from local dev (mac, python 2.7.2, django 1.5.4) to WebFaction (python 2.7.5. I'm storing record ids like so: section_ids = list(sections.values_list('id', flat=True)) request.session['query.section_ids.last'] = section_ids works fine locally and fails on WF with: (as

Re: Admin custom template

2013-11-19 Thread Mrinmoy Das
yup. tried. didnt worked. I am using django 1.6 On Nov 19, 2013 9:17 PM, "Rafael E. Ferrero" wrote: > are you try reading this? > https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#overriding-admin-templates > > > 2013/11/19 Mrinmoy Das > >> any help guys? >> On Nov 19, 2013 6:54 PM, "Mri

Re: Admin custom template

2013-11-19 Thread Sergiy Khohlov
also take a look at https://docs.djangoproject.com/en/dev/ref/contrib/gis/forms-api/ Anyway I would like to write those code by myseld and do not use default admin interface Many thanks, Serge +380 636150445 skype: skhohlov On Tue, Nov 19, 2013 at 5:48 PM, Rafael E. Ferrero wrote: > i mean...

Re: Admin custom template

2013-11-19 Thread Rafael E. Ferrero
i mean... carefully ? 2013/11/19 Rafael E. Ferrero > are you try reading this? > https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#overriding-admin-templates > > > 2013/11/19 Mrinmoy Das > >> any help guys? >> On Nov 19, 2013 6:54 PM, "Mrinmoy Das" wrote: >> >>> Hi, >>> >>> I have mad

Re: Admin custom template

2013-11-19 Thread Rafael E. Ferrero
are you try reading this? https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#overriding-admin-templates 2013/11/19 Mrinmoy Das > any help guys? > On Nov 19, 2013 6:54 PM, "Mrinmoy Das" wrote: > >> Hi, >> >> I have made a functionality where a user can input address through google >> map

Re: Admin custom template

2013-11-19 Thread Mrinmoy Das
any help guys? On Nov 19, 2013 6:54 PM, "Mrinmoy Das" wrote: > Hi, > > I have made a functionality where a user can input address through google > map on a site. Now the thing is, how can I enable the same stuff on django > admin panel? I am using > django-grappelli

Re: Django tables 2 with django-autocomplete-light

2013-11-19 Thread pnichols104
I'll check it out--thanks! On Friday, November 15, 2013 5:47:29 PM UTC-5, somecallitblues wrote: > > I have used datatables js for editable tables. Look up datatables jQuery > and you'll find a nice demo and a code example of how to implement them. > They also provide Ajax post when you press en

Re: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.

2013-11-19 Thread huw_at1
Hi, Many thanks. There is another form in the page which does contain this {% csrf_token %} tag. Removing this does remove the warning so this is indeed the issue. I just need to write the other form out of the template. Thanks for the answer :) On Tuesday, 19 November 2013 13:51:55 UTC, Giuli

Re: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.

2013-11-19 Thread huw_at1
Hi, Many thanks. There is another form in the page which does contain this {% csrf token %}. Removing this does remove the warning so this is indeed the issue. I just need to write the other form out of the template. Thanks for the answer :) On Tuesday, 19 November 2013 13:51:55 UTC, Giulio Ca

Re: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.

2013-11-19 Thread Giulio Calacoci
Il 19/11/2013 13:45, huw_at1 ha scritto: {% csrf_token %} If you are using the ajax metod, you don't need this tag in the form template. According with the documentation, you set the csrf token using javascript in the beforeSend part of the javascript code. Hope I've correctly understood y

Re: Problem with raw query and using in

2013-11-19 Thread huw_at1
Hi, I think I had something similar and followed this thread: http://stackoverflow.com/questions/4574609/executing-select-where-in-using-mysqldb I think this is what Dennis has already said so apologies if it isn't helpful. Kindest regards On Saturday, 16 November 2013 12:40:52 UTC, Thorsten

UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value.

2013-11-19 Thread huw_at1
Hi there, I'm trying to get to the bottom of this warning that I am getting: /usr/local/lib/python2.7/site-packages/django/template/defaulttags.py:59: UserWarning: A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestC

Re: order_by result of sum of fields computed from an annotate

2013-11-19 Thread Leonardo Giordani
Well, indeed the matter is not simple =) I looked at the raw SQL for your queries and the results are the following (just print queryset.query to show SQL). The SQL query for Author.objects.extra(select={'average_delay': "Avg('all_books__published_date')-Avg('all_books__added_date')"}) is SELE

Re: order_by result of sum of fields computed from an annotate

2013-11-19 Thread Jorge Cardoso Leitão
I'm sorry, you are right, I should have provided them. Let me formulate the question again, but with a complete example. # models.py class Book(models.Model): added_date = models.DateField()# date it was added to my shelf published_date = models.DateField() # date it was publishe