Re: django Page

2014-07-24 Thread aRkadeFR
If it's only static pages, you could look first django.contrib.flatpages to
see how to do it.

On 23/07/14 00:05, ngangsia akumbo wrote:
> I want to create an app where the user has the ability to create new pages 
> on their website
> 
> the app should be called pages 
> 
> can someone give me an idea pease?
> 
> -- 
> 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/e431fc80-fe0a-4eca-bfe3-70379906d1d9%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20140724074947.GA2404%40rkade-thinkpad.
For more options, visit https://groups.google.com/d/optout.


Forcing Django to use INNER JOIN instead of LEFT OUTER JOIN

2014-07-24 Thread Frankline
I have implemented search in my Django application to allow searching by
more than one field. This results in Django always using a LEFT OUTER JOIN,
which in my case generates the wrong results. However, when I change the
SQL generated from a LEFT OUTER JOIN to an INNER JOIN, it returns the
correct result.

I am thinking it has to do with the way Q object in my code below.

from django.db import models, transaction...def construct_search(field_name):
if field_name.startswith('^'):
return "%s__istartswith" % field_name[1:]
elif field_name.startswith('='):
return "%s__iexact" % field_name[1:]
elif field_name.startswith('@'):
return "%s__search" % field_name[1:]
else:
return "%s__icontains" % field_name

class CoreSearchMixin(object):
"""Subclasses must define search_fields = [field_1, ...field_n]
where the field is a string, the name of a field, and can contain
the following prefix characters:

'^': the search field must start with the search term, case insensitive
'=': the search field must exactly equal the search term, case insensitive
'@': full-text search

If no prefix is given, any string that contains the search field will match.
"""
search_fields = None
search_form_class = SearchForm

@cachedproperty
def search_form(self):
return self.search_form_class(getattr(self.request,
self.request.method))

def get_query_help_message(self):
"""Returns a comma separated list of fields that are used in
the search, to help the user
create a search.
"""
fields = []
if self.search_fields:
for search_field in self.search_fields:
field = get_field_from_path(self.model, search_field)
fields.append(field.verbose_name.title())
return ",".join(fields)

def get_filtered_queryset(self, queryset):
if self.search_form.is_valid():
self.query = self.search_form.cleaned_data['q']
else:
self.query = None
if self.search_fields and self.query:
orm_lookups =
(construct_search(str(search_field).replace('.', '__'))
   for search_field in self.search_fields)
chained_or_queries = None
for bit in self.query.split():
or_queries = (models.Q(**{orm_lookup: bit})
  for orm_lookup in orm_lookups)
if chained_or_queries:
chained_or_queries =
itertools.chain(chained_or_queries, or_queries)
else:
chained_or_queries = or_queries
return queryset.filter(reduce(operator.or_, chained_or_queries))
else:
return queryset

def get_context_data(self, **kwargs):
return super(CoreSearchMixin, self).get_context_data(
search_form=self.search_form,
query_help_message=self.get_query_help_message(),
search_fields=self.search_fields,
**kwargs
)

How can I ensure that an INNER JOIN is used instead of a LEFT OUTER JOIN in
the case of my code above?


http://stackoverflow.com/questions/24927062/forcing-django-to-use-inner-join-instead-of-left-outer-join

-- 
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/CAEAUGdVL7sJQsmh8WEC%3Dp031dL%3D-YF8mg5c_kvFyjCSAPwVxNA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Hiding models from certain UserAdmin

2014-07-24 Thread alireza sanaee
I want to hide some models in django admin from some users which are admins 
but I don't know it is possible or not  .
Thank you in advance .

-- 
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/08b37b2f-37de-4d7c-b074-dfeb093b08de%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Hiding models from certain UserAdmin

2014-07-24 Thread Gonzalo Delgado
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA256

El 24/07/14 09:36, alireza sanaee escribió:
> I want to hide some models in django admin from some users which
> are admins but I don't know it is possible or not  .

Django's permissions system[0] should allow you to do exactly that.

[0]
https://docs.djangoproject.com/en/1.6/topics/auth/default/#topic-authorization

- -- 
Gonzalo Delgado
-BEGIN PGP SIGNATURE-
Version: GnuPG v1
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iF4EAREIAAYFAlPRAK0ACgkQzbfdFL5JoUmA3AD/etZo/zjdFK+q0n+MTnHYQhu7
oBDYg9/trbisA5uiTi0BAISY3krV26Yn6toRkuA31aMD5BIMWoHjPGWTm3Gs6W30
=4wfU
-END PGP SIGNATURE-

-- 
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/53D100AE.1050808%40gonzalodelgado.com.ar.
For more options, visit https://groups.google.com/d/optout.


Re: Forcing Django to use INNER JOIN instead of LEFT OUTER JOIN

2014-07-24 Thread Tom Evans
On Thu, Jul 24, 2014 at 1:17 PM, Frankline  wrote:
> I have implemented search in my Django application to allow searching by
> more than one field. This results in Django always using a LEFT OUTER JOIN,
> which in my case generates the wrong results. However, when I change the SQL
> generated from a LEFT OUTER JOIN to an INNER JOIN, it returns the correct
> result.
>
> I am thinking it has to do with the way Q object in my code below.
>
> from django.db import models, transaction
> ...
> def construct_search(field_name):
> if field_name.startswith('^'):
> return "%s__istartswith" % field_name[1:]
> elif field_name.startswith('='):
> return "%s__iexact" % field_name[1:]
> elif field_name.startswith('@'):
> return "%s__search" % field_name[1:]
> else:
> return "%s__icontains" % field_name
>
>
> class CoreSearchMixin(object):
> """Subclasses must define search_fields = [field_1, ...field_n]
> where the field is a string, the name of a field, and can contain the
> following prefix characters:
>
> '^': the search field must start with the search term, case insensitive
> '=': the search field must exactly equal the search term, case
> insensitive
> '@': full-text search
>
> If no prefix is given, any string that contains the search field will
> match.
> """
> search_fields = None
> search_form_class = SearchForm
>
> @cachedproperty
> def search_form(self):
> return self.search_form_class(getattr(self.request,
> self.request.method))
>
> def get_query_help_message(self):
> """Returns a comma separated list of fields that are used in the
> search, to help the user
> create a search.
> """
> fields = []
> if self.search_fields:
> for search_field in self.search_fields:
> field = get_field_from_path(self.model, search_field)
> fields.append(field.verbose_name.title())
> return ",".join(fields)
>
> def get_filtered_queryset(self, queryset):
> if self.search_form.is_valid():
> self.query = self.search_form.cleaned_data['q']
> else:
> self.query = None
> if self.search_fields and self.query:
> orm_lookups = (construct_search(str(search_field).replace('.',
> '__'))
>for search_field in self.search_fields)
> chained_or_queries = None
> for bit in self.query.split():
> or_queries = (models.Q(**{orm_lookup: bit})
>   for orm_lookup in orm_lookups)
> if chained_or_queries:
> chained_or_queries = itertools.chain(chained_or_queries,
> or_queries)
> else:
> chained_or_queries = or_queries
> return queryset.filter(reduce(operator.or_, chained_or_queries))
> else:
> return queryset
>
> def get_context_data(self, **kwargs):
> return super(CoreSearchMixin, self).get_context_data(
> search_form=self.search_form,
> query_help_message=self.get_query_help_message(),
> search_fields=self.search_fields,
> **kwargs
> )
>
> How can I ensure that an INNER JOIN is used instead of a LEFT OUTER JOIN in
> the case of my code above?
>
>
> http://stackoverflow.com/questions/24927062/forcing-django-to-use-inner-join-instead-of-left-outer-join
>

Can you reduce that code to a single line test case please.

Eg, "Foo.objects.filter(Q(...) | Q(...)) is making a LEFT OUTER JOIN, why"

I suspect that you are OR'ing lookups that span the same relationship.

Cheers

Tom

-- 
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/CAFHbX1LP87H11rX_%2Ba6ysvfCa36fCQkVsMgJOH9QggKp9CkXtg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Problem in the Tutorial 01

2014-07-24 Thread Fabian Zentner
Hey guys, 

I'm new with Django and Python as well. I'm doing the tutorial 1 on the 
website (https://docs.djangoproject.com/en/1.6/intro/tutorial01/). 
I'm using Python27 (C:\Python27) 
In C:\Python27\Scripts\ I have the project mysite and polls like in the 
tutorial 

In the part "Playing with the API" 




































































































































*c:\Python27\Scripts\mysite >manage.py syncdb Creating tables ... Creating 
table polls_poll Creating table polls_choice Installing custom SQL ... 
Installing indexes ... Installed 0 object(s) from 0 fixture(s) 
c:\Python27\Scripts\mysite>manage.py shell Python 2.7.7 (default, Jun  1 
2014, 14:21:57) [MSC v.1500 64 bit (AMD64)] on win 32 Type "help", 
"copyright", "credits" or "license" for more information. 
(InteractiveConsole) >>> from polls.models import Poll, Choice >>> 
Poll.objects.all() [] >>> from django.utils import timezone >>> p = 
Poll(question="What's new?", pub_date=timezone.now()) >>> p.save() >>> p.id 
1 >>> p.question "What's new?" >>> p.pub_date datetime.datetime(2014, 7, 
24, 11, 10, 43, 935000, tzinfo=) >>> p.question = "What's up?" >>> 
p.save() >>> Poll.objects.all() [] >>> from polls.models 
import Poll, Choice >>> Poll.objects.all() [] >>> 
Poll.objects.filter(id=1) [] >>> Poll.objects.all() 
[] >>> Poll.objects.filter(id=1) [] 
>>> Poll.objects.filter(question__startswith='What') [] 
>>> from django.utils import timezone >>> current_year = 
timezone.now().year >>> Poll.objects.get(pub_date__year=current_year) 
 >>> Poll.objects.get(id=2) Traceback (most recent call 
last):   File "", line 1, inFile 
"C:\Python27\lib\site-packages\django\db\models\manager.py", line 151, in 
 get return self.get_queryset().get(*args, **kwargs)   File 
"C:\Python27\lib\site-packages\django\db\models\query.py", line 310, in g 
et self.model._meta.object_name) DoesNotExist: Poll matching query does 
not exist. >>> Poll.objects.get(pk=1)  >>> p = 
Poll.objects.get(pk=1) >>> o.was_published_recently() Traceback (most 
recent call last):   File "", line 1, in  NameError: name 
'o' is not defined >>> p.was_published_recently() Traceback (most recent 
call last):   File "", line 1, in  AttributeError: 'Poll' 
object has no attribute 'was_published_recently' >>> p = 
Poll.objects.get(pk=1) >>> p.was_published_recently() Traceback (most 
recent call last):   File "", line 1, in  AttributeError: 
'Poll' object has no attribute 'was_published_recently' >>> from 
polls.models import Poll, Choice >>> Poll.objects.all() [] >>> from django.utils import timezone >>> p = 
Poll(question="What's new?", pub_date=timezone.now()) >>> p.save() >>> p.id 
2 >>> p.question "What's new?" >>> p.pub_date datetime.datetime(2014, 7, 
24, 11, 54, 15, 453000, tzinfo=) >>> p.question = "What's up?" >>> 
p.save() >>> Poll.objects.all() [, ] 
>>> from polls.models import Poll, Choice >>> Poll.objects.all() [, ] >>> Poll.objects.filter(id=1) [] >>> Poll.objects.filter(question__startswith='What') [, ] >>> from django.utils import timezone 
>>> current_year = timezone.now().year >>> 
Poll.objects.get(pub_date__year=current_year) Traceback (most recent call 
last):   File "", line 1, inFile 
"C:\Python27\lib\site-packages\django\db\models\manager.py", line 151, in 
 get return self.get_queryset().get(*args, **kwargs)   File 
