Re: Using Aggregate and Count

2013-11-21 Thread Daniel Roseman
On Thursday, 21 November 2013 00:49:52 UTC, Timothy W. Cook wrote:
>
> Does the fact that I use a relat_name on the Review.paper field have 
> anything to do with it not working? 
>
> In the Review model, notice: 
> paper = models.ForeignKey(Paper, verbose_name=_('Paper'), 
> related_name="%(app_label)s_%(class)s_related+", null=False, 
> blank=False, help_text=_("Select a paper.")) 
>
> In the annotation I tried: 
> papers = 
> Paper.objects.filter(project__id=self.kwargs['pk']).annotate(Count('papers_reviews_related+'))
>  
>
>
>
The documentation for related_name 
(https://docs.djangoproject.com/en/1.6/ref/models/fields/#django.db.models.ForeignKey.related_name)
 
states that if the value is, or ends with, "+", then no reverse 
relationship will be created. I'm not sure why you are doing that, but 
remove the "+" from the related_name in the ForeignKey definition.
--
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/53a5d84f-cd6e-4464-a03d-1bf57d0e80c2%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using Aggregate and Count

2013-11-21 Thread Timothy W. Cook
On Thu, Nov 21, 2013 at 8:25 AM, Daniel Roseman  wrote:
> states that if the value is, or ends with, "+", then no reverse relationship
> will be created. I'm not sure why you are doing that, but remove the "+"
> from the related_name in the ForeignKey definition.

Thanks for pointing this out.  I knew there had to be a reason.

Cheers,
Tim

-- 
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%2B%3DOU3V4%3DXC2u7smMDkUegMBadWFPr1Y%2BBKOgius9zfoNCuN-A%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model Design: Adding Params to Relationship FIelds

2013-11-21 Thread Daniel Roseman
On Wednesday, 20 November 2013 22:49:28 UTC, Thomas Murphy wrote:
>
> Hi all, 
>
> I'm working on a hour-reporting system. 
>
> Each Project has many Users, and each User has many Projects(These are 
> established and working nicely). 
>
> My design issue is this: 
> How can I assign each User an IntegerField "Hours" on each Project 
> they are assigned to? This Integer Field is personal to them, but must 
> be able to summed by the Project "Hours" count later(This last part is 
> trivial to design, just wanted to include) 
>
> Here's relevant code: 
>
> class Project(models.Model): 
> client = models.CharField(max_length=500) 
> name = models.CharField(max_length=500) 
> campaign_start_date = models.DateField() 
> hours = models.IntegerField(default=0) 
> members = models.ManyToManyField(User) 
> hours = models.IntegerField(default=0) 
>
> def __unicode__(self): 
> return self.name 
>
> class UserProfile(models.Model): 
>
> user = models.OneToOneField(User) 
>
> #Additional Attributes Defined Below 
> project = models.ManyToManyField(Project) 
> rate = models.IntegerField(default=0) 
>
> def __unicode__(self): 
> return self.user.username 
>
> def project_names(self): 
> return ', '.join([p.name for p in self.project.all()]) 
>


This is well covered in the documentation under "Extra fields on 
many-to-many relationships":
https://docs.djangoproject.com/en/1.6/topics/db/models/#intermediary-manytomany 
--
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/6e6d5b33-ce10-4dac-b2e1-a7f64c8ada7e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I use mathematical calculations on my forloop Article/Publication list?

2013-11-21 Thread James Turley
On number 3, annotate returns the annotated queryset, not the particular
result of the annotation. The annotation is added to each individual object
in the set.

Turning that into an integer doesn't make sense, because num_publications
is a property of *each individual *entry in the set, not the set itself.

articles[0].num_publications() would return the number of publications
associated with the first article in the set, for example.

James


On Wed, Nov 20, 2013 at 9:29 PM, Pepsodent Cola wrote:

> 1.)
> How do I use mathematical calculations on my forloop Article/Publication
> list?
>
> * I have attached a screenshot with the table field that I'm working on 
> *"Publicists
> coverage (%)"*.
> * Admin user/pass = joe/joe
> * I have also attached my project files so that you can see things for
> yourselves.
>
>
> 2.)
> Is the solution I'm working with in "Index View page" the correct practice
> to do my mathematical calculations?
>
>
> #___
>
> def index(request):
> publications = Publication.objects.all()
>
>
> # sum_publications = Publication.objects.filter(article__pk=1).count()
> articles =
> Article.objects.all().annotate(num_publications=Count('publications'))
> *#articles_int = int(articles)*
>
> *sum_publicists = Publication.objects.all().count()*
>
> *#publicists_coverage = articles/sum_publicists*
>
>
> #context = {'publications':publications,
> 'sum_publicists':sum_publicists,
> #   'publicists_coverage':publicists_coverage,
> 'articles':articles}
> context = {'publications':publications,
> 'sum_publicists':sum_publicists,
>'articles':articles}
> return render(request, 'magazine/index.html', context)
>
> #___
>
> 
> How many Publications was each Article in?
>
> {% if articles %}
> 
> 
> Article id
> Article
> Publication
> *Publicists coverage (%)*
> 
> {% for row in articles %}
> 
> {{ row.id }}
> {{ row.headline }}
> {{ row.num_publications }}
> (*{{ row.num_publications }} / {{ sum_publicists }}*) = x
> %
> 
> {% endfor %}
> 
> {% else %}
> No Articles are available.
> {% endif %}
>
> 
> 
>
>
> #___
>
>
> 3.)
> When I try to convert articles object into int it doesn't work.  Am I
> going the wrong direction when thinking about solving things like this?
>
>
> Exception Type: TypeError
> Exception Value: *int() argument must be a string or a number, not
> 'QuerySet'*
> Exception Location: /home/linux/Django/ManyToMany/magazine/views.py in
> index, line 17
>
>
> >>> articles =
> Article.objects.all().annotate(num_publications=Count('publications'))
> >>> type(articles)
> 
> >>>
> >>> *articles_int = int(articles)*
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: int() argument must be a string or a number, not 'QuerySet'
> >>>
>
>
>
>
>
>
>  --
> 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/eaa87962-c182-4261-8668-69285dde8de3%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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/CAAb4X%3DyEebUmaMRZRaFNSd-4yn-vJAx-y3eb08UTk0-23oT6TQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Form Wizard and middle step data manipulation

