Re:

2010-10-11 Thread Jirka Vejrazka
> My Url look like this
>
> di/sub?word=check&type=00&submit=Submit
>                         ---
>  but it shows the error for symbols "?"
> ---
>  i want to print only the word check in this url and it can be anyword
> given by user

Hi Sami,

  while you technically *can* make this working, it's not the usual
way of handling URL's. Anything beyond a question mark is a parameter
and is better handled inside your view.

  So, your urls.py would look like this:

(r"^wap/di/sub", hellow)

  And your view would contain the following code:

def hellow(request):
   word = request.GET['word']
   return HttpResponse(word)

 But you should need two things:

  - the code does not contain any error checking (i.e. what happens if
"word" is not provided in the URL
  - There is a security issue. Displaying anything that user provides
on the output page *without checking it first* is insecure and can
lead to various security-related issues

  I'll leave the JavaScript bit to your excercise as I don't really
understand what you're trying to achieve with that.

  Cheers

Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:

2010-10-11 Thread sami nathan
HI

THIS IS MY REQUIRED URL
http://localhost/flip/wap/di/sub?word=check&type=00&submit=Submit

here check should be displayed in my page we are using this for
dictionary  but my task is to just display that word check in my page
, moreover its user defined
 my  urls.py is looking like this


urlpatterns = patterns('',

   (r"^wap/di/sub",current_datetime),


And my view looks like this


from django.http import HttpResponse


def current_datetime(request):

   word = request.GET['word']
  return HttpResponse(word)

but it still showing  Error
Exception Value:

unindent does not match any outer indentation level (view.py, line 7)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: trouble creating first project

2010-10-11 Thread harryos
do you have django_settings_module set?if so you will get this error
http://code.djangoproject.com/ticket/11980

otherwise it is a path problem
HTH
harry

On Oct 11, 6:47 am, Phil  wrote:
> Hi,
>
> I am having trouble creating my first project. I am running the latest
> version of Ubuntu and I installed Django from svn, when I run 'import
> django' i get no errors back so I assume its installed OK.
>
> When I run 'django-admin.py startproject myproject' I get back an
> error saying 'django-admin.py: command not found'.
>
> How can I solve/get around this error? Appreciate any help/ advice
> offered

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



[no subject]

2010-10-11 Thread sami nathan
my re reuested url is
http://localhost/wap/di/sub?word=check&type=00&submit=Submit



I want to print the word "CHECK" which will be given by user

my urls.py looks like this

from django.conf.urls.defaults import *
from flip.view import current_datetime
urlpatterns = patterns('',

   (r"^wap/di/sub?word=(\w+)&type=00&submit=Submit",current_datetime),


)
My view.py look like this

from django.http import HttpResponse


def current_datetime(request):
  html = "" + word + ""
return HttpResponse(html)

But the error shown is
SyntaxError: 'return' outside function

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:

2010-10-11 Thread Jirka Vejrazka
> def current_datetime(request):
>
>   word = request.GET['word']
>  return HttpResponse(word)
>
> but it still showing  Error
> Exception Value:
>
> unindent does not match any outer indentation level (view.py, line 7)

  The error is exactly what is says - indentation is important in
Python and the bottom line is clearly indented differently then the
line above it.

  You might consider spending a bit of time with some Python tutorial
such as http://diveintopython.org/

  Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:

2010-10-11 Thread Jirka Vejrazka
> my re reuested url is
> http://localhost/wap/di/sub?word=check&type=00&submit=Submit

Sami,

  please don't spam the list with the same requests. Your other
question has been answered and if you have follow up questions, it's
better to keep them in the same email thread. (also, please use a
proper email subject next time you email to the list).

  Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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-use the sitemap.xml

2010-10-11 Thread het.oosten
I want to put a sitemap on my page with all the links for better
navigation. I could write a new view to fetch all links, but is there
a way to include my sitemap.xml (i use the sitemap framework) in a
template?

I could convert the xml to html by using xslt.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 specify NULL as the default of a model field.

2010-10-11 Thread David De La Harpe Golden
On 09/10/10 08:06, Tim Diggins wrote:
> It may seem odd but I want to explicitly specify NULL as the default
> for a particular field / column. (This is so that South picks up that
> the default value is null, rather than there being no default
> specified, which is what happens if you specify "null=True"
> 
> any thoughts (or it may just be impossible)

just in case - you may have to do

null=True, blank=True, default=None

on some field types (e.g. char ones which default='' not None, the
latter being mapped to db null, the former a zero-length string).

(though probably not your south-related issue as a default still exists
it just isn't null)




-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



design problem..how to store web page's data for later comparison

2010-10-11 Thread jimgardener
hi
I am trying  to write an application that checks a web page today and
again checks it after somedays and compares them.For this purpose I
need to store the page data on these 2 occassions in my program  .

How can I do this?I can get the page data of current moment as a
string using urllib.urlopen and store it in a variable, say
current_page_data.But ,how do I store yesterday's data so that I can
compare the two?Do I need to store it as a field in database?(I am not
very familiar with database programming..I am using postgres for web
app development with django.So I don't know if storing such a large
string like that is possible).

I considered writing the data to a file..but suppose a lot of users
want to do the comparison of 2 versions of many pages..?I would be
creating so many files =usercount * number_of_url_by_each_user  .If
the time duration between 2 comparisons was some seconds/minutes then
I can just use 2 local variables andmay not need persistence.But ,to
compare data of yesterday and today  I may need some such mechanism..
I guess this may be  a common problem and there may some solution for
this.
Can someone comment/suggest how this can be done?
thanks
jim

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:

2010-10-11 Thread sami nathan
HI Jirka Vejrazka
sorry ya i am very new to this group and i am going through the python
 But it would be helpful to me if u convey me which part of python
should i go throgh for time beingthank u

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: design problem..how to store web page's data for later comparison

2010-10-11 Thread Jonathan Barratt
Hi Jim,

> How can I do this?I can get the page data of current moment as a
> string using urllib.urlopen and store it in a variable, say
> current_page_data.But ,how do I store yesterday's data so that I can
> compare the two?Do I need to store it as a field in database?(I am not
> very familiar with database programming..I am using postgres for web
> app development with django.So I don't know if storing such a large
> string like that is possible).

Yes, it's definitely possible. DBs support very large text fields nowadays, I 
wouldn't worry about it. Postgres's text field type is only limited by the 1GB 
value-size limit general to all Postgres DB fields.

> I considered writing the data to a file..but suppose a lot of users
> want to do the comparison of 2 versions of many pages..?I would be
> creating so many files =usercount * number_of_url_by_each_user  .If
> the time duration between 2 comparisons was some seconds/minutes then
> I can just use 2 local variables andmay not need persistence.But ,to
> compare data of yesterday and today  I may need some such mechanism..

You will definitely want persistence, but if you do choose to go the files 
route I wouldn't worry about the storage space. If you have enough users for 
that to be a problem you should be able to afford the space, cloud-based 
storage like Amazon's S3 is cheap and easy. If you're really resource 
constrained you can always just compress\decompress the files, text compresses 
very well. It'll add some processing overhead for sure, but there's no magic 
bullet that's not going to cost you some form of resource or another. Just 
limit the number of versions that can be kept and remove the old-ones on a 
rolling basis...

Good luck,
Jonathan

> I guess this may be  a common problem and there may some solution for
> this.
> Can someone comment/suggest how this can be done?
> thanks
> jim
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: Re:

2010-10-11 Thread Kenneth Gonsalves
On Mon, 2010-10-11 at 17:37 +0700, Jonathan Barratt wrote:
> Here's a couple of suggestions for Python learning resources:
> http://www.diveintopython.org/toc/index.html (best online Python intro
> I
> know of) 

but this is not for newbies - the OP could try 'python for you and me'
which i written by and Indian, so the language will be easier to grasp.
-- 
regards
Kenneth Gonsalves

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:

2010-10-11 Thread sami nathan
Sir,
i got two way of suggestion s now i am bitter confused waht should i
use now,now i will clearly tell my requirement
http://m.broov.com/wap/di/sub?word=check&type=00&submit=Submit
pls visit this site  and replace the word check with any word u like
it will display some rsults below now i don't want that  results to be
printed below
 i want only that word should be  printed i got two suggestionfrom
django users
   1. So, your urls.py would look like this:

(r"^wap/di/sub", hellow)

 And your view would contain the following code:

def hellow(request):
  word = request.GET['word']
  return HttpResponse(word)
---
2.So url looks like this
(r"^wap/di/sub?word=(\w+)&type=00&submit=Submit",hellow),
view look like this
html = "" + word + ""
 which is the best to use but both getting error

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:

2010-10-11 Thread sami nathan
THANK U GUYS AT LAST I GOT WHAT I NEED AND ITS WORKING THANK U FOR U R
RESPONSE GREAT YA
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-us...@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 way to change pk field type

2010-10-11 Thread Scott Gould
With a huge whopping disclaimer that I've never done this before:

Wouldn't you simply be abe to add an explicit "id =
BigIntegerField(primary_key=True)" to the model and change the column
type accordingly in mysql?

On Oct 7, 4:16 pm, indymike  wrote:
> Here's my issue - I'm going to run out of integers for my primary key
> in one of my tables.  I'm using MySQL, which has been absolutely
> fantastic, and will for at least a few more decades if I can make a
> change from INT to BIGINT.
>
> What's the right way to switch from INT to BIGINT so the PK works
> correctly?
>
> / First thought was a big, fat south migration, but I I wonder if
> there's anything in Django's code that this will break?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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 way to change pk field type

2010-10-11 Thread derek
On Oct 7, 10:16 pm, indymike  wrote:
> Here's my issue - I'm going to run out of integers for my primary key
> in one of my tables.  I'm using MySQL, which has been absolutely
> fantastic, and will for at least a few more decades if I can make a
> change from INT to BIGINT.
>
> What's the right way to switch from INT to BIGINT so the PK works
> correctly?
>
> / First thought was a big, fat south migration, but I I wonder if
> there's anything in Django's code that this will break?

Found this:
http://stackoverflow.com/questions/283724/big-integer-field-in-django-models
which implies it should "just work" from version 1.2 onwards.

Be aware that Django's sync method wil create the PK field with a
default of int(11), not bigint, so you'll need to change that in the
database itself.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: django, celery and mysql: Lost connection to MySQL server during query

2010-10-11 Thread Massimiliano della Rovere
I raised the log level to debug:
./manage.py celeryd -l debug

That's the new piece of information:
Out of memory (Needed 24492 bytes)
Out of memory (Needed 24492 bytes)
Out of memory (Needed 24492 bytes)
Out of memory (Needed 24492 bytes)
Out of memory (Needed 24492 bytes)
Out of memory (Needed 24492 bytes)
Out of memory (Needed 16328 bytes)
Out of memory (Needed 16328 bytes)
Out of memory (Needed 16328 bytes)
Out of memory (Needed 16328 bytes)
Out of memory (Needed 16328 bytes)
Out of memory (Needed 16328 bytes)
Out of memory (Needed 8164 bytes)
Out of memory (Needed 8164 bytes)
Out of memory (Needed 8164 bytes)
Out of memory (Needed 8164 bytes)
Out of memory (Needed 8164 bytes)

Looks suspiciously like a memory leak...


On Sun, Oct 10, 2010 at 19:26, Erik Cederstrand  wrote:
>
> Den 10/10/2010 kl. 17.55 skrev Massimiliano della Rovere:
>> > * Which process(es) on the server is using 100% CPU time?
>> directly from htop:
>> PID USER     PRI  NI  VIRT   RES   SHR S CPU% MEM%   TIME+  Command
>> 544 mader     20   0  969M  953M  1444 R 96.0 47.4 50:09.85 python 
>> ./manage.py celeryd -l warning
>
> This, and the fact that you have no errors or seriously long queries in your 
> slow query log, indicates that the MySQL server is operating fine.
>
> Something seems to be timing out on the MySQL side. I'm not sure if you 
> mentioned it, but are these InnoDB tables? The stack trace you posted is in 
> the rollback of a transaction. It's possible that everything is running 
> within the same transaction which MySQL is shutting down at some point. Try 
> this:
>
> SQL> show variables where variable_name LIKE '%timeout%';
>
> to see the values in your current server instance.
>
> If nothing suspicious turns up, I guess it's time to follow the stack trace 
> into the celery source code or where your own code calls celery and add some 
> debugging. Maybe it's a specific query that trips the code. Maybe it's a 
> specific number of queries. Maybe it's at a specific timespan after 
> connecting to MySQL.
>
> Thanks,
> Erik

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



moving from Postgres to MySQL

2010-10-11 Thread Chris Withers

Hi All,

I have an existing Django app with lots of data in it. For reasons 
beyond my control, this app needs to move from Postgres to MySQL.


What's the best way of going doing this?

cheers,

Chris

--
Simplistix - Content Management, Batch Processing & Python Consulting
- http://www.simplistix.co.uk

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-us...@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: moving from Postgres to MySQL

2010-10-11 Thread Shawn Milochik
One way would be to use the dumpdata command to export everything, change your 
settings to point to the new database, then loaddata to restore.

There may be a better way, but this way allows you to dump to a 
database-agnostic backup so it seems like it would suit your needs.

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-us...@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:

2010-10-11 Thread sami nathan
ISORRY YA  AGAIN i got problem of
SyntaxError: 'return' outside function



now my view code
from django.http import HttpResponse


def current_datetime(request):

 word = request.GET['word']

return HttpResponse(word)




now my url code
from django.conf.urls.defaults import *
from flip.view import current_datetime


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

urlpatterns = patterns('',
# Example:
   (r"^wap/di/sub",current_datetime)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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:

2010-10-11 Thread Jonathan Barratt

On 11 ต.ค. 2010, at 20:43, sami nathan wrote:

> ISORRY YA  AGAIN i got problem of
> SyntaxError: 'return' outside function

Rather than using curly braces to define code blocks, i.e. function { ... } 
Python uses indentation. Thus:

> now my view code
> from django.http import HttpResponse
> 
> 
> def current_datetime(request):
> 
> word = request.GET['word']
> 
> return HttpResponse(word)

Needs to be:

> def current_datetime(request):
>   word = request.GET['word']
>   return HttpResponse(word)

Hth,
Jonathan

> 
> 
> 
> 
> now my url code
> from django.conf.urls.defaults import *
> from flip.view import current_datetime
> 
> 
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
> 
> urlpatterns = patterns('',
># Example:
>   (r"^wap/di/sub",current_datetime)
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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:

2010-10-11 Thread sami nathan
just before getting u r message i tried that it worked!! whats the
best editor for 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-us...@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:

2010-10-11 Thread Jonathan Barratt
On 11 ต.ค. 2010, at 20:52, sami nathan wrote:

> just before getting u r message i tried that it worked!! whats the
> best editor for django

For me it's an easy call: eclipse + pydev. As of pydev v 1.5.6+ (?) pydev 
include Django support. Can't recommend it enough.

Aside from that, two must-have Django additions in my book are south for 
database migration and django-extensions (formerly django-command-extensions) 
that provides runserver_plus which with the Werkzeug debugger provides the best 
Django debugging environment I'm aware of.

Google them and you'll find the download links and installation instructions...

Happy coding!
Jonathan
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



Smaller Than in Django database API

2010-10-11 Thread Sithembewena Lloyd Dube
Hi all,

How does one filer objects by "smaller than" criteria in the data access
API? For example, in the following line:

MySite.objects.filter(*rank < 11*, display_on_site = 1).order_by('rank') -
how would one handle the highlighted criterion?

Thanks.

-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Smaller Than in Django database API

2010-10-11 Thread Jonathan Barratt
On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote:

> Hi all,
> 
> How does one filer objects by "smaller than" criteria in the data access API? 
> For example, in the following line:

I believe it's by appending the field name with _lte

> MySite.objects.filter(rank < 11, display_on_site = 1).order_by('rank') - how 
> would one handle the highlighted criterion?

Thus this would be:

> MySite.objects.filter(rank_lte=11).filter(display_on_site = 
> 1).order_by('rank')

Note also that, AFAIK, multiple where criteria are accomplished by chaining 
filters rather than providing them as a list to one filter call.

But I am new to Django myself, so if anyone corrects this advice - follow their 
directions not mine! :)

Good luck!
Jonathan
> 
> Thanks.
> 
> -- 
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.com
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



Unicode, utf8, mysql

2010-10-11 Thread Mathieu Leduc-Hamel
Hi all,

I'm the main maintainer of a website called l'Agenda Du libre du
Québec. On this website, people can submit events about free/open
software in their local community.

Yesterday, somebody tried to submit a new event, but the in
description of the event, there was a strange character: "→". Django
can deal with this unicode character, and MySQL, correctly configured,
should be able to also.

But it's not the case. MySQL just refuse to save it ! Saying that
there's an invalid character inside this field.

What can do ? I don't want to filtering it manually and just wait for
the next bug for the next incompatible character with MySQL !



-- 
Mathieu Leduc-Hamel

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Smaller Than in Django database API

2010-10-11 Thread Tom Evans
2010/10/11 Jonathan Barratt :
> On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote:
> Note also that, AFAIK, multiple where criteria are accomplished by chaining
> filters rather than providing them as a list to one filter call.
> But I am new to Django myself, so if anyone corrects this advice - follow
> their directions not mine! :)

That's not quite right, both are suitable (and _can_ have different
meanings, although not in this case).

If you assume models like so:

class Item:
  name = CharField
  type = ManyToManyField('Type')

class Type:
  name = CharField
  enabled = BooleanField
  displayable = BooleanField

then these two lines are different query sets:

Item.objects.filter(type__enabled=True, type__displayable=True)

Item.objects.filter(type__enabled=True).filter(type__displayable=True)


The former selects Items with one or more associated Type instances
that are both enabled and displayable. The latter selects Items that
have one or more associated Type instances that are enabled and
displayable, but not necessarily the on the same Type object.

When the filter is not over a m2m field though, the two forms are
largely equivalent.

For more info see the manual:

http://docs.djangoproject.com/en/1.2/topics/db/queries/#spanning-multi-valued-relationships

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Smaller Than in Django database API

2010-10-11 Thread Sithembewena Lloyd Dube
@Jonathan, thanks. That does the trick.

@Tom, thanks for bringing the subtle, yet important, difference between the
two forms of that expression to my attention.

2010/10/11 Tom Evans 

> 2010/10/11 Jonathan Barratt :
> > On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote:
> > Note also that, AFAIK, multiple where criteria are accomplished by
> chaining
> > filters rather than providing them as a list to one filter call.
> > But I am new to Django myself, so if anyone corrects this advice - follow
> > their directions not mine! :)
>
> That's not quite right, both are suitable (and _can_ have different
> meanings, although not in this case).
>
> If you assume models like so:
>
> class Item:
>  name = CharField
>  type = ManyToManyField('Type')
>
> class Type:
>  name = CharField
>  enabled = BooleanField
>  displayable = BooleanField
>
> then these two lines are different query sets:
>
> Item.objects.filter(type__enabled=True, type__displayable=True)
>
> Item.objects.filter(type__enabled=True).filter(type__displayable=True)
>
>
> The former selects Items with one or more associated Type instances
> that are both enabled and displayable. The latter selects Items that
> have one or more associated Type instances that are enabled and
> displayable, but not necessarily the on the same Type object.
>
> When the filter is not over a m2m field though, the two forms are
> largely equivalent.
>
> For more info see the manual:
>
>
> http://docs.djangoproject.com/en/1.2/topics/db/queries/#spanning-multi-valued-relationships
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.com

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



POST the form several times

2010-10-11 Thread LA_
hi all,
need your help to understand whether the following can be done with
django (and if can - then how).
I have items array, which contains details of files. I need to upload
them to the server (with POST request), but it supports uploading of 5
files at once only, filenames to be passed in fields file1, file2 etc.
My items array can contain much more elements (i.e. files) then 5. Is
there any way to take 5 first files from the array, send it, wait for
result, then take next 5 files, send them etc.?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.



Legacy URLs redirect

2010-10-11 Thread bax...@gretschpages.com
I'm sure this is simple and I'm just not constructing the URL
properly. Basically, it used to be a drupal site, with the cruddy old
Drupal every url is a querystring setup. What I want is pretty
simple... all of those old URLs resolve to the home page and send a
301 to the spider.

I tried:
(r'^?q=taxonomy/term/[0-9]+$', redirect_to, {'url': '/', 'permanent':
True}),

And failed most spectacularly. Do I need to be escaping something, or
what am I missing?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Smaller Than in Django database API

2010-10-11 Thread Jonathan Barratt
Ah, most enlightening and makes perfect sense, thanks Tom!

? 11 ?.?. 2553  21:45 Tom Evans  ?:

> 2010/10/11 Jonathan Barratt :
>> On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote:
>> Note also that, AFAIK, multiple where criteria are accomplished by chaining
>> filters rather than providing them as a list to one filter call.
>> But I am new to Django myself, so if anyone corrects this advice - follow
>> their directions not mine! :)
> 
> That's not quite right, both are suitable (and _can_ have different
> meanings, although not in this case).
> 
> If you assume models like so:
> 
> class Item:
>  name = CharField
>  type = ManyToManyField('Type')
> 
> class Type:
>  name = CharField
>  enabled = BooleanField
>  displayable = BooleanField
> 
> then these two lines are different query sets:
> 
> Item.objects.filter(type__enabled=True, type__displayable=True)
> 
> Item.objects.filter(type__enabled=True).filter(type__displayable=True)
> 
> 
> The former selects Items with one or more associated Type instances
> that are both enabled and displayable. The latter selects Items that
> have one or more associated Type instances that are enabled and
> displayable, but not necessarily the on the same Type object.
> 
> When the filter is not over a m2m field though, the two forms are
> largely equivalent.
> 
> For more info see the manual:
> 
> http://docs.djangoproject.com/en/1.2/topics/db/queries/#spanning-multi-valued-relationships
> 
> Cheers
> 
> Tom
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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.



Custom validation in model formset

2010-10-11 Thread Duane Hilton
Hi all,

I'm trying to do some custom validation on a model formset, but I'm
not having good luck. Thank you in advance for your suggestions ...

In my views, I have:

class BaseCandFormSet(BaseModelFormSet):
def clean(self):
super(BaseCandFormSet, self).clean()
for form in self.forms:
x = form['x_field']
y = form['y_field']
if y < x:
raise forms.ValidationError('Y cannot be less than x.')

I get the following error:

Exception Value: 'list' object has no attribute 'ValidationError'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Unicode, utf8, mysql

2010-10-11 Thread Jonathan Barratt


ณ 11 ต.ค. 2553 เวลา 21:34 Mathieu Leduc-Hamel  เขียน:

> Hi all,
> 
> I'm the main maintainer of a website called l'Agenda Du libre du
> Québec. On this website, people can submit events about free/open
> software in their local community.
> 
> Yesterday, somebody tried to submit a new event, but the in
> description of the event, there was a strange character: "→". Django
> can deal with this unicode character, and MySQL, correctly configured,
> should be able to also.

Correctly configured being the key factor here; can you tell us the 
charset/collation listed by MySQL for 'show create table' on the relevant 
entity?

> But it's not the case. MySQL just refuse to save it ! Saying that
> there's an invalid character inside this field.
> 
> What can do ? I don't want to filtering it manually and just wait for
> the next bug for the next incompatible character with MySQL !
> 
> 
> 
> -- 
> Mathieu Leduc-Hamel
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: Custom validation in model formset