"C:\Python27\lib\site-packages\django\db\models\query.py", line 313, in g 
et (self.model._meta.object_name, num)) MultipleObjectsReturned: get() 
returned more than one Poll -- it returned 2! >>> Poll.objects.get(id=2) 
 >>> Poll.objects.get(pk=1)  >>> p = 
Poll.objects.get(pk=1) >>> p.was_published_recently() Traceback (most 
recent call last):   File "", line 1, in  AttributeError: 
'Poll' object has no attribute 'was_published_recently' >>> p = 
Poll.objects.get(pk=1) >>> p.choice_set.all() [] >>> 
p.choice_set.create(choice_text='Not much', votes=0)  >>> p.choice_set.create(choice_text="The Sky", votes=0)  >>> c = p.choice_set.create(choice_text="Just hacking 
again", votes=0) >>> c.poll  >>> p.choice_set.all() 
[, , , 
, , ] 
>>> p.choice_set.count() 6 *
I get always Poll: Poll object or Choice: Choice object instead of the 
defined text. Also I have problems with the part of 



* p = Poll.objects.get(pk=1) >>> p.was_published_recently() * 
Could somebody help me please? Before I start with the tutorial number 2... 

Thanks a lot. 

Fabian 

-- 
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/f67739a9-d300-463a-8ea3-6c8b2d3a2a14%40googlegroups.com.
For more options, 

Re: Problem in the Tutorial 01

2014-07-24 Thread Sergiy Khohlov
On Thu, Jul 24, 2014 at 3:53 PM, Fabian Zentner <
zentner.fab...@googlemail.com> wrote:

> *Poll.objects.get(pub_date__year=current_year) *


try to use
*Poll.objects.first()*
 you have 2 object and it is a reason of your traceback

Many thanks,

Serge


+380 636150445
skype: skhohlov

-- 
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/CADTRxJNYz1imQ9i50EnSW9oYzREhT38pmdjbX6gsSqq8vYtJRA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Problem in the Tutorial 01

2014-07-24 Thread Daniel Roseman
On Thursday, 24 July 2014 13:53:54 UTC+1, Fabian Zentner wrote:
>
> Hey guys, 
>
> I'm new with Django and Python as well. I'm doing the tutorial 1 on the 
> website (https://docs.djangoproject.com/en/1.6/intro/tutorial01/). 
> I'm using Python27 (C:\Python27) 
> In C:\Python27\Scripts\ I have the project mysite and polls like in the 
> tutorial 
>
> In the part "Playing with the API" 
>
>
> **
>
 

>
>
>
>
>
> *>>> p.choice_set.all() [, , 
> , , , 
> ] >>> p.choice_set.count() 6 *
> I get always Poll: Poll object or Choice: Choice object instead of the 
> defined text. Also I have problems with the part of 
>
>
>
> * p = Poll.objects.get(pk=1) >>> p.was_published_recently() * 
> Could somebody help me please? Before I start with the tutorial number 
> 2... 
>
> Thanks a lot. 
>
> Fabian
>


After you make changes to the code,  you need to reload it: the easiest way 
is exit your shell and go back in.
-- 
DR.

-- 
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/d80dc547-6194-4398-81d9-e93db01ca9cf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to django-registration (unmaintaned since September 2013)

2014-07-24 Thread Scot Hacker
On Friday, July 18, 2014 5:31:14 AM UTC-7, Santiago L wrote:
>
> Hi,
>
> Some weeks ago I noticed that django-registration is not longer maintained 
> by
> its creator:
>

I've switched to django-allauth for my Django projects, which does an 
equally superb job of supporting both social and traditional logins, is 
very well documented, actively supported, and easy to implement. 

https://github.com/pennersr/django-allauth

YMMV. 

./s

-- 
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/23766955-9002-40bf-a064-c28e5ada382a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Alternative to django-registration (unmaintaned since September 2013)

2014-07-24 Thread Oscar Carballal
Same for me in my personal projects and in our company, we fully switched
to django-allauth and we are quite happy

Regards,
Oscar

--
Oscar Carballal Prego - Senior Software Developer
http://oscarcp.com | @pizte


2014-07-23 8:15 GMT+01:00 Santiago L :

> El sábado, 19 de julio de 2014 02:17:24 UTC+2, Russell Keith-Magee
> escribió:
>
>>
>> On Fri, Jul 18, 2014 at 8:31 PM, Santiago L  wrote:
>>
>>> Hi,
>>>
>>> Some weeks ago I noticed that django-registration is not longer
>>> maintained by
>>> its creator:
>>>
>>> quoting https://bitbucket.org/ubernostrum/django-registration/wiki/Home
>>> > django-registration
>>> > I stepped down as maintainer of this application in September 2013.
>>> Pull
>>> > requests, issues and comments sent to this repository will be ignored.
>>>
>>>
>>> As I'm currently using this app in my project, I wonder if there is any
>>> alternative for django-registration? Maybe someone knows about a fork.
>>>
>>
>> I'm not aware of an active fork. If you're looking to step into open
>> source contribution, this would be a good project to adopt - the code base
>> is stable, so the management overhead should be relatively low.
>>
>
> I like the idea about contributing and get in charge of a fork, but I'm
> not sure about my availability...
>
>
>>
>>
>>> Besides that, I found a related issue report (rejected because is not
>>> the good
>>> place to ask this question, but relevant anyway)[2]
>>>
>>> [2] https://code.djangoproject.com/ticket/13164
>>>
>>> Because there's no single answer to the question.
>>
>> Authentication is a topic that is hard to get right, and there's a very
>> limited number of "right" answers. Passwords *must* be done well, or you
>> risk vulnerability, and what constitutes "well" requires considerable
>> expertise.
>>
>> However, the requirements for registration and signup will vary between
>> projects, and will depend on project requirements. Some projects will need
>> a fully verified personal profile before you can continue; some only
>> require a verified email address; some will allow an email address, but
>> allow later verification, and some will require completely anonymous
>> profiles that are filled in at a critical point in workflow (e.g., at
>> checkout in an e-commerce site).
>>
>> There's also nothing especially technically complex about these workflows
>> - unlike Authentication, there aren't any real land mines that could lead
>> to vulnerabilities (beyond those that are inherent in building *any* web
>> page).
>>
>> So, the Django project has made the decision to keep Authentication as a
>> core piece of functionality, but keep registration as a third-party thing.
>> This means that the wider community can contribute alternate approaches. It
>> also means that the core team isn't a bottleneck on progress -
>> django-regsistration has it's own release cycles, bug tracking processes,
>> and so on.
>>
>> This arrangement has worked well for 8 years; it's only because James has
>> stepped down and nobody has volunteered to take over that a problem now
>> exists.
>>
>>
> Thanks for your explanation!!
>
> --
> 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/a8450ee8-96a0-4a1e-9071-2740544e5533%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BXe2iaED-arSkS7R1zTrZyTpkLEUBTz_hmJmubT%3Db7%3DaQc9fQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


display Foreign Key values in Django haystack search results

2014-07-24 Thread Kannan
Hello Everyone..

I have posted this question in Stackoverflow. I didn't not get answers so
far.. posting here to hope some help from you guys..

http://stackoverflow.com/questions/24936919/display-foreign-key-values-in-django-haystack-search-results


I am new to django and haystack. Can anyone please help me with this code.
I have the below Models in models.py file

class UserProfile(models.Model):
street_address = models.CharField(max_length=100, blank=False, null=False)
city = models.CharField(max_length=100, blank=False, null=False)
zip_code = models.PositiveIntegerField(blank=False, null=True)
class UserProfessional(models.Model):
userprofile = models.ForeignKey(UserProfile, unique=True,
related_name = 'user_profiles')
company = models.CharField(max_length=200, blank=False, null=False)
professional_type = models.CharField(max_length=50,
choices=PROFESSIONAL_TYPE)
bio_exp = models.CharField(max_length=300)

*The search criteria would be zip_code, city and state. So we can search by
zip code but the results should display the user_profile, company, and
bio_exp.*

I have been trying the following code.. but it is not working as expected.

class UserProfileIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.CharField(document=True,use_template=True)
name = indexes.CharField()

def get_model(self):
return UserProfile

def index_queryset(self, using=None):
"""Used when the entire index for model is updated."""
return self.get_model().objects.all().select_related('user_profiles')

def prepare_name(self, obj):
return obj.user_profiles.bio_exp


-- 
With regards,

Kannan. R. P,
Blog @: http://kannan4k.wordpress.com/

-- 
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/CAL4xV_A-1Wqah_2TGWDp-9K254bovDrBoh1%2B9xmudjJ0k240Tg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Migration failure in 1.7c1 on DateTimeField defaults

2014-07-24 Thread dolsen
I have created two new fields on my model. Created and updated. They are 
both DateTimeField objects. When I run makemigrations it asks for a fix 
because there is no default value for the two fields. I have tried 
datetime.now(), datetime.datetime.now(), datetime.date.today(), etc. 
However, I keep getting the same error so I can't update my tables. Here is 
the error I am getting:

You are trying to add a non-nullable field 'created' to chore without a 
default;
we can not do that (the database needs something to populate existing rows).
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows)
 2) Quit, and let me add a default in models.py
