Re: Using IN clause with parameterized raw queries

2014-05-29 Thread J Y
It works! Thanks. It seems so obvious in hindsight that I am kicking myself for not thinking of it. On Thursday, May 29, 2014 7:26:58 PM UTC-7, Simon Charette wrote: > > Did you try: > > cursor.execute("SELECT username FROM users WHERE username NOT IN (%s, %s, > %s)", ['user_a', 'user_b', 'use

Re: Using IN clause with parameterized raw queries

2014-05-29 Thread Simon Charette
Did you try: cursor.execute("SELECT username FROM users WHERE username NOT IN (%s, %s, %s)", ['user_a', 'user_b', 'user_c']) Le jeudi 29 mai 2014 18:10:04 UTC-4, J Y a écrit : > > Let say I have this query I would like to execute: > > SELECT username FROM users WHERE username NOT IN ('user_a', '

Using IN clause with parameterized raw queries

2014-05-29 Thread J Y
Let say I have this query I would like to execute: SELECT username FROM users WHERE username NOT IN ('user_a', 'user_b', 'user_c') How do you run this using raw()? I've tried the following: cursor = connections["db"].cursor() cursor.execute("SELECT username FROM users WHERE username NOT IN (%s

Re: How to create a custom user model ?

2014-05-29 Thread Arnaud Vandecasteele
Hi Kirby, Thank you very much for these detailed information. Finally, I've went to the source code of Django's auth and I understand a bit better the process. Thanks again A. On Thu, May 29, 2014 at 2:43 PM, C. Kirby wrote: > Ah. > AbstractUser (AU) inherits from AbstractBaseUser (ABU). > A

Re: Django and Rails

2014-05-29 Thread Enrique Shadah
Thanks everyone. You've confirmed what I have suspected. Also, an MIT CS prof. suggested today to stick to python/django. Rails may be fast and cool, but that it may offer too much "magic" to really know what's going on and debug if needed. For a newbie like me, I need explicit guidance and

Re: Using AWS Redshift database Django 1.6

2014-05-29 Thread jpk
Ah, I see! I was mistaken, then. So the base db backend's sql_create_model is what generates the create table with the constraint? Then a db backend subclass just needs to override that to do whatever dbms-specific stuff it wants? Is there documentation on what all the methods in a django.db.ba

Re: Using AWS Redshift database Django 1.6

2014-05-29 Thread C. Kirby
I'll answer what I can from a quick review of the codebase. On Thursday, May 29, 2014 12:36:39 PM UTC-5, jpk wrote: > > Yeah, I came across that as well, but it didn't work on 1.6. I cloned and > debugged it up until I got the exact same error as the paste in my first > message. :( > > So, a fe

Re: Using AWS Redshift database Django 1.6

2014-05-29 Thread jpk
Yeah, I came across that as well, but it didn't work on 1.6. I cloned and debugged it up until I got the exact same error as the paste in my first message. :( So, a few questions: - Am I correct in my analysis that the syncdb command alone is generating the table creation sql that includes

Re: How to create a custom user model ?

2014-05-29 Thread C. Kirby
Ah. AbstractUser (AU) inherits from AbstractBaseUser (ABU). ABU only provides password and last login fields. You should use it as your base class if you want to do something radically different from the django user. The best example would be using email addresse for the username field.A standa

Re: How to create a custom user model ?

2014-05-29 Thread Geotribu
Hi, Thank you for your answer and this interesting link. But in this example, the class used is AbstractBaseUser. Can I just follow this example if I use AbstractUser. In fact my initial question was more related to a general understanding of Django and the differences between AbstractBaseUser

Re: Using AWS Redshift database Django 1.6

2014-05-29 Thread C. Kirby
Wow, redshift lets you save quite a bit of data. It looks like someone started in on a redshift backend, I found something on github (https://github.com/binarydud/django-redshift) It appears to be unmaintained, and maybe not even complete, but you might get some idea's of where work needs to be d

Re: How to create a custom user model ?

2014-05-29 Thread C. Kirby
The django documentation has a full example with code of using custom user models here On Thursday, May 29, 2014 8:06:24 AM UTC-5, Geotribu wrote: > > Hi Guys, > > I've developed a couple of website using Django, but

Using AWS Redshift database Django 1.6

2014-05-29 Thread jpk
Greetings, I'm attempting to set up a django project using amazon redshift as the database backend. I started a fresh 1.6.5 project and set up the database portion of settings.py to use the redshift cluster. With just the default apps (admin, auth, contenttypes, sessions, messages, and staticfile

Re: How to concatenate a list of Q objects?

2014-05-29 Thread Степан Дибров
from django.db.models import Q import operator qs = SomeModel.objects.all() # use reduce rules = [] for rule_key, rule_value in calculated_rules: rules.append(Q(rule_key=rule_value)) if rules: qs = qs.filter(reduce(operator.or_, rules)) # not use it q_collect = None for rule_key, rule_v

Re: Django and Rails

2014-05-29 Thread willyhakim
Django learning curve might be steeper than Rails, but it will make you a better web dev in the long run. Check out realpython.com and maybe start by getting a solid foundation on python On Wednesday, May 28, 2014 10:55:58 PM UTC-5, Enrique Shadah wrote: > > Hi all, > > I am learning Django aft

How to create a custom user model ?

2014-05-29 Thread Geotribu
Hi Guys, I've developed a couple of website using Django, but this is the first time I must develop one that integrates a user authentication process and the possibility to have some roles. Thanks to Django's flexibility, it looks like very easy to do it and pretty straightforward. >From my und

Re: @method_decorator(login_required) but how to add "login_url=''login/" to login_required

2014-05-29 Thread Kwaw Annor
In your settings.py create this variables LOGIN_URL = '/login_url/' LOGIN_REDIRECT_URL = '/redirect_url/' your can also try this On Monday, May 27, 2013 2:24:52 AM UTC, nany wrote: > > Thank your help,but could you

Date string do not parsed to date object in Model.objects.create

2014-05-29 Thread Mustafa Duman
I have a model like: class SomeModel(Model): created = DateField(...) I created an object using a date string (instead of date object) > new_rec = SomeModel.objects.create(created="2014-05-28") > new_rec.created >> "2014-05-28" > type(new_rec.created) >> str Whi

Re: reverse function

2014-05-29 Thread Kelvin Wong
Oooppps! print reverse('detail', args=[12]) # prints /specifics/12/ K On Thursday, May 29, 2014 4:04:47 AM UTC-7, Kelvin Wong wrote: > > The functions reverse and reverse_lazy are useful for figuring out the > paths from labels. If you or someone else changes the urlconf in the > future, your

Re: reverse function

2014-05-29 Thread Kelvin Wong
The functions reverse and reverse_lazy are useful for figuring out the paths from labels. If you or someone else changes the urlconf in the future, your app uses the new paths without difficulty. If you have in your urls.py url(r'^home/$', views.home, name='home'), url(r'^specifics/(?P\d+)/$',

Re: Django and Rails

2014-05-29 Thread WongoBongo
Try the tutorial and if you like it then stick with Django. Also, go and meet other python developers. Meetup is good for finding local groups. There might also be an active SIG nearby. K On Wednesday, May 28, 2014 8:55:58 PM UTC-7, Enrique Shadah wrote: > > Hi all, > > These are just two limit

reverse function

2014-05-29 Thread Agnese Camellini
Good morning everyone, i was using django as of django 0.9 and now i'm looking again in the tutorial and i have to say that a lot has changed. I undestand che basics (even if i cannot understan why in the tutorial they use the context and doesn'use any more "render_to_response") but however what i

Re: Custom user model backend

2014-05-29 Thread Kelvin Wong
Maybe try putting some logging in your CustomUserModelBackend. Near the top, put in some logging boilerplate: import logging logger = logging.getLogger(__name__) Then in your backend, something like this: class CustomUserModelBackend(ModelBackend): ... def get_user(self, user_id):

Re: backbonejs and django

2014-05-29 Thread Sanjay Bhangar
Hi, On Thu, May 29, 2014 at 3:07 PM, Eddilbert Macharia wrote: > Hi All, > > i am using django-tastypie to return django models as json object. > > when i run the following code > > var org = Backbone.Model.extend({ > >urlRoot: 'api/orgnanization/', > }); > > > var

Re: The installation instructions for Windows is based on Python 3.4 But The MySQL connectors for Python are only for 2.7, 3.2 and 3.3

2014-05-29 Thread Christian Weiss
Am 21.05.2014 01:05, schrieb Varuna Seneviratna: The installation instructions for Windows is based on Python 3.4 But The MySQL connectors for Python are only for 2.7, 3.2 and 3.3 What is the solution the problem? Varuna -- You received this message because you are subscribed to the Google Gro

backbonejs and django

2014-05-29 Thread Eddilbert Macharia
Hi All, i am using django-tastypie to return django models as json object. when i run the following code var org = Backbone.Model.extend({ urlRoot: 'api/orgnanization/', }); var orgColl=Backbone.Collection.extend({ model: org, urlRoot: