Re: problem with deploying django using mod wsgi

2013-08-07 Thread Nick Dokos
sah  writes:

> Though i remove those two line it did not change anything. It works
> the same as before, i get the search_form page and if i give some
> value for search, I get a 404 error page saying that the page is not
> available in the server.
>

Then check the /var/log/apache2/error.log file on the server to see what
URL is being passed. I often do a `tail -f' on that file in an xterm
window so I can watch for errors.  And you might want to turn up the
verbosity of your server in /etc/apache2/apache2.conf - look for
LogLevel:

,
| #
| # LogLevel: Control the number of messages logged to the error_log.
| # Possible values include: debug, info, notice, warn, error, crit,
| # alert, emerg.
| #
| LogLevel warn
`

-- 
Nick

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


Re: Returning random model objects - is order_by('?') on Postgres safe to use now?

2013-08-07 Thread Victor Hooi
Hi,

The issue is that apparently, for ORDER BY RANDOM, the database will foo
through and generate a random number for *every* row in a new column, then
do a sort by that be column.

Obviously that's an expensive operation and since that column is random,
it's a worst case sort.

For my code I was using randint to generate random numbers between 0 and
the highest pk (and handling ObjectDoesNotExist).

Hence, this was meant to be faster and cheaper.

However, I'm curious if database backend has changes significantly?

Cheers,
Victor
On 08/08/2013 12:11 PM, "Tom Lockhart"  wrote:

> I haven't used the feature, but there is no reason to think that having
> the db backend do a random sort is any slower than you doing it yourself.
>
> If your query can reduce the number of rows returned to a relatively small
> number, any "order by" should have acceptable performance. If not, it will
> be expensive no matter who does the work.
>
> hth
>
> - Tom
>
> On 2013-08-07, at 6:55 PM, Victor Hooi  wrote:
>
> Hi,
>
> We have some code to return randomised Django model instances.
>
> Initially, I was using random.randint(), and returning objects by index
> between 0 < max_id.
>
> This was based on the Django docs:
>
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by
>
> specifically, the part:
>
> Note: order_by('?') queries may be expensive and slow, depending on the
>> database backend you’re using.
>
>
> This blog post from February 2011 also seems to back that up:
>
> http://www.peterbe.com/plog/getting-random-rows-postgresql-django
>
> However, I just ran the benchmarks on my own box running Django 1.5 and
> Postgres 9.2.4, and the ORDER BY RANDOM() approach was slower, but not
> substantially so (certainly not to the extent hinted at by the blog post).
>
> I'm curious - what are other people's experiences with using ORDERY BY
> RANDOM versus other approaches?
>
> Has Postgres made some recent changes which makes ORDER BY RANDOM the
> better option now?
>
> Which database backends specifically should we be warned about when saying
> that order_by('?') is expensive and slow?
> Cheers,
> Victor
>
> --
> 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.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/QJk3HDYAkro/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Returning random model objects - is order_by('?') on Postgres safe to use now?

2013-08-07 Thread Tom Lockhart
I haven't used the feature, but there is no reason to think that having the db 
backend do a random sort is any slower than you doing it yourself.

If your query can reduce the number of rows returned to a relatively small 
number, any "order by" should have acceptable performance. If not, it will be 
expensive no matter who does the work.

hth

- Tom

On 2013-08-07, at 6:55 PM, Victor Hooi  wrote:

> Hi,
> 
> We have some code to return randomised Django model instances.
> 
> Initially, I was using random.randint(), and returning objects by index 
> between 0 < max_id.
> 
> This was based on the Django docs:
> 
> https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by
> 
> specifically, the part:
> 
> Note: order_by('?') queries may be expensive and slow, depending on the 
> database backend you’re using.  
> 
> This blog post from February 2011 also seems to back that up:
> 
> http://www.peterbe.com/plog/getting-random-rows-postgresql-django
> 
> However, I just ran the benchmarks on my own box running Django 1.5 and 
> Postgres 9.2.4, and the ORDER BY RANDOM() approach was slower, but not 
> substantially so (certainly not to the extent hinted at by the blog post).
> 
> I'm curious - what are other people's experiences with using ORDERY BY RANDOM 
> versus other approaches? 
> 
> Has Postgres made some recent changes which makes ORDER BY RANDOM the better 
> option now?
> 
> Which database backends specifically should we be warned about when saying 
> that order_by('?') is expensive and slow?
> 
> Cheers,
> Victor
> 
> -- 
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Returning random model objects - is order_by('?') on Postgres safe to use now?