2010-10-11 Thread Jonathan Barratt


? 11 ?.?. 2553  23:44 Duane Hilton  ?:

> Hi all,
> 
> I'm trying to do some custom validation on a model formset, but I'm
> not having good luck. Thank you in advance for your suggestions ...
> 
> In my views, I have:
> 
> class BaseCandFormSet(BaseModelFormSet):
>def clean(self):
>super(BaseCandFormSet, self).clean()
>for form in self.forms:
>x = form['x_field']
>y = form['y_field']
>if y < x:
>raise forms.ValidationError('Y cannot be less than x.')
> 
> I get the following error:
> 
> Exception Value: 'list' object has no attribute 'ValidationError'
On my mobile so can't check but I suspect forms is a list of form objects, try 
form.validation error instead...

Good luck!
Jonathan

> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@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-us...@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: Add message on specific error to 500 page

2010-10-11 Thread Streamweaver
I'm still looking into this if anyone has any insight.

On Oct 7, 2:04 pm, Streamweaver  wrote:
> On our 500 error page I would like to display a message specifically
> if the error is in the Database connection, and not display the
> message on any other uncaught exception but I can't seem to figure out
> a way to catch the specific exception going to a 500 page.
>
> Has anyone done this?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Add message on specific error to 500 page

2010-10-11 Thread Łukasz Rekucki
On 11 October 2010 18:54, Streamweaver  wrote:
> I'm still looking into this if anyone has any insight.
>
> On Oct 7, 2:04 pm, Streamweaver  wrote:
>> On our 500 error page I would like to display a message specifically
>> if the error is in the Database connection, and not display the
>> message on any other uncaught exception but I can't seem to figure out
>> a way to catch the specific exception going to a 500 page.
>>
>> Has anyone done this?