Select an option: 1
Please enter the default value now, as valid Python
The datetime module is available, so you can do e.g. datetime.date.today()
>>> datetime.datetime.now
Traceback (most recent call last):
  File "/Applications/PyCharm.app/helpers/pycharm/django_manage.py", line 23
, in 
run_module(manage_file, None, '__main__', True)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py"
, line 176, in run_module
fname, loader, pkg_name)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py"
, line 82, in _run_module_code
mod_name, mod_fname, mod_loader, pkg_name)
  File 
"/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py"
, line 72, in _run_code
exec code in run_globals
  File "...manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File "...lib/python2.7/site-packages/django/core/management/__init__.py", 
line 385, in execute_from_command_line
utility.execute()
  File "...lib/python2.7/site-packages/django/core/management/__init__.py", 
line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "...lib/python2.7/site-packages/django/core/management/base.py", 
line 288, in run_from_argv
self.execute(*args, **options.__dict__)
  File "...lib/python2.7/site-packages/django/core/management/base.py", 
line 337, in execute
output = self.handle(*args, **options)
  File 
"...lib/python2.7/site-packages/django/core/management/commands/makemigrations.py"
, line 111, in handle
convert_apps=app_labels or None,
  File "...lib/python2.7/site-packages/django/db/migrations/autodetector.py"