2013-11-21 Thread Lachlan Musicman
Hola,

I want to collect an integer x in the first form, and then use that to
select the x oldest items from collections of items that may have From this perspective it is natural that anarchism be marked by
spontaneity, differentiation, and experimentation that it be marked by
an expressed affinity with chaos, if chaos is understood to be what
lies outside or beyond the dominant game or system. Because of the
resistance to definition and categorisation, the anarchist principle
has been variously interpreted as, rather than an articulated
position, “a moral attitude, an emotional climate, or even a mood”.
This mood hangs in dramatic tension between utopian hope or dystopian
nihilism...
-
http://zuihitsu.org/godspeed-you-black-emperor-and-the-politics-of-chaos

-- 
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/CAGBeqiNMGsKbEaO2Mq5VAew1QAjp0GanV%3Dffw5qSFbHzsECmZw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


return multiple fields for foreignkey

2013-11-21 Thread Chantal Rosmuller
Hi,

I'm pretty new to Django soi excuse me if this is a stupid question, but 
here we go.

I have the following model:

class Motivation(models.Model):
def __unicode__(self):  # Python 3: def __str__(self):
return self.score

score   = models.CharField(max_length=100)
description = models.CharField(max_length=300)
insert_date = models.DateTimeField(auto_now_add=True) #insert date
update_date = models.DateTimeField(auto_now=True)  #last updated 
date

and another model with a foreign key to the first one:

class PerformanceAnimal(models.Model):
def __unicode__(self):  # Python 3: def __str__(self):
 return u'%s' % self.animal

training_session   = models.ForeignKey('Training')
animal = models.ForeignKey('animals.Animal')
state_of_mind  = models.CharField(max_length=200, blank=True)
motivation = models.ForeignKey('behaviour.Motivation')

In the admin panel the foreign key select field shows the score (like it's 
supposed to), but I would like it to show score, description

How do I go about that?

Thanks for your 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/db2ae4c7-4842-4e9d-afdc-376e2a0ad51b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: ATOMIC_REQUESTS Alternative - better for highly concurrent systems

2013-11-21 Thread Oleg Korsak
Great!
21 нояб. 2013 г. 22:17 пользователь "SteveB"  написал:

> Hi,
>I want to offer something the the community of Django users.
> If you like the safety net of having each request handled by a
> transaction, but don't want unnecessary blocking on highly concurrent web
> applications, then the following may be of interest.
> The Django transaction documentation offers you two choices:
>
>1. Turn on the database setting ATOMIC_REQUESTS, and the for those
>view functions which don't need transaction protection, decorate these with
>@transaction.non_atomic_requests
>2. Don't turn ATOMIC_REQUESTS for your database, and instead decorate
>those view functions for which you want transaction protection with
>@transaction.atomic.
>
> However, there are a couple of downsides to both of these approaches:
>
>1. There may be lots of view functions to be so decorated.
>2. Many view functions follow the pattern where they accept both GET
>and POST requests. The GET request returns the form to be filled in, and
>the POST request submits the filled in form for processing. You want the
>POST request to be processed by a transaction, as there may be multple
>tables to be updated, however, you don't want the GET request to have the
>transaction overhead. Therefore decorating such view functions with
>non_atomic_requests or atomic won't do what you want.
>
> A solution:
>
> I offer a middleware module which looks to see if the request is a
> modifying one (that is, one of POST, PUT, DELETE or PATCH). If not, it does
> not use a transaction for the request. If it is a modifying request it will
> use a transaction, provided that the database ATOMIC_REQUESTS is not on
> (don't want to double up), and that the view function is not decorated with
> @transaction.non_atomic_requests.
>
> The middleware has to overcome a limitation that it cannot simpy do
> something like "with transaction.atomic():", because in the process_view
> method, the middleware has to return control before the view function is
> called. It also has to work where several databases may be involved, so it
> creates a list of transaction.Atomic instances, one per configured
> database, saves them on the request object, and calls their __enter__()
> methods.
>
> The process_response() method then has to invoke the __exit__() method of
> these Atomic instances in the reverse order, and handle any exceptions
> which may occur.
>
> It also provides a process_exception() method, which invokes the
> __exit__() method of the Atomic instances, also in reverse order, passing
> to it the exception information, and handling any exceptions which may
> occur. For each Atomic instance whose __enter__() method was called, it has
> to invoke the corresponding __exit__() method.
>
> I welcome any comments from the group on this piece of middleware.
>
> - Stephen Brooks
>
> 
>
> File: atomicmodifyingrequests.py
>
> from django.db import connections, transaction
> import sys
>
> class AtomicModifyingRequestsMiddleware(object):
> '''This middleware puts django.db.transaction.Atomic contexts (one per
> database
> if the database does not have the ATOMIC_REQUESTS set) around
> the view function if the request method is a modifying one and
> the view function is not annotated with
> @transaction.non_atomic_requests.
> Author: Stephen Brooks
> Minimum Django Version: 1.6
> '''
>
> def process_view(self, request, view_func, view_args, view_kwargs):
> if request.method in ('POST', 'PUT', 'DELETE', 'PATCH'):
> non_atomic_requests = getattr(view_func,
> '_non_atomic_requests', set())
> try:
> for db in connections.all():
> if (not db.settings_dict['ATOMIC_REQUESTS'] and
> db.alias not in non_atomic_requests):
> if not hasattr(request,
> '_atomic_modifying_requests_middleware_atomic_contexts'):
>
> request._atomic_modifying_requests_middleware_atomic_contexts = []
> atm_ctxt = transaction.Atomic(db.alias, True)
>
> request._atomic_modifying_requests_middleware_atomic_contexts.append(atm_ctxt)
> atm_ctxt.__enter__()
> except Exception as e:
> self.process_exception(request, e)
> raise
>
> return None
>
> def process_response(self, request, response):
> if hasattr(request,
> '_atomic_modifying_requests_middleware_atomic_contexts'):
> exc_info = (None, None, None,)
> exc = None
> for atm_ctxt in
> reversed(request._atomic_modifying_requests_middleware_atomic_contexts):
> try:
> atm_ctxt.__exit__(*exc_info)
> except Exception as exc:
> exc_info = sys.exc_info()
> if exc:
> raise exc
> return response
>
>   

I'm looking for a Part-Time (4h/day) Django job - remote only

2013-11-21 Thread Python_enthusiast
I'm looking for a  Part-Time (4h/day) Django job. I've more than one and a 
half year of experience using Django. 

- very good knowledge of Python/Django
- experience with MySql, PostgreSql
- Linux, GIT
- competent in technologies like JS, HTML, Ajax
- knowledge of good programming practice
- Python enthusiast

Contact with me: 
pythonde...@gmail.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/ee21ad61-b36a-43af-9557-300eedbfe016%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Model Design: Adding Params to Relationship FIelds

2013-11-21 Thread Thomas Murphy
Thanks Daniel!

I try to always RTFM, but this slipped by me.

On Thu, Nov 21, 2013 at 5:32 AM, Daniel Roseman  wrote:
> On Wednesday, 20 November 2013 22:49:28 UTC, Thomas Murphy wrote:
>>
>> Hi all,
>>
>> I'm working on a hour-reporting system.
>>
>> Each Project has many Users, and each User has many Projects(These are
>> established and working nicely).
>>
>> My design issue is this:
>> How can I assign each User an IntegerField "Hours" on each Project
>> they are assigned to? This Integer Field is personal to them, but must
>> be able to summed by the Project "Hours" count later(This last part is
>> trivial to design, just wanted to include)
>>
>> Here's relevant code:
>>
>> class Project(models.Model):
>> client = models.CharField(max_length=500)
>> name = models.CharField(max_length=500)
>> campaign_start_date = models.DateField()
>> hours = models.IntegerField(default=0)
>> members = models.ManyToManyField(User)
>> hours = models.IntegerField(default=0)
>>
>> def __unicode__(self):
>> return self.name
>>
>> class UserProfile(models.Model):
>>
>> user = models.OneToOneField(User)
>>
>> #Additional Attributes Defined Below
>> project = models.ManyToManyField(Project)
>> rate = models.IntegerField(default=0)
>>
>> def __unicode__(self):
>> return self.user.username
>>
>> def project_names(self):
>> return ', '.join([p.name for p in self.project.all()])
>
>
>
> This is well covered in the documentation under "Extra fields on
> many-to-many relationships":
> https://docs.djangoproject.com/en/1.6/topics/db/models/#intermediary-manytomany
> --
> 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/6e6d5b33-ce10-4dac-b2e1-a7f64c8ada7e%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/CALgvumUvfyLmrhRxMCPw%3DrSitQN0jLo%3DTSpkR%3Dfr4B%3DvRnQ%2BEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


ATOMIC_REQUESTS Alternative - better for highly concurrent systems

2013-11-21 Thread SteveB
Hi,
   I want to offer something the the community of Django users.
If you like the safety net of having each request handled by a transaction, 
but don't want unnecessary blocking on highly concurrent web applications, 
then the following may be of interest.
The Django transaction documentation offers you two choices:

   1. Turn on the database setting ATOMIC_REQUESTS, and the for those view 
   functions which don't need transaction protection, decorate these with 
   @transaction.non_atomic_requests
   2. Don't turn ATOMIC_REQUESTS for your database, and instead decorate 
   those view functions for which you want transaction protection with 
   @transaction.atomic.

However, there are a couple of downsides to both of these approaches:

   1. There may be lots of view functions to be so decorated.
   2. Many view functions follow the pattern where they accept both GET and 
   POST requests. The GET request returns the form to be filled in, and the 
   POST request submits the filled in form for processing. You want the POST 
   request to be processed by a transaction, as there may be multple tables to 
   be updated, however, you don't want the GET request to have the transaction 
   overhead. Therefore decorating such view functions with non_atomic_requests 
   or atomic won't do what you want.

A solution:

I offer a middleware module which looks to see if the request is a 
modifying one (that is, one of POST, PUT, DELETE or PATCH). If not, it does 
not use a transaction for the request. If it is a modifying request it will 
use a transaction, provided that the database ATOMIC_REQUESTS is not on 
(don't want to double up), and that the view function is not decorated with 
@transaction.non_atomic_requests.

The middleware has to overcome a limitation that it cannot simpy do 
something like "with transaction.atomic():", because in the process_view 
method, the middleware has to return control before the view function is 
called. It also has to work where several databases may be involved, so it 
creates a list of transaction.Atomic instances, one per configured 
database, saves them on the request object, and calls their __enter__() 
methods.

The process_response() method then has to invoke the __exit__() method of 
these Atomic instances in the reverse order, and handle any exceptions 
which may occur.

It also provides a process_exception() method, which invokes the __exit__() 
method of the Atomic instances, also in reverse order, passing to it the 
exception information, and handling any exceptions which may occur. For 
each Atomic instance whose __enter__() method was called, it has to invoke 
the corresponding __exit__() method.

I welcome any comments from the group on this piece of middleware.

- Stephen Brooks



File: atomicmodifyingrequests.py

from django.db import connections, transaction
import sys

class AtomicModifyingRequestsMiddleware(object):
'''This middleware puts django.db.transaction.Atomic contexts (one per 
database
if the database does not have the ATOMIC_REQUESTS set) around
the view function if the request method is a modifying one and
the view function is not annotated with 
@transaction.non_atomic_requests.
Author: Stephen Brooks
Minimum Django Version: 1.6
'''

def process_view(self, request, view_func, view_args, view_kwargs):
if request.method in ('POST', 'PUT', 'DELETE', 'PATCH'):
non_atomic_requests = getattr(view_func, 
'_non_atomic_requests', set())
try:
for db in connections.all():
if (not db.settings_dict['ATOMIC_REQUESTS'] and
db.alias not in non_atomic_requests):
if not hasattr(request, 
'_atomic_modifying_requests_middleware_atomic_contexts'):

request._atomic_modifying_requests_middleware_atomic_contexts = []
atm_ctxt = transaction.Atomic(db.alias, True)

request._atomic_modifying_requests_middleware_atomic_contexts.append(atm_ctxt)
atm_ctxt.__enter__()
except Exception as e:
self.process_exception(request, e)
raise

return None

def process_response(self, request, response):
if hasattr(request, 
'_atomic_modifying_requests_middleware_atomic_contexts'):
exc_info = (None, None, None,)
exc = None
for atm_ctxt in 
reversed(request._atomic_modifying_requests_middleware_atomic_contexts):
try:
atm_ctxt.__exit__(*exc_info)
except Exception as exc:
exc_info = sys.exc_info()
if exc:
raise exc
return response

def process_exception(self, request, exception):
if hasattr(request, 
'_atomic_modifying_requests_middleware_atomic_contexts'):
exc_in

Re: manage.py deprecation message for model/sql arguments

2013-11-21 Thread Steve Sawyer
Thanks, tim, but it looks like the message says "is deprecated" rather than 
"will be deprecated" - unless this is just how these warnings are worded.

On Thursday, November 21, 2013 11:54:36 AM UTC-5, tim wrote:
>
> It looks like an issue with pywintypes, not Django. A deprecation warning 
> means some code needs to update itself in order to work with future 
> versions of some other code. In this case, it looks to me like pywintypes 
> is using some functionality that will probably be removed in a future 
> version of Python.
>
> On Thursday, November 21, 2013 10:56:57 AM UTC-5, Steve Sawyer wrote:
>>
>> Working my way through the Django tutorial (running Python 3.3 and Django 
>> 1.6), and when I run manage.py with any of the model arguments 
>> (validate/sqlcustom/sqlclear/sqlall etc.) the output seems to be what the 
>> tutorial leads me to expect, but I'm getting this message:
>>
>> *C:\Python33\lib\site-packages\win32\lib\pywintypes.py:39: 
>> DeprecationWarning: imp.get_suffixes() is deprecated; use the constants 
>> defined on importlib.machinery instead*
>>
>> Is this something that requires some corrective action on my part? Is 
>> this an indicator that something is NOT working properly, or MAY NOT work 
>> properly in some of these processes?
>>
>> 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/af791030-1e16-41a3-87c2-ee4eaad6fc6b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: return multiple fields for foreignkey

2013-11-21 Thread Rafael E. Ferrero
class Motivation(models.Model):
def __unicode__(self):  # Python 3: def __str__(self):
return '%s - %s' % (self.score, self.description)

score   = models.CharField(max_length=100)
description = models.CharField(max_length=300)
insert_date = models.DateTimeField(auto_now_add=True) #insert date
update_date = models.DateTimeField(auto_now=True)  #last updated
date


2013/11/21 Chantal Rosmuller 

> Hi,
>
> I'm pretty new to Django soi excuse me if this is a stupid question, but
> here we go.
>
> I have the following model:
>
> class Motivation(models.Model):
> def __unicode__(self):  # Python 3: def __str__(self):
> return self.score
>
> score   = models.CharField(max_length=100)
> description = models.CharField(max_length=300)
> insert_date = models.DateTimeField(auto_now_add=True) #insert date
> update_date = models.DateTimeField(auto_now=True)  #last updated
> date
>
> and another model with a foreign key to the first one:
>
> class PerformanceAnimal(models.Model):
> def __unicode__(self):  # Python 3: def __str__(self):
>  return u'%s' % self.animal
>
> training_session   = models.ForeignKey('Training')
> animal = models.ForeignKey('animals.Animal')
> state_of_mind  = models.CharField(max_length=200, blank=True)
> motivation = models.ForeignKey('behaviour.Motivation')
>
> In the admin panel the foreign key select field shows the score (like it's
> supposed to), but I would like it to show score, description
>
> How do I go about that?
>
> Thanks for your 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/db2ae4c7-4842-4e9d-afdc-376e2a0ad51b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>



-- 
Rafael E. Ferrero

-- 
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/CAJJc_8V3xNN6vfpSxtbkZMNaU0D70FVhZ-96wyUEOxaOQ8FHeg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How do I use mathematical calculations on my forloop Article/Publication list?

2013-11-21 Thread Pepsodent Cola
@James

Now I understand what you mean. :)  I will work on this some more tonight.



On Wednesday, November 20, 2013 10:29:24 PM UTC+1, Pepsodent Cola wrote:
>
> 1.)
> How do I use mathematical calculations on my forloop Article/Publication 
> list?
>
> * I have attached a screenshot with the table field that I'm working on 
> *"Publicists 
> coverage (%)"*.
> * Admin user/pass = joe/joe
> * I have also attached my project files so that you can see things for 
> yourselves.
>
>
> 2.)
> Is the solution I'm working with in "Index View page" the correct practice 
> to do my mathematical calculations?
>
>
> #___
>
> def index(request):
> publications = Publication.objects.all()
>
>
> # sum_publications = Publication.objects.filter(article__pk=1).count()
> articles = 
> Article.objects.all().annotate(num_publications=Count('publications'))
> *#articles_int = int(articles)*
>
> *sum_publicists = Publication.objects.all().count()*
>
> *#publicists_coverage = articles/sum_publicists*
>
>
> #context = {'publications':publications, 
> 'sum_publicists':sum_publicists,
> #   'publicists_coverage':publicists_coverage, 
> 'articles':articles}
> context = {'publications':publications, 
> 'sum_publicists':sum_publicists,
>'articles':articles}
> return render(request, 'magazine/index.html', context)
>
> #___
>
> 
> How many Publications was each Article in?
>
> {% if articles %}
> 
> 
> Article id
> Article
> Publication
> *Publicists coverage (%)*
> 
> {% for row in articles %}
> 
> {{ 
> row.id}}
> {{ row.headline }}
> {{ row.num_publications }}
> (*{{ row.num_publications }} / {{ sum_publicists }}*) = x 
> %
> 
> {% endfor %}
> 
> {% else %}
> No Articles are available.
> {% endif %}
>
> 
> 
>
>
> #___
>
>
> 3.)
> When I try to convert articles object into int it doesn't work.  Am I 
> going the wrong direction when thinking about solving things like this?
>
>
> Exception Type: TypeError
> Exception Value: *int() argument must be a string or a number, not 
> 'QuerySet'*
> Exception Location: /home/linux/Django/ManyToMany/magazine/views.py in 
> index, line 17
>
>
> >>> articles = 
> Article.objects.all().annotate(num_publications=Count('publications'))
> >>> type(articles)
> 
> >>> 
> >>> *articles_int = int(articles)*
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: int() argument must be a string or a number, not 'QuerySet'
> >>> 
>
>
>
>
>
>
>

