Re: "Building you first Django app, Part 1" example not working

2008-12-21 Thread Chris

No directory created in my cd, but I see you're working remotely, no?
I'm trying to get it running on my Mac first before running it on a
server or remote machine. Am I wrong? What I'd really appreciate is
someone telling me EXACTLY what I need to do – every single aspect of
installation, explained in dummy terms, if possible. I know I'm
overlooking something stupid – it says it can't find django-
admin.py... so I'm lost – thanks for the reply, though!

On Dec 20, 5:58 pm, Jeff Anderson  wrote:
> Chris wrote:
> > When I'm in the command line, and run the command django-admin.py
> > startproject mysite, I don't get an error, but nothing happens... as
> > far as I can tell!
>
> Did you check to see if the 'mysite' directory was created? Here's what
> it looks like on my osx terminal:
>
>     jeffe...@pax:~$ django-admin.py startproject mysite
>     jeffe...@pax:~$ cd mysite/
>     jeffe...@pax:~/mysite$
>
> Cheers!
>
> Jeff Anderson
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
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: custom templatetags and problem with importing photologue.models - namespace collision?

2008-12-21 Thread Bartek

Bartek pisze:
> Hi all
> When I loop over sys.modules in templatetags/pobierz.py there's
> django.templatetags.photologue, so probably that's why "from
> photologue.models import Gallery" throws ImportException - there's  not
> models in django.templatetags.photologue
> 
> Anyway in sys.modules there's photologue.models as well.
> Is there any way to import models from photologue?
I found solution myself today which is:

localphotologue=sys.modules['photologue.models']
gals=localphotologue.Gallery.objects.all().order_by('?')[:4]


Is this the correct, pythonic way?


-- 
Bartosz Radwan
jid: bar...@sq9mev.info
spamtrap: http://sq9mev.info/spamtrap.html


--~--~-~--~~~---~--~~
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: "Building you first Django app, Part 1" example not working

2008-12-21 Thread Jeff Anderson
Chris wrote:
> No directory created in my cd, but I see you're working remotely, no?
> I'm trying to get it running on my Mac first before running it on a
> server or remote machine. Am I wrong? What I'd really appreciate is
> someone telling me EXACTLY what I need to do – every single aspect of
> installation, explained in dummy terms, if possible. I know I'm
> overlooking something stupid – it says it can't find django-
> admin.py... so I'm lost – thanks for the reply, though!
>   
No, that was locally on my mac. That's exactly what you need to do. The
django-admin.py script exits on success with no output. That's what it's
supposed to do. Does the mysite directory not exist after you run that
command?


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: "Building you first Django app, Part 1" example not working

2008-12-21 Thread Jeff Anderson
Chris wrote:
> it says it can't find django-admin.py
I didn't see that for my most recent reply. Your problem is that
django-admin.py isn't on your PATH. Either put it in your PATH or run it
with a full path: /path/to/django-admin.py

If you're unfamiliar with this terminology, you need to read up on some
unix basics. There are many tutorials about the unix shell out there. I
can't recommend one because I would just google for an introduction to
the unix/linux/macos terminal.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: Installing django admin on apache/ mod_python

2008-12-21 Thread paultanner

No more input on this for a while so I tried various moving the
directories around.
My supposition is that it can't find the part of the distribution
containing the admin code.

vhost.conf (on a subdomain)
---

  SetHandler python-program
  PythonHandler django.core.handlers.modpython
  SetEnv DJANGO_SETTINGS_MODULE mysite.settings
  PythonPath "['/var/www/test','/var/www/test/django'] + sys.path"
  PythonDebug On


urls.py

from django.conf.urls.defaults import *
from django.contrib import admin
from mysite.views import current_datetime
admin.autodiscover()

urlpatterns = patterns('',
  (r'^admin/(.*)', admin.site.root),
  (r'^time/$', current_datetime),
)


mysite directory is at /var/www/test
django distribution is in the same place

Is the problem with the PythonPath as:

/time app in myuysite runs OK
/foo gives a 404 error via django debug
/admin just hangs (blank browser - nothing appears on apache error
log.)

Any suggestions pls?

Paul

On Nov 18, 12:08 pm, "Karen Tracey"  wrote:
> On Tue, Nov 18, 2008 at 3:39 AM, paultanner  wrote:
>
> > I got a fresh distribution (1.01) and installed it on RHEL4 linux/
> > apache/mod_python (in a subdomain)
> > python is 2.3.4
> > the trivial app /tim (from the book) works OK so most of the config
> > must be right
> > then tried to add the admin interface, modifying settings.py and ..
>
> > urls.py
> > ---
>
> > from django.conf.urls.defaults import *
> > from django.contrib import admin
> > from mysite.views import current_datetime
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
> >  (r'^admin/(.*)', admin.site.root),
> >  (r'^time/$', current_datetime),
> > )
>
> > This just hangs.  Does not throw an error. An entry in the access_log
> > shows that it tried to redirect.
>
> A cut-n-paste of what you're seeing the the log might be enlightening.
>
> The other urlpattern you find is old, and will not work with 1.0.x
>
> Karen- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django on Lighttpd: HTTP requests with captures in them return pages without static content.

2008-12-21 Thread jmags

Hi, I've been building a Django site using Lighttpd as a server for a
local sandbox. URLs that do not capture data to send to the view,
e.g.:

(r'^index$', 'Gallerie500.viewer.views.index'),

are working fine. However, galleries that are sending data in the
request, e.g.:

(r'^display/(\d)$', 'Gallerie500.viewer.views.obj_display'),

render the page, but without any static elements (i.e.: CSS and
Javascript).

The Django section of my lighttpd.conf looks like this:

# fcgi for Django
fastcgi.server = (
"/Gallerie500.fcgi" => (
"main" => (
"socket" => "/tmp/test.sock",
"check-local" => "disable",
)
),
)

# It may be better to define these in Django settings, except that I
tried and
# it didn't work.
alias.url = (
"/static/" => "/Users/jmags/Code/Gallerie500/static/"
)

url.rewrite-once = (
"^(/static.*)$" => "$1",
# "^/favicon\.ico$" => "/static/favicon.ico",
"^(/.*)$" => "/Gallerie500.fcgi$1",
)

I left the MEDIA_ROOT and MEDIA_URL values in settings.py blank.
Again, for most pages this works fine. I'm not sending the Django fcgi
or Lighttpd instances to the background, and neither console reports
and error. I hope this looks familiar to somebody, thanks in advance.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Post tutorial help needed - generic.create_update.create_object

2008-12-21 Thread schwim

OK, I'm a total newbie. I ran through the tutorial on the django site,
and decided to extend the poll system a bit just to learn more.  I
figured quite a bit out, but on this one I'm stuck.

I want to provide a page at polls/new to add a new poll.  I'm trying
to use the generic.create_update.create_object generic view to provide
the form, which works, but when I submit the post, it doesn't follow
the post_save_redirect I specify.  I think I know why, but first,
here's my urlconf:

 (r'^new/$', 'django.views.generic.create_update.create_object',
dict({'model': Poll}, post_save_redirect="../")),

I've no idea if that is right, but I stopped getting errors with it,
and my template will display.  Here's the template I'm using:

 
 New Poll: {{ form.question }}
 

This generates the expected form. When I click submit, I get returned
to the same page, no errors.  I'm pretty sure this is happening
because I have NOT NULL in the pub_date field, and I'm trying to
insert a new record without a date.  Makes sense to me, but how do I
get there?  Like I said, I'm a total newbie to this - bash me if you
want. ;)

So, what am I doing wrong, and more important to the long term, how
the heck do I debug something like this? I'm getting no errors.

TIA
schwim

--~--~-~--~~~---~--~~
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: "Building you first Django app, Part 1" example not working

2008-12-21 Thread Chris

Thanks Jeff - I've figured it out now... I'm new to Python - I'm 14...
Anyway, it's not the UNIX that was screwing me up, it's that I hadn't
installed Django properly - just dragged it into site-packages without
setting a symlink. Again, thanks for replying - no doubt I'll have
more questions for you guys!

Best,

Chris

On Dec 21, 12:41 am, Jeff Anderson  wrote:
> Chris wrote:
> > it says it can't find django-admin.py
>
> I didn't see that for my most recent reply. Your problem is that
> django-admin.py isn't on your PATH. Either put it in your PATH or run it
> with a full path: /path/to/django-admin.py
>
> If you're unfamiliar with this terminology, you need to read up on some
> unix basics. There are many tutorials about the unix shell out there. I
> can't recommend one because I would just google for an introduction to
> the unix/linux/macos terminal.
>
> Jeff Anderson
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Django app deployment creating users without admin app

2008-12-21 Thread Juan Kinunt
Hi!
What is the best practice to deploy a Django application creating a user but
not installing the admin app. I want to deploy my app to clients cleanly
(like i.e "make install") and I need to create a user to be able to start
using the django app.
I think that a Django app is a bit complicated to do a deploy using only
similar to "make install" but I would like to hear about best practices to
do it.
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: "Building you first Django app, Part 1" example not working

2008-12-21 Thread Chris

Okay... I'm on part two of the tut now and I am attemping to use
Python's built-in SQLite Database just to get a feel for Django.
However, the tutorial confuses me in part one when it defines
DATABASE_NAME, "The name of your database. If you're using SQLite, the
database will be a file on your computer; in that case, DATABASE_NAME
should be the full absolute path, including filename, of that file. If
the file doesn't exist, it will automatically be created when you
synchronize the database for the first time (see below)."

It say, "see below," but all that is below is the reference, "If
you're using SQLite, you don't need to create anything beforehand -
the database file will be created automatically when it is needed."
which is wonderful, but I recieve the error shown below when I try to
run the admin interface, as I haven't specified the DATABASE_NAME. How
can I if I don't know where it was created?

Anyway, here's my error. Running almost any other command at the promt
gives me an error ending with "ImproperlyConfigured: Please fill out
DATABASE_NAME in the settings module before using the database.", but
the error shown when I try to run the admin is included below...