You can process the exception using a middleware[1], so that you can
later access it's type in your custom 500 handler[2].


[1]: 
http://docs.djangoproject.com/en/dev/topics/http/middleware/#process-exception
[2]: 
http://docs.djangoproject.com/en/dev/topics/http/views/#the-500-server-error-view

-- 
Łukasz Rekucki

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: trouble creating first project

2010-10-11 Thread Steve Holden
On 10/11/2010 1:47 AM, Phil wrote:
> Hi,
> 
> I am having trouble creating my first project. I am running the latest
> version of Ubuntu and I installed Django from svn, when I run 'import
> django' i get no errors back so I assume its installed OK.
> 
> When I run 'django-admin.py startproject myproject' I get back an
> error saying 'django-admin.py: command not found'.
> 
> How can I solve/get around this error? Appreciate any help/ advice
> offered
> 
When you install Django from svn it doesn't add django-admin to any of
the directories that your system looks for programs in (i.e. those
directories on your path).

When you install Django with setuptools (i.e. using setup.py) then you
should find that django-admin is placed where it can be found.

The simplest way around this is to make a symbolic link from one of the
directories on your path to the django-admin.py file.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Custom validation in model formset

2010-10-11 Thread Duane Hilton
Changing forms to form brings a new error:

*Exception Value: 'CandidateFeedForm' object has no attribute
'ValidationError'*

