Re: serving root from static

2008-06-09 Thread Andre Meyer
thanks a lot, Colin, i will contact the WebFaction guys for the apache
setup. they are always very helpful ;-)

HOWEVER: for testing purposes only, using only runserver and sqlite, how to
preceed for making this work?

*http://localhost:8000/ --> static/index.html (NOT a
template)
*http:// localhost:8000
myapp1   -->
myapp1/index.html (a template)
http:// localhost:8000
/myapp2   -->
myapp2/index.html (a template)
http:// localhost:8000
/admin   --> the admin
interface

how to get the first url work with runserver? i can only get it to render a
template, but not server up an html file from the static directory.

thanks again
André


On Tue, Jun 10, 2008 at 1:34 AM, Colin Bean <[EMAIL PROTECTED]> wrote:

>
> On Mon, Jun 9, 2008 at 3:25 PM, Andre Meyer <[EMAIL PROTECTED]>
> wrote:
> > thanks Jeff
> >
> > yes, i had found this method of having django serve static content, too,
> and
> > know it is not ideal.
> >
> > what i want is different: use apache for serving the static content at
> the
> > root of the site (defind in settings.py and urls.py) and have a couple of
> > django apps which are accessible just with simple paths. the urls are
> what
> > disturbs me, because i cannot get anything from just http://mysite.org/,
> but
> > instead need to access http://mysite.org/myproject.
> >
> > again, the non-functional code (raises "TemplateDoesNotExist at
> > /static/index.html" in views):
> >
> > urls.py
> >
> > urlpatterns = patterns('myproject.views',
> > (r'^$', 'home')
> >
> > views.py
> >
> > def home(request):
> > return render_to_response('static/index.html')
> >
> > maybe use something like
> > return HttpResponse('/static/index.html')
> > but how?
> >
> >
>
> Hi Andre,
>
> You'll need to set this up in your apache configuration, and the part
> that deals with serving static files is going to be independent of any
> django code or settings.
>
> You just need to change the DocumentRoot of your site to the "static"
> directory where your index.html is located.  It sounds like you've
> already got django set up to serve the "myproject" directories, so
> you're pretty close.  Don't know how apache setup works at WebFaction,
> but if you're having trouble you should post the relevant sections
> from your apache configuration (if possible).
>
> A quick read over the apache docs will explain this much more
> thourghly than I did :)  If there's one concept to take away, remember
> that if apache's serving a static file, apache handles absolutely
> every step of the process, and if python/django got involved in any
> way you'd lose the performance benefit of serving directly from from
> apache.
>
> Colin
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: raise AlreadyRegistered

2008-06-09 Thread Russell Keith-Magee

On Tue, Jun 10, 2008 at 6:32 AM, Andre Meyer <[EMAIL PROTECTED]> wrote:
> hi all
>
> i was trying to write a little script to populate my database with test data
> after i have rebuilt it due to model changes. it seems to work (set the path
> and imports appropriately), but i get this infamous
> django.contrib.admin.sites.AlreadyRegistered error when running the script.
>
> is there any news on whether this error can be removed or is there a better
> way to populate the database?

It's a know problem, logged as ticket #6776. Fixing this is a blocker
on merging newforms admin, so I'd be expecting a fix sooner rather
than later.

The ticket has some patches attached; I haven't tried them myself, but
they might be worth a try.

If you want the cheap fix, you can hack the line in newforms-admin
that raises the exception. As I understand it, removing the exception
won't actually break anything - it just means that you won't be warned
if you register an application multiple times with conflicting
settings.

The other workaround is to be rigorous with your imports. The common
cause here is having references to

from myproject.myapp.models import MyModel

and

from myapp.models import MyModel

in the same body of code. This causes two separate imports, which
causes a clash on admin regsistration. If you are rigorous about only
using one form of import (I suggest the second), you can avoid a lot
of the registration problems.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: raise AlreadyRegistered

2008-06-09 Thread Andre Meyer
On Tue, Jun 10, 2008 at 12:32 AM, Andre Meyer <[EMAIL PROTECTED]>
wrote:

> hi all
>
> i was trying to write a little script to populate my database with test
> data after i have rebuilt it due to model changes. it seems to work (set the
> path and imports appropriately), but i get this infamous
> django.contrib.admin.sites.AlreadyRegistered error when running the script.
>
> is there any news on whether this error can be removed or is there a better
> way to populate the database?
>
> thanks
> André
> **



btw i am using the newforms-admin branch and here is the code:

#!/usr/bin/env python

import myproject
import os
os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'

from datetime import datetime
from myapp.models import Task
from django.contrib.auth.models import User

user = User.objects.get(username='andre')

t1 = Task()
t1.title = 'first task'
t1.user = user
t1.save()

and here is the error message:

Traceback (most recent call last):
  File "mock_db.py", line 11, in 
user = User.objects.get(username='andre')
  File "E:\projects\django\newforms-admin\django\db\models\manager.py", line
82,
 in get
return self.get_query_set().get(*args, **kwargs)
  File "E:\projects\django\newforms-admin\django\db\models\query.py", line
191,
in get
clone = self.filter(*args, **kwargs)
  File "E:\projects\django\newforms-admin\django\db\models\query.py", line
370,
in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File "E:\projects\django\newforms-admin\django\db\models\query.py", line
388,
in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File "E:\projects\django\newforms-admin\django\db\models\sql\query.py",
line 1
068, in add_q
can_reuse=used_aliases)
  File "E:\projects\django\newforms-admin\django\db\models\sql\query.py",
line 9
60, in add_filter
alias, True, allow_many, can_reuse=can_reuse)
  File "E:\projects\django\newforms-admin\django\db\models\sql\query.py",
line 1
097, in setup_joins
field, model, direct, m2m = opts.get_field_by_name(name)
  File "E:\projects\django\newforms-admin\django\db\models\options.py", line
249
, in get_field_by_name
cache = self.init_name_map()
  File "E:\projects\django\newforms-admin\django\db\models\options.py", line
276
, in init_name_map
for f, model in self.get_all_related_m2m_objects_with_model():
  File "E:\projects\django\newforms-admin\django\db\models\options.py", line
349
, in get_all_related_m2m_objects_with_model
cache = self._fill_related_many_to_many_cache()
  File "E:\projects\django\newforms-admin\django\db\models\options.py", line
363
, in _fill_related_many_to_many_cache
for klass in get_models():
  File "E:\projects\django\newforms-admin\django\db\models\loading.py", line
134
, in get_models
self._populate()
  File "E:\projects\django\newforms-admin\django\db\models\loading.py", line
55,
 in _populate
self.load_app(app_name, True)
  File "E:\projects\django\newforms-admin\django\db\models\loading.py", line
70,
 in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "E:\projects\django\pastiche\..\pastiche\dada\models.py", line 127,
in 
admin.site.register(Item, ItemOptions)
  File "E:\projects\django\newforms-admin\django\contrib\admin\sites.py",
line 8
0, in register
raise AlreadyRegistered('The model %s is already registered' %
model.__name_
_)
django.contrib.admin.sites.AlreadyRegistered: The model Item is already
register
ed

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why my django site doesn't create .pyc file?

2008-06-09 Thread Jeff Anderson
Scott Moonen wrote:
>> I think this way, apache could be a little more faster. Am I right?
>>
>> 
>
> I don't think it will be faster.  Django normally runs as a long-standing
> process (either inside Apache or as a standalone process, depending on the
> deployment model you've chosen).  So, unlike ordinary CGI scripts, your
> Python bytecode will not need to be generated except for the very first time
> that your code is loaded.  Once it's up and running it will already be in
> memory so it won't need to be reinterpreted.
>   
When I first noticed that mod_python didn't seem to spit out .pyc files,
I figured that this was a "feature" because of its one-time loading
nature. I kind of liked the concept because .pyc files seem like clutter
sometimes. Good to know that my assumption was wrong. I'm going to keep
my permissions the way that they are. :)



signature.asc
Description: OpenPGP digital signature


Re: why my django site doesn't create .pyc file?

2008-06-09 Thread pength

Tim and Scott, thank you very much!