---

Traceback (most recent call last):

  File "/Library/Python/2.5/site-packages/django/core/servers/
basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)

  File "/Library/Python/2.5/site-packages/django/core/servers/
basehttp.py", line 635, in __call__
return self.application(environ, start_response)

  File "/Library/Python/2.5/site-packages/django/core/handlers/
wsgi.py", line 243, in __call__
response = middleware_method(request, response)

  File "/Library/Python/2.5/site-packages/django/contrib/sessions/
middleware.py", line 35, in process_response
request.session.save()

  File "/Library/Python/2.5/site-packages/django/contrib/sessions/
backends/db.py", line 52, in save
session_key = self.session_key,

  File "/Library/Python/2.5/site-packages/django/contrib/sessions/
backends/base.py", line 152, in _get_session_key
self._session_key = self._get_new_session_key()

  File "/Library/Python/2.5/site-packages/django/contrib/sessions/
backends/base.py", line 144, in _get_new_session_key
if not self.exists(session_key):

  File "/Library/Python/2.5/site-packages/django/contrib/sessions/
backends/db.py", line 25, in exists
Session.objects.get(session_key=session_key)

  File "/Library/Python/2.5/site-packages/django/db/models/
manager.py", line 93, in get
return self.get_query_set().get(*args, **kwargs)

  File "/Library/Python/2.5/site-packages/django/db/models/query.py",
line 304, in get
num = len(clone)

  File "/Library/Python/2.5/site-packages/django/db/models/query.py",
line 160, in __len__
self._result_cache = list(self.iterator())

  File "/Library/Python/2.5/site-packages/django/db/models/query.py",
line 275, in iterator
for row in self.query.results_iter():

  File "/Library/Python/2.5/site-packages/django/db/models/sql/
query.py", line 206, in results_iter
for rows in self.execute_sql(MULTI):

  File "/Library/Python/2.5/site-packages/django/db/models/sql/
query.py", line 1733, in execute_sql
cursor = self.connection.cursor()

  File "/Library/Python/2.5/site-packages/django/db/backends/
__init__.py", line 56, in cursor
cursor = self._cursor(settings)

  File "/Library/Python/2.5/site-packages/django/db/backends/sqlite3/
base.py", line 139, in _cursor
raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
settings module before using the database."

ImproperlyConfigured: Please fill out DATABASE_NAME in the settings
module before using the database.

---

Pretty much the same as the errors I'm getting at the command line...
Any insight would be appreciated - I think I'll just install MySQL
locally and use that, as SQLite sounds like a limiting pain in the
ass... Verification on this? Anyway, any help is greatly appreciated -
you Django people are awesome.

Best,

Chris

On Dec 21, 2:20 am, Chris  wrote:
> Thanks Jeff - I've figured it out now... I'm new to Python - I'm 14...
> Anyway, it's not the UNIX that was screwing me up, it's that I hadn't
> installed Django properly - just dragged it into site-packages without
> setting a symlink. Again, thanks for replying - no doubt I'll have
> more questions for you guys!
>
> Best,
>
> Chris
>
> On Dec 21, 12:41 am, Jeff Anderson  wrote:
>
> > Chris wrote:
> > > it says it can't find django-admin.py
>
> > I didn't see that for my most recent reply. Your problem is that
> > django-admin.py isn't on your PATH. Either put it in your PATH or run it
> > with a full path: /path/to/django-admin.py
>
> > If y

Re: "Building you first Django app, Part 1" example not working

2008-12-21 Thread mrtot

Hi Chris,

maybe it's the best to just do what the error message suggest:

"Please fill out DATABASE_NAME in the settings module before using the
database. "

Put in something like '/home/chris/projects/django-tutorial/db/db.db'

You can create your own name. Django just wants to know where it
should store the database.
No need to install MySQL for your local sandboxes :)

Greets,
Martin

On 21 Dez., 12:40, Chris  wrote:
> Okay... I'm on part two of the tut now and I am attemping to use
> Python's built-in SQLite Database just to get a feel for Django.
> However, the tutorial confuses me in part one when it defines
> DATABASE_NAME, "The name of your database. If you're using SQLite, the
> database will be a file on your computer; in that case, DATABASE_NAME
> should be the full absolute path, including filename, of that file. If
> the file doesn't exist, it will automatically be created when you
> synchronize the database for the first time (see below)."
>
> It say, "see below," but all that is below is the reference, "If
> you're using SQLite, you don't need to create anything beforehand -
> the database file will be created automatically when it is needed."
> which is wonderful, but I recieve the error shown below when I try to
> run the admin interface, as I haven't specified the DATABASE_NAME. How
> can I if I don't know where it was created?
>
> Anyway, here's my error. Running almost any other command at the promt
> gives me an error ending with "ImproperlyConfigured: Please fill out
> DATABASE_NAME in the settings module before using the database.", but
> the error shown when I try to run the admin is included below...
>
> ---
>
> Traceback (most recent call last):
>
>   File "/Library/Python/2.5/site-packages/django/core/servers/
> basehttp.py", line 278, in run
>     self.result = application(self.environ, self.start_response)
>
>   File "/Library/Python/2.5/site-packages/django/core/servers/
> basehttp.py", line 635, in __call__
>     return self.application(environ, start_response)
>
>   File "/Library/Python/2.5/site-packages/django/core/handlers/
> wsgi.py", line 243, in __call__
>     response = middleware_method(request, response)
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> middleware.py", line 35, in process_response
>     request.session.save()
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> backends/db.py", line 52, in save
>     session_key = self.session_key,
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> backends/base.py", line 152, in _get_session_key
>     self._session_key = self._get_new_session_key()
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> backends/base.py", line 144, in _get_new_session_key
>     if not self.exists(session_key):
>
>   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> backends/db.py", line 25, in exists
>     Session.objects.get(session_key=session_key)
>
>   File "/Library/Python/2.5/site-packages/django/db/models/
> manager.py", line 93, in get
>     return self.get_query_set().get(*args, **kwargs)
>
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 304, in get
>     num = len(clone)
>
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 160, in __len__
>     self._result_cache = list(self.iterator())
>
>   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> line 275, in iterator
>     for row in self.query.results_iter():
>
>   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> query.py", line 206, in results_iter
>     for rows in self.execute_sql(MULTI):
>
>   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> query.py", line 1733, in execute_sql
>     cursor = self.connection.cursor()
>
>   File "/Library/Python/2.5/site-packages/django/db/backends/
> __init__.py", line 56, in cursor
>     cursor = self._cursor(settings)
>
>   File "/Library/Python/2.5/site-packages/django/db/backends/sqlite3/
> base.py", line 139, in _cursor
>     raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> settings module before using the database."
>
> ImproperlyConfigured: Please fill out DATABASE_NAME in the settings
> module before using the database.
>
> ---
>
> Pretty much the same as the errors I'm getting at the command line...
> Any insight would be appreciated - I think I'll just install MySQL
> locally and use that, as SQLite sounds like a limiting pain in the
> ass... Verification on this? Anyway, any help is greatly appreciated -
> you Django people are awesome.
>
> Best,
>
> Chris
>
> On Dec 21, 2:20 am, Chris  wrote:
>
> > Thanks Jeff - I've figured it out no

Optional fields in admin page

2008-12-21 Thread Mirat Can Bayrak

hi, i have a state selection which has options "exists", "not exists" and 
"redirected" when it is selected as exists i want to show some more fields, but 
on other selections i dont want him to show them. can i do that it django?
-- 
Mirat Can Bayrak 

--~--~-~--~~~---~--~~
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: Optional fields in admin page

2008-12-21 Thread James PIC

On Sun, Dec 21, 2008 at 4:46 PM, Mirat Can Bayrak
 wrote:
>
> hi, i have a state selection which has options "exists", "not exists" and 
> "redirected" when it is selected as exists i want to show some more fields, 
> but on other selections i dont want him to show them. can i do that it django?

AFAIK not OOTB. I hope for you that someone is going to post a more
comprehensive reply than this one.

It's hopefully pretty easy to "predict" how django will generate it's
input field, label and fieldset ids in the HTML result. Use your
favorite javascript framework to deal with it:
- attach an event onChange on a field,
- show/hide fields you want when the field's value match something you expected.

I had to create some javascript function to help me (models with
hundred of fields, dozens of conditions), drawbacks are: no
documentation, requires jquery. Reading it might help making your
application specific functions development /slightly/ faster.

function show_field(name)
{
id = 'id_' + name
$('.' + name).show();
$('#' + id).show();
$('label[for=' + id + ']').show();
}

function hide_field(name)
{
id = 'id_' + name
$('.' + name).hide();
$('#' + id).hide();
$('label[for=' + id + ']').hide();
}
// geodjango
function show_map(name)
{
show_field(name);
$('#' + id).hide();
$('#id_' + name + '_admin_map').show();
}

function hide_map(name)
{
$('#id_' + name + '_admin_map').hide();
hide_field(name);
}

Because of the lack of documentation, this is an example usage which
you'll unfortunnately have to reverse engineer, i've tryed to cut out
everything you don't need and "unfactorized it" to make it "easier" to
understand:

residence_specific_fields = new Array(
'departement',
'cp',
'ville',
'addresse1',
'addresse2',
'secteur',
'quartier',
'ville_diffusion'
);