Below is the view that is using the BaseCandFormSet code that I included in
the original message. Maybe something is wrong in it? Thanks in advance for
your suggestions. I've spent a few days using the documentation and trying
to get this to work. I really appreciate the help. ...

*def state_office(request):
CandFormSet = modelformset_factory(CandidateFeed,
**queryset=CandidateFeed.objects.all().order_by('last_name',
'county'),** formset=BaseCandFormSet, extra=0)
if request.method == 'POST':
formset = CandFormSet(request.POST, request.FILES)
if formset.is_valid():
formset.save()
return HttpResponseRedirect('/foo/bar/')
else:
formset =
CandFormSet(queryset=CandidateFeed.objects.all().order_by('last_name',
'county'))
return render_to_response('state_office.html', { 'formset': formset })*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Custom validation in model formset

2010-10-11 Thread ringemup
try this...

from django.forms import ValidationError

...
  for form in self.forms:
...
raise ValidationError('whatever')



On Oct 11, 1:32 pm, Duane Hilton  wrote:
> Changing forms to form brings a new error:
>
> *Exception Value: 'CandidateFeedForm' object has no attribute
> 'ValidationError'*
>
> Below is the view that is using the BaseCandFormSet code that I included in
> the original message. Maybe something is wrong in it? Thanks in advance for
> your suggestions. I've spent a few days using the documentation and trying
> to get this to work. I really appreciate the help. ...
>
> *def state_office(request):
>     CandFormSet = modelformset_factory(CandidateFeed,
> **queryset=CandidateFeed.objects.all().order_by('last_name',
> 'county'),** formset=BaseCandFormSet, extra=0)
>     if request.method == 'POST':
>         formset = CandFormSet(request.POST, request.FILES)
>         if formset.is_valid():
>             formset.save()
>             return HttpResponseRedirect('/foo/bar/')
>     else:
>         formset =
> CandFormSet(queryset=CandidateFeed.objects.all().order_by('last_name',
> 'county'))
>     return render_to_response('state_office.html', { 'formset': formset })*

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: moving from Postgres to MySQL