-- 
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/b6c2d614-15a1-4741-a099-64bd4637fa14%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Announce] Django Graphos - Django charting made *really* easy

2013-11-21 Thread Fabio Caritas Barrionuevo da Luz
These modifications made by "anentropic" are good too.


https://github.com/anentropic/django-graphos/tree/a7bae2c0e67d6f8deda1a75fac8c1574ab1b884c

 

-- 
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/ebc73d92-4b7e-4e25-8962-e7cd80ea9bf0%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


prefetch_related() failure in django 1.6

2013-11-21 Thread Rhett G.
Trying to migrate our Django 1.5 application to 1.6. I hit what I think is 
a bug, or at the very least very confusing behavior. 
Imagine some models like the following:

  class Img(Model):
uuid = CharField()


  class ImgResolutions(Model):
img = ForeignKey(Img, related_name='resolutions')
url = CharField()


  # Lots of things have images, this is just one, so I want to leave off 
the related name, just as is documented in
  # 
https://docs.djangoproject.com/en/1.6/ref/models/fields/#django.db.models.ForeignKey.related_name
  class Place(Model):
detail_img = ForeignKey(Img, related_name='+')
icon_img = ForeignKey(Img, related_name='+')


Now, when I do a query like this:

places = Place.objects.filter(.. whatever 
..).prefetch_related('detail_img__resolutions')