2013-08-07 Thread Victor Hooi
Hi,

We have some code to return randomised Django model instances.

Initially, I was using random.randint(), and returning objects by index 
between 0 < max_id.

This was based on the Django docs:

https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by

specifically, the part:

Note: order_by('?') queries may be expensive and slow, depending on the 
> database backend you’re using.  


This blog post from February 2011 also seems to back that up:

http://www.peterbe.com/plog/getting-random-rows-postgresql-django

However, I just ran the benchmarks on my own box running Django 1.5 and 
Postgres 9.2.4, and the ORDER BY RANDOM() approach was slower, but not 
substantially so (certainly not to the extent hinted at by the blog post).

I'm curious - what are other people's experiences with using ORDERY BY 
RANDOM versus other approaches? 

Has Postgres made some recent changes which makes ORDER BY RANDOM the 
better option now?

Which database backends specifically should we be warned about when saying 
that order_by('?') is expensive and slow?
Cheers,
Victor

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




Re: NuoDB released 1.2 along with a Django Driver

2013-08-07 Thread Russell Keith-Magee
This is deeply concerning -- from my initial inspection of the code, it's
pretty clear that the NuoDB backend has been substantially copied from
Django's postgresql_psycopg2 backend.

The code in the Django postgresql_psycogpy2 backend, like all of Django, is
covered by Django's BSD license, which requires attribution of the
copyright to:

Copyright (c) Django Software Foundation and individual contributors.
All rights reserved.

The DSF takes this copyright very seriously. While I'm enthusiastic about
the prospect of a new database supporting Django, that can't be at the cost
of the Django community losing it's intellectual property rights. Lindsey
-- I'll be in touch shortly in my capacity as DSF President to discuss this
issue.

Yours,
Russ Magee %-)


On Wed, Aug 7, 2013 at 9:27 PM, Michael Manfre  wrote:

> Copyright (c) 2012, NuoDB, Inc.
> All rights reserved.
>
> You might want to update the license to reflect that most of the code is
> actually a copy & paste from Django's postgresql_psycopg2 backend, which
> was obvious because whoever worked on the backend forgot to remove all of
> the "postgresql" comments from the code.
>
> Regards,
> Michael Manfre
>
>
> On Tuesday, August 6, 2013 2:18:35 PM UTC-4, Lindsey Hoyem wrote:
>>
>> Read a full description of the 1.2 Release here : http://bit.ly/187MJYX,
>> including previews, bug fixes, and product enhancements!  If your
>> interested in the Django Driver, it can be found on github:
>> http://bit.ly/15Gpis6
>
>  --
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Exception Value: Could not parse the remainder: '().order_by('-votes')' from 'poll.altword_set.all().order_by('-votes')'

2013-08-07 Thread Ramiro Morales
On Wed, Aug 7, 2013 at 6:59 PM, Pepsodent Cola  wrote:
> How come when I replace this:
> {% for choice2 in poll.altword_set.all %}
> to this:
> {% for choice2 in poll.altword_set.all().order_by('-votes')  %}
> then I get this error:
>
> Exception Type: TemplateSyntaxError
> Exception Value:
>
> Could not parse the remainder: '().order_by('-votes')' from
> 'poll.altword_set.all().order_by('-votes')'
>
>
>
> How do I write the correct syntax for ordering my list?

You can't. The template language only supports calling methods without
arguments, and in that case the () aren't needed.

Please read this section of the documentation fully for more details:

https://docs.djangoproject.com/en/1.5/topics/templates/#accessing-method-calls

You will need to implement the ordering with a method in another layer
and invoke it from the template layer.

Regards,

--
Ramiro Morales
@ramiromorales

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




Re: problem with deploying django using mod wsgi

2013-08-07 Thread sah
Though i remove those two line it did not change anything. It works the 
same as before, i get the search_form page and if i give some value for 
search, 
I get a 404 error page saying that the page is not available in the server.

