referencing fields on the model without F()

2011-04-13 Thread Roman Klesel
Hello,

I have an old version of django here where the F() object is not
available (0.96).

Is there a chance to reference a field on the same model without using
using F()?

I'd like to write:

hw=Hardware.objects.filter(he=F('rack__he'))

... but there is no F() in this version.

Any ideas?

Regards Roman

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Django-Installation problem

2011-04-13 Thread PremAnand Lakshmanan
Yes, that was the problem..It installed properly now..

On Wed, Apr 13, 2011 at 5:32 AM, werefr0g  wrote:

> Are you using python 3?
>
>   --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Prem
408-393-2545

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Using Q objects vs explicit filters

2011-04-13 Thread Gianluca Sforna
In writing a complex filter for an application, I've found a different
behavior between a filter like:
Model.objects.exclude(filter1, filter2)

and one like:
Model.objects.exclude(Q(filter1), Q(filter2))

where filter1 and filter2 are both field lookups on related models; in
particular only the second syntax yields the desired result set. Are
the above forms supposed to produce comparable queryset?

Thanks in advance

G.


-- 
Gianluca Sforna

http://morefedora.blogspot.com
http://identi.ca/giallu - http://twitter.com/giallu

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Password Auto-reset and Expiry Policy (every X Months)

2011-04-13 Thread gladys
Django's auth module will do just fine.

You can store other information, such as 'date_password_modified' in a
model (UserProfile perhaps) which has a one-to-one correspondence with
User. Then you need to override the login view to check the validity
of the password based on this field. Now to determine the first login,
you can add a first_login boolean field to this model as well and use
it for checking.


--
Gladys
http://blog.bixly.com


On Apr 12, 2:47 am, Harish Tejwani  wrote:
> What would be the best module or app that can support
>
> a) User's Password expiring every 6 months, so they are forced to
> change it
>
> b) For new user's that get system generated passwords, and are forced
> to change at FIRST login
>
> Any ideas/suggestions would help how to go about implementing this
>
> Following are currently installed APPS
>
> INSTALLED_APPS = (
>     'django.contrib.auth',
>     'django.contrib.contenttypes',
>     'django.contrib.sessions',
>     'django.contrib.sites',
>     'django.contrib.messages',
>     'django.contrib.staticfiles',
>     # Uncomment the next line to enable the admin:
>     'django.contrib.admin',
>     # Uncomment the next line to enable admin documentation:
>     'django.contrib.admindocs',
>     'django.contrib.staticfiles',
> )

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: get_object_or_404 Tutorial part 3

2011-04-13 Thread Yuka Poppe
Dear darekodz,

I noticed this myself a while back; It was'nt django specific, and I dont
know about IE, I generally try to avoid using that; But in case of Chrome,
whenever it encounters a 404 error (or certain other conditions) it seems to
decide the visitor is better off being served a generic google
designed/generated status report about whats happening on the page then one
authored by the webserver/webapp itself. I think there was a browser setting
to enable/disable this behaviour.

Im unsure of what other conditions triggered this behaviour, there seemed to
be a kind of random variation to it when it did and didnt occur, but I'll
have to say I didnt put a lot of energy into finding out.

-- 
Regards,

Yuka

On Wed, Apr 13, 2011 at 3:02 PM, darekodz  wrote:

> I've very strange error in part 3. I want to test using function
> get_object_or_404. I've 3 polls, so in that adress:
> http://localhost:8000/polls/1/
> http://localhost:8000/polls/2/
> http://localhost:8000/polls/3/
> everything is OK.
> In that adress:
> http://localhost:8000/polls/4/
> Should be exeptions 404. I have made my own template 404.html. In
> firefox is OK - it's works but in IE and Chrome is error like: Oops!
> This link appears to be broken.
> Could you tell me why the other clients don't use my template?
>
> views.py:
> from mysite.polls.models import Poll
> from django.http import HttpResponse
> from django.shortcuts import render_to_response, get_object_or_404
>
> def index(request):
>latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
>return render_to_response('polls/index.html', {'latest_poll_list':
> latest_poll_list})
>
> def detail(request, poll_id):
>p = get_object_or_404(Poll, pk=poll_id)
>return render_to_response('polls/detail.html', {'poll': p})
>
> def results(request):
>return HttpResponse('results')
>
> def vote(request):
>return HttpResponse('vote')
>
> urls.py:
> from django.conf.urls.defaults import *
> from mysite.polls.models import Poll
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>(r'^polls/$', 'mysite.polls.views.index'),
>(r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'),
>(r'^polls/(?P\d+)/results/$',
> 'mysite.polls.views.results'),
>(r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'),
>(r'^admin/(.*)', admin.site.root),
> )
>
> 404.html:
> Error 404
>
> 404.html is in C:\django\mysite\my_templates
>
> Before this everything in this tutorial works.
>
> Can you help me?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Using Q objects vs explicit filters

2011-04-13 Thread Brian Bouterse
Could you include the output to highlight the differences?

Brian

On Wed, Apr 13, 2011 at 9:32 AM, Gianluca Sforna  wrote:

> In writing a complex filter for an application, I've found a different
> behavior between a filter like:
> Model.objects.exclude(filter1, filter2)
>
> and one like:
> Model.objects.exclude(Q(filter1), Q(filter2))
>
> where filter1 and filter2 are both field lookups on related models; in
> particular only the second syntax yields the desired result set. Are
> the above forms supposed to produce comparable queryset?
>
> Thanks in advance
>
> G.
>
>
> --
> Gianluca Sforna
>
> http://morefedora.blogspot.com
> http://identi.ca/giallu - http://twitter.com/giallu
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Brian Bouterse
ITng Services

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Looking For A Solid Learning Tutorial

2011-04-13 Thread Nick Hird
I am just starting out with Django and would love to find a tutorial that is
great for learning but also teaches the many aspects of the framework. I
have a few books but they seem to go off on one direction or another and
skip the basics to really get you up and running. I would like to build a
solid application step by step and see a finished working site and then take
off and customize it on my own. I just haven't found any such tutorial.

Thanks,
--Nick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: referencing fields on the model without F()

2011-04-13 Thread Yuka Poppe
You could possibly resort to the extra() queryset method, allthough it eats
raw sql, its documented in the manual. Im not sure if its in 0.96 though.

-- 
Regards, Yuka

On Wed, Apr 13, 2011 at 3:09 PM, Roman Klesel
wrote:

> Hello,
>
> I have an old version of django here where the F() object is not
> available (0.96).
>
> Is there a chance to reference a field on the same model without using
> using F()?
>
> I'd like to write:
>
> hw=Hardware.objects.filter(he=F('rack__he'))
>
> ... but there is no F() in this version.
>
> Any ideas?
>
> Regards Roman
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Looking For A Solid Learning Tutorial

2011-04-13 Thread Shawn Milochik
Try James Bennett's book, "Practical Django Projects."

It walks you step-by-step through creating full apps.

Shawn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: referencing fields on the model without F()

2011-04-13 Thread Roman Klesel
Hello Yuka,

2011/4/13 Yuka Poppe :
> You could possibly resort to the extra() queryset method, allthough it eats
> raw sql, its documented in the manual. Im not sure if its in 0.96 though.

Yes, thanks!

I think I found a solution:

hw=Hardware.objects\
.filter(rack__he__isnull=False)\
.extra(where=['`hardware`.`he`=`hardware__rack`.`he`'])

Seems to work.

Regards Roman

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Looking For A Solid Learning Tutorial

2011-04-13 Thread Baurzhan Ismagulov
On Wed, Apr 13, 2011 at 09:19:31AM -0400, Nick Hird wrote:
> I am just starting out with Django and would love to find a tutorial that is
> great for learning but also teaches the many aspects of the framework. I
> have a few books but they seem to go off on one direction or another and
> skip the basics to really get you up and running. I would like to build a
> solid application step by step and see a finished working site and then take
> off and customize it on my own. I just haven't found any such tutorial.

I used http://docs.djangoproject.com/en/1.3/intro/tutorial01/ and found
it to be just what I needed.

With kind regards,
Baurzhan.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Redoing a C/CGI web app in Python/Django?

2011-04-13 Thread lilspikey
You could refactor the C code into a library, then call it from
Django.

There are several ways to interface with a C library in Python, but
you might want to look at ctypes:

  http://docs.python.org/library/ctypes.html

It means you don't have to write extra C code just to do the
interfacing.

On Apr 13, 12:14 am, Graeck  wrote:
> Hi all,
>
> Just looking for input ... tips, suggestions, etc.
>
> We have an old web app written in C using CGIs.  All the html is
> generating in the C code using print statements. It's become almost
> impossible to do anything other than make very minor UI changes due to
> the complexity of the code and the tediousness of trying to make UI
> updates via 1000s of print statements. So, we're thinking of moving to
> something like Django.
>
> Since Python can call C code (libraries, functions, etc, if I'm
> understanding correctly - I'm pretty new at Python myself - and
> Django), would it be feasible to build the UI templates in Python/
> Django and still be able to reuse some of our C code - the stuff that
> crunches the huge amounts of data that we have to process?
>
> I've started reading:http://docs.python.org/extending/extending.html
>
> But any input (esp from people that might have trie such a migration
> before) would be appreciated.
>
> Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Looking For A Solid Learning Tutorial

2011-04-13 Thread jsierra
Also http://docs.djangoproject.com/en/1.3/topics/ is another place to look 
for more focused topics that aren't covered in detail in the tutorials. I 
found the documentation and tutorials that I find through 
searching Google to be more than sufficient for learning and figuring my way 
around django.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Admin Interface Super User Not Logging In

2011-04-13 Thread bruno desthuilliers
Beware of non-printable characters when copy-pasting the password ;)