I get something like:

  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 96, in __iter__
self._fetch_all()
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 856, in _fetch_all
self._prefetch_related_objects()
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 517, in _prefetch_related_objects
prefetch_related_objects(self._result_cache, 
self._prefetch_related_lookups)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 1598, in prefetch_related_objects
obj_list, additional_prl = prefetch_one_level(obj_list, prefetcher, 
attr)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 1697, in prefetch_one_level
prefetcher.get_prefetch_queryset(instances)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/fields/related.py",
 
line 277, in get_prefetch_queryset
qs = self.get_queryset(instance=instances[0]).filter(**query)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 590, in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/query.py",
 
line 608, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1202, in add_q
clause = self._add_q(where_part, used_aliases)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1236, in _add_q
current_negated=current_negated)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1101, in build_filter
allow_explicit_fk=True)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1356, in setup_joins
names, opts, allow_many, allow_explicit_fk)
  File 
"/postmates/virtualenv.d/postal-main/env/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
 
line 1279, in names_to_path
"Choices are: %s" % (name, ", ".join(available)))
FieldError: Cannot resolve keyword '+' into field. Choices are: 
date_created, date_updated, deleted, id, resolutions, uuid

>From what I can tell, this has something to do with the addition of 
related_query_name.
For some reason, it's trying to build a filter that looks like '+_in', 
because of L276 in django/db/models/fields/related.py :

query = {'%s__in' % self.field.related_query_name(): instances}

I think it's trying to build a query like "Img.place in [place list]" 

Am I doing something wrong or is this a bug?

Thanks,

Rhett

-- 
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/9deabf4a-61a2-48c6-9ad7-756b65d360e5%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: I'm looking for a Part-Time (4h/day) Django job - remote only

2013-11-21 Thread Cal Leeming [Simplicity Media Ltd]
I'll be very surprised if you get any offers from this post in its
current format, you might get a better response if you post more
information about yourself.

For example;

* Blog (if you have one)
* Linkedin profile
* Github profile
* Your real name

Hope this helps

Cal

On Thu, Nov 21, 2013 at 7:33 PM, Python_enthusiast
 wrote:
> I'm looking for a  Part-Time (4h/day) Django job. I've more than one and a
> half year of experience using Django.
>
> - very good knowledge of Python/Django
> - experience with MySql, PostgreSql
> - Linux, GIT
> - competent in technologies like JS, HTML, Ajax
> - knowledge of good programming practice
> - Python enthusiast
>
> Contact with me:
> pythonde...@gmail.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/ee21ad61-b36a-43af-9557-300eedbfe016%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/CAHKQagFdr6CpvezJN1TL%2BcfmnGLg02L%3DSz_M0xbr0YRULR-%3DSA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Apache environment variables in Django 1.6

2013-11-21 Thread Jon Dufresne
On Thu, Nov 21, 2013 at 8:46 AM, Mike Starov  wrote:
> I encountered same issue in my deployment. Have you found a solution?
>

Yes I did. I am still not sure if this is a bug or intentional. It
appears that in 1.6, settings.py is now imported *before* the first
run of the WSGI application. Therefore the settings.py is loaded
before the environment variables can be setup. I now load the WSGI
application as late as possible using the following code. This way,
the settings.py isn't imported until I've received the environ from
Apache. Please feel free to use it to fix your project:

---
import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
_application = None

def application(environ, start_response):
os.environ['MY_SETTING'] = environ['MY_SETTING']
global _application
if _application is None:
from django.core.wsgi import get_wsgi_application
_application = get_wsgi_application()
return _application(environ, start_response)
---

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


manage.py deprecation message for model/sql arguments

2013-11-21 Thread Steve Sawyer
Working my way through the Django tutorial (running Python 3.3 and Django 
1.6), and when I run manage.py with any of the model arguments 
(validate/sqlcustom/sqlclear/sqlall etc.) the output seems to be what the 
tutorial leads me to expect, but I'm getting this message:

*C:\Python33\lib\site-packages\win32\lib\pywintypes.py:39: 
DeprecationWarning: imp.get_suffixes() is deprecated; use the constants 
defined on importlib.machinery instead*

Is this something that requires some corrective action on my part? Is this 
an indicator that something is NOT working properly, or MAY NOT work 
properly in some of these processes?

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/f68c0891-893f-4575-9cb4-3cb7d483988f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using admin views "outside" of admin

2013-11-21 Thread Brad Smith
Thanks for the reply! The main thing I'm looking for is the ability to 
create more granular permissions. For example, I want only the person who 
creates an instance of something (plus a few admins) the be able to modify 
that instance. I talk about working "outside" the admin interface because 
my understanding from other threads I've read is that the admin is designed 
on the assumption that everyone either has admin privileges or doesn't on a 
per-class (as opposed to per-object) basis, and if you want more than that 
you're going to have to build your own editing interface. 

Of course, what I'd love to hear is that I have this all wrong and there's 
an easy way to implement the concept of object ownership, custom 
permissions, etc in the existing admin interface. I guess subclassing 
AdminSite could be a start to this, but at least at first glanceI don't see 
anything in the docs about replacing or extending the access control 
mechanism. Anyone have advice along those lines?