function show_residence_specific()
{
for (i=0; ihttp://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Fwd: Optional fields in admin page

2008-12-21 Thread James PIC

Errata, this email has correct sources, sorry for the pollution.

On Sun, Dec 21, 2008 at 4:46 PM, Mirat Can Bayrak
 wrote:
>
> hi, i have a state selection which has options "exists", "not exists" and 
> "redirected" when it is selected as exists i want to show some more fields, 
> but on other selections i dont want him to show them. can i do that it django?

AFAIK not OOTB. I hope for you that someone is going to post a more
comprehensive reply than this one.

It's hopefully pretty easy to "predict" how django will generate it's
input field, label and fieldset ids in the HTML result. Use your
favorite javascript framework to deal with it:
- attach an event onChange on a field,
- show/hide fields you want when the field's value match something you expected.

I had to create some javascript function to help me (models with
hundred of fields, dozens of conditions), drawbacks are: no
documentation, requires jquery. Reading it might help making your
application specific functions development /slightly/ faster.

function show_field(name)
{
   id = 'id_' + name
   $('.' + name).show();
   $('#' + id).show();
   $('label[for=' + id + ']').show();
}

function hide_field(name)
{
   id = 'id_' + name
   $('.' + name).hide();
   $('#' + id).hide();
   $('label[for=' + id + ']').hide();
}
// geodjango
function show_map(name)
{
   show_field(name);
   $('#' + id).hide();
   $('#id_' + name + '_admin_map').show();
}

function hide_map(name)
{
   $('#id_' + name + '_admin_map').hide();
   hide_field(name);
}

Because of the lack of documentation, this is an example usage which
you'll unfortunnately have to reverse engineer, i've tryed to cut out
everything you don't need and "unfactorized it" to make it "easier" to
understand:

foo_specific_fields = new Array(
   'droits',
   // [...],
   // that's actually a list of field name as they are in your models sources
   'loi_defisc',
);

$(document).ready(function() {
   $('#id_foo_bar').change(function() {
   if ($(this).val() == "Foo")
   {
   for (i=0; ihttp://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Keeping order with order_by while using id__in

2008-12-21 Thread Raisins

i = [ 1, 5,2,6]
Model.objects.filter(id__in = i)

This currently will order them by id, even if i call order_by()  with
no parameters. The docs say "If you don't want any ordering to be
applied to a query, not even the default ordering, call order_by()
with no parameters."

Is there  a way to maintain the order I have in the list?
--~--~-~--~~~---~--~~
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 formatting

2008-12-21 Thread MS

Thanks to Graham and Jeff.

I moved my code out of the document root and used the proper alias to
tell Apache where to find Django's admin.media files.
Problem solved ?

MS



> For mod_wsgi see:
>
>  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>  http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines#Hosting...
>
> When using mod_wsgi you do not need to do the Location/SetHandler None
> hack that is required in mod_python to have Alias directive honoured.
> In mod_wsgi for case of static media at sub URL of Django site, just
> use Alias directives and they will correctly take precedence.
>
> Graham
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



PDF to Text Coverter

2008-12-21 Thread Harish

Hi Friends...

I know this is a not a right place to ask this question.
but it is related to Python. I thought it to ask.

Is there any python library is available to read a pdf  files... ?

Or any library to convert the pdf into text files?

If you have any idea about above issues

please let me know...

Regards
Harish Bhat M

--~--~-~--~~~---~--~~
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: image uploading, validation by using form

2008-12-21 Thread Chuck22

Before I can write validation of uploaded images, I first need to know
how to save multiple upload images in view. Can anyone share some code
or reference on this? Thanks.

On Dec 20, 10:31 pm, Brandon Taylor  wrote:
> Hi,
>
> You can do validation on images by using a custom form for your admin
> Model. This example validates that a thumbnail image is a specific
> dimension, file type and file size,
>
> from django.core.files.images import get_image_dimensions
>
> class MyModelAdminForm(forms.ModelForm):
>     model = MyModel
>
>     def clean_thumbnail(self):
>         thumbnail_image = self.cleaned_data['thumbnail']
>
>         try:
>             main, sub = thumbnail_image.content_type.split('/')
>             w, h = get_image_dimensions(thumbnail_image)
>
>             if w != 128 or h != 96:
>                 raise forms.ValidationError(u'Please use an image that
> is 128 x 96 pixels for thumbnails')
>
>             if not (main == 'image' and sub in ['jpeg', 'pjpeg']):
>                 raise forms.ValidationError(u'Please use a JPEG
> image.')
>
>             if len(thumbnail_image) > 20480: #bytes
>                 raise forms.ValidationError(u'Thumbnail file size must
> not exceed 20 KB.')
>
>         except AttributeError:
>             pass
>
>         return thumbnail_image
>
> class MyModelAdmin(admin.ModelAdmin):
>     form = MyModelAdminForm
>
> HTH,
> Brandon
>
> On Dec 20, 8:00 pm, Chuck22  wrote:
>
>
>
> > Here is my model:
>
> > class Book(models.Model):
> >     title = models.CharField(max_length=150)
> >     category = models.CharField(max_length=50)
> >     description = models.CharField(max_length=2000)
> >     image1 = models.ImageField(upload_to='img/bk', blank=True)
> >     image2 = models.ImageField(upload_to='img/bk', blank=True)
> >     image3 = models.ImageField(upload_to='img/bk', blank=True)
>
> > I want to create a form to add/edit a book which can upload image
> > files (I want to make sure it is an image file and individual image
> > file is within size limit, e.g. 500kb, and dimension limit, e.g.
> > 800X600 px).
>
> > I don't think I can use ModelForm because this validation requirement,
> > also because I want to automatically set the category value for the
> > form on the fly. But don't know 1) how to save uploaded images in view
> > along with the new Model object. 2) how to do validation on the
> > uploaded image files.
>
> > I found a close reference:
>
> >http://www.oluyede.org/blog/2007/03/18/django-image-uploading-validat...
>
> > But it reads: "This post is outdated now - if you’re using the latest
> > django, do not follow this post." I don't know what to follow for
> > Django 1.0.2 that I am using. The Django document on 
> > forms:http://docs.djangoproject.com/en/dev/topics/forms/
> > does not even mention how to ceate a form for ImageField in Model. Can
> > anyone help with some code snippets? Thanks.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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: Post tutorial help needed - generic.create_update.create_object

2008-12-21 Thread Fridrik Mar Jonsson

Hi schwim,

Welcome to Django!  Glad to have you. ;-)

You probably receive the same page again because there were errors in
the form, most probably because you didn't include all the fields
required (as you suspect).  To see specifically what errors there
were, please refer to:

http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#customizing-the-form-template

It is usually wise to simply iterate through all fields (if you
require a custom form layout, otherwise you can just do ``{{ form }}``
or ``{{ form.as_* }}``) than to manually write up every field directly
in the HTML.  This means that all fields that exist in the form will
be exhausted and printed on the page.  Then you will only have to
change the form to make a change to the form's HTML if you add, change
or remove a field.

http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#looping-over-the-form-s-fields

Note that if you want to declare a ``pub_date`` without having to
enter the date explicitely in the form (having it default to when it
is updated or created), use ``auto_now`` or ``auto_now_add``.

http://docs.djangoproject.com/en/dev/ref/models/fields/#datefield

Regards,
Friðrik Már

On Dec 21, 7:02 am, schwim  wrote:
> OK, I'm a total newbie. I ran through the tutorial on the django site,
> and decided to extend the poll system a bit just to learn more.  I
> figured quite a bit out, but on this one I'm stuck.
>
> I want to provide a page at polls/new to add a new poll.  I'm trying
> to use the generic.create_update.create_object generic view to provide
> the form, which works, but when I submit the post, it doesn't follow
> the post_save_redirect I specify.  I think I know why, but first,
> here's my urlconf:
>
>      (r'^new/$', 'django.views.generic.create_update.create_object',
> dict({'model': Poll}, post_save_redirect="../")),
>
> I've no idea if that is right, but I stopped getting errors with it,
> and my template will display.  Here's the template I'm using:
>
>      
>      New Poll: {{ form.question }}
>      
>
> This generates the expected form. When I click submit, I get returned
> to the same page, no errors.  I'm pretty sure this is happening
> because I have NOT NULL in the pub_date field, and I'm trying to
> insert a new record without a date.  Makes sense to me, but how do I
> get there?  Like I said, I'm a total newbie to this - bash me if you
> want. ;)
>
> So, what am I doing wrong, and more important to the long term, how
> the heck do I debug something like this? I'm getting no errors.
>
> TIA
> schwim
--~--~-~--~~~---~--~~
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 anyone explain why reverse() never seems to work?

2008-12-21 Thread Bradley Wright

Cheers, I was just doing something stupid then. :)
--~--~-~--~~~---~--~~
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: Overwriting Django Authentication / Session Logic

2008-12-21 Thread Bradley Wright

I have the same issue, but my issue is that Django is interfacing with
a web service and ideally will have *no user database* on the front
end. All the examples I've seen involve essentially copying the user
from LDAP/wherever and sticking them in the User model, which:

a) Is duplication across services (which creates lots of uninteresting
and painful synchronisation problems); and
b) Doesn't solve my problem at all.

Is it stupidly difficult to do what I wanted to do? If I create my own
AnonymousUser etc. objects and write an auth-backend to use in
AUTHENTICATION_BACKENDS, will I be able to make it work? It all seems
really tightly coupled to the User model at the moment.

PS: I Googled loads, and came up with *only* examples using the User
model.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Request dictionary in view

2008-12-21 Thread Alex Jonsson

Hey guys,

I want to check the user's user agent string in a template tag, but
when I try to use the request variable in the template I get a Caught
an exception while rendering: Failed lookup for key [request] error
message.

I'm using the generic list_detail templates, is there anything special
I should set somewhere?
--~--~-~--~~~---~--~~
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: Request dictionary in view

2008-12-21 Thread Bradley Wright

Request isn't ending up in the context, try installing:

http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-context-processors-request

It's not enabled by default, and you need it to make request available
in templates.
--~--~-~--~~~---~--~~
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: "Building you first Django app, Part 1" example not working

2008-12-21 Thread Chris

Oh shit, that's awesome! Thanks! I thought it had already created the
DB and wanted me to fill in that info... I'm so stupid sometimes.
Thanks a bunch mrtot...

On Dec 21, 3:50 am, mrtot  wrote:
> Hi Chris,
>
> maybe it's the best to just do what the error message suggest:
>
> "Please fill out DATABASE_NAME in the settings module before using the
> database. "
>
> Put in something like '/home/chris/projects/django-tutorial/db/db.db'
>
> You can create your own name. Django just wants to know where it
> should store the database.
> No need to install MySQL for your local sandboxes :)
>
> Greets,
> Martin
>
> On 21 Dez., 12:40, Chris  wrote:
>
> > Okay... I'm on part two of the tut now and I am attemping to use
> > Python's built-in SQLite Database just to get a feel for Django.
> > However, the tutorial confuses me in part one when it defines
> > DATABASE_NAME, "The name of your database. If you're using SQLite, the
> > database will be a file on your computer; in that case, DATABASE_NAME
> > should be the full absolute path, including filename, of that file. If
> > the file doesn't exist, it will automatically be created when you
> > synchronize the database for the first time (see below)."
>
> > It say, "see below," but all that is below is the reference, "If
> > you're using SQLite, you don't need to create anything beforehand -
> > the database file will be created automatically when it is needed."
> > which is wonderful, but I recieve the error shown below when I try to
> > run the admin interface, as I haven't specified the DATABASE_NAME. How
> > can I if I don't know where it was created?
>
> > Anyway, here's my error. Running almost any other command at the promt
> > gives me an error ending with "ImproperlyConfigured: Please fill out
> > DATABASE_NAME in the settings module before using the database.", but
> > the error shown when I try to run the admin is included below...
>
> > ---
>
> > Traceback (most recent call last):
>
> >   File "/Library/Python/2.5/site-packages/django/core/servers/
> > basehttp.py", line 278, in run
> >     self.result = application(self.environ, self.start_response)
>
> >   File "/Library/Python/2.5/site-packages/django/core/servers/
> > basehttp.py", line 635, in __call__
> >     return self.application(environ, start_response)
>
> >   File "/Library/Python/2.5/site-packages/django/core/handlers/
> > wsgi.py", line 243, in __call__
> >     response = middleware_method(request, response)
>
> >   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> > middleware.py", line 35, in process_response
> >     request.session.save()
>
> >   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> > backends/db.py", line 52, in save
> >     session_key = self.session_key,
>
> >   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> > backends/base.py", line 152, in _get_session_key
> >     self._session_key = self._get_new_session_key()
>
> >   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> > backends/base.py", line 144, in _get_new_session_key
> >     if not self.exists(session_key):
>
> >   File "/Library/Python/2.5/site-packages/django/contrib/sessions/
> > backends/db.py", line 25, in exists
> >     Session.objects.get(session_key=session_key)
>
> >   File "/Library/Python/2.5/site-packages/django/db/models/
> > manager.py", line 93, in get
> >     return self.get_query_set().get(*args, **kwargs)
>
> >   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> > line 304, in get
> >     num = len(clone)
>
> >   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> > line 160, in __len__
> >     self._result_cache = list(self.iterator())
>
> >   File "/Library/Python/2.5/site-packages/django/db/models/query.py",
> > line 275, in iterator
> >     for row in self.query.results_iter():
>
> >   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> > query.py", line 206, in results_iter
> >     for rows in self.execute_sql(MULTI):
>
> >   File "/Library/Python/2.5/site-packages/django/db/models/sql/
> > query.py", line 1733, in execute_sql
> >     cursor = self.connection.cursor()
>
> >   File "/Library/Python/2.5/site-packages/django/db/backends/
> > __init__.py", line 56, in cursor
> >     cursor = self._cursor(settings)
>
> >   File "/Library/Python/2.5/site-packages/django/db/backends/sqlite3/
> > base.py", line 139, in _cursor
> >     raise ImproperlyConfigured, "Please fill out DATABASE_NAME in the
> > settings module before using the database."
>
> > ImproperlyConfigured: Please fill out DATABASE_NAME in the settings
> > module before using the database.
>
> > ---
>
> > Pretty much the same as the errors I'm gett

Problem with url tag

2008-12-21 Thread patrick91

Hi, I've a problem with the url tag, when I call this template:
Visualizza
I get this error:
Caught an exception while rendering: Reverse for
'catsnc.show_worksheet' with arguments '(5537,)' and keyword arguments
'{}' not found.

But when I call this code from the shell:
>>> from django.core.urlresolvers import reverse
>>> reverse('show_worksheet', args=(5537,))
I get the url:
'/riparazioni/foglio/5537/'

could you help me to resolve this problem?

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: Request dictionary in view

2008-12-21 Thread Alex Jonsson

Did it!

Thanks a bunch.

On Dec 21, 8:16 pm, Bradley Wright  wrote:
> Request isn't ending up in the context, try installing:
>
> http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-c...
>
> It's not enabled by default, and you need it to make request available
> in templates.
--~--~-~--~~~---~--~~
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: i18n/setlang TypeError :(((

2008-12-21 Thread pielgrzym

Thank you Karen :)

My python install had some weird patches. Now everything works
absolutely fine :)

Thanks again :)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



A Top-Level Django Index for the root URL

2008-12-21 Thread Ben Pritchard





Hello everyone,

First, a warning: I'm a total noob but I have really enjoyed working
through the tutorial.

The first post-tutorial thing I've done is construct a top-level page
that gets rendered using:

urlpatterns = patterns('',
    (r'^$', 'mysite.views.index'),    

This was necessary because since I've added (r'^polls/',
include('mysite.polls.urls')), the link http://localhost:8000/
failed to render a response (which is understandable).


The intention is that this page will list all my of sandbox projects. 
So at the moment it just links to http://localhost:8000/polls but (a)
coding the link seems like a HTML solution rather than a Django
solution and (b) it will be tedious to update this html template file
each time I add a new subsection to my site.

So, is there a Django solution that can list the available mini-sites
that are available?

I look forward to any help that someone can offer me.

Thanks,
Ben


p.s.: I've searched the mailing list archives but (not surprisingly)
hits for "top-level" "site" "index" "projects" and "list" are producing
rather a lot of hits!!  One candidate I've found is the sites
framework?  Is the answer hidden in there somewhere?

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---





newbie question: validation of primary_key field

2008-12-21 Thread Kaaia

Hi,

  I am very new in django (and python) so my question may be quite
dummy, so be patient please. I am playing with example based on
django's tutorial.

I have following class:

class Pilot(models.Model):
...
cn = models.CharField('Soutěžní znak', max_length = 3, primary_key
= True)


and for form processing another class based on this class:

class formularPilot(ModelForm):
class Meta:
model = Pilot

View code is simple - just like 
http://docs.djangoproject.com/en/dev/topics/forms/#using-a-form-in-a-view
Template code is simple too - just calling "context.as_table" method.

Form processing (validation) works fine except following: when there
is no value in field "cn", then KeyError exception is raised (complete
tracback - http://dpaste.com/101323/). My expected behaviour is, that
message "required field is empty" should be shown.

Am I totally wrong?

Thanks,
--kb

--~--~-~--~~~---~--~~
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: Overwriting Django Authentication / Session Logic

2008-12-21 Thread Bradley Wright

On Sun, Dec 21, 2008 at 8:00 PM, Sahil R Cooner  wrote:
> You don't have to store anything in the database you can just use the models 
> to store
> information then return that the user is authenticated...I can post a code 
> example for you I
> have made using ldap auth without storing to a database

If you could, that would be great, but before you do I just want to
make sure we're not misunderstanding each other:

- I don't want to use a database at all for the user information - all
the LDAP examples I've seen end up creating a new User() object when
the information from LDAP returns.

If yours doesn't do the above, then by all means I'd love to see the code!

--~--~-~--~~~---~--~~
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: newbie question: validation of primary_key field

2008-12-21 Thread Daniel Roseman

On Dec 21, 7:40 pm, Kaaia  wrote:
> Hi,
>
>   I am very new in django (and python) so my question may be quite
> dummy, so be patient please. I am playing with example based on
> django's tutorial.
>
> I have following class:
>
> class Pilot(models.Model):
>     ...
>     cn = models.CharField('Soutěžní znak', max_length = 3, primary_key
> = True)
>     
>
> and for form processing another class based on this class:
>
> class formularPilot(ModelForm):
>     class Meta:
>         model = Pilot
>
> View code is simple - just 
> likehttp://docs.djangoproject.com/en/dev/topics/forms/#using-a-form-in-a-...
> Template code is simple too - just calling "context.as_table" method.
>
> Form processing (validation) works fine except following: when there
> is no value in field "cn", then KeyError exception is raised (complete
> tracback -http://dpaste.com/101323/). My expected behaviour is, that
> message "required field is empty" should be shown.
>
> Am I totally wrong?
>
> Thanks,
> --kb

I see from the traceback that the problem is occurring in
validate_unique. There were various bugs in the validation of unique
elements in forms in version 1.0, which were mainly fixed in version
1.0.2. Try downloading that version instead and see if that fixes your
problem.
--
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-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: Post tutorial help needed - generic.create_update.create_object

2008-12-21 Thread Daniel Roseman

On Dec 21, 7:02 am, schwim  wrote:
> OK, I'm a total newbie. I ran through the tutorial on the django site,
> and decided to extend the poll system a bit just to learn more.  I
> figured quite a bit out, but on this one I'm stuck.
>
> I want to provide a page at polls/new to add a new poll.  I'm trying
> to use the generic.create_update.create_object generic view to provide
> the form, which works, but when I submit the post, it doesn't follow
> the post_save_redirect I specify.  I think I know why, but first,
> here's my urlconf:
>
>      (r'^new/$', 'django.views.generic.create_update.create_object',
> dict({'model': Poll}, post_save_redirect="../")),
>
> I've no idea if that is right, but I stopped getting errors with it,
> and my template will display.  Here's the template I'm using:
>
>      
>      New Poll: {{ form.question }}
>      
>
> This generates the expected form. When I click submit, I get returned
> to the same page, no errors. I'm pretty sure this is happening
> because I have NOT NULL in the pub_date field, and I'm trying to
> insert a new record without a date.  Makes sense to me, but how do I
> get there?  Like I said, I'm a total newbie to this - bash me if you
> want. ;)
>
> So, what am I doing wrong, and more important to the long term, how
> the heck do I debug something like this? I'm getting no errors.


You won't see errors because you haven't included them in your
template. Either render the whole form with {{ form.as_p }} - which
will render the errors as well - or for each field include a reference
to that field's errors - {{ form.fieldname.errors }} - plus
{{ form.non_field_errors }} at the top of the form.

If you've got a non-blank field in your model that you don't want to
display in your form, make sure you include it in the exclude list in
the inner Meta class. Then set it the value manually in your view.

class MyForm(forms.ModelForm):
class Meta:
 exclude=['pub_date']

... in the view ...
if request.method=='POST':
form = MyForm(request.POST)
if form.is_valid()
new_obj = form.save(commit=True)
new_obj.pub_date=datetime.date.today()
new_obj.save()

etc.
--
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-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: newbie question: validation of primary_key field

2008-12-21 Thread Kaaia

> I see from the traceback that the problem is occurring in
> validate_unique. There were various bugs in the validation of unique
> elements in forms in version 1.0, which were mainly fixed in version
> 1.0.2. Try downloading that version instead and see if that fixes your
> problem.

Exactly! Validation works fine after upgrading to 1.0.2. Thanks a lot
for immediate reply!

--kb
--~--~-~--~~~---~--~~
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: "Mix and match" model form?

2008-12-21 Thread stormlifter

Well that kind of dodges the question.
I two am looking for a way to mix and match a ModelForm

I've got...

# Create your models here.
class PersonForm(ModelForm):
class Meta:
model = Person
exclude = ('address',)

class AddressForm(ModelForm):
class Meta:
model = Address


 models.py ==

class Person(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
status = models.CharField(max_length=2,
choices=STATUS_CHOICES)
gender = models.CharField(max_length=1,
choices=GENDER_CHOICES)
address = models.ForeignKey('Address')

 # definitions
def __unicode__(self):
return '%s %s' % (self.first_name, self.last_name)

def full_name(self):
return '%s %s' % (self.first_name, self.last_name)

def get_absolute_url(self):
return "/person/%i/" % self.id
#



class Address(models.Model):
line_1 = models.CharField(max_length=60)
#   line_2 = models.CharField(max_length=60,blank=True,null=True)
city = models.CharField(max_length=30)
state = USStateField()
zip_code = models.CharField(max_length=10)
On Nov 4, 5:28 am, "Jonathan Buchanan" 
wrote:
> On Tue, Nov 4, 2008 at 9:59 AM, Håkan Waara  wrote:
>
> > I would love any ideas or feedback around this area, and to hear of
> > how others in the community do it.
>
> > /Håkan
>
> I would just use two Forms.
>
> Forms:
>
>     class EditUserForm(forms.ModelForm):
>         class Meta:
>             model = User
>             fields = (email, first_name, last_name)
>
>     class EditProfileForm(forms.ModelForm):
>         class Meta:
>             model = Profile
>             fields = (avatar, location)
>
> View:
>
>     def edit_user(request, user_id):
>         user = get_object_or_404(User, id=user_id)
>         profile = user.get_profile()
>
>         if request.method == 'POST':
>             user_form = EditUserForm(request.POST, instance=user)
>             profile_form = EditProfileForm(request.POST,
>                                            instance=profile)
>             if all([user_form.is_valid(), profile_form.is_valid()]):
>                 user_form.save()
>                 profile_form.save()
>                 return HttpResponseRedirect(
>                     reverse('user_profile', args=[user_id]))
>         else:
>             user_form = EditUserForm(instance=user)
>             profile_form = EditProfileForm(instance=profile)
>
>         return render_to_response('edit_user.html', {
>             'user_': user,
>             'user_form': user_form,
>             'profile_form': profile_form,
>         }, context_instance=RequestContext(request))
>
> Template:
>
>     
>       {{ user_form.as_p }}
>       {{ profile_form.as_p }}
>       
>         
>         Cancel
>       
>     
>
> Regards,
> 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-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: S3Storage.py and Thumbnails using PIL (IOError / cannot identify image file)

2008-12-21 Thread j...@zigzap.com

>From what I can tell your not wrapping the thumbnail file in
ContentFile your just returning the raw file from the string IO.  To
use the the ImageField django provides you must provide it with a file
that is in a special wrapper called ContentFile.  I would suggest
trying this:

from django.core.files.base import ContentFile   (import this function
at the top of your view or where ever you put def resize_image)

change the last line of def resize_image from "return o.getvalue()" to
"return ContentFile(o.getvalue())"

I would also recommend changing "new_profile.picture.save(filename,
thumbnail_content)" to "new_profile.picture.save(filename,
thumbnail_content, save=False)" so that you are not hitting the
database twice.


--~--~-~--~~~---~--~~
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: Django Session Variables

2008-12-21 Thread j...@zigzap.com

Thanks

On Dec 20, 11:26 am, Jeff FW  wrote:
> Looking 
> athttp://code.djangoproject.com/browser/django/trunk/django/contrib/aut...
> it doesn't look like it clears the session.  It *does* generate a new
> key, but that shouldn't affect anything.  It should only take you
> about two minutes to test it though--just try it out.
>
> -Jeff
>
> On Dec 19, 6:18 pm, "j...@zigzap.com"  wrote:
>
> > Does django maintain session variables when logging in or does it
> > generate a new session when you use the built in authentication.
> > Essentially I want to be able to assign session values to an Anonymous
> > User and be able to carry them through when they log in.
--~--~-~--~~~---~--~~
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: A Top-Level Django Index for the root URL

2008-12-21 Thread Wayper, Paul
 



From: Ben Pritchard
Subject: A Top-Level Django Index for the root URL

The intention is that this page will list all my of sandbox
projects.  So at the moment it just links to http://localhost:8000/polls
but (a) coding the link seems like a HTML solution rather than a Django
solution and (b) it will be tedious to update this html template file
each time I add a new subsection to my site.

So, is there a Django solution that can list the available
mini-sites that are available? 

 
 
Hi Ben,
 
I'm in that same boat, and I'm considering my options:
 
My first attempt was to change the way the INSTALLED_APPS is built - as
detailed in
http://www.mabula.net/tbfw/2008/11/07#2008-11-07-dont-repeat-yourself-tn
g - and to write a middleware which presented the 'shown apps' as a
structure to read in the template.  Following the principle of Don't
Repeat Yourself, this then lists each application once along with all
the information relevant to it.  This is, however, a fairly heavy-handed
approach in my opinion as it means re-jiggering things in settings.py.
 
My second idea, not yet implemented, is to write a middleware which
introspects the list of URLs.  If it finds one named 'index' (where
'named' means 'named or with a view named'), that's taken to be the root
URL.  Anything with '(.*)_index' that is in the same directory as the
root URL is taken to be an application - that URL becomes the
application URL path.  Once you're in that application, anything with
'(.*)_index' in the same directory as the application's URL path is a
sub-menu of that application and so forth.  That makes it relatively
easy to list URLs in a structure that most projects follow without
repeating the application structure elsewhere or having to do terrible
things to settings.py.
 
My question is: is the second idea Django-ish enough?  I'd like some
feedback from the list before I start work on it as to whether it's a
dead end, whether there's a better way, or just to hear any improvements
on that scheme.
 
Your thoughts?

-- 
Paul Wayper 
SYSTEMS ENGINEER 
TransACT 

Telephone: 02 6229 8026 
Mobile: 0422 392 081 

PO Box 1006, Civic Square  ACT  2608 

www.transact.com.au 


--~--~-~--~~~---~--~~
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: Problems when searching acute or tilde letters in a textfield under tiny_mce.js

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 16:41 -0800, Vizcayno wrote:
> Hello:
> Using tiny_mce.js into django Admin (change_form.html) is nice, but
> when you include into a textField letters such as á or ñ and try to
> find them using the django search engine, no results are obtained
> because internally the á is represented by á and ñ is
> represented by ñ. Is there a way to solve this?
> Regards.

You could run some kind of converter over the input data before saving
it so that it is converted back from HTML entities to the corresponding
unicode characters. That would require hooking up your own form in the
admin interface (if you're using Tiny MCE in the admin interface).

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: Keeping order with order_by while using id__in

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 08:58 -0800, Raisins wrote:
> i = [ 1, 5,2,6]
> Model.objects.filter(id__in = i)
> 
> This currently will order them by id, even if i call order_by()  with
> no parameters. The docs say "If you don't want any ordering to be
> applied to a query, not even the default ordering, call order_by()
> with no parameters."
> 
> Is there  a way to maintain the order I have in the list?

There is no ordering going on here. The results are coming back in
whatever (arbitrary) order they are stored in the database, which is
often the order in which they were inserted (although not always,
particularly with PostgreSQL). The database doesn't pull out the results
one at a time in the order you specify them. It finds the intersection
between your list of values and those that are available as rows in the
database and does no further sorting (SQL is primarily set operations,
after all).

I'm only going into all that detail so that you can see what's really
going on here. The point being that there's no ordering at all going on.

There isn't any way with Django's ORM (or standard SQL -- although, from
memory, some databases have extensions that might allow this) to specify
the ordering you're after here. However, it's not too hard to do this in
Python. Here's one (untested, but it should be close) approach:

id_list = [1, 5, 2, 6]
qs = Model.objects.filter(id__in=id_list)
index = dict([(id, pos) for (pos, id) in enumerate(id_list)])
result = [None] * len(id_list)
for obj in qs:
result[index[obj.id]] = obj

The "result" list will be the sorted results. There are some alternative
approaches as well, but that should give you a starting point.

Regards,
Malcolm



> > 
> 


--~--~-~--~~~---~--~~
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: Problem with url tag

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 11:45 -0800, patrick91 wrote:
> Hi, I've a problem with the url tag, when I call this template:
> Visualizza
> I get this error:
> Caught an exception while rendering: Reverse for
> 'catsnc.show_worksheet' with arguments '(5537,)' and keyword arguments
> '{}' not found.
> 
> But when I call this code from the shell:
> >>> from django.core.urlresolvers import reverse
> >>> reverse('show_worksheet', args=(5537,))
> I get the url:
> '/riparazioni/foglio/5537/'
> 
> could you help me to resolve this problem?

Certainly a bit unexpected. Can you paste the relevant lines from your
URL Conf file, please?

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: newbie question: validation of primary_key field

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 11:40 -0800, Kaaia wrote:
> Hi,
> 
>   I am very new in django (and python) so my question may be quite
> dummy, so be patient please. I am playing with example based on
> django's tutorial.
> 
> I have following class:
> 
> class Pilot(models.Model):
> ...
> cn = models.CharField('Soutěžní znak', max_length = 3, primary_key
> = True)
> 
> 
> and for form processing another class based on this class:
> 
> class formularPilot(ModelForm):
> class Meta:
> model = Pilot
> 
> View code is simple - just like 
> http://docs.djangoproject.com/en/dev/topics/forms/#using-a-form-in-a-view
> Template code is simple too - just calling "context.as_table" method.
> 
> Form processing (validation) works fine except following: when there
> is no value in field "cn", then KeyError exception is raised (complete
> tracback - http://dpaste.com/101323/). My expected behaviour is, that
> message "required field is empty" should be shown.
> 
> Am I totally wrong?

This was a bug in Django 1.0, but it was fixed on 21 October, so Django
the 1.0.1 and 1.0.2 releases contain a fix for it.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: "Mix and match" model form?

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 13:18 -0800, stormlifter wrote:
> Well that kind of dodges the question.
> I two am looking for a way to mix and match a ModelForm

No, it doesn't dodge the question (although, because you top-posted, the
response was hidden: the suggestion was to use two form objects).
ModelForms are designed to be a simple form wrapper around a simple
model. Forms (including ModelForms) are designed to represent part of an
HTML form (not the entire form) so that you can deliberately use more
than one Django Form object in a single HTML form.

Thus, if you want to use two ModelForms in the same form, you can. If
you want to use fields from multiple models in a specific order on the
page (intermingled), then you should construct the form manually (as a
Form subclass) and your view will be responsible for extracting the
right fields and saving them to the right model.

You are trying to do something that is beyond the scope of ModelForm, in
other words.

Regards,
Malcolm


> I've got...
> 
> # Create your models here.
> class PersonForm(ModelForm):
> class Meta:
> model = Person
> exclude = ('address',)
> 
> class AddressForm(ModelForm):
> class Meta:
> model = Address
> 
> 
>  models.py ==
> 
> class Person(models.Model):
> first_name = models.CharField(max_length=30)
> last_name = models.CharField(max_length=30)
> status = models.CharField(max_length=2,
> choices=STATUS_CHOICES)
> gender = models.CharField(max_length=1,
> choices=GENDER_CHOICES)
> address = models.ForeignKey('Address')
> 
>  # definitions
> def __unicode__(self):
> return '%s %s' % (self.first_name, self.last_name)
> 
> def full_name(self):
> return '%s %s' % (self.first_name, self.last_name)
> 
> def get_absolute_url(self):
> return "/person/%i/" % self.id
> #
> 
> 
> 
> class Address(models.Model):
> line_1 = models.CharField(max_length=60)
> # line_2 = models.CharField(max_length=60,blank=True,null=True)
> city = models.CharField(max_length=30)
> state = USStateField()
> zip_code = models.CharField(max_length=10)
> On Nov 4, 5:28 am, "Jonathan Buchanan" 
> wrote:
> > On Tue, Nov 4, 2008 at 9:59 AM, Håkan Waara  wrote:
> >
> > > I would love any ideas or feedback around this area, and to hear of
> > > how others in the community do it.
> >
> > > /Håkan
> >
> > I would just use two Forms.
> >
> > Forms:
> >
> > class EditUserForm(forms.ModelForm):
> > class Meta:
> > model = User
> > fields = (email, first_name, last_name)
> >
> > class EditProfileForm(forms.ModelForm):
> > class Meta:
> > model = Profile
> > fields = (avatar, location)
> >
> > View:
> >
> > def edit_user(request, user_id):
> > user = get_object_or_404(User, id=user_id)
> > profile = user.get_profile()
> >
> > if request.method == 'POST':
> > user_form = EditUserForm(request.POST, instance=user)
> > profile_form = EditProfileForm(request.POST,
> >instance=profile)
> > if all([user_form.is_valid(), profile_form.is_valid()]):
> > user_form.save()
> > profile_form.save()
> > return HttpResponseRedirect(
> > reverse('user_profile', args=[user_id]))
> > else:
> > user_form = EditUserForm(instance=user)
> > profile_form = EditProfileForm(instance=profile)
> >
> > return render_to_response('edit_user.html', {
> > 'user_': user,
> > 'user_form': user_form,
> > 'profile_form': profile_form,
> > }, context_instance=RequestContext(request))
> >
> > Template:
> >
> > 
> >   {{ user_form.as_p }}
> >   {{ profile_form.as_p }}
> >   
> > 
> > Cancel
> >   
> > 
> >
> > Regards,
> > 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-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
-~--~~~~--~~--~--~---



Problems when searching acute or tilde letters in a textfield under tiny_mce.js

2008-12-21 Thread Vizcayno

Hello:
Using tiny_mce.js into django Admin (change_form.html) is nice, but
when you include into a textField letters such as á or ñ and try to
find them using the django search engine, no results are obtained
because internally the á is represented by á and ñ is
represented by ñ. Is there a way to solve this?
Regards.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Table inheritance and polymorphic admin forms

2008-12-21 Thread George Sakkis

Hi all,

I have a situation which I think would best be modeled as (single)
inheritance, involving product reviews for various kinds of products.
Naturally, there are some fields which are common to all reviews
(overall rating, user, review date) and some which are specific to the
type of product. Given such an appropriate model set, I'd like to use
the admin interface to, say, edit the reviews of a user "inline",
where for each review the appropriate form would be rendered (i.e.
including all the fields related to each given product). Is this
possible, and if not, is there a workaround ?

George
--~--~-~--~~~---~--~~
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: Table inheritance and polymorphic admin forms

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 18:50 -0800, George Sakkis wrote:
> Hi all,
> 
> I have a situation which I think would best be modeled as (single)
> inheritance, involving product reviews for various kinds of products.
> Naturally, there are some fields which are common to all reviews
> (overall rating, user, review date) and some which are specific to the
> type of product. Given such an appropriate model set, I'd like to use
> the admin interface to, say, edit the reviews of a user "inline",
> where for each review the appropriate form would be rendered (i.e.
> including all the fields related to each given product). Is this
> possible, and if not, is there a workaround ?

My inner philosopher is protesting that if there is a workaround, that
would make it possible to do something, right? So if it's not possible,
there's no workaround, pretty much by definition. :-)

Anyway, there are two answers to your question: (1) yes, it Just Works,
and (2) What happened when you tried it? It's not really that hard to
test this out.

Create a simple model inheritance situation with Parent and Child,
inheriting from Parent. Give the Child and admin entry and go and add a
new child. You'll see all the Parent fields right there on the page. It
works transparently.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



accessing to a field value in the template

2008-12-21 Thread irunsoft

Hi,

I am new in Django and I am wondering if it is possible to access to a
form field value in through a template.

I know that I can access to the field by {{field}} and also can access
to the field.label, errors, label_tag, but I would like to access to
the intial value of a field.

Suppose I have the field = 
it is possible to get the value only through a template ?  Something
like field.value ? or field.data ? or field.initial ??

I have tried all of them but cannot access to the value.  If you have
any hint it will be appreciate.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Language code prefix in url

2008-12-21 Thread Tirta K. Untario

Hi all, I'm new to Django, and trying to port my old site to Django for 
practice purpose.

Different from Django multilingual implementation by using cookie, I want to 
add lang code to every url, i.e:

/en/my_app/something_here/1/2/3/4/
/de/my_app/something_here/1/2/3/4/
/fr/my_app/something_here/1/2/3/4/

The main reason I do this if for Google to index more pages from my site. I 
don't want Google to index just the English version (default language), but I 
think that what will happen if I use cookies.

I hope this approcae can be integrated with pre-existing Django apps without 
much hassles. I currently in fond of flatpages :)

Do anyone have any idea on how to do this? TIA.

--Tirta


--~--~-~--~~~---~--~~
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: Language code prefix in url

2008-12-21 Thread Wayper, Paul

> From: Tirta K. Untario
> Subject: Language code prefix in url
> 
> /en/my_app/something_here/1/2/3/4/
> /de/my_app/something_here/1/2/3/4/
> /fr/my_app/something_here/1/2/3/4/

My suggestion would be to look at e.g. Apache's URL rewriting rules.
Take those URLs and produce
/my_app/something_here/1/2/3/4/?lang={en,de,fr}, then pick that up in
your environment.  Maybe make some middleware that picks that out of the
GET parameters automatically and gives you it in some useful way.  I'm
guessing what you want to use it for is to select which directory you
pick your templates from.

Just a thought,

--
Paul Wayper
SYSTEMS ENGINEER
TransACT

Telephone: 02 6229 8026
Mobile: 0422 392 081

PO Box 1006, Civic Square  ACT  2608

www.transact.com.au

--~--~-~--~~~---~--~~
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: accessing to a field value in the template

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 19:57 -0800, iruns...@gmail.com wrote:
> Hi,
> 
> I am new in Django and I am wondering if it is possible to access to a
> form field value in through a template.
> 
> I know that I can access to the field by {{field}} and also can access
> to the field.label, errors, label_tag, but I would like to access to
> the intial value of a field.
> 
> Suppose I have the field =  name="myfield" value="1000">
> it is possible to get the value only through a template ?  Something
> like field.value ? or field.data ? or field.initial ??

In the current code, that particular value isn't easily available, no,
and that is probably an omission we should fix.

That particular value comes from one of three sources. In order of
highest priority to lowest, they are:

(1) Data submitted to the form (for redisplaying submitted data
for errors).
(2) Initial data provided to the form class
(3) Initial data provided to the field class (when it was
created as part of the form).

The code does a semi-complex dance to pull out the right value and it's
not something you can really emulate at the template level. That's
something worth adding for Django 1.1.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: Language code prefix in url

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 19:52 -0800, Tirta K. Untario wrote:
> Hi all, I'm new to Django, and trying to port my old site to Django for 
> practice purpose.
> 
> Different from Django multilingual implementation by using cookie, I want to 
> add lang code to every url, i.e:
> 
> /en/my_app/something_here/1/2/3/4/
> /de/my_app/something_here/1/2/3/4/
> /fr/my_app/something_here/1/2/3/4/
> 
> The main reason I do this if for Google to index more pages from my site. I 
> don't want Google to index just the English version (default language), but I 
> think that what will happen if I use cookies.
> 
> I hope this approcae can be integrated with pre-existing Django apps without 
> much hassles. I currently in fond of flatpages :)
> 
> Do anyone have any idea on how to do this? TIA.

Joost Cassee's localeurl project
(http://code.google.com/p/django-localeurl/ ) is one approach to this
problem that seems fairly well thought out.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



where are the code that handle image file upload in Django admin page?

2008-12-21 Thread Chuck22

I have three ImageField in my form and model, I want to know how to
upload the three image files in the form processing code. I found
Django Admin page handles the image file upload nicely. And I want to
do the exactly same work. But I can not find the piece of code that
does the job when searching the Django source code. Can anyone point
to me where these code are located? Or share some code snippets
related to this.

in my model:
image1 = models.ImageField(upload_to='img/bk', blank=True)
image2 = models.ImageField(upload_to='img/bk', blank=True)
image3 = models.ImageField(upload_to='img/bk', blank=True)

in my form processing:

if request.method == 'POST':
f = MyForm(request.POST, request.FILES)
if f.is_valid():
email = f.cleaned_data['email']
title = f.cleaned_data['title']
...

# save the uploaded images
for v in request.FILES:
save_upload_file(v)   < this is where i am stuck
--~--~-~--~~~---~--~~
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: Post tutorial help needed - generic.create_update.create_object

2008-12-21 Thread Greg Schwimer
OK, that was very helpful, thank you.  Yes, my problem is because I am not
setting the date.   Thinking it through, I don't want the user changing
this, so it would be helpful to use the auto_now_add idea you suggested.
However, I can't get that working.  Here's my mode; definition for pub_date:

 pub_date = models.DateTimeField('date published')

The docs you referred to suggest the approach might look something like
this:

pub_date = models.DateTimeField([auto_now_add=True], 'date published)

or

pub_date = models.DateTimeField.auto_now_add('date published')

But neither work, nor does any variation thereof.

What am I missing?

Thanks again!
Greg


On Sun, Dec 21, 2008 at 11:34 AM, Fridrik Mar Jonsson wrote:

>
> Hi schwim,
>
> Welcome to Django!  Glad to have you. ;-)
>
> You probably receive the same page again because there were errors in
> the form, most probably because you didn't include all the fields
> required (as you suspect).  To see specifically what errors there
> were, please refer to:
>
>
> http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#customizing-the-form-template
>
> It is usually wise to simply iterate through all fields (if you
> require a custom form layout, otherwise you can just do ``{{ form }}``
> or ``{{ form.as_* }}``) than to manually write up every field directly
> in the HTML.  This means that all fields that exist in the form will
> be exhausted and printed on the page.  Then you will only have to
> change the form to make a change to the form's HTML if you add, change
> or remove a field.
>
>
> http://docs.djangoproject.com/en/dev/topics/forms/?from=olddocs#looping-over-the-form-s-fields
>
> Note that if you want to declare a ``pub_date`` without having to
> enter the date explicitely in the form (having it default to when it
> is updated or created), use ``auto_now`` or ``auto_now_add``.
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#datefield
>
> Regards,
> Friðrik Már
>
> On Dec 21, 7:02 am, schwim  wrote:
> > OK, I'm a total newbie. I ran through the tutorial on the django site,
> > and decided to extend the poll system a bit just to learn more.  I
> > figured quite a bit out, but on this one I'm stuck.
> >
> > I want to provide a page at polls/new to add a new poll.  I'm trying
> > to use the generic.create_update.create_object generic view to provide
> > the form, which works, but when I submit the post, it doesn't follow
> > the post_save_redirect I specify.  I think I know why, but first,
> > here's my urlconf:
> >
> >  (r'^new/$', 'django.views.generic.create_update.create_object',
> > dict({'model': Poll}, post_save_redirect="../")),
> >
> > I've no idea if that is right, but I stopped getting errors with it,
> > and my template will display.  Here's the template I'm using:
> >
> >  
> >  New Poll: {{ form.question }}
> >  
> >
> > This generates the expected form. When I click submit, I get returned
> > to the same page, no errors.  I'm pretty sure this is happening
> > because I have NOT NULL in the pub_date field, and I'm trying to
> > insert a new record without a date.  Makes sense to me, but how do I
> > get there?  Like I said, I'm a total newbie to this - bash me if you
> > want. ;)
> >
> > So, what am I doing wrong, and more important to the long term, how
> > the heck do I debug something like this? I'm getting no errors.
> >
> > TIA
> > schwim
> >
>

--~--~-~--~~~---~--~~
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: Post tutorial help needed - generic.create_update.create_object

2008-12-21 Thread Greg Schwimer
On Sun, Dec 21, 2008 at 1:47 PM, Daniel Roseman <
roseman.dan...@googlemail.com> wrote:

>
>
> You won't see errors because you haven't included them in your
> template. Either render the whole form with {{ form.as_p }} - which
> will render the errors as well - or for each field include a reference
> to that field's errors - {{ form.fieldname.errors }} - plus
> {{ form.non_field_errors }} at the top of the form


Yes, that showed me the errors.  Very helpful.


>
>
> If you've got a non-blank field in your model that you don't want to
> display in your form, make sure you include it in the exclude list in
> the inner Meta class. Then set it the value manually in your view.
>
> class MyForm(forms.ModelForm):
>class Meta:
> exclude=['pub_date']


So I put this in my model directly?  Under the class definition, or?


>
>
> ... in the view ...
> if request.method=='POST':
>form = MyForm(request.POST)
>if form.is_valid()
>new_obj = form.save(commit=True)
>new_obj.pub_date=datetime.date.today()
>new_obj.save()


OK, I get that, but I'm trying to use the generic views, so is this
applicable to my use case?

Thanks for the help!!
Greg

--~--~-~--~~~---~--~~
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: Post tutorial help needed - generic.create_update.create_object

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 21:46 -0700, Greg Schwimer wrote:
> OK, that was very helpful, thank you.  Yes, my problem is because I am
> not setting the date.   Thinking it through, I don't want the user
> changing this, so it would be helpful to use the auto_now_add idea you
> suggested.  However, I can't get that working.  Here's my mode;
> definition for pub_date:
> 
>  pub_date = models.DateTimeField('date published')
> 
> The docs you referred to suggest the approach might look something
> like this:
> 
> pub_date = models.DateTimeField([auto_now_add=True], 'date
> published)

The square brackets in documentation are a fairly standard way of saying
that parameter is optional. To use the parameter, type it in without the
square brackets. Thus:

pub_date = models.DateTimeField('date published', auto_now_add=True)

Regards,
Malcolm



--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Understanding the execution logic of a view

2008-12-21 Thread eldonp2

Please help me understand the execution logic of a view. I have copied
the example from the official Django documentation:

def contact(request):
if request.method == 'POST': # If the form has been submitted...
form = ContactForm(request.POST) # A form bound to the POST
data
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
return HttpResponseRedirect('/thanks/') # Redirect after
POST
else:
form = ContactForm() # An unbound form

return render_to_response('contact.html', {
'form': form,
})


Lets imagine that I have clicked on a url that is mapped to the
contact view. Is this the correct execution logic:

1. The else part will execute and create an unbound ContactForm
instance that will be passed to the contact.html template
2. When the user clicks submit, the POST method will be executed, and
the user will be redirected to the url '/thanks/'

Please let me know if this is incorect? I'm just struggling to
understand how the same view gets executed twice - once for the
loading of the html page, and a second time for the POST method after
submitting. Also, should the unbound form logic not be above the POST
logic?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Pseudo OneToOneFields

2008-12-21 Thread Brent Hagany

Hi there.  I'm not looking for a fully definite answer here
necessarily, but I am searching for input on the best way to attack
this problem.  Here it is, somewhat abstracted so that you don't have
to wrap your head around my problem domain:

Let's say I've got two models -

ModelOne(models.Model):
some_field = models.CharField(max_length=10)

ModelTwo(models.Model):
f_key = models.ForeignKey(ModelOne)
is_current = models.BooleanField(default=True)

I didn't bother reproducing a custom manager I've written that ensures
that only one ModelTwo has is_current = True for each set of ModelTwos
that all refer to the same ModelOne.  So, take it as a given that
ModelTwo.objects.filter(f_key=some_int, is_current=True) will return
no more than one ModelTwo every time.

Now, what this means is that ModelOne has a *conceptual* one-to-one
relationship with ModelTwo, because I almost never want ModelTwos that
have is_current=False (I keep them around because I need the history
at unpredictable times).  I'd like to be able to express this in the
code somehow, both for a cleaner, more intuitive interface, and
because I'd like to access ModelTwos (with is_current=True) through
ModelOnes without doing an extra query.

I have a few ideas about how to go about this, but I'm relatively new
at this level of Django customization, and I find myself running in
circles.  Here are my general ideas for implementing what I want (and
no guarantees that these are even possible):

1.  A PseudoOneToOneField.  The call would look something like:
modeltwo = PseudoOneToOneField("ModelTwo", conditions={'is_current':
True}).  I kind of like this one because it's very generic, and can be
used in many situations (and I have more than one situation in my
app).  However, I know next to nothing about subclassing fields.

2.  Subclass QuerySet.  I don't know exactly how, but I feel as though
it should be possible to make a QuerySet that will do this in one
query.  I think this might require a new QuerySet for each model I
want to modify, though.

3.  A custom Manager.  I've made one custom manager, but I don't know
the limits of their capabilities.  Can they modify a query deeply
enough for this?

4.  Custom SQL.  Not a real problem, but I just try to avoid this, if
it's possible, and I've been successful so far.  Plus, my dev and prod
environments are on different backends (not my choice).

Opinions and educational rants welcome.  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
-~--~~~~--~~--~--~---



Ordering by foreign key object field

2008-12-21 Thread sunn

from django.db import models

class Page(models.Model):
sortorder = models.IntegerField()
parent = models.ForeignKey('self', null=True, blank=True)
class Meta:
ordering = ['sortorder']
def __unicode__(self):
return self.display

class Block(models.Model):
sortorder = models.IntegerField()
page = models.ForeignKey('Page')
class Meta:
order_with_respect_to = 'page'
ordering = ['sortorder']
def __unicode__(self):
return self.page.display + " - " + self.display

I would like to order my Block objects by first page.sortorder and
then sortorder. Any idea on how to accomplish this?
I have tried with ordering = ['page.sortorder', 'sortorder'] but this
does not work ("ordering" refers to "page.sortorder", a field that
doesn't exist).
--~--~-~--~~~---~--~~
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: Ordering by foreign key object field

2008-12-21 Thread Malcolm Tredinnick

On Sun, 2008-12-21 at 23:07 -0800, sunn wrote:

[...]
> I would like to order my Block objects by first page.sortorder and
> then sortorder. Any idea on how to accomplish this?
> I have tried with ordering = ['page.sortorder', 'sortorder'] but this
> does not work ("ordering" refers to "page.sortorder", a field that
> doesn't exist).

You're close:

ordering = ['page__sortorder', 'sortorder']

You refer to related fields for ordering using the same syntax as in
filter() calls. The documentation for that (including ordering by
related fields) is here:

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

Regards,
Malcolm



--~--~-~--~~~---~--~~
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: Ordering by foreign key object field

2008-12-21 Thread sunn

Thanks!

On Dec 22, 10:16 am, Malcolm Tredinnick 
wrote:
> On Sun, 2008-12-21 at 23:07 -0800, sunn wrote:
>
> [...]
>
> > I would like to order my Block objects by first page.sortorder and
> > then sortorder. Any idea on how to accomplish this?
> > I have tried with ordering = ['page.sortorder', 'sortorder'] but this
> > does not work ("ordering" refers to "page.sortorder", a field that
> > doesn't exist).
>
> You're close:
>
> ordering = ['page__sortorder', 'sortorder']
>
> You refer to related fields for ordering using the same syntax as in
> filter() calls. The documentation for that (including ordering by
> related fields) is here:
>
> http://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by-f...
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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: Understanding the execution logic of a view

2008-12-21 Thread Daniel Roseman

On Dec 22, 5:20 am, eldonp2  wrote:
> Please help me understand the execution logic of a view. I have copied
> the example from the official Django documentation:
>
> def contact(request):
>     if request.method == 'POST': # If the form has been submitted...
>         form = ContactForm(request.POST) # A form bound to the POST
> data
>         if form.is_valid(): # All validation rules pass
>             # Process the data in form.cleaned_data
>             # ...
>             return HttpResponseRedirect('/thanks/') # Redirect after
> POST
>     else:
>         form = ContactForm() # An unbound form
>
>     return render_to_response('contact.html', {
>         'form': form,
>     })
>
> Lets imagine that I have clicked on a url that is mapped to the
> contact view. Is this the correct execution logic:
>
> 1. The else part will execute and create an unbound ContactForm
> instance that will be passed to the contact.html template
> 2. When the user clicks submit, the POST method will be executed, and
> the user will be redirected to the url '/thanks/'
>
> Please let me know if this is incorect? I'm just struggling to
> understand how the same view gets executed twice - once for the
> loading of the html page, and a second time for the POST method after
> submitting. Also, should the unbound form logic not be above the POST
> logic?

Yes, that's correct. The key is in the actual HTML - this is the
recommended way to display a form:

So the 'action' of the form, which is the URL the data is POSTed to,
is the same as the URL used to display the form in the first place.
This is why you the same view is executed twice.

You don't need to do it this way - you could set action to a different
URL and keep the processing logic there, separate from the display
logic - but then you'd need to handle the third case when the form is
submitted, but is invalid and needs redisplaying with errors. The
pattern above handles that neatly.

--
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-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: Post tutorial help needed - generic.create_update.create_object

2008-12-21 Thread Daniel Roseman

On Dec 22, 4:49 am, "Greg Schwimer"  wrote:
> On Sun, Dec 21, 2008 at 1:47 PM, Daniel Roseman <
>
> roseman.dan...@googlemail.com> wrote:
>
> > You won't see errors because you haven't included them in your
> > template. Either render the whole form with {{ form.as_p }} - which
> > will render the errors as well - or for each field include a reference
> > to that field's errors - {{ form.fieldname.errors }} - plus
> > {{ form.non_field_errors }} at the top of the form
>
> Yes, that showed me the errors.  Very helpful.
>
>
>
> > If you've got a non-blank field in your model that you don't want to
> > display in your form, make sure you include it in the exclude list in
> > the inner Meta class. Then set it the value manually in your view.
>
> > class MyForm(forms.ModelForm):
> >    class Meta:
> >         exclude=['pub_date']
>
> So I put this in my model directly?  Under the class definition, or?

No, it's a separate class. Put it wherever you like - it's often put
in a separate forms.py, but it just needs to be somewhere you can
import it.
BTW, I missed off a line - there should be
model=Poll
at the end, at the same indentation level as exclude.

>
> > ... in the view ...
> > if request.method=='POST':
> >    form = MyForm(request.POST)
> >    if form.is_valid()
> >        new_obj = form.save(commit=True)
> >        new_obj.pub_date=datetime.date.today()
> >        new_obj.save()
>
> OK, I get that, but I'm trying to use the generic views, so is this
> applicable to my use case?

That does make it tricky. You can pass the form in as a parameter via
the URL, but that won't help with the post-save customisation.

One possibility is to 'wrap' the generic view in a custom view. James
Bennett wrote a good blog post about this a couple of years ago:
http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-generic-views/
--
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-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: Keeping order with order_by while using id__in

2008-12-21 Thread Raisins

Thanks for the in depth feedback about what is going on with the
order.

Also thanks for the code snippet. I ended up doing something very
similar.

On Dec 21, 8:16 pm, Malcolm Tredinnick 
wrote:
> On Sun, 2008-12-21 at 08:58 -0800, Raisins wrote:
> > i = [ 1, 5,2,6]
> > Model.objects.filter(id__in = i)
>
> > This currently will order them by id, even if i call order_by()  with
> > no parameters. The docs say "If you don't want any ordering to be
> > applied to a query, not even the default ordering, call order_by()
> > with no parameters."
>
> > Is there  a way to maintain the order I have in the list?
>
> There is no ordering going on here. The results are coming back in
> whatever (arbitrary) order they are stored in the database, which is
> often the order in which they were inserted (although not always,
> particularly with PostgreSQL). The database doesn't pull out the results
> one at a time in the order you specify them. It finds the intersection
> between your list of values and those that are available as rows in the
> database and does no further sorting (SQL is primarily set operations,
> after all).
>
> I'm only going into all that detail so that you can see what's really
> going on here. The point being that there's no ordering at all going on.
>
> There isn't any way with Django's ORM (or standard SQL -- although, from
> memory, some databases have extensions that might allow this) to specify
> the ordering you're after here. However, it's not too hard to do this in
> Python. Here's one (untested, but it should be close) approach:
>
>         id_list = [1, 5, 2, 6]
>         qs = Model.objects.filter(id__in=id_list)
>         index = dict([(id, pos) for (pos, id) in enumerate(id_list)])
>         result = [None] * len(id_list)
>         for obj in qs:
>             result[index[obj.id]] = obj
>
> The "result" list will be the sorted results. There are some alternative
> approaches as well, but that should give you a starting point.
>
> Regards,
> Malcolm
>
>
--~--~-~--~~~---~--~~
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: Problem with url tag

2008-12-21 Thread patrick91

On 22 Dic, 02:17, Malcolm Tredinnick  wrote:
> Certainly a bit unexpected. Can you paste the relevant lines from your
> URL Conf file, please?
>
> Regards,
> Malcolm

Sure :)
here it is:
url(r'foglio/(?P[0-9]+)/$', views.show_worksheet,
name='show_worksheet'),

Thanks for the reply
--~--~-~--~~~---~--~~
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: Language code prefix in url

2008-12-21 Thread Tirta K. Untario
Wow, this is exactly what I'm looking for. I'm gonna try this app soon. Thanks!

--Tirta 
-Original Message-
From: Malcolm Tredinnick 

Date: Mon, 22 Dec 2008 15:26:42 
To: 
Subject: Re: Language code prefix in url



On Sun, 2008-12-21 at 19:52 -0800, Tirta K. Untario wrote:
> Hi all, I'm new to Django, and trying to port my old site to Django for 
> practice purpose.
> 
> Different from Django multilingual implementation by using cookie, I want to 
> add lang code to every url, i.e:
> 
> /en/my_app/something_here/1/2/3/4/
> /de/my_app/something_here/1/2/3/4/
> /fr/my_app/something_here/1/2/3/4/
> 
> The main reason I do this if for Google to index more pages from my site. I 
> don't want Google to index just the English version (default language), but I 
> think that what will happen if I use cookies.
> 
> I hope this approcae can be integrated with pre-existing Django apps without 
> much hassles. I currently in fond of flatpages :)
> 
> Do anyone have any idea on how to do this? TIA.

Joost Cassee's localeurl project
(http://code.google.com/p/django-localeurl/ ) is one approach to this
problem that seems fairly well thought out.

Regards,
Malcolm





--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---