More seriously: this is the only reason I can think of that would
explain your problem :-/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to insert a csrf_token when entering datas through a bot ?

2011-04-13 Thread dave b
On 12 April 2011 22:09, JustinMarsan  wrote:
> Hello,
>
> What would be the best way to allow some bots to POST some content to
> a website. Without crsf_token, the bot will get a 403, and I would
> prefer not to remove this behavior but rather find a way to make the
> bot send a token. How could I do that ?
>
> I was thinking of making sure the bot is authorizied to post with some
> identifiers but I guess there might be a better way to do this using
> the built-in token system.
>
> Any ideas ?
>

Why can't you make your bot csrf token aware ?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Looking For A Solid Learning Tutorial

2011-04-13 Thread 小白
Yes I think "Practical Django Projects" is very good for newbie, after
reading that i
start my own job using Django to setup a CMS.

On Wed, Apr 13, 2011 at 9:55 PM, Shawn Milochik  wrote:

> Try James Bennett's book, "Practical Django Projects."
>
> It walks you step-by-step through creating full apps.
>
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Creating this query with django Models

2011-04-13 Thread Martin J. Laubach
What problems did you encounter? It's easier to help you knowing what went 
wrong.

mjl


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Creating this query with django Models

2011-04-13 Thread Martin J. Laubach
What problems did you encounter? It's easier to help you knowing what went 
wrong.

mjl


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: get_object_or_404 Tutorial part 3

2011-04-13 Thread Jacob Kaplan-Moss
On Wed, Apr 13, 2011 at 6:41 AM, Yuka Poppe  wrote:
> I noticed this myself a while back; It was'nt django specific, and I dont
> know about IE, I generally try to avoid using that; But in case of Chrome,
> whenever it encounters a 404 error (or certain other conditions) it seems to
> decide the visitor is better off being served a generic google
> designed/generated status report about whats happening on the page then one
> authored by the webserver/webapp itself.

It actually has to do with the length (in bytes) of the 404 page.
Certain browsers -- some versions of IE, and Chrome -- detect "short"
404 pages and substitute the browser's 404 page instead.

I believe that the cutoff is 512 bytes, but you may want to test in
different browsers to be sure.

To fix it, you'll just have to pad your 404 page; this is why you'll
sometimes see something like::



In the source for 404 pages.