On Wednesday, August 7, 2013 5:25:01 PM UTC-4, sah wrote:
>
> Hello , I am trying to deploy django using apache and mod_wsgi but not 
> able to , can anyone help me on this :
>
> httpd.conf
> --
> LoadModule wsgi_module modules/mod_wsgi.so
>
> WSGIScriptAlias /mice /home/getMice/webproject/wsgi.wsgi
> 
>
> 
> Order deny,allow
> Allow from all
> AddHandler wsgi-script .wsgi
> SetHandler wsgi-script
> 
>  
>
> --
>
> My views file has two functions 
>
> One is a search_form and other is a search results ,vi
>
> I am able to get the search_form page but when i give input i dont get the 
> results page.
>
> urls.py
> --
>
> from django.conf.urls.defaults import *
> from django.conf import settings
>
> from webapp import views
>
>
>
> urlpatterns = patterns('',url(r'^search_mice/$', views.search_mice) 
> ,url(r'^search/$', views.search),)
>
>
>
>
> Please help me with this .
>
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Exception Value: Could not parse the remainder: '().order_by('-votes')' from 'poll.altword_set.all().order_by('-votes')'

2013-08-07 Thread Pepsodent Cola
I wrote one line wrong at:

4.)
>>> *p.altword_set.all().order_by('-votes')*
[, ]


How do I write the correct syntax for ordering my list?




On Wednesday, August 7, 2013 11:59:38 PM UTC+2, Pepsodent Cola wrote:
>
> Hi,
> I have some database query ordering problems.
>
> 1.)
> On my webpage I see this output:
>
> * Option-1 = 18 votes
> * Option-2 = 50 votes
>
>
> 2.)
> *altword_list.html*
>
> 
> {% for choice2 in poll.altword_set.all %}
> 
> {{ choice2.rosword }} - {{ choice2.alt_ros_word }} - {{ 
> choice2.alt_transl_word }} - {{ choice2.articulate }} = {{ choice2.votes }} 
> votes
> {% endfor %}
> 
>
>
> 3.)
> I want my webpage to order the output by *most votes down to least votes*like 
> so:
>
> * Option-2 = 50 votes
> * Option-1 = 18 votes
>
>
> 4.)
> In Python shell I managed to accomplish that by doing like so:
>
> >>> p = Word.objects.get(pk=1)
> >>> p
> 
> >>> p.altword_set.all()
> [, ]
>
> >>> *p.altword_set.all().order_by('votes')*
> [, ]
>
>
> 5.)
> How come when I replace this:
> {% for choice2 in poll.altword_set.all %}
> to this:
> {% for choice2 in poll.altword_set.all().order_by('-votes')  %}
> then I get this error:
>
> Exception Type: TemplateSyntaxError  Exception Value:  
>
> Could not parse the remainder: '().order_by('-votes')' from 
> 'poll.altword_set.all().order_by('-votes')'
>
>
>
> How do I write the correct syntax for ordering my 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.
For more options, visit https://groups.google.com/groups/opt_out.




Exception Value: Could not parse the remainder: '().order_by('-votes')' from 'poll.altword_set.all().order_by('-votes')'

2013-08-07 Thread Pepsodent Cola
Hi,
I have some database query ordering problems.

1.)
On my webpage I see this output:

* Option-1 = 18 votes
* Option-2 = 50 votes


2.)
*altword_list.html*


{% for choice2 in poll.altword_set.all %}

{{ choice2.rosword }} - {{ choice2.alt_ros_word }} - {{ 
choice2.alt_transl_word }} - {{ choice2.articulate }} = {{ choice2.votes }} 
votes
{% endfor %}



3.)
I want my webpage to order the output by *most votes down to least votes*like 
so:

* Option-2 = 50 votes
* Option-1 = 18 votes


4.)
In Python shell I managed to accomplish that by doing like so:

>>> p = Word.objects.get(pk=1)
>>> p

>>> p.altword_set.all()
[, ]

>>> *p.altword_set.all().order_by('votes')*
[, ]


5.)
How come when I replace this:
{% for choice2 in poll.altword_set.all %}
to this:
{% for choice2 in poll.altword_set.all().order_by('-votes')  %}
then I get this error:

Exception Type: TemplateSyntaxError  Exception Value:  

Could not parse the remainder: '().order_by('-votes')' from 
'poll.altword_set.all().order_by('-votes')'



How do I write the correct syntax for ordering my 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: problem with deploying django using mod wsgi

2013-08-07 Thread Bill Freeman
I think that AddHandler stuff sounds like a ghost of mod_python days.  I
don't use it in my mod_wsgi deployments.

See http://code.google.com/p/modwsgi/ for good information.

Bill


On Wed, Aug 7, 2013 at 5:25 PM, sah  wrote:

> Hello , I am trying to deploy django using apache and mod_wsgi but not
> able to , can anyone help me on this :
>
> httpd.conf
> --
> LoadModule wsgi_module modules/mod_wsgi.so
>
> WSGIScriptAlias /mice /home/getMice/webproject/wsgi.wsgi
> 
>
> 
> Order deny,allow
> Allow from all
> AddHandler wsgi-script .wsgi
> SetHandler wsgi-script
> 
> 
>
> --
>
> My views file has two functions
>
> One is a search_form and other is a search results ,vi
>
> I am able to get the search_form page but when i give input i dont get the
> results page.
>
> urls.py
> --
>
> from django.conf.urls.defaults import *
> from django.conf import settings
>
> from webapp import views
>
>
>
> urlpatterns = patterns('',url(r'^search_mice/$', views.search_mice)
> ,url(r'^search/$', views.search),)
>
>
>
>
> Please help me with this .
>
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




problem with deploying django using mod wsgi

2013-08-07 Thread sah
Hello , I am trying to deploy django using apache and mod_wsgi but not able 
to , can anyone help me on this :

httpd.conf
--
LoadModule wsgi_module modules/mod_wsgi.so

WSGIScriptAlias /mice /home/getMice/webproject/wsgi.wsgi



Order deny,allow
Allow from all
AddHandler wsgi-script .wsgi
SetHandler wsgi-script

 
--

My views file has two functions 

One is a search_form and other is a search results ,vi

I am able to get the search_form page but when i give input i dont get the 
results page.

urls.py
--

from django.conf.urls.defaults import *
from django.conf import settings

from webapp import views



urlpatterns = patterns('',url(r'^search_mice/$', views.search_mice) 
,url(r'^search/$', views.search),)




Please help me with this .

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




Re: connecting to MS SQL server in addition to default MySQL

2013-08-07 Thread Andre Terra
You can use django-mssql[0] as a backend, and then either use the ORM as
usual, write RAW queries with Django[1] or just use SQL directly[2].


Cheers,
AT

[0] http://django-mssql.readthedocs.org/en/latest/
[1] https://docs.djangoproject.com/en/dev/topics/db/sql/
[2]
https://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly


On Wed, Aug 7, 2013 at 2:42 PM, Larry Martell wrote:

> I have a django app that connects to a MySQL server in the usual way.
> I've noe been asked to add some new functionality that requires that I
> pull data from a MS SQL server database running on a Windows box. I
> don't want to use the django ORM with the db, just access it directly
> with some sql in my python code. What's the best way to accomplish
> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: handling FileField and FileSystemStorage in WizardView - Django 1.4

2013-08-07 Thread pravasi

On Tuesday, 29 January 2013 02:12:38 UTC-6, devver wrote:
>
> I created a form wizard of 6 steps, 
> in step sixth, have filefield for uploading docfile1
>
> django docs is poor on this topic, google does not help.
>
>
> my code working ok, but how handle filefield.
>
> need example, thanks
>
>
> forms.py
>
> class Step6(forms.Form):
>
>  docfile1 = forms.FileField(required=False)
>
>
> view.py
>
>
>1. class RegInfo(SessionWizardView):
>2. template_name = 'gest/wizard_form.html'
>3. file_storage = FileSystemStorage(location=os.path.join(settings.
>MEDIA_ROOT, 'docs'))
>4.  
>5. def get_context_data(self, form, **kwargs):
>6. context = super(RegInfo, self).get_context_data(form,
> **kwargs)
>7.
>8. if self.steps.current == 'six':
>9. print 'step 6'
>10.
>11. return context
>12.  
>13. def done(self, form_list, **kwargs):
>14. dati = self.get_all_cleaned_data()
>15.  
>16. s = Info()
>17. s.tec = self.request.user
>18. s.dataso = dati['dataso']
>19.
>20. s.docfile1 = 
>21.
>22. s.save()
>23.  
>24. return render_to_response('gest/done.html', {
>25. 'form_data': [form.cleaned_data for form in form_list],
>26. })
>27.  
>28. 
>
> docfile1= self.request.FILES['-docfile1']
> s.docfile1 = docfile1
>
Note that there is a prefix for the  request.FILES key which is the 'step' 
name defined for the form.

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




Re: Query Set and Output

2013-08-07 Thread Arnold Krille
Hi,

On Tue, 6 Aug 2013 20:19:01 -0700 (PDT) Muhammed TÜFEKYAPAN
 wrote:
> def home(request):
> output = Excuse.objects.order_by('?')[:1]

[:1] selects all elements from the beginning up to the first and
returns that list. true, its a list with only one member, but still a
list.

You want [0] to get the first element of the list/set that
Excuse.objects.order_by returns.

> template = loader.get_template('index.html')
> context = {'output': output}
> return render(request, 'index.html', context)
> 
> I get output like this: []
> i just want to blabla section and how i get away from  []

Have fun,

Arnold


signature.asc
Description: PGP signature


connecting to MS SQL server in addition to default MySQL

2013-08-07 Thread Larry Martell
I have a django app that connects to a MySQL server in the usual way.
I've noe been asked to add some new functionality that requires that I
pull data from a MS SQL server database running on a Windows box. I
don't want to use the django ORM with the db, just access it directly
with some sql in my python code. What's the best way to accomplish
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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: NuoDB released 1.2 along with a Django Driver

2013-08-07 Thread Michael Manfre


Copyright (c) 2012, NuoDB, Inc.
All rights reserved.

You might want to update the license to reflect that most of the code is 
actually a copy & paste from Django's postgresql_psycopg2 backend, which 
was obvious because whoever worked on the backend forgot to remove all of 
the "postgresql" comments from the code.

Regards,
Michael Manfre

On Tuesday, August 6, 2013 2:18:35 PM UTC-4, Lindsey Hoyem wrote:
>
> Read a full description of the 1.2 Release here : http://bit.ly/187MJYX, 
> including previews, bug fixes, and product enhancements!  If your 
> interested in the Django Driver, it can be found on github: 
> http://bit.ly/15Gpis6 

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




Re: Django 1.5.1 and clearsessions

2013-08-07 Thread Derrick Jackson
Thanks Richard.  I'll double-check and try again.


On Wed, Aug 7, 2013 at 10:39 AM, Richard E. Cooke wrote:

> Works fine for me.  Must be a path issue.
>
>
>
>
> On Wednesday, August 7, 2013 9:41:37 AM UTC-4, Derrick Jackson wrote:
>
>> Hmm...
>>
>> When I attempt to run django-admin.py clearsessions while using django
>> 1.5.1 I am told that clearsessions is an unknown command.  Has anyone
>> successfully used clearsessions as of yet?
>>
>  --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/v9kX4feh1DI/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




How to integrate my app into a theme / template

2013-08-07 Thread Christian Erhardt
Hi,

currently i'm using pinax for my project and therefor 
pinax-theme-bootstrap. I wrote some apps and want to integrate them into my 
template. Right now, i copied the file site_base.html into my projects 
template directory and added the menu links i needed to the {% block nav %} 
in this file. 

But is there a way to integrate my app without modifying the theme itself? 
I'd like to define the apps sub-menu in my app, and as i add this app to my 
project, the menu structure gets extended. 

I tried to create a file site_base.html in my app, only adding the block 
"nav" to it, but this is ignored. Maybe there is an app for creating 
dynamic menus?

Same thing would be nice, not only for the menu, but for information shown 
on the homepage or in a users dashboard.

Regards Christian

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




Re: Django 1.5.1 and clearsessions

2013-08-07 Thread Richard E. Cooke
Works fine for me.  Must be a path issue.



On Wednesday, August 7, 2013 9:41:37 AM UTC-4, Derrick Jackson wrote:
>
> Hmm...
>
> When I attempt to run django-admin.py clearsessions while using django 
> 1.5.1 I am told that clearsessions is an unknown command.  Has anyone 
> successfully used clearsessions as of yet?
>

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




Re: Django 1.5.1 and clearsessions

2013-08-07 Thread Derrick Jackson
UPDATE:  I am able to run this via PyCharm's Tools > Run manage.py Task.

However, for the life of me I cannot figure out how to run this from the 
command line.  What am I missing?

On Wednesday, August 7, 2013 9:41:37 AM UTC-4, Derrick Jackson wrote:
>
> Hmm...
>
> When I attempt to run django-admin.py clearsessions while using django 
> 1.5.1 I am told that clearsessions is an unknown command.  Has anyone 
> successfully used clearsessions as of yet?
>

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




Django 1.5.1 and clearsessions

2013-08-07 Thread Derrick Jackson
Hmm...