2010-10-11 Thread Jeff Green
I am in the process of migrating a postgresql database to oracle which has a
lot of data.
I tried to use the dumpdata command but because of the amount of data I  had
to scrap the plan. My alternative solution with Django 1.2 is to do a read
and write from postgresql to oracle.




On Mon, Oct 11, 2010 at 8:03 AM, Shawn Milochik  wrote:

> One way would be to use the dumpdata command to export everything, change
> your settings to point to the new database, then loaddata to restore.
>
> There may be a better way, but this way allows you to dump to a
> database-agnostic backup so it seems like it would suit your needs.
>
> 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-us...@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-us...@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: Legacy URLs redirect

2010-10-11 Thread Jirka Vejrazka
> And failed most spectacularly. Do I need to be escaping something, or
> what am I missing?

Yes. Even for the raw regular expressions, the question mark at the
beginning must be escaped. Try a simple test case:

import sys
import re

s = r'\?q=taxonomy/term/[0-9]+$'

re_pattern = re.compile(s, re.IGNORECASE)
if re_pattern.search(sys.argv[1]) is not None:
print 'Match'


$ django_test.py http://aaa.com/test?q=taxonomy/term/23
Match


  Cheers

Jirka

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: Legacy URLs redirect

2010-10-11 Thread Daniel Roseman
On Oct 11, 5:08 pm, "bax...@gretschpages.com" 
wrote:
> I'm sure this is simple and I'm just not constructing the URL
> properly. Basically, it used to be a drupal site, with the cruddy old
> Drupal every url is a querystring setup. What I want is pretty
> simple... all of those old URLs resolve to the home page and send a
> 301 to the spider.
>
> I tried:
>         (r'^?q=taxonomy/term/[0-9]+$', redirect_to, {'url': '/', 'permanent':
> True}),
>
> And failed most spectacularly. Do I need to be escaping something, or
> what am I missing?

What you're missing is that elements after the ? are *not* part of the
URL - they are part of the querystring. These are passed through into
the view and can be accessed via request.GET.

In any case, for a blanket redirect like that, you would be better off
doing it directly via Apache (or whatever your webserver software is),
rather than invoking Django each time.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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: I can't select day with calendar widget

2010-10-11 Thread renevie...@gmail.com
On Sat, Oct 9, 2010 at 10:37 AM, Steve Holden  wrote:
> As others have observed, I see the correct dates for holidays I created,
> including 2010-10-10.
>
> regards
>  Steve
>

Hello

I have a new antecedent to add.
the 2010-10-10, our local clocks has changed from clt to clst

can this to be the blame

thank you

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.