Thanks again!
--Brad

On Wednesday, November 20, 2013 5:32:30 PM UTC-5, Gonzalo Delgado wrote:
>
> -BEGIN PGP SIGNED MESSAGE- 
> Hash: SHA256 
>
> El 20/11/13 12:54, Brad Smith escribi�: 
> > Based on other threads I've read here, it seems that the 
> > conventional wisdom is that the admin interface is only for 
> > low-level access to the database, and isn't designed for anything 
> > "fancy", like users with different levels of administrative rights 
> > within an app, etc. Ok, I get that, but if I may grasp at some 
> > straws briefly I'd like to ask one follow-up that I haven't seen 
> > answered elsewhere: my app has a bunch of objects with complicated 
> > relationships for which I've devised a reasonably pretty and 
> > intuitive editing interface using Django's admin and Grappelli. 
> > Since this took a nontrivial amount of effort, I wanted to ask here 
> > if there are any tricks I should know about for re-using *any* 
> > views, inlines, etc from that admin interface in a more integrated 
> > editing interface with granular access controls, or do I just need 
> > to suck it up and rewrite everything from scratch using regular 
> > Django forms? 
>
> The django admin code is very extensible and re-usable. The 
> documentation may not stress this enough, but it is possible to do 
> virtually anything you want with it. 
>
> If I'm understanding your "outside" of the admin concept correctly, 
> what you want to do is extend the AdminSite[0] class (or maybe not 
> even that, just create a new instance) and attach the ModelAdmins you 
> want to it. I think you can even use autodiscover with a custom 
> AdminSite instance too if you need to have all models from 
> settings.INSTALLED_APPS attached to it. 
>
>
> [0] 
> https://docs.djangoproject.com/en/1.6/ref/contrib/admin/#adminsite-objects
>  
>
> - -- 
> Gonzalo Delgado 
> -BEGIN PGP SIGNATURE- 
> Version: GnuPG v1.4.15 (Darwin) 
> Comment: Using GnuPG with Thunderbird - 
> http://www.enigmail.net/
>  
>
> iF4EAREIAAYFAlKNOH4ACgkQzbfdFL5JoUlCVQD6A1TUqYfKbgBDITrpvFblkQfo 
> nrVMCxnxSPIiREHgJaMBAKTR2auknxE6sX5s62B0j8eiH+AJB1EG1+AxeXoVHlGX 
> =kthG 
> -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/4bd041e0-2e4c-449c-9da8-2260c3af66f4%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


How mature is Microsoft SQL Server support by the ORM?

2013-11-21 Thread CLIFFORD ILKAY
Hello,

There is an upcoming project where support for an existing application
where Microsoft SQL Server is being used. Switching to another database
is not an option. There are hundreds of custom reports that the users
have created with Crystal Reports. I found django-sqlserver
. The latest version of
SQL Server it supports is 2008r2, which would be a problem given that
some sites are already running newer versions. How mature is this? Are
there any limitations or show-stoppers that you're aware of?

-- 
Regards,

Clifford Ilkay

647-778-8696

Dinamis



-- 
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/528E4ED2.1090207%40dinamis.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: manage.py deprecation message for model/sql arguments

2013-11-21 Thread tim
It looks like an issue with pywintypes, not Django. A deprecation warning 
means some code needs to update itself in order to work with future 
versions of some other code. In this case, it looks to me like pywintypes 
is using some functionality that will probably be removed in a future 
version of Python.

On Thursday, November 21, 2013 10:56:57 AM UTC-5, Steve Sawyer wrote:
>
> Working my way through the Django tutorial (running Python 3.3 and Django 
> 1.6), and when I run manage.py with any of the model arguments 
> (validate/sqlcustom/sqlclear/sqlall etc.) the output seems to be what the 
> tutorial leads me to expect, but I'm getting this message:
>
> *C:\Python33\lib\site-packages\win32\lib\pywintypes.py:39: 
> DeprecationWarning: imp.get_suffixes() is deprecated; use the constants 
> defined on importlib.machinery instead*
>
> Is this something that requires some corrective action on my part? Is this 
> an indicator that something is NOT working properly, or MAY NOT work 
> properly in some of these processes?
>
> 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/614d4a75-4f34-40bb-a94b-4eb7eabfcc31%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using admin views "outside" of admin

2013-11-21 Thread Brad Smith
...and of course now I find a FAQ item that seems to talk about exactly 
what I want to do:

  
https://docs.djangoproject.com/en/1.6/faq/admin/#how-do-i-limit-admin-access-so-that-objects-can-only-be-edited-by-the-users-who-created-them

I'm still curious to hear comments, though, because if this is possible 
then I'm no longer clear what the conventional wisdom is regarding when and 
how to use AdminSite vs when it's time to buckle down and write your own 
interface. 

While I'm at it, and possibly related to the above, ultimately what I'd 
like to be able to do is load and submit editing forms from within the view 
interface via AJAX (ie click an icon on an object and the regular content 
is replaced with the corresponding admin edit form).  It looks like you can 
add '_popup=1' to any admin url and get something that could work 
reasonably well for embedding, and then you'd just need some javascript to 
cause the submit button to use e.g. jQuery.post()... right? 

Any tips/warnings with regard to this?

--Brad

-- 
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/dfae28eb-b7d6-4abd-afac-564e7f389521%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: How mature is Microsoft SQL Server support by the ORM?

2013-11-21 Thread Larry Martell
On Thu, Nov 21, 2013 at 1:20 PM, CLIFFORD ILKAY
wrote:

> Hello,
>
> There is an upcoming project where support for an existing application
> where Microsoft SQL Server is being used. Switching to another database
> is not an option. There are hundreds of custom reports that the users
> have created with Crystal Reports. I found django-sqlserver
> . The latest version of
> SQL Server it supports is 2008r2, which would be a problem given that
> some sites are already running newer versions. How mature is this? Are
> there any limitations or show-stoppers that you're aware of?
>