Jacob

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: get_object_or_404 Tutorial part 3

2011-04-13 Thread Yuka Poppe
> I believe that the cutoff is 512 bytes, but you may want to test in
> different browsers to be sure.

I suspected as much but wasnt quite sure, it didn't matter as much at the
time I had to deal with it, and the problem went away by itself. None the
less its nice to have this information floating around my brain the next
time it does become an issue; Thank you Jacob, for the follow-up.

> To fix it, you'll just have to pad your 404 page; this is why you'll
> sometimes see something like::
>
> 

I would opt to go with zero visibility/width characters as byte padding to
fool these beasts though -- assuming that would work -- just because I
hate poluting neat source code ;-)

-- 
Regards, Yuka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Redoing a C/CGI web app in Python/Django?

2011-04-13 Thread Graeck
Thanks, I think that might be what I was looking for.


On Apr 13, 7:10 am, lilspikey  wrote:
> You could refactor the C code into a library, then call it from
> Django.
>
> There are several ways to interface with a C library in Python, but
> you might want to look at ctypes:
>
>  http://docs.python.org/library/ctypes.html
>
> It means you don't have to write extra C code just to do the
> interfacing.
>
> On Apr 13, 12:14 am, Graeck  wrote:
>
> > Hi all,
>
> > Just looking for input ... tips, suggestions, etc.
>
> > We have an old web app written in C using CGIs.  All the html is
> > generating in the C code using print statements. It's become almost
> > impossible to do anything other than make very minor UI changes due to
> > the complexity of the code and the tediousness of trying to make UI
> > updates via 1000s of print statements. So, we're thinking of moving to
> > something like Django.
>
> > Since Python can call C code (libraries, functions, etc, if I'm
> > understanding correctly - I'm pretty new at Python myself - and
> > Django), would it be feasible to build the UI templates in Python/
> > Django and still be able to reuse some of our C code - the stuff that
> > crunches the huge amounts of data that we have to process?
>
> > I've started reading:http://docs.python.org/extending/extending.html
>
> > But any input (esp from people that might have trie such a migration
> > before) would be appreciated.
>
> > Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: [Suspected Spam] Redoing a C/CGI web app in Python/Django?

2011-04-13 Thread Sells, Fred
That's essentially what google does.

I would suggest dealing with the Python~C integration/test as a command
line execution and when that works, learn to call the python wrapper
from django.

It's been 15 years since I actually did any of this, but it is pretty
straight forward with SWIG.  There are other ways also, I just don't
know them.

Depending on how heavily site is used, you can also run the c program as
a shell script using popen, et. Al.  This is crude but effective when
you have unmaintainable C code that runs.

-Original Message-
From: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] On Behalf Of Graeck
Sent: Tuesday, April 12, 2011 7:15 PM
To: Django users
Subject: [Suspected Spam] Redoing a C/CGI web app in Python/Django?

Hi all,

Just looking for input ... tips, suggestions, etc.

We have an old web app written in C using CGIs.  All the html is
generating in the C code using print statements. It's become almost
impossible to do anything other than make very minor UI changes due to
the complexity of the code and the tediousness of trying to make UI
updates via 1000s of print statements. So, we're thinking of moving to
something like Django.

Since Python can call C code (libraries, functions, etc, if I'm
understanding correctly - I'm pretty new at Python myself - and
Django), would it be feasible to build the UI templates in Python/
Django and still be able to reuse some of our C code - the stuff that
crunches the huge amounts of data that we have to process?

I've started reading: http://docs.python.org/extending/extending.html

But any input (esp from people that might have trie such a migration
before) would be appreciated.

Thanks!

-- 
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Best Practice for Raw SQL

2011-04-13 Thread Sells, Fred
In my case I had to read some legacy data from a different schema on the
same MySQL server and it was easy (but perhaps not elegant) to just
establish a separate connection using MySQLdb module.

-Original Message-
From: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] On Behalf Of Jacob Kaplan-Moss
Sent: Monday, April 11, 2011 11:51 AM
To: django-users
Subject: Re: Best Practice for Raw SQL