When I attempt to run django-admin.py clearsessions while using django 
1.5.1 I am told that clearsessions is an unknown command.  Has anyone 
successfully used clearsessions as of yet?

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




How do I find out how many AdminSites exist?

2013-08-07 Thread Richard E. Cooke
I want to use Grappelli and Django-extensions with my Admin site.  But I 
also need to use modelAdmin.queryset to restrict my records.

Both Grappelli and Django-extensions Auto Complete Lookups use the model's 
base queryset.

I want to put in a request to change the code, which is easy - so long as I 
can determine WHICH admin site the data model is registered with.

I just thought of another wrinklye - it could be registered with multiple 
sites.

Here are links to my other discussions on this topic.

All suggestions truly appreciated!

Thanks in advance,
Rich.

Django-extensions (soon to be extinct pull request):
 - https://github.com/django-extensions/django-extensions/pull/354

Grappelli discussion on this topic:
 - https://github.com/sehmaschine/django-grappelli/issues/362



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




Re: Query Set and Output

2013-08-07 Thread Muhammed TÜFEKYAPAN
   "outout = Excuse.objects.order_by('?')[0]"

This works well.

Thank you.

On Wednesday, August 7, 2013 6:19:01 AM UTC+3, Muhammed TÜFEKYAPAN wrote:
>
> Hello everyone,
>
> I write a basic model in django 1.5.1
>
> My model is looks like this:
> class Excuse(models.Model):
> text = models.CharField(max_length=300)
>
> def __unicode__(self):
> return self.text
>
> And i have a basic function to get random excuse from this model.
>
> def home(request):
> output = Excuse.objects.order_by('?')[:1]
> template = loader.get_template('index.html')
> context = {'output': output}
> return HttpResponse(output)
>
> If i write my view looks like above everything works well. I get a random 
> excuse and write it on the page. But when i change this like this:
>
> def home(request):
> output = Excuse.objects.order_by('?')[:1]
> template = loader.get_template('index.html')
> context = {'output': output}
> return render(request, 'index.html', context)
>
> I get output like this: []
> i just want to blabla section and how i get away from  []
>
>
> Thanks for all!
>

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




Re: Query Set and Output

2013-08-07 Thread abhijeet shete
Hi,

If you tries to access values from list using slice it returns you the
subset of list not a single value.The query *(*Excuse.objects.order_by('?')*
)* from your view returns a list and you are trying to access values from
that list using slice which in turn returns subset of list and because of
it when your trying to display output in template it is displaying as list.
If you want single object use index instead of slice for example if you
want 1st object from list then
   outout = Excuse.objects.order_by('?')[0]

This will return single object of Excuse.

In your template if you want to display only text from Excuse then use
*output.
*in this case your fieldname is text so use *output.text *instead of just *
output*.



   {{ output.text }} 




Regards.
Abhijeet Shete
Software Engineer | mquotient |  Mobile +91.9860219715


On Wed, Aug 7, 2013 at 2:30 PM, Muhammed TÜFEKYAPAN
wrote:

> It looks like this:
>
> 
>
>{{ output }} 
>
> 
>
> On Wednesday, August 7, 2013 6:58:17 AM UTC+3, Bulkan-Savun Evcimen wrote:
>
>> Hi there,
>>
>> What does your template index.html look like ?
>>
>> Cheers
>>
>> http://bulkan-evcimen.com
>>
>>
>> On Wed, Aug 7, 2013 at 1:19 PM, Muhammed TÜFEKYAPAN 
>> wrote:
>>
>>> Hello everyone,
>>>
>>> I write a basic model in django 1.5.1
>>>
>>> My model is looks like this:
>>> class Excuse(models.Model):
>>> text = models.CharField(max_length=**300)
>>>
>>> def __unicode__(self):
>>> return self.text
>>>
>>> And i have a basic function to get random excuse from this model.
>>>
>>> def home(request):
>>> output = Excuse.objects.order_by('?')[:**1]
>>> template = loader.get_template('index.**html')
>>> context = {'output': output}
>>> return HttpResponse(output)
>>>
>>> If i write my view looks like above everything works well. I get a
>>> random excuse and write it on the page. But when i change this like this:
>>>
>>> def home(request):
>>> output = Excuse.objects.order_by('?')[:**1]
>>> template = loader.get_template('index.**html')
>>> context = {'output': output}
>>> return render(request, 'index.html', context)
>>>
>>> I get output like this: []
>>> i just want to blabla section and how i get away from  []
>>>
>>>
>>> Thanks for all!
>>>
>>> --
>>> 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...@**googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at 
>>> http://groups.google.com/**group/django-users
>>> .
>>> 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.
> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Query Set and Output