On Jun 9, 10:03 pm, Tim Chase <[EMAIL PROTECTED]> wrote:
> >> I think this way, apache could be a little more faster. Am I
> >> right?
>
> > I don't think it will be faster.  Django normally runs as a
> > long-standing process (either inside Apache or as a standalone
> > process, depending on the deployment model you've chosen).
> > So, unlike ordinary CGI scripts, your Python bytecode will not
> > need to be generated except for the very first time that your
> > code is loaded.  Once it's up and running it will already be
> > in memory so it won't need to be reinterpreted.
>
> If you want, you can pre-compile everything as described at
>
>http://effbot.org/pyfaq/how-do-i-create-a-pyc-file.htm
>
> which shows you can issue
>
>bash$ cd ~/code
>bash$ python -m compileall .
>[output]
>
> which will compile each .py file into a corresponding .pycfile
> within the current directory and subdirectories.  I believe the
> Debian variants (others may as well) do this in the system
> directories upon installation so users don't have to recompile
> all the system libraries.
>
> The time saved is minimal, but there's no harm in preemptively
> compiling your files.
>
> -tim
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django and mysql SET datatype?

2008-06-09 Thread Silfheed

Heyas

So we have a table which makes use of mysql's SET datatype to store
the status of a page ('active','inappropriate','optout') with the
status being any combination of the three.  This helps us keep the
complexity of our schemas down since we just need one column (rather
than 3 tables) to represent our status.  Unfortunatly, Django doesnt
have anything in django.models to handle sets.  It does have
CommaSeparatedIntegerField, but it means having to store ints rather
than more descriptive texts.

Does anyone else out there happen to be using mysql SET+django and
have an elegant method for handling the situation?

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Choose the fields for inline editing

2008-06-09 Thread Cliff

Hi,
I really like the inline editing option, but found that sometimes I
don't want to list all the attributes of an object for inline editing.
I guess there is a way to do this, but I cannot find it. Really
appreciate if someone can help me out.
Thanks
Cliff
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: serving root from static

2008-06-09 Thread Colin Bean

On Mon, Jun 9, 2008 at 3:25 PM, Andre Meyer <[EMAIL PROTECTED]> wrote:
> thanks Jeff
>
> yes, i had found this method of having django serve static content, too, and
> know it is not ideal.
>
> what i want is different: use apache for serving the static content at the
> root of the site (defind in settings.py and urls.py) and have a couple of
> django apps which are accessible just with simple paths. the urls are what
> disturbs me, because i cannot get anything from just http://mysite.org/, but
> instead need to access http://mysite.org/myproject.
>
> again, the non-functional code (raises "TemplateDoesNotExist at
> /static/index.html" in views):
>
> urls.py
>
> urlpatterns = patterns('myproject.views',
> (r'^$', 'home')
>
> views.py
>
> def home(request):
> return render_to_response('static/index.html')
>
> maybe use something like
> return HttpResponse('/static/index.html')
> but how?
>
>

Hi Andre,

You'll need to set this up in your apache configuration, and the part
that deals with serving static files is going to be independent of any
django code or settings.

You just need to change the DocumentRoot of your site to the "static"
directory where your index.html is located.  It sounds like you've
already got django set up to serve the "myproject" directories, so
you're pretty close.  Don't know how apache setup works at WebFaction,
but if you're having trouble you should post the relevant sections
from your apache configuration (if possible).

A quick read over the apache docs will explain this much more
thourghly than I did :)  If there's one concept to take away, remember
that if apache's serving a static file, apache handles absolutely
every step of the process, and if python/django got involved in any
way you'd lose the performance benefit of serving directly from from
apache.

Colin

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django graphic designers

2008-06-09 Thread John M

There are a TON of free resources for all of that, let me see if I can
post a few for u .

http://www.cssbeauty.com/
http://www.templatesbox.com/
http://vyk1.spaces.live.com/Blog/cns!EBE3A761F939F926!1051.entry
http://www-128.ibm.com/developerworks/library/wa-freeweb/

Good Luck


On Jun 9, 3:37 pm, Juanjo Conti <[EMAIL PROTECTED]> wrote:
> I'd like to know if there is a community of graphic designers working
> with django. Maybe a website with resources (css, html tamplates...)?
>
> I am writing a little personal app and it looks really ugly :)
>
> One of my options is to hire a designer, but I would prefer to hire one
> with Django knowledges.
>
> Juanjo
> --
> mi blog:http://www.juanjoconti.com.ar
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "intro to django" script -

2008-06-09 Thread John M

Also, the week in django has some really good webcasts, maybe we could
get them to post it to your website?

http://blog.michaeltrier.com/2008/6/9/this-week-in-django-25-2008-06-08

On Jun 9, 8:04 am, Carl Karsten <[EMAIL PROTECTED]> wrote:
> I want to make ahttp://showmedo.com"Getting started with Django"
>
> I expect it to be about 5 min long.  The goal is not show someone how to be
> productive, but how easy it is to get started.
>
> At most 1 min on install python, install django, make sure you can do python 
> -c
> "import django" without error.
>
> Then some magic, python manage.py runserver, browse, “Welcome to Django”
>
> Then some more magic, syncdb,http://127.0.0.1:8000/admin/"log in"
>
> Then define a model, view, html, url pattern.  maybe even a public facing 
> form.
>
> I am a bit fuzzy on what is considered 'best practices' for the 2 magic parts.
>   I hear what the tutorial/book describes (django-admin.py startproject 
> mysite;
> startapp myapp) isn't what the the pros do now, or at least what the pros 
> would
> recommend.  What I haven't heard is an alternative.
>
> I am tempted to show creating all the files by hand.  (I can't do it all in 5
> minutes, but some Julia Child moves and sped up video should make it faster 
> than
> explaining what startproject and startapp do.)
>
> Any suggestions?  Any writeups that cover this?
>
> Carl K
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Testing framework or model save behaves differently after qsrf merge?

2008-06-09 Thread peschler

I'm currently facing a weird problem with the testing framework after
updating to the latest trunk version of the newforms-admin branch. I
have written a small example and a unittest to explain the issue and
to show that there seems to be some sort of problem after the qsrf
merge. I'm not quite sure where the problem is - unittest or qsrf -
that's why i post.

Below are two simple models Vocabulary and Term. A vocabulary contains
terms. When a new vocabulary is created (saved the first time), it
automatically creates a root term for the vocabulary.
Both models overload the save() method.

Running the unittest given below with django 0.97-newforms-admin-
SVN-7233 all tests pass fine.

When running the unittest given below with django 0.97-newforms-admin-
SVN-7599 the tests give the following error:

==
FAIL: test_qsrf (nmy.qsrftest.tests.QsrfTestCase)
--
Traceback (most recent call last):
  File "/home/peter/src/nmy/site-packages/nmy/qsrftest/tests.py", line
27, in test_qsrf
self.failUnlessEqual(v.root, v.root.vocabulary.root)
AssertionError:  != None

--

I tried to track down the problem, checked my unittest, checked my
models - but the only thing I could find is weird: As soon as I
reference the ``vocabulary`` field in a term's save() method the test
fails. If I remove all references to the ``vocabulary`` field from the
save() method the tests pass fine.
I found that a simple read-only operation like print or even a simple
noop reference of the ``vocabulary`` field changes the behaviour of
the unittest.

--- qsrftest/models.py
from django.db import models

class Vocabulary(models.Model):
root = models.ForeignKey('Term', null=True, blank=True,
related_name='root_of')

def save(self):
"""When a vocabulary is saved and it has no root term, a new
root
term is created. This happens only the first time a vocabulary
is
saved.
"""
super(Vocabulary, self).save()

if not self.root:
self.root = Term.objects.create(vocabulary=self)
super(Vocabulary, self).save()

class Term(models.Model):
vocabulary = models.ForeignKey(Vocabulary)

def save(self):
 super(Term, self).save()

 # As soon as self.vocabulary is referenced here, the unittest
fails.
 # It does not matter if the self.vocabulary is printed, used
or changed.
 # Any of the following will make the unittest fail with
r7599!
 #print "term.vocabulary:", self.vocabulary
 self.vocabulary

---
--- qsrftest/tests.py
import unittest

from qsrftest.models import Vocabulary, Term

class QsrfTestCase(unittest.TestCase):

def test_qsrf(self):
v = Vocabulary.objects.create()

# Check if the new vocabulary has a root term
self.failUnless(v.root != None,
'A newly created vocabulary must have a root
term.')

# Check that the root item is associated to the vocabulary.
self.failUnlessEqual(v, v.root.vocabulary,
'The vocabulary of the implicity created root
term must'\
'be set. %s != %s'\
 % (v, v.root.vocabulary))

# Check cyclic correctness. This test succeeds with r7433 and
fails
# with r7599 when the ``vocabulary`` field is referenced in
the
# term's save() method.
self.failUnlessEqual(v.root, v.root.vocabulary.root)
---


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Bug in sqlite backend? Custom query gives OperationalError

2008-06-09 Thread Michael P. Soulier
Pong wrote:
> Hi,
> 
> what is wrong with this query?
> 
> user_id_tuple = (2, 3, 25, 15) # for example
> cursor = connection.cursor()
> cursor.execute(SELECT
> week, year, SUM(data), SUM(data1), SUM(data2),
> SUM(data3),
> SUM(data4) FROM user_table
> WHERE user_id IN %s GROUP BY week, year
> ORDER BY year, week""" , [user_id_tuple])
> 
> Django gives me OperationalError when I try to run it. I tried the
> same query with mysql on different server(same django version) and it
> worked great.

Since you're talking about the sqlite backend, did you try this on the
sqlite command-line?

Mike
-- 
Michael P. Soulier <[EMAIL PROTECTED]>
"Any intelligent fool can make things bigger and more complex... It
takes a touch of genius - and a lot of courage to move in the opposite
direction." --Albert Einstein



signature.asc
Description: OpenPGP digital signature


Django graphic designers

2008-06-09 Thread Juanjo Conti

I'd like to know if there is a community of graphic designers working 
with django. Maybe a website with resources (css, html tamplates...)?

I am writing a little personal app and it looks really ugly :)

One of my options is to hire a designer, but I would prefer to hire one 
with Django knowledges.

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



raise AlreadyRegistered

2008-06-09 Thread Andre Meyer
hi all

i was trying to write a little script to populate my database with test data
after i have rebuilt it due to model changes. it seems to work (set the path
and imports appropriately), but i get this infamous
django.contrib.admin.sites.AlreadyRegistered error when running the script.

is there any news on whether this error can be removed or is there a better
way to populate the database?

thanks
André

**

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: serving root from static

2008-06-09 Thread Andre Meyer
thanks Jeff

yes, i had found this method of having django serve static content, too, and
know it is not ideal.

what i want is different: use apache for serving the static content at the
root of the site (defind in settings.py and urls.py) and have a couple of
django apps which are accessible just with simple paths. the urls are what
disturbs me, because i cannot get anything from just http://mysite.org/, but
instead need to access http://mysite.org/myproject.

again, the non-functional code (raises "TemplateDoesNotExist at
/static/index.html"
in views):

urls.py

urlpatterns = patterns('myproject.views',
(r'^$', 'home')

views.py

def home(request):
return render_to_response('static/index.html')

maybe use something like
return HttpResponse('/static/index.html')
but how?


On Thu, Jun 5, 2008 at 6:07 PM, Jeff Anderson <[EMAIL PROTECTED]>
wrote:

> Andre Meyer wrote:
>
>> hi all
>>
>> is it possible to serve static files from the root of a domain name? these
>> files would either be served by apache or runserver from the static
>> directory as defined in the settings.
>>
> Yes this is possible.
>
> You don't want to have django serve static files if its running under
> apache.
> You can make django serve static files.
>
> See: http://www.djangoproject.com/documentation/static_files/
>
> Note the "Big fat disclaimer" near the top
>
>
> Jeff Anderson
>
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "intro to django" script -

2008-06-09 Thread Jeff Johnson

Carl:  There may be some useful stuff here.  Webfaction is a web hosting 
site that specializes in hosting "long processes" like Django.

http://www.webfaction.com/demos/django

I plan on getting into Django, but I just recently got a whole bunch of 
new work and can't find the time right now.

Carl Karsten wrote:
> I want to make a http://showmedo.com "Getting started with Django"
> 
> I expect it to be about 5 min long.  The goal is not show someone how to be 
> productive, but how easy it is to get started.
> 
> At most 1 min on install python, install django, make sure you can do python 
> -c 
> "import django" without error.
> 
> Then some magic, python manage.py runserver, browse, “Welcome to Django”
> 
> Then some more magic, syncdb, http://127.0.0.1:8000/admin/ "log in"
> 
> Then define a model, view, html, url pattern.  maybe even a public facing 
> form.
> 
> I am a bit fuzzy on what is considered 'best practices' for the 2 magic 
> parts. 
>   I hear what the tutorial/book describes (django-admin.py startproject 
> mysite; 
> startapp myapp) isn't what the the pros do now, or at least what the pros 
> would 
> recommend.  What I haven't heard is an alternative.
> 
> I am tempted to show creating all the files by hand.  (I can't do it all in 5 
> minutes, but some Julia Child moves and sped up video should make it faster 
> than 
> explaining what startproject and startapp do.)
> 
> Any suggestions?  Any writeups that cover this?
> 
> Carl K
> 
> > 
> 

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HELP: Foreign keys, models, and querysets

2008-06-09 Thread Huuuze

Its a typo.  It should've been...

>> pid = models.ForeignKey(Person)

On Jun 9, 5:06 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> What is this `pid = models.ForiegnKey()` ?
>
> On 9 июн, 23:44, Huuuze <[EMAIL PROTECTED]> wrote:
>
> > I have the following models in my models.py file:
>
> > >> class Person(models.Model):
> > >>   pid = models.AutoField(primary_key=True)
> > >>   fname = models.CharField(max_length=50)
> > >>   lname = models.CharField(max_length=50)
> > >> class Books(models.Model)
> > >>   bid = models.AutoField(primary_key=True)
> > >>   name = models.CharField(max_length=50)
> > >>   pid = models.ForiegnKey()
>
> > In my views.py, I'd like to run a query that returns a list of people
> > and their books, where "st" are the "search terms" being passed into
> > the view:
>
> > >> results = Person.objects.filter(Q(fname__istartswith=st) | 
> > >> Q(lname__istartswith=st))
>
> > This only returns the "Person" object.  Is there a "Django-y" way to
> > have it return both associated objects?  From what I can tell, it
> > looks like I need to use "Person.objects.extra()" to tie in the
> > additional "where" statements.
>
> > I apologize in advance if I've missed something obvious.  New to
> > Django and just looking for help.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Bug in sqlite backend? Custom query gives OperationalError

2008-06-09 Thread Pong

Hi,

what is wrong with this query?

user_id_tuple = (2, 3, 25, 15) # for example
cursor = connection.cursor()
cursor.execute(SELECT
week, year, SUM(data), SUM(data1), SUM(data2),
SUM(data3),
SUM(data4) FROM user_table
WHERE user_id IN %s GROUP BY week, year
ORDER BY year, week""" , [user_id_tuple])

Django gives me OperationalError when I try to run it. I tried the
same query with mysql on different server(same django version) and it
worked great.

Part of error raport:
Exception Type: OperationalError
Exception Value:near "?": syntax error
Exception Location: C:\Python25\Django\django\db\backends
\sqlite3\base.py in execute, line 136

C:\Python25\Django\django\db\backends\util.py in execute

  11. def __init__(self, cursor, db):
  12. self.cursor = cursor
  13. self.db = db # Instance of a BaseDatabaseWrapper subclass
  14. def execute(self, sql, params=()):
  15. start = time()
  16. try:
  18. return self.cursor.execute(sql, params)

C:\Python25\Django\django\db\backends\sqlite3\base.py in execute

 129. """
 130. Django uses "format" style placeholders, but pysqlite2 uses
"qmark" style.
 131. This fixes it -- but note that if you want to use a literal "%s"
in a query,
 132. you'll need to use "%%s".
 133. """
 134. def execute(self, query, params=()):
 135. query = self.convert_query(query, len(params))

 136. return Database.Cursor.execute(self, query, params)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HELP: Foreign keys, models, and querysets

2008-06-09 Thread Alex Koshelev

What is this `pid = models.ForiegnKey()` ?

On 9 июн, 23:44, Huuuze <[EMAIL PROTECTED]> wrote:
> I have the following models in my models.py file:
>
> >> class Person(models.Model):
> >>   pid = models.AutoField(primary_key=True)
> >>   fname = models.CharField(max_length=50)
> >>   lname = models.CharField(max_length=50)
> >> class Books(models.Model)
> >>   bid = models.AutoField(primary_key=True)
> >>   name = models.CharField(max_length=50)
> >>   pid = models.ForiegnKey()
>
> In my views.py, I'd like to run a query that returns a list of people
> and their books, where "st" are the "search terms" being passed into
> the view:
>
> >> results = Person.objects.filter(Q(fname__istartswith=st) | 
> >> Q(lname__istartswith=st))
>
> This only returns the "Person" object.  Is there a "Django-y" way to
> have it return both associated objects?  From what I can tell, it
> looks like I need to use "Person.objects.extra()" to tie in the
> additional "where" statements.
>
> I apologize in advance if I've missed something obvious.  New to
> Django and just looking for help.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: HELP: Foreign keys, models, and querysets

2008-06-09 Thread Richard Dahl
from:
http://www.djangoproject.com/documentation/db-api/
 Backward

If a model has a ForeignKey, instances of the foreign-key model will have
access to a Manager that returns all instances of the first model. By
default, this Manager is named FOO_set, where FOO is the source model name,
lowercased. This Manager returns QuerySets, which can be filtered and
manipulated as described in the "Retrieving objects" section above.
 The 'Django-y' way is to access the related fields through a related
manager.  In your case Books is related to Person via pid which should have
models.ForeignKey(Person), I assume it is in your model.  So you would just
get the books related to the person via:
p = Person.objects.get(pk=1)
p.books_set.all()

Also, generally in Django, you do not necessarily need to specify the id (a
field called id will be created for you) and people usually will give
related fields names that are more descriptive of the object accessed, i.e.
:

class Person(models.Model):
fname = models.CharField(max_length=50)
lname = models.CharField(max_length=50)

class Books(models.Model)
name = models.CharField(max_length=50)
person = models.ForiegnKey(Person)

as when you use it you are getting the related objects rather than just
related ids, but this is obviously a matter of ones personal taste.
hth,
-richard


On 6/9/08, Huuuze <[EMAIL PROTECTED]> wrote:
>
>
> I have the following models in my models.py file:
>
> >> class Person(models.Model):
> >>   pid = models.AutoField(primary_key=True)
> >>   fname = models.CharField(max_length=50)
> >>   lname = models.CharField(max_length=50)
>
> >> class Books(models.Model)
> >>   bid = models.AutoField(primary_key=True)
> >>   name = models.CharField(max_length=50)
> >>   pid = models.ForiegnKey()
>
> In my views.py, I'd like to run a query that returns a list of people
> and their books, where "st" are the "search terms" being passed into
> the view:
>
> >> results = Person.objects.filter(Q(fname__istartswith=st) |
> Q(lname__istartswith=st))
>
> This only returns the "Person" object.  Is there a "Django-y" way to
> have it return both associated objects?  From what I can tell, it
> looks like I need to use "Person.objects.extra()" to tie in the
> additional "where" statements.
>
> I apologize in advance if I've missed something obvious.  New to
> Django and just looking for help.
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



HELP: Foreign keys, models, and querysets

2008-06-09 Thread Huuuze

I have the following models in my models.py file:

>> class Person(models.Model):
>>   pid = models.AutoField(primary_key=True)
>>   fname = models.CharField(max_length=50)
>>   lname = models.CharField(max_length=50)

>> class Books(models.Model)
>>   bid = models.AutoField(primary_key=True)
>>   name = models.CharField(max_length=50)
>>   pid = models.ForiegnKey()

In my views.py, I'd like to run a query that returns a list of people
and their books, where "st" are the "search terms" being passed into
the view:

>> results = Person.objects.filter(Q(fname__istartswith=st) | 
>> Q(lname__istartswith=st))

This only returns the "Person" object.  Is there a "Django-y" way to
have it return both associated objects?  From what I can tell, it
looks like I need to use "Person.objects.extra()" to tie in the
additional "where" statements.

I apologize in advance if I've missed something obvious.  New to
Django and just looking for help.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic initialization of MultipleChoiceField

2008-06-09 Thread Adi

Yeah.. you are right.. you will have to initialize the superclass..

the complete code that i have used is something like this..

class TestForm(ModelForm):
   items = forms.MultipleChoiceField( choices = (), required
=
False )



On Jun 9, 1:35 pm, puff <[EMAIL PROTECTED]> wrote:
> Isn't it necessary to initialize the super class with
>
> super(RecoverForm, self).__init__(*args, **kwargs)
>
> When I did so i got an illegal keyword argument!
>
> On Jun 9, 1:55 pm, Adi <[EMAIL PROTECTED]> wrote:
>
>
>
> > Another option would be to create a __init__ (self,choices=()) method
> > on form
> > Then in the method, assign
> > self.fields['items'].choices = choices
>
> > and when you instantiate a form, you can specify the choices
> > choices = [('1', '1'), ('2', '2')]
> > form=RecoverForm(choices)
>
> > -Adi
>
> > On Jun 9, 12:43 pm, puff <[EMAIL PROTECTED]> wrote:
>
> > > I needed to create a dynamically initialized MultipleChoiceField.
> > > Unfortunately, the Django docs when talking about initialize didn't go
> > > into how to deal with MultipleChoiceField.  A bit of scratching around
> > > didn't show a real solution although Getting dynamic model choices in
> > > newforms (http://www.djangosnippets.org/snippets/26/) is useful.  I
> > > did find a ticket (#5033: Dynamic initial values for
> > > MultipleChoiceFields in newforms) that was apparently closed for
> > > rather poor reasons.  Finally, I stumbled on this solution and am
> > > posting it here in the hope that others can find it.
>
> > > In the form:
>
> > > class RecoveryForm( forms.Form ):
> > >     items = forms.MultipleChoiceField( choices = (), required =
> > > False )
>
> > > When it comes time to use it:
> > >         choices = [('1', '1'), ('2', '2')]
> > >         form = RecoveryForm( )
> > >         form.fields[ 'items' ].choices = choices
>
> > > Problem solved.
>
> > > That said, I'm new to Django and VERY new to newforms so there may
> > > well be a better way.- 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "more than 1 ForeignKey" error in newforms-admin

2008-06-09 Thread Andre Meyer
On Mon, Jun 9, 2008 at 9:21 PM, James Bennett <[EMAIL PROTECTED]> wrote:

>
> On Mon, Jun 9, 2008 at 2:08 PM, Andre Meyer <[EMAIL PROTECTED]>
> wrote:
> > i have a model with a class that has a foreign key and a subclass that
> has
> > another. this works well for creating the database, but the admin does
> not
> > like it.
>
> I believe your problem is that support for hierarchies of subclassed
> models is still in progress. Right now, using the admin on top of such
> models doesn't work.


oh, that's why. will try to cook up some custom interface then...

thanks
André

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "more than 1 ForeignKey" error in newforms-admin

2008-06-09 Thread James Bennett

On Mon, Jun 9, 2008 at 2:08 PM, Andre Meyer <[EMAIL PROTECTED]> wrote:
> i have a model with a class that has a foreign key and a subclass that has
> another. this works well for creating the database, but the admin does not
> like it.

I believe your problem is that support for hierarchies of subclassed
models is still in progress. Right now, using the admin on top of such
models doesn't work.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



trying to modify admin

2008-06-09 Thread Adam Fraser

Hello,

I'm using Django to keep track hours spent working on "projects".  The
data model includes classes "Project" (name, description,...),
"Timecard" (user, date) , and "TimecardHours" (timecard, project,
hours).

With these models plugged in, I get a nice admin page for changing/
reviewing projects.  This includes a form for editing all of the
fields in a project (ie: name, description,...).  However, I would
like to be able to also see (not necessarily edit) 2 other things:

1: How much time was spent by each user on that project.
2: How much time was logged in each individual Timecard including that
project.

Could someone please give me an idea of what the best/easiest way to
go about this is?  Any suggestions would be much appreciated!

To give you an idea of what I had in mind.  I started modifying my
project class to have 2 new functions to give me summations of hours
by user, and hours per timecard:

def hours_per_person(self):
   '''Returns a dictionary keyed by username of how many hours each
user has worked on this project.'''
   userHours = {}
   for u in User.objects.all():
   userHours[u.username] = 0.0
   for h in TimecardHours.objects.all():
   if (h.project.id == self.id) and (h.hours > 0.0):
   for t in Timecard.objects.all():
   if h.timecard.id == t.id:
   userHours[t.user.username] += h.hours
   return userHours

def hours_per_timecard(self):
   '''Returns a dictionary keyed by "username [-mm-dd]" of how
many hours each user has worked on this project.'''
   tcHours = {}
   for t in Timecard.objects.all():
   tcHours[t.user.username+' ['+str(t.date.year)
+"-"+str(t.date.month)+"-"+str(t.date.day)+"]"] = 0.0
   for h in TimecardHours.objects.all():
   if (h.project.id == self.id) and (h.hours > 0.0):
   for t in Timecard.objects.all():
   if h.timecard.id == t.id:
   userHours[t.user.username+' ['+str(t.date.year)
+"-"+str(t.date.month)+"-"+str(t.date.day)+"]"] += h.hours
   return tcHours



...might there be a good way to use these functions to render to a
template?  I'm still quite new to Django so what might seem obvious to
others is still not quite obvious to me.

thanks much!
Adam

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with login()

2008-06-09 Thread [EMAIL PROTECTED]

And caching

On Jun 9, 2:02 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> Check if your cookies are enabled.
>
> On 9 июн, 22:47, bcrem <[EMAIL PROTECTED]> wrote:
>
> > Sorry, get_user(request) was a blind alley; I'm actually using 'user =
> > request.user' right now, and my first attempt was 'if
> > request.user.is_authenticated():' as you suggest.  Behavior's the
> > same.
>
> > On Jun 9, 2:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
>
> > > what happens when you if you try
> > > user = request.user
>
> > > or (better yet)
>
> > > if request.user.is_authenticated():
> > >    ...
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



"more than 1 ForeignKey" error in newforms-admin

2008-06-09 Thread Andre Meyer
hi all

just a quick question to be sure:

is it on purpose that newforms-admin does not allow more than one
ForeignKey? or is it a not yet supported feature?

i have a model with a class that has a foreign key and a subclass that has
another. this works well for creating the database, but the admin does not
like it.

thanks for clarification
André

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with login()

2008-06-09 Thread Alex Koshelev

Check if your cookies are enabled.

On 9 июн, 22:47, bcrem <[EMAIL PROTECTED]> wrote:
> Sorry, get_user(request) was a blind alley; I'm actually using 'user =
> request.user' right now, and my first attempt was 'if
> request.user.is_authenticated():' as you suggest.  Behavior's the
> same.
>
> On Jun 9, 2:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > what happens when you if you try
> > user = request.user
>
> > or (better yet)
>
> > if request.user.is_authenticated():
> >...
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with login()

2008-06-09 Thread bcrem

Sorry, get_user(request) was a blind alley; I'm actually using 'user =
request.user' right now, and my first attempt was 'if
request.user.is_authenticated():' as you suggest.  Behavior's the
same.

On Jun 9, 2:29 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> what happens when you if you try
> user = request.user
>
> or (better yet)
>
> if request.user.is_authenticated():
>...
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic initialization of MultipleChoiceField

2008-06-09 Thread puff

Isn't it necessary to initialize the super class with

super(RecoverForm, self).__init__(*args, **kwargs)

When I did so i got an illegal keyword argument!



On Jun 9, 1:55 pm, Adi <[EMAIL PROTECTED]> wrote:
> Another option would be to create a __init__ (self,choices=()) method
> on form
> Then in the method, assign
> self.fields['items'].choices = choices
>
> and when you instantiate a form, you can specify the choices
> choices = [('1', '1'), ('2', '2')]
> form=RecoverForm(choices)
>
> -Adi
>
> On Jun 9, 12:43 pm, puff <[EMAIL PROTECTED]> wrote:
>
> > I needed to create a dynamically initialized MultipleChoiceField.
> > Unfortunately, the Django docs when talking about initialize didn't go
> > into how to deal with MultipleChoiceField.  A bit of scratching around
> > didn't show a real solution although Getting dynamic model choices in
> > newforms (http://www.djangosnippets.org/snippets/26/) is useful.  I
> > did find a ticket (#5033: Dynamic initial values for
> > MultipleChoiceFields in newforms) that was apparently closed for
> > rather poor reasons.  Finally, I stumbled on this solution and am
> > posting it here in the hope that others can find it.
>
> > In the form:
>
> > class RecoveryForm( forms.Form ):
> > items = forms.MultipleChoiceField( choices = (), required =
> > False )
>
> > When it comes time to use it:
> > choices = [('1', '1'), ('2', '2')]
> > form = RecoveryForm( )
> > form.fields[ 'items' ].choices = choices
>
> > Problem solved.
>
> > That said, I'm new to Django and VERY new to newforms so there may
> > well be a better way.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with login()

2008-06-09 Thread [EMAIL PROTECTED]

what happens when you if you try
user = request.user

or (better yet)

if request.user.is_authenticated():
   ...


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with login()

2008-06-09 Thread bcrem

Hello,

I'm trying to set up a user login form; that's working fine, however
when I navigate after login to my home page and try to do a simple
"Hello, " I'm getting a False from user.is_authenticated().

Here're some relevant snippets:

>From the login handler:

   uName = request.POST['username']
   uPass = request.POST['password']
   user = authenticate(username=uName, password=uPass)

   if user is not None:
  if user.is_active:
 login(request, user)
 return HttpResponseRedirect(next)
  else:
 message = 'Account Deactivated'


>From the index view handler:

user = get_user(request)

if user.is_authenticated():
message = 'Welcome back!'
else:
message = 'Welcome.'

What am I missing here?  The index() function is in a separate view
file; however even if I move it to the same file as the login handler,
I get the same behavior.  Do I need to do something beyond calling
login() to make the user persistant across all request contexts?

Thanks in advance for any info...
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelChoiceField option values

2008-06-09 Thread Adi

The text displayed in the drop down comes from the __str__ method of
the referenced model.
So, just implement the __str__ method in the model that your
ModelChoiceField references, and the display will show you that.

On Jun 7, 10:55 am, Mihai Damian <[EMAIL PROTECTED]> wrote:
> I'm using a ModelChoiceField on a form and it seems the value
> attributes of the generated option tags are simply their numeric order
> in the queryset. How can I set the value attribute to some useful
> information like id or the __unicode__ representation itself?
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic initialization of MultipleChoiceField

2008-06-09 Thread Adi

Another option would be to create a __init__ (self,choices=()) method
on form
Then in the method, assign
self.fields['items'].choices = choices

and when you instantiate a form, you can specify the choices
choices = [('1', '1'), ('2', '2')]
form=RecoverForm(choices)

-Adi

On Jun 9, 12:43 pm, puff <[EMAIL PROTECTED]> wrote:
> I needed to create a dynamically initialized MultipleChoiceField.
> Unfortunately, the Django docs when talking about initialize didn't go
> into how to deal with MultipleChoiceField.  A bit of scratching around
> didn't show a real solution although Getting dynamic model choices in
> newforms (http://www.djangosnippets.org/snippets/26/) is useful.  I
> did find a ticket (#5033: Dynamic initial values for
> MultipleChoiceFields in newforms) that was apparently closed for
> rather poor reasons.  Finally, I stumbled on this solution and am
> posting it here in the hope that others can find it.
>
> In the form:
>
> class RecoveryForm( forms.Form ):
>     items = forms.MultipleChoiceField( choices = (), required =
> False )
>
> When it comes time to use it:
>         choices = [('1', '1'), ('2', '2')]
>         form = RecoveryForm( )
>         form.fields[ 'items' ].choices = choices
>
> Problem solved.
>
> That said, I'm new to Django and VERY new to newforms so there may
> well be a better way.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Dynamic initialization of MultipleChoiceField

2008-06-09 Thread puff

I needed to create a dynamically initialized MultipleChoiceField.
Unfortunately, the Django docs when talking about initialize didn't go
into how to deal with MultipleChoiceField.  A bit of scratching around
didn't show a real solution although Getting dynamic model choices in
newforms (http://www.djangosnippets.org/snippets/26/) is useful.  I
did find a ticket (#5033: Dynamic initial values for
MultipleChoiceFields in newforms) that was apparently closed for
rather poor reasons.  Finally, I stumbled on this solution and am
posting it here in the hope that others can find it.

In the form:

class RecoveryForm( forms.Form ):
items = forms.MultipleChoiceField( choices = (), required =
False )

When it comes time to use it:
choices = [('1', '1'), ('2', '2')]
form = RecoveryForm( )
form.fields[ 'items' ].choices = choices

Problem solved.

That said, I'm new to Django and VERY new to newforms so there may
well be a better way.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and i18n

2008-06-09 Thread Taevin

Forgot about this for a while... Thanks for that, though.

In reading through the code on that site, I came across the
translation.activate function which is exactly what I needed. Now,
instead of forcing a page refresh, I can just do:

from django.utils.translation import activate

and then just call:
activate(session_language_code)

Thanks again!

On May 31, 3:24 pm, yml <[EMAIL PROTECTED]> wrote:
> hello,
> I have been using this recipe for some times 
> :http://yml-blog.blogspot.com/search/label/Internationalisation
> It seems to exactly answer your requirements.
> I hope that helps.
> --yml
>
> On May 30, 6:09 pm, Taevin <[EMAIL PROTECTED]> wrote:
>
> > I've been working with translation in Django and it mostly works but
> > I'm wondering if there is a 'cleaner' way of doing things.  That is,
> > here is what I seem to have to do to get a page translated into the
> > correct language:
>
> > URLs are of the form $domain/$language_code/$page 
> > (e.g.www.example.com/en/index
> > orwww.example.com/fr/index).
>
> > 1. Look for a language code in the URL.
> > 2. Check the user's session for an existing django_language setting.
> > 3. Compare the two (and include edge cases for None with either).
> > 3.a. If equal, language is the same, just display the page.
> > 3.b. If not equal, set the django_language setting to the language
> > code from the URL and then redirect the page to the same URL (this is
> > the part that I'm wanting to fix).
>
> > In other words, is there a way to immediately set the translation
> > language for the output without a page refresh?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: foreign key and verbose name?

2008-06-09 Thread Alex Koshelev

That fields accepts `model class` as first argument which is more
important then `verbose_name` in this case.

On Jun 9, 8:10 pm, pihentagy <[EMAIL PROTECTED]> wrote:
> Hi all!
>
> In the docs 
> here:http://www.djangoproject.com/documentation/model-api/#verbose-field-n...
>
> Each field type, except for ForeignKey, ManyToManyField and
> OneToOneField, takes an optional first positional argument — a verbose
> name. If the verbose name isn’t given, Django will automatically
> create it using the field’s attribute name, converting underscores to
> spaces.
>
> Is there a good reason to handle the verbose name differently in these
> cases? (Is there a chance it will behave as expected, like other field
> types?)
>
> thanks
> Gergo
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Painfully slow... why?

2008-06-09 Thread [EMAIL PROTECTED]


> What's up with that second line?  Are you doing anything fancy?
>
Second line is (as i recall) a large dataset where I get values only.
That helped a lot, actually, to bring that particular page times down.
It was in the 2 second range.
The thing is, when I say painfully slow, I'm talking from 20--60
seconds from click to page render. It varies alot -- sometimes it
really flies, but when it's slow, it's really, really, really slow.
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Painfully slow... why?

2008-06-09 Thread David Zhou

On Jun 9, 2008, at 12:09 PM, [EMAIL PROTECTED] wrote:

> I'm trying desparately to figure out why my django sites are so slow.
> Using the statsmiddleware, I'm seeing numbers like this:
>
> Stats: Total: 0.08 Python: 0.07 DB: 0.01 Queries: 6
> Stats: Total: 0.48 Python: 0.37 DB: 0.11 Queries: 3
> Stats: Total: 0.21 Python: 0.17 DB: 0.05 Queries: 32
> Stats: Total: 0.27 Python: 0.22 DB: 0.05 Queries: 32

What's up with that second line?  Are you doing anything fancy?

---
David Zhou
[EMAIL PROTECTED]




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



foreign key and verbose name?

2008-06-09 Thread pihentagy

Hi all!

In the docs here:
http://www.djangoproject.com/documentation/model-api/#verbose-field-names

Each field type, except for ForeignKey, ManyToManyField and
OneToOneField, takes an optional first positional argument — a verbose
name. If the verbose name isn’t given, Django will automatically
create it using the field’s attribute name, converting underscores to
spaces.

Is there a good reason to handle the verbose name differently in these
cases? (Is there a chance it will behave as expected, like other field
types?)

thanks
Gergo
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Painfully slow... why?

2008-06-09 Thread [EMAIL PROTECTED]

I'm trying desparately to figure out why my django sites are so slow.
Using the statsmiddleware, I'm seeing numbers like this:

Stats: Total: 0.08 Python: 0.07 DB: 0.01 Queries: 6
Stats: Total: 0.48 Python: 0.37 DB: 0.11 Queries: 3
Stats: Total: 0.21 Python: 0.17 DB: 0.05 Queries: 32
Stats: Total: 0.27 Python: 0.22 DB: 0.05 Queries: 32

So first question... are those numbers acceptable? They seem to me
like they should be.
If not, where do I look next to hone in further on the bottlenecks.
and if so -- this is the big question -- then why is the site still so
damn slow?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



"intro to django" script -

2008-06-09 Thread Carl Karsten

I want to make a http://showmedo.com "Getting started with Django"

I expect it to be about 5 min long.  The goal is not show someone how to be 
productive, but how easy it is to get started.

At most 1 min on install python, install django, make sure you can do python -c 
"import django" without error.

Then some magic, python manage.py runserver, browse, “Welcome to Django”

Then some more magic, syncdb, http://127.0.0.1:8000/admin/ "log in"

Then define a model, view, html, url pattern.  maybe even a public facing form.

I am a bit fuzzy on what is considered 'best practices' for the 2 magic parts. 
  I hear what the tutorial/book describes (django-admin.py startproject mysite; 
startapp myapp) isn't what the the pros do now, or at least what the pros would 
recommend.  What I haven't heard is an alternative.

I am tempted to show creating all the files by hand.  (I can't do it all in 5 
minutes, but some Julia Child moves and sped up video should make it faster 
than 
explaining what startproject and startapp do.)

Any suggestions?  Any writeups that cover this?

Carl K

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: oracle-django problem

2008-06-09 Thread shabda

Or use this,
>From http://www.djangoproject.com/documentation/model-api/#table-names
"To override the database table name, use the db_table parameter in
class Meta."

On Jun 9, 7:46 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Mon, Jun 9, 2008 at 6:43 AM, Harish <[EMAIL PROTECTED]> wrote:
>
> > hi friends
>
> >  i have a django application, which works on postgres as back-end.
> > now i want to migrate the application  back-end  from postgres to
> > oracle.
>
> > The problem i am facing is that, the existing data table names  in
> > postgres is too long
> > (basically  the table name is a combination of application name and
> > class name), which is not allowed
> > in oracle. (using oracle 11g) Basically oracle only allows 30
> > character as table name.
>
> > I am looking forward for any solution to my problem
>
> It isn't clear if you are actually encountering a problem or just
> anticipating one.  I have no experience with Oracle, but it would seem that
> the "naming issues" note here:
>
> http://www.djangoproject.com/documentation/databases/#naming-issues
>
> indicates that the developers of the Oracle support were aware of this issue
> and dealt with it.  Are you running into a problem with this method of
> handling the Oracle limitation?
>
> Karen
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: oracle-django problem

2008-06-09 Thread Karen Tracey
On Mon, Jun 9, 2008 at 6:43 AM, Harish <[EMAIL PROTECTED]> wrote:

>
> hi friends
>
>  i have a django application, which works on postgres as back-end.
> now i want to migrate the application  back-end  from postgres to
> oracle.
>
> The problem i am facing is that, the existing data table names  in
> postgres is too long
> (basically  the table name is a combination of application name and
> class name), which is not allowed
> in oracle. (using oracle 11g) Basically oracle only allows 30
> character as table name.
>
> I am looking forward for any solution to my problem
>

It isn't clear if you are actually encountering a problem or just
anticipating one.  I have no experience with Oracle, but it would seem that
the "naming issues" note here:

http://www.djangoproject.com/documentation/databases/#naming-issues

indicates that the developers of the Oracle support were aware of this issue
and dealt with it.  Are you running into a problem with this method of
handling the Oracle limitation?

Karen

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: oracle-django problem

2008-06-09 Thread Juan Hernandez
why does it have to be that big?? what would be the problem of renaming the
models??

On Tue, Jun 10, 2008 at 6:13 AM, Harish <[EMAIL PROTECTED]> wrote:

>
> hi friends
>
>  i have a django application, which works on postgres as back-end.
> now i want to migrate the application  back-end  from postgres to
> oracle.
>
> The problem i am facing is that, the existing data table names  in
> postgres is too long
> (basically  the table name is a combination of application name and
> class name), which is not allowed
> in oracle. (using oracle 11g) Basically oracle only allows 30
> character as table name.
>
> I am looking forward for any solution to my problem
>
>
> regards
> Harish Bhat
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi-table Models and Fixtures

2008-06-09 Thread Greg Taylor

That clears it up perfectly. This is great to have working, thanks
again!

Greg

On Jun 9, 10:19 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Mon, Jun 9, 2008 at 10:09 PM, Greg Taylor <[EMAIL PROTECTED]> wrote:
>
> > Wonderful, I'll be able to test this pretty extensively tonight.
>
> > Since I don't think it's documented either way, is there a particular
> > procedure I should abide by when dumping/reloading fixtures for the
> > parent and child models? In my case, the parent is in one app, and the
> > child is another. Do I dumpdata for both of those apps and load them
> > in a certain order, or just dump for the child class that inherits
> > access to all of the fields and re-load that fixture?
>
> I've just added some docs about this [1]. You will need to dump both
> parent class and child class. If they're in separate applications,
> that means dumping both applications (or parts of both applications,
> as appropriate).
>
> When fixtures are reloaded, all the fixtures you load in a single
> loaddata command are loaded inside a single transaction. Referential
> integrity (when it's supported by your database) isn't checked until
> the end of the transaction, so the order of creation internal to the
> transaction doesn't matter. As a result, all the following:
>
> loaddata all_data.json
> loaddata parents.json children.json
> loaddata children.json parents.json
>
> will all be equivalent.
>
> There is, of course, once caveat to this - if you're using MySQL with
> InnoDB tables, all bets are off. InnoDB has referential integrity, but
> it doesn't defer to end of transaction, so creation order becomes
> important. This is a known bug, but one that is impossible to solve in
> a generic fashion at our end - we need MySQL to fix their referential
> integrity implementation. MyISAM tables aren't affected - they don't
> have any referential integrity, so no checks are ever performed.
>
> [1]http://www.djangoproject.com/documentation/serialization/#inherited-m...
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi-table Models and Fixtures

2008-06-09 Thread Russell Keith-Magee

On Mon, Jun 9, 2008 at 10:09 PM, Greg Taylor <[EMAIL PROTECTED]> wrote:
>
> Wonderful, I'll be able to test this pretty extensively tonight.
>
> Since I don't think it's documented either way, is there a particular
> procedure I should abide by when dumping/reloading fixtures for the
> parent and child models? In my case, the parent is in one app, and the
> child is another. Do I dumpdata for both of those apps and load them
> in a certain order, or just dump for the child class that inherits
> access to all of the fields and re-load that fixture?

I've just added some docs about this [1]. You will need to dump both
parent class and child class. If they're in separate applications,
that means dumping both applications (or parts of both applications,
as appropriate).

When fixtures are reloaded, all the fixtures you load in a single
loaddata command are loaded inside a single transaction. Referential
integrity (when it's supported by your database) isn't checked until
the end of the transaction, so the order of creation internal to the
transaction doesn't matter. As a result, all the following:

loaddata all_data.json
loaddata parents.json children.json
loaddata children.json parents.json

will all be equivalent.

There is, of course, once caveat to this - if you're using MySQL with
InnoDB tables, all bets are off. InnoDB has referential integrity, but
it doesn't defer to end of transaction, so creation order becomes
important. This is a known bug, but one that is impossible to solve in
a generic fashion at our end - we need MySQL to fix their referential
integrity implementation. MyISAM tables aren't affected - they don't
have any referential integrity, so no checks are ever performed.

[1] http://www.djangoproject.com/documentation/serialization/#inherited-models

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi-table Models and Fixtures

2008-06-09 Thread Greg Taylor

Wonderful, I'll be able to test this pretty extensively tonight.

Since I don't think it's documented either way, is there a particular
procedure I should abide by when dumping/reloading fixtures for the
parent and child models? In my case, the parent is in one app, and the
child is another. Do I dumpdata for both of those apps and load them
in a certain order, or just dump for the child class that inherits
access to all of the fields and re-load that fixture?

Thanks again, this will get my project back on track!

On Jun 9, 10:06 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Mon, Jun 9, 2008 at 8:12 PM, Russell Keith-Magee
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > On Mon, Jun 9, 2008 at 8:06 PM, Greg Taylor <[EMAIL PROTECTED]> wrote:
>
> >> Much appreciated, Russ! I was not sure whether I was doing something
> >> wrong or not, this is good to know this is being looked at. I tinkered
> >> with a fix for a while but ultimately fell flat on my back for lack of
> >> experience with Django internals. Let me know if I can assist with
> >> testing or provide more details.
>
> > I think I have it pretty much under control. I'm just finessing some
> > test cases at the moment. It turns out there are actually a couple of
> > related problems - too much data was being serialized, primary keys
> > were missing a few critical annotations, and the save process was a
> > little too enthusiastic about creating new parent instances. However,
> > I think I've got a solution now; a little more testing, and there
> > should be something in trunk. Watch this space. :-)
>
> OK; committed as [7600]. Let me know if you continue to have
> difficulties with this.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Text Formatting

2008-06-09 Thread yanksluvr7

thanks I'll check that out

On Jun 9, 9:53 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote:
> You'll need to use some sort of rich text editor.  I've used
> TinyMCEin the past; there are others as
> well.
>
>   -- Scott
>
> On Mon, Jun 9, 2008 at 9:51 AM, yanksluvr7 <[EMAIL PROTECTED]> wrote:
>
> > Is there a way to make a django page so you can copy and paste text
> > into the page and have it keep its original formatting? Everything I
> > have found makes it copy as plain text, so any spacing, bullets, bold,
> > italics, or anything else is lost.
>
> --http://scott.andstuff.org/|http://truthadorned.org/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi-table Models and Fixtures

2008-06-09 Thread Russell Keith-Magee

On Mon, Jun 9, 2008 at 8:12 PM, Russell Keith-Magee
<[EMAIL PROTECTED]> wrote:
> On Mon, Jun 9, 2008 at 8:06 PM, Greg Taylor <[EMAIL PROTECTED]> wrote:
>>
>> Much appreciated, Russ! I was not sure whether I was doing something
>> wrong or not, this is good to know this is being looked at. I tinkered
>> with a fix for a while but ultimately fell flat on my back for lack of
>> experience with Django internals. Let me know if I can assist with
>> testing or provide more details.
>
> I think I have it pretty much under control. I'm just finessing some
> test cases at the moment. It turns out there are actually a couple of
> related problems - too much data was being serialized, primary keys
> were missing a few critical annotations, and the save process was a
> little too enthusiastic about creating new parent instances. However,
> I think I've got a solution now; a little more testing, and there
> should be something in trunk. Watch this space. :-)

OK; committed as [7600]. Let me know if you continue to have
difficulties with this.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Trouble trying to use formtools.preview.FormPreview

2008-06-09 Thread shabda

I am trying to use formtools.preview.FormPreview after reading
http://www.djangoproject.com/documentation/form_preview/ and am
getting weird errors.
This is what I did,

1. Have a form called AddReviewForm which is working as expected.
2. Created a class
class ReviewPreviewForm(FormPreview):

def done(self, request, cleaned_data):
import pdb
pdb.set_trace()
3. In my urls.py added this line
url(r'^post/$', ReviewPreviewForm(AddReviewForm),
name='reviews_preview'),
4. Changed template to post the form to '/post/'
5. Now I am expecting that the preview should appear on form posting,
but I am getting exception with traceback,

Traceback:
File "C:\Python25.1\lib\site-packages\django\core\handlers\base.py" in
get_response
  82. response = callback(request, *callback_args,
**callback_kwargs)
File "C:\Python25.1\lib\site-packages\django\contrib\formtools
\preview.py" in __call__
  31. return method(request)
File "C:\Python25.1\lib\site-packages\django\contrib\formtools
\preview.py" in preview_post
  58. f = self.form(request.POST, auto_id=AUTO_ID)

Exception Type: TypeError at /reviews/post/
Exception Value: __init__() takes at least 4 non-keyword arguments (2
given)

What am I doing wrong?


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why my django site doesn't create .pyc file?

2008-06-09 Thread Tim Chase

>> I think this way, apache could be a little more faster. Am I
>> right?
> 
> I don't think it will be faster.  Django normally runs as a
> long-standing process (either inside Apache or as a standalone
> process, depending on the deployment model you've chosen).
> So, unlike ordinary CGI scripts, your Python bytecode will not
> need to be generated except for the very first time that your
> code is loaded.  Once it's up and running it will already be
> in memory so it won't need to be reinterpreted.

If you want, you can pre-compile everything as described at

   http://effbot.org/pyfaq/how-do-i-create-a-pyc-file.htm

which shows you can issue

   bash$ cd ~/code
   bash$ python -m compileall .
   [output]

which will compile each .py file into a corresponding .pyc file 
within the current directory and subdirectories.  I believe the 
Debian variants (others may as well) do this in the system 
directories upon installation so users don't have to recompile 
all the system libraries.

The time saved is minimal, but there's no harm in preemptively 
compiling your files.

-tim




--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Text Formatting

2008-06-09 Thread Scott Moonen
You'll need to use some sort of rich text editor.  I've used
TinyMCEin the past; there are others as
well.

  -- Scott

On Mon, Jun 9, 2008 at 9:51 AM, yanksluvr7 <[EMAIL PROTECTED]> wrote:

>
> Is there a way to make a django page so you can copy and paste text
> into the page and have it keep its original formatting? Everything I
> have found makes it copy as plain text, so any spacing, bullets, bold,
> italics, or anything else is lost.
>
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Text Formatting

2008-06-09 Thread yanksluvr7

Is there a way to make a django page so you can copy and paste text
into the page and have it keep its original formatting? Everything I
have found makes it copy as plain text, so any spacing, bullets, bold,
italics, or anything else is lost.

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why my django site doesn't create .pyc file?

2008-06-09 Thread Scott Moonen
>
> I think this way, apache could be a little more faster. Am I right?
>

I don't think it will be faster.  Django normally runs as a long-standing
process (either inside Apache or as a standalone process, depending on the
deployment model you've chosen).  So, unlike ordinary CGI scripts, your
Python bytecode will not need to be generated except for the very first time
that your code is loaded.  Once it's up and running it will already be in
memory so it won't need to be reinterpreted.

I personally don't think the trade-off is worth it here.  You're giving
Apache write access to your source code (which may not be much of a security
risk relative to other things like the fact that Apache has access to your
database, but it is definitely a blurring of privilege boundaries), and
you're not getting any long-running performance benefit from it; only a
slight initial load benefit.


  -- Scott

On Mon, Jun 9, 2008 at 9:40 AM, pength <[EMAIL PROTECTED]> wrote:

>
> Thanks a lot !
>
> I changed the user information in apache2's conf file, and now it's
> OK!
>
> I think this way, apache could be a little more faster. Am I right?
>
> On 6月9日, 下午7时39分, "Valts Mazurs" <[EMAIL PROTECTED]> wrote:
> > Hello,
> >
> > Check if web server process has enough privileges to write in the
> > directories containing .py files.
> >
> > Regards,
> > Valts.
> >
> > On Mon, Jun 9, 2008 at 1:25 PM, pength <[EMAIL PROTECTED]> wrote:
> >
> > > I have justed built my site on slicehost. Alhough my site is running
> > > properly, I found if I update any  file (.py file, of course), it
> > > never recreate the .pyc file. Actually, if I delete any .pyc file,
> > > then it will never appear.
> >
> > > I think there's something wrong with my site config, can anyone give
> > > me any hint?
> >
> > > I am using nginx as front proxy server and static file server, apache2
> > > and mod_python as backend.
> >
> > > Thanks!
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.org/

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



Re: Use django0.97 with cmemcached

2008-06-09 Thread Randy Barlow

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

mohamed nadir belkhelfa wrote:
> I want to use cmemcached with Django 0.97 but the import of cmemcached in
> source code  cause the following error
> 
> Can't extract file(s) to egg cache The following error occurred while trying
> to extract file(s) to the Python egg cache: [Errno 13] Permission denied:
> '/mnt/.eggcache/python_libmemcached-0.13.1-py2.5-linux-i686.egg-tmp' The
> Python egg cache directory is currently set to: /mnt/.eggcache Perhaps your
> account does not have write access to this directory? You can change the
> cache directory by setting the PYTHON_EGG_CACHE environment variable to
> point to an accessible directory.
> 
> I need to add certainly  something in the configuration of Django but I dont
> know what is it.
> another thing I use Django with lighttpd.

...so does your user have write permissions to that directory?

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkhNNPYACgkQw3vjPfF7QfWj4wCgoouymTWdkKZef4dxsIOKVxIn
zEYAnRoCMMtGzRhKzhvt/uI22q6E+EwM
=7Iq6
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why my django site doesn't create .pyc file?

2008-06-09 Thread pength

Thanks a lot !

I changed the user information in apache2's conf file, and now it's
OK!

I think this way, apache could be a little more faster. Am I right?

On 6月9日, 下午7时39分, "Valts Mazurs" <[EMAIL PROTECTED]> wrote:
> Hello,
>
> Check if web server process has enough privileges to write in the
> directories containing .py files.
>
> Regards,
> Valts.
>
> On Mon, Jun 9, 2008 at 1:25 PM, pength <[EMAIL PROTECTED]> wrote:
>
> > I have justed built my site on slicehost. Alhough my site is running
> > properly, I found if I update any  file (.py file, of course), it
> > never recreate the .pyc file. Actually, if I delete any .pyc file,
> > then it will never appear.
>
> > I think there's something wrong with my site config, can anyone give
> > me any hint?
>
> > I am using nginx as front proxy server and static file server, apache2
> > and mod_python as backend.
>
> > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



hi friends,

2008-06-09 Thread amar

 I am displaying a big report in a scrolling table with left most
column and header fixed,
and I used "overflow = visible" in the style sheet to print the page ,
vertically it's printing all the contents but the horizontal content
is not printing due to the size of paper, can u help me please
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to make two fields appear on a single line

2008-06-09 Thread amar

Thanks for spending your time it worked

On May 21, 4:17 pm, Juanjo Conti <[EMAIL PROTECTED]> wrote:
> amar escribió:
>
> > HI,
> >  I am developing a simple project on django and now i want to make two
> > text boxes appear on a single row, please help me
>
> What are your doing now? {{ form }}?
>
> Try {{ field.label_tag1 }}: {{ form.field1 }} {{ field.label_tag2 }}: {{
> form.field2 }}
>
> Juanjo
> --
> mi blog:http://www.juanjoconti.com.ar
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Importing data from 'MS Access' .mdb files

2008-06-09 Thread M.Ganesh

chefsmart wrote:
> You may follow these steps:
>
> 1. install the MySQL ODBC connector (currently version 5.1)
> 2. create an empty database
> 3. create a DSN pointing to your newly created empty database
> 4. open your .mdb file in Access
> 5. select your table in Access and go to File->Export...
> 6. In the "save as type", choose ODBC databases(), give a name for the
> table in mysql, and then choose your DSN created in step 3 above.
>
> That's all.
>
> On Jun 9, 7:38 am, Julien <[EMAIL PROTECTED]> wrote:
>   
>> The MySQL migration toolkit has worked quite well for 
>> me:http://www.mysql.com/products/tools/migration-toolkit/
>>
>> On Jun 9, 10:23 am, bacccr <[EMAIL PROTECTED]> wrote:
>>
>> 
>>> also, you can export your data from access to xml (within vb) file and
>>> then load it into your mysql db with python. there is a lot of
>>> options, select the way you familiar with.
>>>   
>>> On 9 июн, 04:30, "Jeffrey Johnson" <[EMAIL PROTECTED]> wrote:
>>>   
 Use access on your Windows PC, Get the ODBC drivers for MySQL, map the
 tables and copy the data in by hand.
 
 Jeff
 
 On Sun, Jun 8, 2008 at 10:54 AM, M.Ganesh <[EMAIL PROTECTED]> wrote:
 
> Hi All,
>   
> I am looking for tools/methods to read(if possible also write) data from
> .mdb files which are copied into my linux box with python. I require
> this for coercing existing legacy data into MySQL with some change in
> the data structure. The ultimate aim is to replace an application
> developed in VB with django
>   
> Thanks in advance
> Regards Ganesh
>   
Hi Jeffery, bacccr, Julien, chefsmart & Garrett,

Thanks for all your responses. All the suggested methods are suitable 
for one time migration. Actually I am planning to migrate from VB to 
django in phases. So I may have to update data many times. i.e first 
export a few tables (doing some re-arrangement). After it settles down, 
export few more tables, as well as the new data entered in the phase I 
tables through the VB app. Basically one-time-export-of-tables will not 
work for me. So, if only I can access 'ms access' tables through python, 
I can write a few functions to check if the data has already reached 
MySQL table,  if not add it. The actual .mdb files are in a Windows box, 
so if the setup will require a Windows box it is okay, but it will be 
convenient if I can copy those .mdb files to my linux box, do the 
initial developement and testing and finally point the functions to the 
original .mdb files.

In short I am looking for a way to read(/write) tables in a .mdb file, 
through python.

Any pointers?

Thanks for your time once again

Ganesh


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi-table Models and Fixtures

2008-06-09 Thread Greg Taylor

Excellent news, I appreciate it very much!

On Jun 9, 8:12 am, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Mon, Jun 9, 2008 at 8:06 PM, Greg Taylor <[EMAIL PROTECTED]> wrote:
>
> > Much appreciated, Russ! I was not sure whether I was doing something
> > wrong or not, this is good to know this is being looked at. I tinkered
> > with a fix for a while but ultimately fell flat on my back for lack of
> > experience with Django internals. Let me know if I can assist with
> > testing or provide more details.
>
> I think I have it pretty much under control. I'm just finessing some
> test cases at the moment. It turns out there are actually a couple of
> related problems - too much data was being serialized, primary keys
> were missing a few critical annotations, and the save process was a
> little too enthusiastic about creating new parent instances. However,
> I think I've got a solution now; a little more testing, and there
> should be something in trunk. Watch this space. :-)
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem with mod python: can not import base64mime

2008-06-09 Thread zekUs

Hi,

I have djangp-svn installed (revision 7574) on an archlinux system.
for testing i created an empty project with: "django-admin.py
startproject deneme". when i run the test server i can see the default
welcome page of django.

then i installed mod_python (v 3.3.1) on apache (2.2.8.2). i compile
it from source. without any errors. i configure httpd.conf and test
the installation via mod_python.testhandler. there is no problem.

so the problem is then i try to access the empty project i created
above i get an error message: "ImproperlyConfigured: Error importing
middleware django.middleware.common: "No module named base64mIme" "
i did not touch any of the default project files and on test server no
problem. but with mod_python pfff.

here is my location directive in httpd.conf:

SetHandler python-program
PythonHandler django.core.handlers.modpython
#PythonHandler mod_python.testhandler
SetEnv DJANGO_SETTINGS_MODULE deneme.settings
PythonDebug On
PythonPath "['/home/zekus/devel'] + sys.path"


any ideas?
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi-table Models and Fixtures

2008-06-09 Thread Russell Keith-Magee

On Mon, Jun 9, 2008 at 8:06 PM, Greg Taylor <[EMAIL PROTECTED]> wrote:
>
> Much appreciated, Russ! I was not sure whether I was doing something
> wrong or not, this is good to know this is being looked at. I tinkered
> with a fix for a while but ultimately fell flat on my back for lack of
> experience with Django internals. Let me know if I can assist with
> testing or provide more details.

I think I have it pretty much under control. I'm just finessing some
test cases at the moment. It turns out there are actually a couple of
related problems - too much data was being serialized, primary keys
were missing a few critical annotations, and the save process was a
little too enthusiastic about creating new parent instances. However,
I think I've got a solution now; a little more testing, and there
should be something in trunk. Watch this space. :-)

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi-table Models and Fixtures

2008-06-09 Thread Greg Taylor

Much appreciated, Russ! I was not sure whether I was doing something
wrong or not, this is good to know this is being looked at. I tinkered
with a fix for a while but ultimately fell flat on my back for lack of
experience with Django internals. Let me know if I can assist with
testing or provide more details.

Thanks again,
Greg

On Jun 8, 9:39 pm, "Russell Keith-Magee" <[EMAIL PROTECTED]>
wrote:
> On Mon, Jun 9, 2008 at 12:09 AM, Greg Taylor <[EMAIL PROTECTED]> wrote:
>
> > I've submitted a bug about this since I haven't been able to turn up
> > any kind of response. In the mean-time, I've had to rig something up
> > with generic relations to serve the same purpose. It's a really nasty
> > kludge, I think, which is a shame. I can't believe this hasn't cropped
> > up with anyone else yet, it seems like a really glaring problem,
> > especially for those who use fixtures.
>
> Hi Greg,
>
> Apologies for not responding sooner, even if just to let you know that
> you're not howling at the moon. I'm not ignoring you - I just don't
> have anything to add at this point.
>
> Yes, there is some work required on serialization to support some of
> the additions to QS-RF. Inherited models are one problematic area;
> models with non-primary OneToOneFields are another (although the
> problems are probably related). As soon as I've finished this email,
> I'm going to take a look at these problems and see what I can do about
> a fix.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: why my django site doesn't create .pyc file?

2008-06-09 Thread Valts Mazurs
Hello,

Check if web server process has enough privileges to write in the
directories containing .py files.

Regards,
Valts.

On Mon, Jun 9, 2008 at 1:25 PM, pength <[EMAIL PROTECTED]> wrote:

>
> I have justed built my site on slicehost. Alhough my site is running
> properly, I found if I update any  file (.py file, of course), it
> never recreate the .pyc file. Actually, if I delete any .pyc file,
> then it will never appear.
>
> I think there's something wrong with my site config, can anyone give
> me any hint?
>
> I am using nginx as front proxy server and static file server, apache2
> and mod_python as backend.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: Problem with admin (urls)

2008-06-09 Thread Fred Reillier
Hello. I had the same problem a few days ago (i'm just discovering Django…)
after installing v 0.96. It seems to be a problem with the installer (two
folders not copied during the process : "admin/templates"  and
"admin/media"). 

 

To make things work, I had to copy manually the folders from the Django
Archive to the following locations : 

 

python/libs/site_packges/django/contrib/admin/templates
python/libs/site_packges/django/contrib/admin/media

 

On my Macbook, everything works perfectly now.

 

I found the solution on the page below. Just read the thread to find
indications related to your OS (the place where you should copy the folders
is not the same if you are on Windows or Linux or Mac): 

 

http://groups.google.com/group/django-users/browse_thread/thread/20bb5ab1ed8
df496/7323c1dad954c87b?hl=en=gst=TemplateDoesNotExist+at+%2Fadmin%2F#7
323c1dad954c87b

 

 

 

Fred Reillier

[EMAIL PROTECTED]

 

http://www.lanquarem.com

http://www.musique-electro.net

 

De : django-users@googlegroups.com [mailto:[EMAIL PROTECTED] De
la part de ¤ AbdulHafeez
Envoyé : lundi 9 juin 2008 12:51
À : django-users@googlegroups.com
Objet : Re: Problem with admin (urls)

 

please use this link and check

http://localhost:8000/admin

regards

AbdulHafeez

On Mon, Jun 9, 2008 at 4:15 PM, Nader <[EMAIL PROTECTED]> wrote:


Hello,

I have a question. I have started a new project.

This is my "urls.py" file :

from django.conf.urls.defaults import *

urlpatterns = patterns('',
   # Example:
   # (r'^nadc/', include('nadc.foo.urls')),

   # Uncomment this for admin:
   (r'^admin/', include('django.contrib.admin.urls')),

)

But If I request the admin page ("http://localhost:8000/adim; I get
the next message:

Request Method: GET
Request URL:http://145.23.236.80:8080/admin/
Exception Type: TemplateDoesNotExist
Exception Value:admin/login.html
Exception Location: /data/cesar/home/Python-2.4.4/lib/python2.4/site-
packages/Django-0.96.1-py2.4.egg/django/template/loader.py in
find_template_source, line 72
Template-loader postmortem

Django tried loading these templates, in this order:

   * Using loader
django.template.loaders.filesystem.load_template_source:
   * Using loader
django.template.loaders.app_directories.load_template_source:

Would somebody tell me what the problem is ?

Regards,
Nader





--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with admin (urls)

2008-06-09 Thread ¤ۣۜ๘۩ AbdulHafeez
please use this link and check

http://localhost:8000/admin

regards

AbdulHafeez

On Mon, Jun 9, 2008 at 4:15 PM, Nader <[EMAIL PROTECTED]> wrote:

>
> Hello,
>
> I have a question. I have started a new project.
>
> This is my "urls.py" file :
>
> from django.conf.urls.defaults import *
>
> urlpatterns = patterns('',
># Example:
># (r'^nadc/', include('nadc.foo.urls')),
>
># Uncomment this for admin:
>(r'^admin/', include('django.contrib.admin.urls')),
>
> )
>
> But If I request the admin page ("http://localhost:8000/adim; I get
> the next message:
>
> Request Method: GET
> Request URL:http://145.23.236.80:8080/admin/
> Exception Type: TemplateDoesNotExist
> Exception Value:admin/login.html
> Exception Location: /data/cesar/home/Python-2.4.4/lib/python2.4/site-
> packages/Django-0.96.1-py2.4.egg/django/template/loader.py in
> find_template_source, line 72
> Template-loader postmortem
>
> Django tried loading these templates, in this order:
>
>* Using loader
> django.template.loaders.filesystem.load_template_source:
>* Using loader
> django.template.loaders.app_directories.load_template_source:
>
> Would somebody tell me what the problem is ?
>
> Regards,
> Nader
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with admin (urls)

2008-06-09 Thread Nader

Hello,

I have a question. I have started a new project.

This is my "urls.py" file :

from django.conf.urls.defaults import *

urlpatterns = patterns('',
# Example:
# (r'^nadc/', include('nadc.foo.urls')),

# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),

)

But If I request the admin page ("http://localhost:8000/adim; I get
the next message:

Request Method: GET
Request URL:http://145.23.236.80:8080/admin/
Exception Type: TemplateDoesNotExist
Exception Value:admin/login.html
Exception Location: /data/cesar/home/Python-2.4.4/lib/python2.4/site-
packages/Django-0.96.1-py2.4.egg/django/template/loader.py in
find_template_source, line 72
Template-loader postmortem

Django tried loading these templates, in this order:

* Using loader
django.template.loaders.filesystem.load_template_source:
* Using loader
django.template.loaders.app_directories.load_template_source:

Would somebody tell me what the problem is ?

Regards,
Nader
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



oracle-django problem

2008-06-09 Thread Harish

hi friends

 i have a django application, which works on postgres as back-end.
now i want to migrate the application  back-end  from postgres to
oracle.

The problem i am facing is that, the existing data table names  in
postgres is too long
(basically  the table name is a combination of application name and
class name), which is not allowed
in oracle. (using oracle 11g) Basically oracle only allows 30
character as table name.

I am looking forward for any solution to my problem


regards
Harish Bhat


--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



why my django site doesn't create .pyc file?

2008-06-09 Thread pength

I have justed built my site on slicehost. Alhough my site is running
properly, I found if I update any  file (.py file, of course), it
never recreate the .pyc file. Actually, if I delete any .pyc file,
then it will never appear.

I think there's something wrong with my site config, can anyone give
me any hint?

I am using nginx as front proxy server and static file server, apache2
and mod_python as backend.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to execute function dynamically?

2008-06-09 Thread David.D

I made a mistake! I use 'extra_context=locals()' in my generic view.
Now no problem.

Thanks very much.


On Jun 9, 12:34 pm, "David.D" <[EMAIL PROTECTED]> wrote:
> If there are no parameters, it works fine in django.
> For example:
>
> def functionA(): # no parameter
> ...
> return ...
> def functionB(): # no parameter
> 
> return ...
>
> callDict = {'functionA': functionA, 'functionB':functionB,...}
>
> def myview(request, indata):
> func = callDict.get(indata)
> func() # no parameter
>
> This will be fine. But it's not enough for my needs.
>
> Thank you.
>
> On Jun 8, 2:00 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
>
>
>
> > 2008/6/8 David.D <[EMAIL PROTECTED]>:
>
> > > view.py
> > > =
> > > def functionA(request):
> > >...
> > >return ...
> > > def functionB(request):
> > >
> > >return ...
>
> > > callDict = {'functionA': functionA, 'functionB':functionB,...}
>
> > > def myview(request, indata):
> > >func = callDict.get(indata)
> > >func(request)
>
> > > indata is a string:'functionA'、'functionB'...
>
> > > But it doesn't work. I got TypeError: functionA() takes exactly 1
> > > argument (0 given)
>
> > > Thanks for your help.
>
> > There's something outside of what you've posted that's key here.  What you
> > have shown works fine in a python shell, for example:
>
> > Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)]
> > on win32
> > Type "help", "copyright", "credits" or "license" for more information.>>> 
> > def functionA(request):
>
> > ... print 'functionA called with request = %s' % request
> > ... return 0
> > ...>>> def functionB(request):
>
> > ... print 'functionB called with request = %s' % request
> > ... return 1
> > ...>>> callDict = {'functionA': functionA, 'functionB':functionB }
> > >>> def myview(request, indata):
>
> > ... func = callDict.get(indata)
> > ... func(request)
> > ...>>> myview('request1', 'functionA')
>
> > functionA called with request = request1>>> myview('abcde', 'functionB')
>
> > functionB called with request = abcde
>
> > Karen- Hide quoted text -
>
> > - Show quoted text -- 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: reversing url tag with viewname as variable in the context

2008-06-09 Thread ferran

Thanks Alex the path works for me!

On Jun 8, 11:11 am, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> There is the tickethttp://code.djangoproject.com/ticket/7049
>
> On Jun 8, 1:05 pm, ferran <[EMAIL PROTECTED]> wrote:
>
> > Thanks Alex for confirm my suspicions
>
> > IMHO this is a great feature for url tag, if anyone have a idea for
> > implement this functionality, (like a eval(context_var_viewname)) i
> > work in this
>
> > thnaks
>
> > On Jun 8, 10:54 am, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> > > No. Built-in {% url %} tag doesn't support variable as view name. To
> > > solve this you can write your own url-like template tag with needed
> > > functionality. Or refactor you code to avoid using the view name as
> > > variable:)
>
> > > On Jun 8, 12:39 pm, ferran <[EMAIL PROTECTED]> wrote:
>
> > > > Hi all,
>
> > > > The tag {% url viewname args %} supports a context variable for
> > > > viewname?? i don't know how put a context variable in viewname,  any
> > > > suggestion??
>
> > > > 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Importing data from 'MS Access' .mdb files

2008-06-09 Thread Garrett Garcia
Ganesh,

I just had to tackle the same problem in a django project.  I'm sure this
isn't the best solution but it works if you don't have access to a Windows
machine.  Download and install the mdb-tools package:
http://mdbtools.sourceforge.net/  In my app I run the mdb-export program
from python and save the output to csv files.  I then use python's csv
libraries to read in and manipulate the data and save it in the correct
format using the django models API.

-Garrett

On Sun, Jun 8, 2008 at 10:54 AM, M.Ganesh <[EMAIL PROTECTED]> wrote:

>
> Hi All,
>
> I am looking for tools/methods to read(if possible also write) data from
> .mdb files which are copied into my linux box with python. I require
> this for coercing existing legacy data into MySQL with some change in
> the data structure. The ultimate aim is to replace an application
> developed in VB with django
>
> Thanks in advance
> Regards Ganesh
>
>
> >
>

--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---