I've been trying to get Vernon Cole's django-mssql package working (
https://bitbucket.org/vernondcole/django-mssql-ado-merge) but I have not
been successful. I messed around with this for a month, and then I stopped
working on it. I plan to look at it again next week. I hadn't seen the
package you mention. I'll check it out.

-- 
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/CACwCsY7PPvkEri30ERLG%3DwpV27-u4VCtF8v4ALucq2qwnQnY-g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Trouble running Celery as a service on Windows

2013-11-21 Thread DJ-Tom
Hi,

I followed 
http://mrtn.me/blog/2012/07/04/django-on-windows-run-celery-as-a-windows-service/
 
and managed to get redis run as a service on Windows 7.

Now I tried to get the Celery processes to run as a service but keep 
getting the following error:

Traceback (most recent call last): 
File 
"D:\python27\.virtualenvs\djellis\lib\site-packages\pywin32-218-py2.7-win32.egg\win32serviceutil.py",
 
line 835, in SvcRun self.SvcDoRun() 
File 
"D:\python27\.virtualenvs\djellis\lib\site-packages\django_windows_tools\service.py",
 
line 227, in SvcDoRun self.start() 
File 
"D:\python27\.virtualenvs\djellis\lib\site-packages\django_windows_tools\service.py",
 
line 260, in start self.processes = start_commands(self.config) 
File 
"D:\python27\.virtualenvs\djellis\lib\site-packages\django_windows_tools\service.py",
 
line 134, in start_commands services = config.get(node_name, 'run') if 
config.has_section(node_name) else config.get('services', 'run') 
File "D:\python27\Lib\ConfigParser.py", line 618, in get raise 
NoOptionError(option, section) NoOptionError: No option 'run' in section: 
'services'

the services section of service.ini (which I copied from the link above) 
looks like this, so everything should be fine:

[services]
# Services to be run on all machines
run=celeryd
clean=d:\logs\celery.log

I also checked with ProcessMonitor if the service uses the correct ini file 
and it does.

Any idea what might be wrong?

-- 
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/afbcbecc-ae8b-43c8-827a-83922cc3bf36%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Apache environment variables in Django 1.6

2013-11-21 Thread Mike Starov
I encountered same issue in my deployment. Have you found a solution?

On Wednesday, November 20, 2013 7:16:47 PM UTC-8, Jon Dufresne wrote:
>
> Hi, 
>
> I recently upgraded my Django application from 1.5 to 1.6. This 
> application runs on Apache with mod_wsgi. After upgrading, Django 
> seems unable to access environment variables set by Apache using 
> SetEnv and SetEnvIf. Using Django 1.5 I was able to access this using 
> the following recipe in wsgi.py: 
>
> --- 
> import os 
>
> from django.core.wsgi import get_wsgi_application 
> _application = get_wsgi_application() 
>
> def application(environ, start_response): 
> os.environ['MY_SETTING'] = environ['MY_SETTING'] 
> return _application(environ, start_response) 
> --- 
>
> Then, in settings.py, I would access MY_SETTING using 
> os.environ['MY_SETTING']. 
>
> Is this a bug that this no longer works in Django 1.6? Is there a 
> better way to access Apache environment variables? 
>
> 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/161600e6-6f62-4635-a6bc-33f05326f546%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


django tests

2013-11-21 Thread Harjot Mann
I am creating tests for my django app. Here is my test and I am
getting an error.
Here is my test code.
UserProfile is my model name and profile is my view corresponding to that.

http://tny.cz/82ce97ef

This is the error I am getting
ERROR: test_profile (Automation.tcc.tests.UserProfile)
--
Traceback (most recent call last):
  File "/home/harjot/Automation/../Automation/tcc/tests.py", line 15,
in test_profile
self.assertEqual(self.first_name, "Harjot")
AttributeError: 'UserProfile' object has no attribute 'first_name'

Help me please.

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

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


Re: How mature is Microsoft SQL Server support by the ORM?

2013-11-21 Thread Fred Stluka

Clifford,

I use:
- http://code.google.com/p/django-pyodbc/

No problem except that the MS SQL Server DB identifies itself
as using UTF-8, but actually contains Windows-1252 chars, so
we get UnicoeDecodeError a lot and have to repair the data.

--Fred

Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.


On 11/21/13 1:28 PM, Larry Martell wrote:
On Thu, Nov 21, 2013 at 1:20 PM, CLIFFORD ILKAY 
mailto:clifford_il...@dinamis.com>> wrote:


Hello,

There is an upcoming project where support for an existing application
where Microsoft SQL Server is being used. Switching to another
database
is not an option. There are hundreds of custom reports that the users
have created with Crystal Reports. I found django-sqlserver
. The latest version of
SQL Server it supports is 2008r2, which would be a problem given that
some sites are already running newer versions. How mature is this? Are
there any limitations or show-stoppers that you're aware of?


I've been trying to get Vernon Cole's django-mssql package working 
(https://bitbucket.org/vernondcole/django-mssql-ado-merge) but I have 
not been successful. I messed around with this for a month, and then I 
stopped working on it. I plan to look at it again next week. I hadn't 
seen the package you mention. I'll check it out.

--
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/CACwCsY7PPvkEri30ERLG%3DwpV27-u4VCtF8v4ALucq2qwnQnY-g%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.


--
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/528EE05E.2090700%40bristle.com.
For more options, visit https://groups.google.com/groups/opt_out.


html to odt

2013-11-21 Thread Harjot Mann
I want to save my html django templates to odt file. Is there any way
to do this?
-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

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


Re: django tests

2013-11-21 Thread Charly Román
Your testcase's name and model's name its the same, fix this.

2013/11/21 Harjot Mann :
> I am creating tests for my django app. Here is my test and I am
> getting an error.
> Here is my test code.
> UserProfile is my model name and profile is my view corresponding to that.
>
> http://tny.cz/82ce97ef
>
> This is the error I am getting
> ERROR: test_profile (Automation.tcc.tests.UserProfile)
> --
> Traceback (most recent call last):
>   File "/home/harjot/Automation/../Automation/tcc/tests.py", line 15,
> in test_profile
> self.assertEqual(self.first_name, "Harjot")
> AttributeError: 'UserProfile' object has no attribute 'first_name'
>
> Help me please.
>
> --
> Harjot Kaur Mann
> Blog: http://harjotmann.wordpress.com/
> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
>
> --
> 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/CAB0GQhCWHBLq97OCDY9FrDfR6zRD08_1-zcr6bqN5EP01OGYcQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/CABeWMUYccVtZ3Ek8heM%2BgHutyXEN-FsrXKa3%2BY3ZXaAf44DVLw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django tests

2013-11-21 Thread Harjot Mann
On Fri, Nov 22, 2013 at 11:17 AM, Charly Román  wrote:
> Your testcase's name and model's name its the same, fix this.


Changed it. But still getting the same error. Now the code is this:
http://tny.cz/941266d9

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

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


Re: django tests

2013-11-21 Thread Charly Román
http://tny.cz/c883f980


You need to rea about OOP in Python.



2013/11/22 Harjot Mann :
> On Fri, Nov 22, 2013 at 11:17 AM, Charly Román  wrote:
>> Your testcase's name and model's name its the same, fix this.
>
>
> Changed it. But still getting the same error. Now the code is this:
> http://tny.cz/941266d9
>
> --
> Harjot Kaur Mann
> Blog: http://harjotmann.wordpress.com/
> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
>
> --
> 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/CAB0GQhBYbrkqPsskUKg5j9xVAKJZMMPxiKYKx2TL_ckwN1qJDw%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/CABeWMUbwu9bBTJkVnvKiYSdBqt%2B7UifqwbMkNppeuP8V2nOy7w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django tests

2013-11-21 Thread Charly Román
http://tny.cz/c883f980


You need to read about OOP in Python.

2013/11/22 Charly Román :
> http://tny.cz/c883f980
>
>
> You need to rea about OOP in Python.
>
>
>
> 2013/11/22 Harjot Mann :
>> On Fri, Nov 22, 2013 at 11:17 AM, Charly Román  wrote:
>>> Your testcase's name and model's name its the same, fix this.
>>
>>
>> Changed it. But still getting the same error. Now the code is this:
>> http://tny.cz/941266d9
>>
>> --
>> Harjot Kaur Mann
>> Blog: http://harjotmann.wordpress.com/
>> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
>>
>> --
>> 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/CAB0GQhBYbrkqPsskUKg5j9xVAKJZMMPxiKYKx2TL_ckwN1qJDw%40mail.gmail.com.
>> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/CABeWMUaVUEUwpfLvFhs10J%2BjV_OAtJP%3DZyMCRyLO0CRJJBxUvw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django tests

2013-11-21 Thread Xavier Ordoquy
Hi,

I doubt the error is the same although it might look similar.
Please note that TestCase use setUp instead of setup.

Regards,
Xavier Ordoquy,
Linovia.

Le 22 nov. 2013 à 07:17, Harjot Mann  a écrit :

> On Fri, Nov 22, 2013 at 11:17 AM, Charly Román  wrote:
>> Your testcase's name and model's name its the same, fix this.
> 
> 
> Changed it. But still getting the same error. Now the code is this:
> http://tny.cz/941266d9
> 
> -- 
> Harjot Kaur Mann
> Blog: http://harjotmann.wordpress.com/
> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
> 
> -- 
> 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/CAB0GQhBYbrkqPsskUKg5j9xVAKJZMMPxiKYKx2TL_ckwN1qJDw%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/65C25054-BE40-4C1F-87B2-35F4654925E2%40linovia.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django tests

2013-11-21 Thread Harjot Mann
On Fri, Nov 22, 2013 at 12:13 PM, Xavier Ordoquy  wrote:
> I doubt the error is the same although it might look similar.
> Please note that TestCase use setUp instead of setup.


Oh thankyou. But now I am getting a long list of errors.
http://tny.cz/c4018552

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

-- 
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/CAB0GQhAD23Sj8OpXQF2H0UAUFyacMxP%3DHj_m2peG8LjqA9%2BSUA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django tests

2013-11-21 Thread Charly Román
It's because you have fields in your model that aren't optional, and
in your code you only set one field.



2013/11/22 Harjot Mann :
> On Fri, Nov 22, 2013 at 12:13 PM, Xavier Ordoquy  wrote:
>> I doubt the error is the same although it might look similar.
>> Please note that TestCase use setUp instead of setup.
>
>
> Oh thankyou. But now I am getting a long list of errors.
> http://tny.cz/c4018552
>
> --
> Harjot Kaur Mann
> Blog: http://harjotmann.wordpress.com/
> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
>
> --
> 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/CAB0GQhAD23Sj8OpXQF2H0UAUFyacMxP%3DHj_m2peG8LjqA9%2BSUA%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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


Re: django tests

2013-11-21 Thread Harjot Mann
On Fri, Nov 22, 2013 at 12:50 PM, Charly Román  wrote:
> It's because you have fields in your model that aren't optional, and
> in your code you only set one field.


Ok so I need to give alll the fields and it is having foreign key
constraint I think, so for that I need to use that also?

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

-- 
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/CAB0GQhASUuaAhr9DqyU3---6snn3tS1eJPvVgsSMSc_a6%3DYarQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django tests

2013-11-21 Thread Charly Román
Yes, you need to give all the fields that arent't optional. Included
foreign keys.

2013/11/22 Harjot Mann :
> On Fri, Nov 22, 2013 at 12:50 PM, Charly Román  wrote:
>> It's because you have fields in your model that aren't optional, and
>> in your code you only set one field.
>
>
> Ok so I need to give alll the fields and it is having foreign key
> constraint I think, so for that I need to use that also?
>
> --
> Harjot Kaur Mann
> Blog: http://harjotmann.wordpress.com/
> Daily Dairy: http://harjotmann.wordpress.com/daily-diary/
>
> --
> 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/CAB0GQhASUuaAhr9DqyU3---6snn3tS1eJPvVgsSMSc_a6%3DYarQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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/CABeWMUaGdMAFNDjtkC%2B8wYYDhbd4WWJLrn8TRsFdtva%2BKL8Ysw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django tests

2013-11-21 Thread Harjot Mann
On Fri, Nov 22, 2013 at 1:13 PM, Charly Román  wrote:
> Yes, you need to give all the fields that arent't optional. Included
> foreign keys.


Not optional means that are not validated. If yes why?
I mean these are the compulsory fields, so why we should not give it.
I used all the compulsory fields but still I am getting the same
error. And how we can use foreign key in tests.py file ?

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

-- 
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/CAB0GQhBWVpm04ydYvSt_Vy-k2M-ctX87t_L01YD4SpoyMpE8Eg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.