, line 50, in changes
changes = self._detect_changes(convert_apps, graph)
  File "...lib/python2.7/site-packages/django/db/migrations/autodetector.py"
, line 180, in _detect_changes
self.generate_added_fields()
  File "...lib/python2.7/site-packages/django/db/migrations/autodetector.py"
, line 720, in generate_added_fields
field.default = self.questioner.ask_not_null_addition(field_name, 
model_name)
  File "...lib/python2.7/site-packages/django/db/migrations/questioner.py", 
line 119, in ask_not_null_addition
code = input(">>> ").decode(sys.stdin.encoding)
TypeError: decode() argument 1 must be string, not None



Any ideas how to make this work?

-- 
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/c456ac80-36ff-41d0-bc8a-df98554cc403%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting list of user groups

2014-07-24 Thread Kyle Adams
Thanks for your help, Russ. I'm planning to expose the user to the names of 
the groups using a drop list on my site. They'll choose a group, then our 
site will get the list of users in that group from Django, and then send a 
query to our database to get the data for that group of users.

-- 
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/7dd07c3d-92c7-41fb-b5b8-aee98ff4d44d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Please help:ImportError: No module named django

2014-07-24 Thread New Django User
Hi, I have problems with Django in windows 7.

I installed Django using Windows Powershell: 

PS C:\Python27> pip install django
Requirement already satisfied (use --upgrade to upgrade): django in 
c:\anaconda\lib\site-package.

However, when I run "import django" in Python 2.7.6 shell, it showed the 
following error message:

Traceback (most recent call last):
  File "", line 1, in 
import django
ImportError: No module named django

I searched over the internet and did not find useful information. 

Please help.

Many thanks in advance.


-- 
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/b30d3b18-c728-4bd5-8a72-874dd5a065b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Please help:ImportError: No module named django

2014-07-24 Thread Matt Gushee
Hi, Liu Xuan--

What result do you get when you do the following?

Python 2.7.6

>>> import sys
>>> sys.path

On Thu, Jul 24, 2014 at 1:23 PM, New Django User  wrote:
> Hi, I have problems with Django in windows 7.
>
> I installed Django using Windows Powershell:
>
> PS C:\Python27> pip install django
> Requirement already satisfied (use --upgrade to upgrade): django in
> c:\anaconda\lib\site-package.
>
> However, when I run "import django" in Python 2.7.6 shell, it showed the
> following error message:
>
> Traceback (most recent call last):
>   File "", line 1, in 
> import django
> ImportError: No module named django
>
> I searched over the internet and did not find useful information.
>
> Please help.
>
> Many thanks in advance.
>
>
> --
> 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/b30d3b18-c728-4bd5-8a72-874dd5a065b3%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABrD0efC05zFMNOgTKDX%3D0YcCV5tAnW6JDUbamOosRTRqGQLxg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting list of user groups

2014-07-24 Thread Kyle Adams
One issue I'm still having is actually getting the list of group names. I'm 
trying to use the line

groups = Group.objects.value_list('name', flat=True)

but I'm getting an error that reads 

'GroupManager' object has no attribute 'value_list'


Any idea about this?

-- 
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/cfda2446-eb3d-4a62-b19f-643e9f08b768%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Getting list of user groups

2014-07-24 Thread Kyle Adams
After some more research, turns out it is "values_list" instead of 
"value_list"

-- 
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/54e20481-8952-4f84-b471-7c13556c1354%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Queryset with filtering on reverse foreign key failing

2014-07-24 Thread Anthony Hawkes


Hi All,

I'm currently using a MSSQL DB to access some data and am using django's 
inspectdb results. I've had to tweak some of the model but so far things 
have been smooth sailing. Today I needed to run a lookup that spanned 
through some tables forward and reverse and tested the following in shell 
which worked fine:

>python manage.py shellfrom db_ccmdata.models_auto import 
>TbldataAgentperformancebyperiod as agent_performance
agent_performance.objects.filter(fkagent__tblconfigagentgroupmembers__fkagentgroup__name="IT
 Call Centre Immediate")

When I implemented this in my code I started getting a FieldError and am 
confused as hell.

agent_queue = agent_performance.objects.filter(
midnightstartdate__range=(date + ' 00:00:00', date + ' 
23:59:59')).filter(fkagent__tblconfigagentgroupmembers__fkagentgroup__name='IT 
Call Centre Immediate').order_by('fktimeinterval')

I've checked the relationships are all okay but the perplexing thing is 
that it works in shell as expected.

the relationship is

tbldataagentperformancebyperiod *agentfk* -> *pkey* tblconfigagent *pkey*
 <- *agentfk*tblconfigagentgroupmembers *groupfk* -> *pkey* tblconfiggroup

I'm not sure if it's relevant but doing ./manage.py no longer works and 
manage.py returns ": No such file or directory" (it's definitely 
manage.py/python returning this) so I've been calling it with python 
manage.py etc


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/6061aae0-996b-485c-a971-684cf237b25d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


psycopg2

2014-07-24 Thread Henrique Oliveira





*Hi All,I am trying to install psycopg2 but I am getting this error:*I 
already installed python3-dev and libpq-devAny idea?*

Downloading/unpacking psycopg2
  Downloading psycopg2-2.5.3.tar.gz (690kB): 690kB downloaded
  Running setup.py (path:/opt/d/build/psycopg2/setup.py) egg_info for 
package psycopg2

Installing collected packages: psycopg2
  Running setup.py install for psycopg2
Skipping implicit fixer: buffer
Skipping implicit fixer: idioms
Skipping implicit fixer: set_literal
Skipping implicit fixer: ws_comma
building 'psycopg2._psycopg' extension
gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O2 -Wall 
-Wstrict-prototypes -g -O2 -fstack-protector --param=ssp-buffer-size=4 
-Wformat -Werror=format-security -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 
-DPSYCOPG_VERSION="2.5.3 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1 
-DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DPG_VERSION_HEX=0x090304 
-DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 
-I/usr/include/python3.3m -I. -I/usr/include/postgresql 
-I/usr/include/postgresql/9.3/server -c psycopg/psycopgmodule.c -o 
build/temp.linux-x86_64-3.3/psycopg/psycopgmodule.o 
-Wdeclaration-after-statement
In file included from psycopg/psycopgmodule.c:27:0:
./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or 
directory
 #include 
^
compilation terminated.
error: command 'gcc' failed with exit status 1
Complete output from command /opt/d/bin/python3.3 -c "import 
setuptools, 
tokenize;__file__='/opt/d/build/psycopg2/setup.py';exec(compile(getattr(tokenize,
 
'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" 
install --record /tmp/pip-on_knf-record/install-record.txt 
--single-version-externally-managed --compile --install-headers 
/opt/d/include/site/python3.3:
running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-3.3

creating build/lib.linux-x86_64-3.3/psycopg2

copying lib/extensions.py -> build/lib.linux-x86_64-3.3/psycopg2

copying lib/extras.py -> build/lib.linux-x86_64-3.3/psycopg2

copying lib/__init__.py -> build/lib.linux-x86_64-3.3/psycopg2

copying lib/_range.py -> build/lib.linux-x86_64-3.3/psycopg2

copying lib/psycopg1.py -> build/lib.linux-x86_64-3.3/psycopg2

copying lib/_json.py -> build/lib.linux-x86_64-3.3/psycopg2

copying lib/errorcodes.py -> build/lib.linux-x86_64-3.3/psycopg2

copying lib/pool.py -> build/lib.linux-x86_64-3.3/psycopg2

copying lib/tz.py -> build/lib.linux-x86_64-3.3/psycopg2

creating build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_types_extras.py -> 
build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_async.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/testconfig.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_module.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_with.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_quote.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_cursor.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_cancel.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_transaction.py -> 
build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/__init__.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_connection.py -> 
build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_notify.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_copy.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_green.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_types_basic.py -> 
build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_extras_dictcursor.py -> 
build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_psycopg2_dbapi20.py -> 
build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_lobject.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/test_dates.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/dbapi20.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

copying tests/testutils.py -> build/lib.linux-x86_64-3.3/psycopg2/tests

Skipping implicit fixer: buffer

Skipping implicit fixer: idioms

Skipping implicit fixer: set_literal

Skipping implicit fixer: ws_comma

running build_ext

building 'psycopg2._psycopg' extension

creating build/temp.linux-x86_64-3.3

creating build/temp.linux-x86_64-3.3/psycopg

gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O2 -Wall 
-Wstrict-prototypes -g -O2 -fstack-protector --param=ssp-buffer-size=4 
-Wformat -Werror=format-security -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1 
-DPSYCOPG_VERSION="2.5.3 (dt dec pq3 ext)" -DPS

Re: psycopg2

2014-07-24 Thread Mario Gudelj
Install this first:

sudo apt-get install python-dev

Then try installing that package again.


On 25 July 2014 09:55, Henrique Oliveira 
wrote:

>
>
>
>
>
> *Hi All,I am trying to install psycopg2 but I am getting this error:*I
> already installed python3-dev and libpq-devAny idea?*
>
> Downloading/unpacking psycopg2
>   Downloading psycopg2-2.5.3.tar.gz (690kB): 690kB downloaded
>   Running setup.py (path:/opt/d/build/psycopg2/setup.py) egg_info for
> package psycopg2
>
> Installing collected packages: psycopg2
>   Running setup.py install for psycopg2
> Skipping implicit fixer: buffer
> Skipping implicit fixer: idioms
> Skipping implicit fixer: set_literal
> Skipping implicit fixer: ws_comma
> building 'psycopg2._psycopg' extension
> gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O2 -Wall
> -Wstrict-prototypes -g -O2 -fstack-protector --param=ssp-buffer-size=4
> -Wformat -Werror=format-security -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1
> -DPSYCOPG_VERSION="2.5.3 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1
> -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DPG_VERSION_HEX=0x090304
> -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1
> -I/usr/include/python3.3m -I. -I/usr/include/postgresql
> -I/usr/include/postgresql/9.3/server -c psycopg/psycopgmodule.c -o
> build/temp.linux-x86_64-3.3/psycopg/psycopgmodule.o
> -Wdeclaration-after-statement
> In file included from psycopg/psycopgmodule.c:27:0:
> ./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or
> directory
>  #include 
> ^
> compilation terminated.
> error: command 'gcc' failed with exit status 1
> Complete output from command /opt/d/bin/python3.3 -c "import
> setuptools,
> tokenize;__file__='/opt/d/build/psycopg2/setup.py';exec(compile(getattr(tokenize,
> 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
> install --record /tmp/pip-on_knf-record/install-record.txt
> --single-version-externally-managed --compile --install-headers
> /opt/d/include/site/python3.3:
> running install
>
> running build
>
> running build_py
>
> creating build
>
> creating build/lib.linux-x86_64-3.3
>
> creating build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/extensions.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/extras.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/__init__.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/_range.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/psycopg1.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/_json.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/errorcodes.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/pool.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> copying lib/tz.py -> build/lib.linux-x86_64-3.3/psycopg2
>
> creating build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_types_extras.py ->
> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_async.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/testconfig.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_module.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_with.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_quote.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_cursor.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_cancel.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_transaction.py ->
> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/__init__.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_connection.py ->
> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_notify.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_copy.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_green.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_types_basic.py ->
> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_extras_dictcursor.py ->
> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_psycopg2_dbapi20.py ->
> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_lobject.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/test_dates.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/dbapi20.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> copying tests/testutils.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>
> Skipping implicit fixer: buffer
>
> Skipping implicit fixer: idioms
>
> Skipping implicit fixer: set_literal
>
> Skipping implicit fixer: ws_comma
>
> running build_ext
>
> building 'psycopg2._psycopg' e

Re: psycopg2

2014-07-24 Thread Henrique Oliveira
Hi Mario,

I already installed python-dev
On Jul 24, 2014 9:11 PM, "Mario Gudelj"  wrote:

> Install this first:
>
> sudo apt-get install python-dev
>
> Then try installing that package again.
>
>
> On 25 July 2014 09:55, Henrique Oliveira 
> wrote:
>
>>
>>
>>
>>
>>
>> *Hi All,I am trying to install psycopg2 but I am getting this error:*I
>> already installed python3-dev and libpq-dev Any idea?*
>>
>> Downloading/unpacking psycopg2
>>   Downloading psycopg2-2.5.3.tar.gz (690kB): 690kB downloaded
>>   Running setup.py (path:/opt/d/build/psycopg2/setup.py) egg_info for
>> package psycopg2
>>
>> Installing collected packages: psycopg2
>>   Running setup.py install for psycopg2
>> Skipping implicit fixer: buffer
>> Skipping implicit fixer: idioms
>> Skipping implicit fixer: set_literal
>> Skipping implicit fixer: ws_comma
>> building 'psycopg2._psycopg' extension
>> gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O2 -Wall
>> -Wstrict-prototypes -g -O2 -fstack-protector --param=ssp-buffer-size=4
>> -Wformat -Werror=format-security -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1
>> -DPSYCOPG_VERSION="2.5.3 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1
>> -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DPG_VERSION_HEX=0x090304
>> -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1
>> -I/usr/include/python3.3m -I. -I/usr/include/postgresql
>> -I/usr/include/postgresql/9.3/server -c psycopg/psycopgmodule.c -o
>> build/temp.linux-x86_64-3.3/psycopg/psycopgmodule.o
>> -Wdeclaration-after-statement
>> In file included from psycopg/psycopgmodule.c:27:0:
>> ./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or
>> directory
>>  #include 
>> ^
>> compilation terminated.
>> error: command 'gcc' failed with exit status 1
>> Complete output from command /opt/d/bin/python3.3 -c "import
>> setuptools,
>> tokenize;__file__='/opt/d/build/psycopg2/setup.py';exec(compile(getattr(tokenize,
>> 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
>> install --record /tmp/pip-on_knf-record/install-record.txt
>> --single-version-externally-managed --compile --install-headers
>> /opt/d/include/site/python3.3:
>> running install
>>
>> running build
>>
>> running build_py
>>
>> creating build
>>
>> creating build/lib.linux-x86_64-3.3
>>
>> creating build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/extensions.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/extras.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/__init__.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/_range.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/psycopg1.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/_json.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/errorcodes.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/pool.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> copying lib/tz.py -> build/lib.linux-x86_64-3.3/psycopg2
>>
>> creating build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_types_extras.py ->
>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_bugX000.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_async.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/testconfig.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_module.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_with.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_quote.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_cursor.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_cancel.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_transaction.py ->
>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/__init__.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_connection.py ->
>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_notify.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_copy.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_green.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_types_basic.py ->
>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_extras_dictcursor.py ->
>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_psycopg2_dbapi20.py ->
>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_lobject.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/test_dates.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/dbapi20.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>
>> copying tests/testutils.py -> build/lib.lin

Re: Getting list of user groups

2014-07-24 Thread Russell Keith-Magee
Hi Kyle,

Apologies for the typo on my part that led you astray.

Regarding the approach you describe -- you may want to look into Django's
Forms library. That library is designed to specifically handle the kind of
problem you describe (a pull-down select box filled with all the options
populated from a particular query. In particular, look for details on the
ModelChoiceField. This will save you from writing a bunch of code to render
the select box, validate input received from the user, and so on.

Yours,
Russ Magee %-)



On Fri, Jul 25, 2014 at 5:05 AM, Kyle Adams  wrote:

> After some more research, turns out it is "values_list" instead of
> "value_list"
>
> --
> 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/54e20481-8952-4f84-b471-7c13556c1354%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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJxq848_tp6jQHGcM%2Bf0DD1%3DSPAxNEo7Lqa%2BU%2BYm-eeMCNVvuQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: psycopg2

2014-07-24 Thread Mario Gudelj
In
http://stackoverflow.com/questions/20789063/get-fatal-error-when-install-psycopg2
OP mentions that "Just installed python 3.4 and assumed python3-dev would
suffice. Nope. Had to do python3.4-dev. "

Perhaps you need to do the same thing...



On 25 July 2014 10:29, Henrique Oliveira 
wrote:

> Hi Mario,
>
> I already installed python-dev
> On Jul 24, 2014 9:11 PM, "Mario Gudelj"  wrote:
>
>> Install this first:
>>
>> sudo apt-get install python-dev
>>
>> Then try installing that package again.
>>
>>
>> On 25 July 2014 09:55, Henrique Oliveira 
>> wrote:
>>
>>>
>>>
>>>
>>>
>>>
>>> *Hi All,I am trying to install psycopg2 but I am getting this error:*I
>>> already installed python3-dev and libpq-dev Any idea?*
>>>
>>> Downloading/unpacking psycopg2
>>>   Downloading psycopg2-2.5.3.tar.gz (690kB): 690kB downloaded
>>>   Running setup.py (path:/opt/d/build/psycopg2/setup.py) egg_info for
>>> package psycopg2
>>>
>>> Installing collected packages: psycopg2
>>>   Running setup.py install for psycopg2
>>> Skipping implicit fixer: buffer
>>> Skipping implicit fixer: idioms
>>> Skipping implicit fixer: set_literal
>>> Skipping implicit fixer: ws_comma
>>> building 'psycopg2._psycopg' extension
>>> gcc -pthread -Wno-unused-result -DNDEBUG -g -fwrapv -O2 -Wall
>>> -Wstrict-prototypes -g -O2 -fstack-protector --param=ssp-buffer-size=4
>>> -Wformat -Werror=format-security -fPIC -DPSYCOPG_DEFAULT_PYDATETIME=1
>>> -DPSYCOPG_VERSION="2.5.3 (dt dec pq3 ext)" -DPSYCOPG_EXTENSIONS=1
>>> -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DPG_VERSION_HEX=0x090304
>>> -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1
>>> -I/usr/include/python3.3m -I. -I/usr/include/postgresql
>>> -I/usr/include/postgresql/9.3/server -c psycopg/psycopgmodule.c -o
>>> build/temp.linux-x86_64-3.3/psycopg/psycopgmodule.o
>>> -Wdeclaration-after-statement
>>> In file included from psycopg/psycopgmodule.c:27:0:
>>> ./psycopg/psycopg.h:30:20: fatal error: Python.h: No such file or
>>> directory
>>>  #include 
>>> ^
>>> compilation terminated.
>>> error: command 'gcc' failed with exit status 1
>>> Complete output from command /opt/d/bin/python3.3 -c "import
>>> setuptools,
>>> tokenize;__file__='/opt/d/build/psycopg2/setup.py';exec(compile(getattr(tokenize,
>>> 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))"
>>> install --record /tmp/pip-on_knf-record/install-record.txt
>>> --single-version-externally-managed --compile --install-headers
>>> /opt/d/include/site/python3.3:
>>> running install
>>>
>>> running build
>>>
>>> running build_py
>>>
>>> creating build
>>>
>>> creating build/lib.linux-x86_64-3.3
>>>
>>> creating build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/extensions.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/extras.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/__init__.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/_range.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/psycopg1.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/_json.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/errorcodes.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/pool.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> copying lib/tz.py -> build/lib.linux-x86_64-3.3/psycopg2
>>>
>>> creating build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_types_extras.py ->
>>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_bugX000.py ->
>>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_async.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/testconfig.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_module.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_with.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_quote.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_cursor.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_cancel.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_transaction.py ->
>>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/__init__.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_connection.py ->
>>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_notify.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_copy.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_bug_gc.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_green.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/dbapi20_tpc.py -> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_types_basic.py ->
>>> build/lib.linux-x86_64-3.3/psycopg2/tests
>>>
>>> copying tests/test_extras_dictc