On Mon, Apr 11, 2011 at 7:53 AM, Dan Gentry  wrote:
> Where I run into trouble is that the query returns data in columns,
> but not objects. That means that I can't reference an object attribute
> using dot notation in my templates or views. Instead, I have to
> include each attribute that will be needed as a query column. This
> will limit what I or someone else can do in templates later without a
> mod to the query.

You're looking for the `raw()` method: http://django.me/raw. It takes
a raw SQL query and yields models for you.

Jacob

-- 
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Best Practice for Raw SQL

2011-04-13 Thread Nick Arnett
On Wed, Apr 13, 2011 at 1:38 PM, Sells, Fred
wrote:

> In my case I had to read some legacy data from a different schema on the
> same MySQL server and it was easy (but perhaps not elegant) to just
> establish a separate connection using MySQLdb module.


You shouldn't have to do that.  Use this:

from django.db import connection, transaction
cursor = connection.cursor()

Then you can do anything you would with a MySQLdb cursor, e.g.:

cursor.execute("UPDATE foo SET bar = 3")

After any operation that changes data, apparently you should also call this:

transaction.commit_unless_managed()

I'm doing a lot of that right now to vastly speed up a huge data import.

Nick

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Best Practice for Raw SQL

2011-04-13 Thread Sells, Fred
Xcellent improvement; that's (my code) what happens when you're too busy
fixing the problem to learn the tool ;)

 

From: django-users@googlegroups.com
[mailto:django-users@googlegroups.com] On Behalf Of Nick Arnett
Sent: Wednesday, April 13, 2011 4:44 PM
To: django-users@googlegroups.com
Subject: Re: Best Practice for Raw SQL

 

 

On Wed, Apr 13, 2011 at 1:38 PM, Sells, Fred
 wrote:

In my case I had to read some legacy data from a different schema on the
same MySQL server and it was easy (but perhaps not elegant) to just
establish a separate connection using MySQLdb module.

 

You shouldn't have to do that.  Use this:

 

from django.db import connection, transaction

cursor = connection.cursor()

 

Then you can do anything you would with a MySQLdb cursor, e.g.:

 

cursor.execute("UPDATE foo SET bar = 3")

 

After any operation that changes data, apparently you should also call
this:

 

transaction.commit_unless_managed()

 

I'm doing a lot of that right now to vastly speed up a huge data import.

 

Nick

-- 
You received this message because you are subscribed to the Google
Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Admin Interface Super User Not Logging In

2011-04-13 Thread gladys
There's no way you can check if the password is correct by querying
the db.
What you can do is try changing the pass thru user.set_password('some-
pass') and see if the login will work.


--
Gladys
http://blog.bixly.com


On Apr 13, 10:44 pm, bruno desthuilliers
 wrote:
> Beware of non-printable characters when copy-pasting the password ;)
>
> More seriously: this is the only reason I can think of that would
> explain your problem :-/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Admin Interface Super User Not Logging In

2011-04-13 Thread Joseph Hunt
If you're running the "testserver" it's not using the database, you'll want 
to try "runserver" instead.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ANN: DSE 1.0.0-RC1

2011-04-13 Thread Thomas Weholt
Hi,