2013-08-07 Thread Muhammed TÜFEKYAPAN
It looks like this:



   {{ output }} 



On Wednesday, August 7, 2013 6:58:17 AM UTC+3, Bulkan-Savun Evcimen wrote:
>
> Hi there,
>
> What does your template index.html look like ?
>
> Cheers
>
> http://bulkan-evcimen.com
>  
>
> On Wed, Aug 7, 2013 at 1:19 PM, Muhammed TÜFEKYAPAN 
>  > wrote:
>
>> Hello everyone,
>>
>> I write a basic model in django 1.5.1
>>
>> My model is looks like this:
>> class Excuse(models.Model):
>> text = models.CharField(max_length=300)
>>
>> def __unicode__(self):
>> return self.text
>>
>> And i have a basic function to get random excuse from this model.
>>
>> def home(request):
>> output = Excuse.objects.order_by('?')[:1]
>> template = loader.get_template('index.html')
>> context = {'output': output}
>> return HttpResponse(output)
>>
>> If i write my view looks like above everything works well. I get a random 
>> excuse and write it on the page. But when i change this like this:
>>
>> def home(request):
>> output = Excuse.objects.order_by('?')[:1]
>> template = loader.get_template('index.html')
>> context = {'output': output}
>> return render(request, 'index.html', context)
>>
>> I get output like this: []
>> i just want to blabla section and how i get away from  []
>>
>>
>> Thanks for all!
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Internationalization - top level locale .mo files generated but not recognised in Django 1.5

2013-08-07 Thread katstevens
To follow up on this - when I moved my locale files to a completely new 
location and used a different path in my LOCALE_PATHS settings, the 
translations worked fine. I think it may have been a folder permissions 
issue.

On Tuesday, August 6, 2013 5:02:03 PM UTC+1, katstevens wrote:
>
> I am currently upgrading a project from Django 1.3 to 1.5 and having 
> trouble getting Django to recognise my compiled .mo translations.
>
> My project is structured as follows:
>
> /toplevelfolder
> /myproject
> /app1
> /app2
> /app3
> /templates
> /app1templates
> /app2templates
> /app3templates
> /locale
>
> And I have the following in my settings.py file:
>
> LOCALE_PATHS = (
> '/path/to/toplevelfolder/locale'
> )
>
> When I run the 'makemessages -l de' command in /toplevelfolder, the 
> django.po file is created correctly in 
> the toplevelfolder/locale/de/LC_MESSAGES folder with no errors. I add a 
> test string (in this case for a form label) such as: 
>
> #: .\myproject\app1\usersignupform.py:56
> msgid "I accept the terms and conditions."
> msgstr "I accept the German terms and conditions"
>
> Running 'compilemessages' creates the django.mo file with no errors, so I 
> restart my test server as usual. 
>
> However the test translation string above does not show on the form label 
> - only the Django in-house translations (e.g. basic form validation 
> strings) are being displayed (so the language is definitely set to German). 
>
> Interestingly I tried using lower level /locale folders within the app1, 
> app2 folders and the strings were successfully compiled and displayed. But 
> obviously this only covers the strings in my app code - when I try doing 
> the same within my separate template folder, the files are generated ok but 
> just don't display on the page after compiling, like at the top level. In 
> any case, there are a dozen apps in my project and many shared strings - it 
> would obviously be ideal to get makemessages working at the top level and 
> collate them into one django.po file for our translator.
>
> I am using {% load i18n %} in all the relevant templates and the top level 
> method above worked perfectly well with the same project in Django 1.3, so 
> it is unlikely to be a typo in my template or app code. Should it matter 
> where the template directory is, as long as it's within the scope of where 
> I'm calling django-admin.py (i.e. /toplevelfolder)?
>
> For completeness: I have installed gettext-tools-0.17 for Windows and 
> added the /bin files to my PATH variable (i.e. running xgettext --version 
> from the command line is fine).
>
> I also tried refreshing my Middleware cache by commenting out 
> 'django.middleware.locale.LocaleMiddleware' in my settings and then putting 
> it back in again (as I saw suggested elsewhere), with no luck.
>
> I'd be grateful for any suggestions! Please ask if anything is unclear.
>
>
>
>

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