A short description to wet your appetite: DSE is simplified "bulk"
insert/update for django, created for one simple reason - to insert or
update lots of data as fast as possible ( and still be developer and
django friendly ).
I`ve just released the first ( and hopefully only ) release candidate
of DSE ( http://pypi.python.org/pypi/dse/1.0.0-RC1 ) and if anybody
has time/interest to help me iron out any bugs or issues before I
label it as stable and release the official 1.0 release that would be
great.

Thanks for your attention.

-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is it possible to output a graph from Matplotlib into Django like this?

2011-04-13 Thread nai
Thanks for your help.

I went with 2 views, 1 for the image and 1 for the html.

On Apr 12, 2:06 pm, Sam Walters  wrote:
> I mis-read this... basically you have one view and in the template you
> are rendering you put HTML:
>
> 
> 
>
> so that path will call your other views which return content as
> content_type='image/png' or whatever specific format you're using.
>
> what i was suggesting is you could have:
>
> 
> 
> 
>
> So in your urls.py file it would parameratize 'foo' and in your view
> method you could produce different responses based on the parameter.
> Eg: in an other view i have i can pass lat and long coords as params
> and it would put a dot on the map based on where that lat/long points
> to.
>
>
>
>
>
>
>
> On Tue, Apr 12, 2011 at 2:19 PM, nai  wrote:
> > Actually, could you illustrate how you would go about using 2 views as
> > well? Thanks!
>
> > On Apr 11, 6:39 pm, Xavier Ordoquy  wrote:
> >> Le 11 avr. 2011 à 12:21, nai a écrit :
>
> >> > This is the give example from Matplotlib for Django:
>
> >> > def simple(request):
> >> >    import random
>
> >> >    from matplotlib.backends.backend_agg import FigureCanvasAgg as
> >> > FigureCanvas
> >> >    from matplotlib.figure import Figure
> >> >    from matplotlib.dates import DateFormatter
>
> >> >    fig=Figure()
> >> >    ax=fig.add_subplot(111)
> >> >    x=[]
> >> >    y=[]
> >> >    now=datetime.datetime.now()
> >> >    delta=datetime.timedelta(days=1)
> >> >    for i in range(10):
> >> >        x.append(now)
> >> >        now+=delta
> >> >        y.append(random.randint(0, 1000))
> >> >    ax.plot_date(x, y, '-')
> >> >    ax.xaxis.set_major_formatter(DateFormatter('%Y-%m-%d'))
> >> >    fig.autofmt_xdate()
> >> >    canvas=FigureCanvas(fig)
> >> >    response=django.http.HttpResponse(content_type='image/png')
> >> >    canvas.print_png(response)
> >> >    return response
>
> >> > Is there anyway I can return the image like this `return
> >> > render_to_response('template.html', {'graph':  >> > matplotlib or some other graphing package>}`
>
> >> Hi,
>
> >> Is there any reasons why you couldn't have a view that would just render 
> >> the image and the other one that would have a img tag pointing to the 
> >> first view ?
> >> It is possible to embed an image in the web page, but I'm sure it goes 
> >> against the best practices.
>
> >> Regards,
> >> Xavier.
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Password Auto-reset and Expiry Policy (every X Months)

2011-04-13 Thread gkuenning


On Apr 12, 6:47 am, Harish Tejwani  wrote:
> What would be the best module or app that can support
>
> a) User's Password expiring every 6 months, so they are forced to
> change it

Although Django supports it, I would STRONGLY discourage you from
implementing such a policy.  Password expiration is well known in the
security community as being a horrible idea that has somehow become
popular.  Refer to Bruce Schneier's writings on the subject if you
want more information, but briefly, expiring passwords is based on the
assumption that a bad guy has acquired an encrypted password and needs
longer than the expiration period to crack the encryption.  This
assumption is nearly always false, especially with a 6-month
expiration period.

The other reason it's a horrible idea is that it forces people to pick
bad passwords.  Choosing a good password takes time, and suddenly
presenting them with a requirement that they pick a new password makes
that time unavailable.  (FWIW, my current password is over six years
old.  My servers get attacked daily and have never been cracked.)

> b) For new user's that get system generated passwords, and are forced
> to change at FIRST login

This is a much more sensible idea, but if you want your users to be
safe, be sure they are notified of this requirement well before the
first login, so that they can spend some time thinking about good
passwords.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can not download file from my site ( django + uwsgi )

2011-04-13 Thread Roberto De Ioris

Il giorno 12/apr/2011, alle ore 04.05, Lei Zhang ha scritto:

> the static file is returned by nginx, and it is works well.
> But the file returned by dynamic pages does't works very well.


You have a pretty standard configuration.

Check the uWSGI logs (they report the response size) to see where is the problem

--
Roberto De Ioris
http://unbit.it

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Dajaxice and CSRF issues

2011-04-13 Thread Vincent den Boer
On Friday 08 of April 2011 13:37:53 Casey Greene wrote:
> Can you change the request type from POST to GET?  It sounds like this
> is not a database modifying operation.
> 
> Casey
Yes, I could but the generated Dajaxice script doesn't give me the option to 
use 
a GET request. Perhaps I should just write my own script (if Dajaxice even 
accepts GET requests).

On Friday 08 of April 2011 13:06:03 Sam Walters wrote:
> Also looking at the request in firebug you can see the 'X-CSRFToken'
> needs to be added as an attribute with the javascript you use.
At the point the first AJAX request is sent, the user doesn't have a valid CSRF 
token yet, since the user hasn't visited a Django page yet. .That's why a GET 
may be preferable here.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: New to Django-Installation problem

2011-04-13 Thread werefr0g

Are you using python 3?

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



[JOB] Django/Python/HTML/JS Developer (Vienna, Austria)

2011-04-13 Thread Bernhard Schandl
Gnowsis.com, a Vienna-based hightech startup, are looking for a full-
time or part-time Django/Python User Interface Developer (f/m) to
extend their team in Vienna. You will work on an appealing user
interface for http://www.getrefinder.com.

Ideally you have the following technical skills:

 + Python/Django
 + Javascript + HTML
 + CSS
 + Experience in user interface design, development, and testing with
end users

Your background:

 + Familiarity with SCRUM and agile development methodologies
 + Customer orientation: understanding customer's requirements and
inputs
 + Good oral and written communication skills in English

We offer:

 + an interesting, diversified occupation in a cutting-edge high-tech
startup
 + the possibility to significantly influence the software development
process

We are looking forward to receiving your CV and cover letter in
English or German and will invite you for a personal interview. Send
your application and all other questions to j...@gnowsis.com.

http://www.gnowsis.com/about/content/join-team

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Stackoverflow kind of Answer/commenting app in Django

2011-04-13 Thread Martin Pajuste
Are You aware of Django’s comments framework?
http://docs.djangoproject.com/en/dev/ref/contrib/comments/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Stackoverflow kind of Answer/commenting app in Django

2011-04-13 Thread AJ
I am kind of aware of that. I just want to add a Stackoverflow kind of a
commenting system (with comments on answers and voting on answers) to my
already present application.

Does anyone know if Django's own comment app can be enhanced to be that or
has anyone already done that?



On Wed, Apr 13, 2011 at 6:41 AM, Martin Pajuste wrote:

> Are You aware of Django’s comments framework?
> http://docs.djangoproject.com/en/dev/ref/contrib/comments/
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



get_object_or_404 Tutorial part 3

2011-04-13 Thread darekodz
I've very strange error in part 3. I want to test using function
get_object_or_404. I've 3 polls, so in that adress:
http://localhost:8000/polls/1/
http://localhost:8000/polls/2/
http://localhost:8000/polls/3/
everything is OK.
In that adress:
http://localhost:8000/polls/4/
Should be exeptions 404. I have made my own template 404.html. In
firefox is OK - it's works but in IE and Chrome is error like: Oops!
This link appears to be broken.
Could you tell me why the other clients don't use my template?

views.py:
from mysite.polls.models import Poll
from django.http import HttpResponse
from django.shortcuts import render_to_response, get_object_or_404

def index(request):
latest_poll_list = Poll.objects.all().order_by('-pub_date')[:5]
return render_to_response('polls/index.html', {'latest_poll_list':
latest_poll_list})

def detail(request, poll_id):
p = get_object_or_404(Poll, pk=poll_id)
return render_to_response('polls/detail.html', {'poll': p})

def results(request):
return HttpResponse('results')

def vote(request):
return HttpResponse('vote')

urls.py:
from django.conf.urls.defaults import *
from mysite.polls.models import Poll

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P\d+)/results/$', 'mysite.polls.views.results'),
(r'^polls/(?P\d+)/vote/$', 'mysite.polls.views.vote'),
(r'^admin/(.*)', admin.site.root),
)

404.html:
Error 404

404.html is in C:\django\mysite\my_templates

Before this everything in this tutorial works.

Can you help me?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.