Re: confusing query involving time ranges

2010-08-13 Thread Emily Rodgers
On Aug 12, 10:00 pm, Paulo Almeida 
wrote:
> Can you sequentially add the states for each foo? I'm thinking of something
> like:
>
> states = []
> for foo in foos:
>     foo_state = State.objects.filter(foo=foo, first_dt__lte=dt,
> last_dt__gte=dt)
>     if foo_state:
>         states.append(foo_state)
>     else:
>         states = State.objects.filter(foo=foo, last_dt__lte=dt):
>         states.append(state.latest)
>
> Of course you would have to define latest in the model Meta.
>
> - Paulo

The thing is, there could be say 3000 distinct foos in the table. It
would take ages to return the results if I did this. I was hoping to
do it in one query. Might have to revert to SQL if I can't do it using
the django ORM.

>
> On Thu, Aug 12, 2010 at 8:26 PM, Alec Shaner  wrote:
> > Hopefully some django sql guru will give you a better answer, but I'll take
> > a stab at it.
>
> > What you describe does sound pretty tricky. Is this something that has to
> > be done in a single query statement? If you just need to build a list of
> > objects you could do it in steps, e.g.:
>
> > # Get all State objects that span the requested dt
> > q1 = State.objects.filter(first_dt__lte=dt, last_dt__gte=dt)
>
> > # Get all State objects where foo is not already in q1, but have a last_dt
> > prior to requested dt
> > q1_foo = q1.values_list('foo')
> > q2 =
> > State.objects.exclude(foo__in=q1_foo).filter(last_dt__lt=dt).order_by('-last_dt')
>
> > But q2 would not have unique foo entries, so some additional logic would
> > need to be applied to get the first occurrence of each distinct foo value in
> > q2.
>
> > Probably not the best solution, but maybe it could give you some hints to
> > get started.
>
> > On Thu, Aug 12, 2010 at 12:51 PM, Emily Rodgers <
> > emily.kate.rodg...@gmail.com> wrote:
>
> >> Hi,
>
> >> I am a bit stuck on this and can't seem to figure out what to do.
>
> >> I have a model that (stripped down for this question) looks a bit like
> >> this:
>
> >> class State(models.Model):
> >>    first_dt = models.DateTimeField(null=True)
> >>    last_dt = models.DateTimeField(null=True)
> >>    foo = models.CharField(FooModel)
> >>    bar = models.ForeignKey(BarModel, null=True)
> >>    meh = models.ForeignKey(MehModel, null=True)
>
> >> This is modeling / logging state of various things in time (more
> >> specifically a mapping of foo to various other bits of data). The data
> >> is coming from multiple sources, and what information those sources
> >> provide varies a lot, but all of them provide foo and a date plus some
> >> other information.
>
> >> What I want to do, is given a point in time, return all the 'states'
> >> that span that point in time. This seems trivial except for one thing
> >> - a state for a particular 'foo' may still be persisting after the
> >> last_dt until the next 'state' for that 'foo' starts. This means that
> >> if there are no other 'states' between the point in time and the start
> >> of the next state for a given foo, I want to return that state.
>
> >> I have built a query that kindof explains what I want to do (but
> >> obviously isn't possible in its current form):
>
> >> dt = '2010-08-12 15:00:00'
>
> >> lookups = State.objects.filter(
> >>    Q(
> >>        Q(first_dt__lte=dt) & Q(last_dt__gte=dt) |
> >>        Q(first_dt__lte=dt) &
>
> >> Q(last_dt=State.objects.filter(foo=F('foo')).filter(first_dt__lte=dt).latest('last_dt'))
> >>    )
> >> )
>
> >> I know this doesn't work, but I think it illustrates what I am trying
> >> to do better than words do.
>
> >> Does anyone have any advice? Should I be using annotate or something
> >> to show what the last_dt for each foo is? I might be being really
> >> stupid and completely missing something but I have been trying to
> >> figure this out for too long!
>
> >> Cheers,
> >> Emily
>
> >> --
> >> You received this message because you are subscribed to the Google Groups
> >> "Django users" group.
> >> To post to this group, send email to django-us...@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com
> >> .
> >> For more options, visit this group at
> >>http://groups.google.com/group/django-users?hl=en.
>
> >  --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Re: confusing query involving time ranges

2010-08-13 Thread Paulo Almeida
I see. What about Alec Shaner's suggestion? If you replace 'order_by' with
'latest' it will be similar to my suggestion with just two queries.

- Paulo

On Fri, Aug 13, 2010 at 8:28 AM, Emily Rodgers  wrote:

> On Aug 12, 10:00 pm, Paulo Almeida 
> wrote:
> > Can you sequentially add the states for each foo? I'm thinking of
> something
> > like:
> >
> > states = []
> > for foo in foos:
> > foo_state = State.objects.filter(foo=foo, first_dt__lte=dt,
> > last_dt__gte=dt)
> > if foo_state:
> > states.append(foo_state)
> > else:
> > states = State.objects.filter(foo=foo, last_dt__lte=dt):
> > states.append(state.latest)
> >
> > Of course you would have to define latest in the model Meta.
> >
> > - Paulo
>
> The thing is, there could be say 3000 distinct foos in the table. It
> would take ages to return the results if I did this. I was hoping to
> do it in one query. Might have to revert to SQL if I can't do it using
> the django ORM.
>
> >
> > On Thu, Aug 12, 2010 at 8:26 PM, Alec Shaner 
> wrote:
> > > Hopefully some django sql guru will give you a better answer, but I'll
> take
> > > a stab at it.
> >
> > > What you describe does sound pretty tricky. Is this something that has
> to
> > > be done in a single query statement? If you just need to build a list
> of
> > > objects you could do it in steps, e.g.:
> >
> > > # Get all State objects that span the requested dt
> > > q1 = State.objects.filter(first_dt__lte=dt, last_dt__gte=dt)
> >
> > > # Get all State objects where foo is not already in q1, but have a
> last_dt
> > > prior to requested dt
> > > q1_foo = q1.values_list('foo')
> > > q2 =
> > >
> State.objects.exclude(foo__in=q1_foo).filter(last_dt__lt=dt).order_by('-last_dt')
> >
> > > But q2 would not have unique foo entries, so some additional logic
> would
> > > need to be applied to get the first occurrence of each distinct foo
> value in
> > > q2.
> >
> > > Probably not the best solution, but maybe it could give you some hints
> to
> > > get started.
> >
> > > On Thu, Aug 12, 2010 at 12:51 PM, Emily Rodgers <
> > > emily.kate.rodg...@gmail.com> wrote:
> >
> > >> Hi,
> >
> > >> I am a bit stuck on this and can't seem to figure out what to do.
> >
> > >> I have a model that (stripped down for this question) looks a bit like
> > >> this:
> >
> > >> class State(models.Model):
> > >>first_dt = models.DateTimeField(null=True)
> > >>last_dt = models.DateTimeField(null=True)
> > >>foo = models.CharField(FooModel)
> > >>bar = models.ForeignKey(BarModel, null=True)
> > >>meh = models.ForeignKey(MehModel, null=True)
> >
> > >> This is modeling / logging state of various things in time (more
> > >> specifically a mapping of foo to various other bits of data). The data
> > >> is coming from multiple sources, and what information those sources
> > >> provide varies a lot, but all of them provide foo and a date plus some
> > >> other information.
> >
> > >> What I want to do, is given a point in time, return all the 'states'
> > >> that span that point in time. This seems trivial except for one thing
> > >> - a state for a particular 'foo' may still be persisting after the
> > >> last_dt until the next 'state' for that 'foo' starts. This means that
> > >> if there are no other 'states' between the point in time and the start
> > >> of the next state for a given foo, I want to return that state.
> >
> > >> I have built a query that kindof explains what I want to do (but
> > >> obviously isn't possible in its current form):
> >
> > >> dt = '2010-08-12 15:00:00'
> >
> > >> lookups = State.objects.filter(
> > >>Q(
> > >>Q(first_dt__lte=dt) & Q(last_dt__gte=dt) |
> > >>Q(first_dt__lte=dt) &
> >
> > >>
> Q(last_dt=State.objects.filter(foo=F('foo')).filter(first_dt__lte=dt).latest('last_dt'))
> > >>)
> > >> )
> >
> > >> I know this doesn't work, but I think it illustrates what I am trying
> > >> to do better than words do.
> >
> > >> Does anyone have any advice? Should I be using annotate or something
> > >> to show what the last_dt for each foo is? I might be being really
> > >> stupid and completely missing something but I have been trying to
> > >> figure this out for too long!
> >
> > >> Cheers,
> > >> Emily
> >
> > >> --
> > >> You received this message because you are subscribed to the Google
> Groups
> > >> "Django users" group.
> > >> To post to this group, send email to django-us...@googlegroups.com.
> > >> To unsubscribe from this group, send email to
> > >> django-users+unsubscr...@googlegroups.com
> 
> >
> > >> .
> > >> For more options, visit this group at
> > >>http://groups.google.com/group/django-users?hl=en.
> >
> > >  --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Django users" group.
> > > To post to this group, send email to django-us...@googlegroups.com.
> > > To unsubscribe from this group, send email to
> > > django-users+unsubscr...@googlegroups.com
> 
> >
> > > .
> > > For 

Re: confusing query involving time ranges

2010-08-13 Thread Emily Rodgers
On Aug 12, 8:26 pm, Alec Shaner  wrote:
> Hopefully some django sql guru will give you a better answer, but I'll take
> a stab at it.
>
> What you describe does sound pretty tricky. Is this something that has to be
> done in a single query statement?

It doesn't have to be, but I would like to try to use a single query
that I can index the database for if possible.

>  If you just need to build a list of
> objects you could do it in steps, e.g.:
>
> # Get all State objects that span the requested dt
> q1 = State.objects.filter(first_dt__lte=dt, last_dt__gte=dt)
>
> # Get all State objects where foo is not already in q1, but have a last_dt
> prior to requested dt
> q1_foo = q1.values_list('foo')
> q2 =
> State.objects.exclude(foo__in=q1_foo).filter(last_dt__lt=dt).order_by('-last_dt')
>
> But q2 would not have unique foo entries, so some additional logic would
> need to be applied to get the first occurrence of each distinct foo value in
> q2.
>
> Probably not the best solution, but maybe it could give you some hints to
> get started.
>

Thanks. I may have to do this if I can't figure out a single
statement.


> On Thu, Aug 12, 2010 at 12:51 PM, Emily Rodgers <
>
> emily.kate.rodg...@gmail.com> wrote:
> > Hi,
>
> > I am a bit stuck on this and can't seem to figure out what to do.
>
> > I have a model that (stripped down for this question) looks a bit like
> > this:
>
> > class State(models.Model):
> >    first_dt = models.DateTimeField(null=True)
> >    last_dt = models.DateTimeField(null=True)
> >    foo = models.CharField(FooModel)
> >    bar = models.ForeignKey(BarModel, null=True)
> >    meh = models.ForeignKey(MehModel, null=True)
>
> > This is modeling / logging state of various things in time (more
> > specifically a mapping of foo to various other bits of data). The data
> > is coming from multiple sources, and what information those sources
> > provide varies a lot, but all of them provide foo and a date plus some
> > other information.
>
> > What I want to do, is given a point in time, return all the 'states'
> > that span that point in time. This seems trivial except for one thing
> > - a state for a particular 'foo' may still be persisting after the
> > last_dt until the next 'state' for that 'foo' starts. This means that
> > if there are no other 'states' between the point in time and the start
> > of the next state for a given foo, I want to return that state.
>
> > I have built a query that kindof explains what I want to do (but
> > obviously isn't possible in its current form):
>
> > dt = '2010-08-12 15:00:00'
>
> > lookups = State.objects.filter(
> >    Q(
> >        Q(first_dt__lte=dt) & Q(last_dt__gte=dt) |
> >        Q(first_dt__lte=dt) &
>
> > Q(last_dt=State.objects.filter(foo=F('foo')).filter(first_dt__lte=dt).latest('last_dt'))
> >    )
> > )
>
> > I know this doesn't work, but I think it illustrates what I am trying
> > to do better than words do.
>
> > Does anyone have any advice? Should I be using annotate or something
> > to show what the last_dt for each foo is? I might be being really
> > stupid and completely missing something but I have been trying to
> > figure this out for too long!
>
> > Cheers,
> > Emily
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

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



Help needed for XML to xslt conversion

2010-08-13 Thread Rahul
Hi
I have seen a lots of example to pick the data from simple xml for example






Empire Burlesque
Bob Dylan
USA
Columbia
10.90
1985



to convert it into a table following xsl works

  



  
  

But what if input is something complex like



  
This defines the origin of the last configuration action
affecting the object.
  
  
This defines the origin of the last configuration action
affecting the object..
  
  
  
  

  

  
  
  


  




  change_origin_t
  








  
Value is set by the system
  

  



If I need to pick class="XXX" or name="Origin".

Please help

Regards
Rahul

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



Re: new Django-Python can't get to sqlite

2010-08-13 Thread Piotr Zalewa

Google "install sqlite/mysql $your_operating_system"
If you provide more info (result of running yolk and your operating 
system) we will be able to help you a bit more.


zalun

On 10-08-13 03:15, Tom wrote:

It's my first time using Django&  I'm unable to get the demo going. I
would like to use sqlite (ultimately mysql).
Python 2.7 installed ok.  Then I installed (I think) Django 1.2.1.
The "manage.py runserver" works, but the "syncdb" fails.  How do I
"install" sqlite or pysqlite2 (or even mysql)?  I thought Python 2.5+
came with sqlite installed.

[myserver]$ tar xf Python-2.7.tgz
[myserver]$ cd Python-2.7
[myserver]$ mkdir   /opt/Python-2.7
[myserver]$ chown simonst   /opt/Python-2.7
[myserver]$ ./configure --prefix=/opt/Python-2.7
[myserver]$ make
[myserver]$ sudo make install
[myserver]$ export PATH=/opt/Python-2.7/bin:$PATH
[myserver]$ python -V
Python 2.7

[myserver]$ sudo tar xzf Django-1.2.1.tar.gz -C /opt
[myserver]$ cd /opt/Django-1.2.1
[myserver]$ sudo ln -s /opt/Django-1.2.1/django /opt/Python-2.7/lib/
python2.7/site-packages
[myserver]$ export PATH=/opt/Django-1.2.1/django/bin:$PATH
[myserver]$ django-admin.py --version
1.2.1

[myserver]$ django-admin.py startproject mysite
[myserver]$ cd mysite
[myserver]$ ./manage.py runserver
Validating models...
0 errors found
Django version 1.2.1, using settings 'mysite.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[12/Aug/2010 20:38:04] "GET / HTTP/1.1" 200 2051
[myserver]$ cp -p settings.py settings.py_ORIG
[myserver]$ vi settings.py
[myserver]$ diff settings.py settings.py_ORIG
<   'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
<   'NAME': 'django_db', # Or path to database file if
using sqlite3.
---
   

  'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'postgresql', 
'mysql', 'sqlite3' or 'oracle'.
  'NAME': '',  # Or path to database file if using sqlite3.
 

[myserver]$ ./manage.py syncdb
   <-- snip traceback lines -->
 return import_module('.base', backend_name)
   File "/opt/Python-2.7/lib/python2.7/site-packages/django/utils/
importlib.py", line 35, in import_module
 __import__(name)
   File "/opt/Python-2.7/lib/python2.7/site-packages/django/db/backends/
sqlite3/base.py", line 34, in
 raise ImproperlyConfigured("Error loading %s: %s" % (module, exc))
django.core.exceptions.ImproperlyConfigured: Error loading either
pysqlite2 or sqlite3 modules (tried in that order): No module named
_sqlite3

   



--
blog http://piotr.zalewa.info
jobs http://webdev.zalewa.info
twit http://twitter.com/zalun
face http://www.facebook.com/zaloon

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



Re: confusing query involving time ranges

2010-08-13 Thread Steven Davidson
Hmm, I can't fathom it.

I would opt for a single simple query that returns a little more than you
need and post-process it in python. This would be more maintainable than a
hairy ORM query, I'd say; but if you have vast numbers of results that may
not be appropriate.

Alternatively, and presuming you can't add and keep up to date an
'is_current' (or whatever) column in the database to make the status of a
given State explicit, you could construct a database view which computes
this flag instead, backed by a different model with Options.managed = False.


That's the view from my armchair, anyway!
Steven.

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



Re: reading pickled files

2010-08-13 Thread Daniel Roseman
On Aug 12, 4:53 pm, Tony  wrote:
> This is more of a python question but its in my Django project.  I am
> reading a unicode object and an integer from a database into a
> dictionnary and storing that in a pickled file.  Ive confirmed the
> dictionary is done correctly because i print it out from the pickled
> file later to check.  I also cast the unicode object as a string
> before making it the key corresponding to an integer in the
> dictionary.  This also appears to work.  However, when I try to use an
> if statement to check if a key is in the dictionary I get this error:
> "sequence item 0: expected string, int found".  Ive tried not casting
> the dictionary keys as strings and I get the same error.  I dont
> understand because when I print the dictionary after reading it from
> the pickled file it is in string form.  I should also say that these
> unicode objects Im reading in are always integer numbers.  So when i
> read in from the database my end result it something like: {'200': 1,
> '300': 4, etc...}.  WHat is going wrong here?

Impossible to say without seeing some code. I would say, though, that
if you're just saving a dictionary of string/integer pairs, you may be
better off with a serialization format like json - which is in the
standard library - rather than pickling.
--
DR.

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



Re: confusing query involving time ranges

2010-08-13 Thread Emily Rodgers


On Aug 13, 9:51 am, Steven Davidson 
wrote:
> Hmm, I can't fathom it.
>
> I would opt for a single simple query that returns a little more than you
> need and post-process it in python. This would be more maintainable than a
> hairy ORM query, I'd say; but if you have vast numbers of results that may
> not be appropriate.
>
> Alternatively, and presuming you can't add and keep up to date an
> 'is_current' (or whatever) column in the database to make the status of a
> given State explicit, you could construct a database view which computes
> this flag instead, backed by a different model with Options.managed = False.
>
> That's the view from my armchair, anyway!
> Steven.

Thanks - yeah if I can't figure it out I may have to go for adding
another field into the model. It would have to be another datetime
field rather than an is_current flag because an is_current flag
wouldn't help me for queries in the past (if that makes sense).

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



Re: confusing query involving time ranges

2010-08-13 Thread Steven Davidson
>
> It would have to be another datetime field rather than an is_current flag
> because an is_current flag wouldn't help me for queries in the past (if that
> makes sense).


Ah yes, of course, I had not fully grasped that bit. A nullable foreign key
reference to the State that supersedes it might come in useful in future,
and avoids adding another pesky date field. But thinking about it some more
it would probably make the ORM query a little more involved.

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



Re: Help needed for XML to xslt conversion

2010-08-13 Thread Boguslaw Faja
Hi,

are you trying to do that using django or this group had been choosed
at random? :-)

I suggest looking for 'xpath'.

hint: /[...@attr="val"]

best regards,

On Fri, Aug 13, 2010 at 8:36 AM, Rahul  wrote:
>
> Hi
> I have seen a lots of example to pick the data from simple xml for example
>
> 
> 
> 
> 
>     
>         Empire Burlesque
>         Bob Dylan
>         USA
>         Columbia
>         10.90
>         1985
>     
> 
>
> to convert it into a table following xsl works
> 
>   
>     
>     
>     
>   
>   
>
> But what if input is something complex like
>
>  hidden="false" create="true" update="true" delete="true">
>      status="approved" category="Operation and Maintenance" releaseId="767">
>   
>     This defines the origin of the last configuration action
> affecting the object.
>   
>   
>     This defines the origin of the last configuration action
> affecting the object..
>   
>   
>   
>   
>      type="optional"/>
>   
>     
>   
>   
>   
>     
>      bidirectional="no"/>
>   
>     
>     
>      dataType="String"/>
>      dataType="String"/>
>   change_origin_t
>   
>     
>     
>     
>     
>     
>     
>     
>     
>   
>     Value is set by the system
>   
>     
>   
>     
> 
>
> If I need to pick class="XXX" or name="Origin".
>
> Please help
>
> Regards
> Rahul
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Bogusław Faja
tel. (+48) 691544955

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



form developer

2010-08-13 Thread Laurentiu
Hello!

I am new to django and i want to ask if i can find a form developer
with drag and drop support for widgets and validations, database
binding fields, etc (like a desktop application).

i look at some solutions for django like formunculous but i want
something more complex.


thanks a lot

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



Re: form developer

2010-08-13 Thread Baurzhan Ismagulov
On Fri, Aug 13, 2010 at 02:19:11AM -0700, Laurentiu wrote:
> I am new to django and i want to ask if i can find a form developer
> with drag and drop support for widgets and validations, database
> binding fields, etc (like a desktop application).
> 
> i look at some solutions for django like formunculous but i want
> something more complex.

I've read that http://www.gnuenterprise.org/ has something in that
direction. It also uses Python and is reported to generate a web front
end (at least in the past) but does not use Django and has very small
community.

I've developed an enterprise application using Django. I didn't need a
form designer -- copy-paste worked pretty well for me. What I would like
to see are nested dialogs with state tracking; even admin's popups
wrapped into a function would be better than nothing.

With kind regards,
Baurzhan.

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



Programmatically connecting to a database

2010-08-13 Thread Jonathan Endersby
Hi

I have a requirement that I imagine can't be too unique, however I am
unable to find examples online of how to achieve what I'm trying to
do.

In simple terms, I need a setup where each one of my user's data is
stored in their own database. (We're using mysql).

I have a master database that stores which users exist and which
database their data is in.

I realise that this architecture might seem very odd but we have our
reasons.

The problem I face is that I want to use multiple database support but
I don't want (can't) have all of the databases defined in the
settings.py's DATABASES dict. We'll have thousands of users on a
single box.

So, for each request I need to interrogate the request, determine
which user it is, open up a connection to their database, do stuff,
and then return the result.

Each users' database's structure is identical so I would like to use
the ORM to interact with the data.

Does anyone have any pointers on how to do this with Django?

Thanks in advance,
j.

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



Best practice for maintaining the "Django stack"

2010-08-13 Thread Oivvio Polite
I started playing around with Django sometime early 2009, did the
tutorial and got started on a toy project. Then something came inbetween
and now, coming back to my toy project I notice that the unit test spit
out a lot of errors relating to the migration tool South. I've haven't
written any test relating to South. My project isn't importing South and
when I remove South from INSTALLED_APPS the errors go away.

So I guess these errors are relating to some testing Django and/or
South does per default and that the errors might be due to some version
incompatibility between the Django/South versions I had installed last
year and the ones that are installed now.

My question isn't really about how to resolve this particular issue but
rather about best practices for maintaining a consistent "Django stack",
so that similar errors will not happen in the future.


Oivvio

-- 
http://pipedreams.polite.se/about/


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



Re: confusing query involving time ranges

2010-08-13 Thread Emily Rodgers


On Aug 13, 11:18 am, Steven Davidson 
wrote:
> > It would have to be another datetime field rather than an is_current flag
> > because an is_current flag wouldn't help me for queries in the past (if that
> > makes sense).
>
> Ah yes, of course, I had not fully grasped that bit. A nullable foreign key
> reference to the State that supersedes it might come in useful in future,
> and avoids adding another pesky date field. But thinking about it some more
> it would probably make the ORM query a little more involved.

I actually like that idea. Like a linked list. It would mean the
django query could be simpler, and the post processing wouldn't be too
bad.

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



Re: Best practice for maintaining the "Django stack"

2010-08-13 Thread Daniel Abel
On Aug 13, 2:43 pm, Oivvio Polite  wrote:
> So I guess these errors are relating to some testing Django and/or
> South does per default and that the errors might be due to some version
> incompatibility between the Django/South versions I had installed last
> year and the ones that are installed now.
>
> My question isn't really about how to resolve this particular issue but
> rather about best practices for maintaining a consistent "Django stack",
> so that similar errors will not happen in the future.

You have basically two choices:

1) have someone do the 'which versions work together' testing for you.
This is what linux distributions implicitly promise: "use only
packages from the stable repository because those have been tested
that they work in combination". When something breaks, complain to
your linux distributor's maintainers.

2) 'Freeze' the package versions when you have something that works,
and run tests when you upgrade some packages to ensure that nothing
breaks. In this case, using virtualenv and pip can help a lot: you
write a requirements file that lists all the components you use, with
explicit version numbers and when deploying install (on a per-site,
not per-server basis) exactly those versions. (google 'virtualenv pip
django') The advantage is that nothing will break by suprise, the
disadvantage is that you don't get bugfixes (including security
bugfixes) silently.

(Personally I use option 2, virtualenv and pip)

Hope this helps,
Daniel Abel

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



Re: Programmatically connecting to a database

2010-08-13 Thread Joao Silva
Your answer is on this blog post:

http://tidbids.posterous.com/saas-with-django-and-postgresql

Good luck



On Aug 13, 2:19 pm, Jonathan Endersby  wrote:
> Hi
>
> I have a requirement that I imagine can't be too unique, however I am
> unable to find examples online of how to achieve what I'm trying to
> do.
>
> In simple terms, I need a setup where each one of my user's data is
> stored in their own database. (We're using mysql).
>
> I have a master database that stores which users exist and which
> database their data is in.
>
> I realise that this architecture might seem very odd but we have our
> reasons.
>
> The problem I face is that I want to use multiple database support but
> I don't want (can't) have all of the databases defined in the
> settings.py's DATABASES dict. We'll have thousands of users on a
> single box.
>
> So, for each request I need to interrogate the request, determine
> which user it is, open up a connection to their database, do stuff,
> and then return the result.
>
> Each users' database's structure is identical so I would like to use
> the ORM to interact with the data.
>
> Does anyone have any pointers on how to do this with Django?
>
> Thanks in advance,
> j.

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



Re: Best practice for maintaining the "Django stack"

2010-08-13 Thread joconnell
Hi,

I'd second that. PIP and virtual env have worked well for me too. You
could also combine it with fabric in order to automate the building of
different environments, so once you get a stable working environment
you can use pip's 'freeze' command to create a requirements file with
the exact versions of all currently installed packages and use fabric,
pip and virtualenv to deploy your code into a new virtualenv anytime
you like

You could then, for example,  create a new environment to test the
latest versions of some or all packages

Use package >= version_number instead of package == version_number in
your requirements file.

That way you won't break your production environment while you are
testing that the latest versions of packages play well together.

As noted above, there are loads of blog posts on doing this kind of
thing, it's pretty well documented.

John

On Aug 13, 1:54 pm, Daniel Abel  wrote:
> On Aug 13, 2:43 pm, Oivvio Polite  wrote:
>
> > So I guess these errors are relating to some testing Django and/or
> > South does per default and that the errors might be due to some version
> > incompatibility between the Django/South versions I had installed last
> > year and the ones that are installed now.
>
> > My question isn't really about how to resolve this particular issue but
> > rather about best practices for maintaining a consistent "Django stack",
> > so that similar errors will not happen in the future.
>
> You have basically two choices:
>
> 1) have someone do the 'which versions work together' testing for you.
> This is what linux distributions implicitly promise: "use only
> packages from the stable repository because those have been tested
> that they work in combination". When something breaks, complain to
> your linux distributor's maintainers.
>
> 2) 'Freeze' the package versions when you have something that works,
> and run tests when you upgrade some packages to ensure that nothing
> breaks. In this case, using virtualenv and pip can help a lot: you
> write a requirements file that lists all the components you use, with
> explicit version numbers and when deploying install (on a per-site,
> not per-server basis) exactly those versions. (google 'virtualenv pip
> django') The advantage is that nothing will break by suprise, the
> disadvantage is that you don't get bugfixes (including security
> bugfixes) silently.
>
> (Personally I use option 2, virtualenv and pip)
>
> Hope this helps,
> Daniel Abel

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



javascript

2010-08-13 Thread Imad Elharoussi
Hi
Is it possible to give a javascript function a django variable as a
parameter?
thank you

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



Re: javascript

2010-08-13 Thread Tim Sawyer
Yes

myJavaScriptFunction( {{DjangoTemplateVariable}} );

function myJavaScriptFunction( pValue ) {
  ...
}

Tim.

> Hi
> Is it possible to give a javascript function a django variable as a
> parameter?
> thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


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



Re: javascript

2010-08-13 Thread Boguslaw Faja
Hi,

Why not?

onclick="javascript:alert('{{param}}');"

?

best regards,

On Fri, Aug 13, 2010 at 4:31 PM, Imad Elharoussi
 wrote:
> Hi
> Is it possible to give a javascript function a django variable as a
> parameter?
> thank you
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Bogusław Faja
tel. (+48) 691544955

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



Re: Best practice for maintaining the "Django stack"

2010-08-13 Thread Thomas Guettler
Hi,

I develop on Linux and all my code is in $HOME and the code
of django and third party apps are in $HOME, too.

The Django SVN branch 
http://code.djangoproject.com/svn/django/branches/releases/1.2.X/
is checked out to _django1.2.X. And there is a symlink from $HOME/django to 
_djangoVERSION.
This way I can check out server django versions (trunk, 1.2.x, ...) and swith
between them with 'ln -sf _djangoVERSION/django django'

And the same for south. I checked it out to _south_hg and there is a symlink
from south to _south_hg/south. But I only use head/trunk from south.

What kind of error do you get? Please post the traceback.

If you remove south from INSTALLED_APPS, you get no errors, but you can't use 
it. I don't want
to miss it. It is a great tool.

  Thomas


Oivvio Polite wrote:
> I started playing around with Django sometime early 2009, did the
> tutorial and got started on a toy project. Then something came inbetween
> and now, coming back to my toy project I notice that the unit test spit
> out a lot of errors relating to the migration tool South. I've haven't
> written any test relating to South. My project isn't importing South and
> when I remove South from INSTALLED_APPS the errors go away.
> 
> So I guess these errors are relating to some testing Django and/or
> South does per default and that the errors might be due to some version
> incompatibility between the Django/South versions I had installed last
> year and the ones that are installed now.
> 
> My question isn't really about how to resolve this particular issue but
> rather about best practices for maintaining a consistent "Django stack",
> so that similar errors will not happen in the future.
> 
> 
> Oivvio
> 

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

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



Re: javascript

2010-08-13 Thread Imad Elharoussi
I mean can we make operations to the DjangoTemplateVariable in the
javascript function
 for example:
function myJavaScriptFunction( pValue ) {

  {{pValue.getName}}
...
}

2010/8/13 Tim Sawyer 

> Yes
>
> myJavaScriptFunction( {{DjangoTemplateVariable}} );
>
> function myJavaScriptFunction( pValue ) {
>  ...
> }
>
> Tim.
>
> > Hi
> > Is it possible to give a javascript function a django variable as a
> > parameter?
> > thank you
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com
> .
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



How to check for m2m orphans before deleting an object?

2010-08-13 Thread Alessandro Pasotti
Hi,

I have a m2m like this:

class TrackCategory(Model):
  

class Track(Model):
  category = models.ManyToManyField(TrackCategory)

I want to avoid that users delete a TrackCategory which contains Tracks, the
best would be to allow deletion of the TrackCategory if and only the linked
Tracks belongs to more than one category.

In other words, I want to avoid to have uncategorized Tracks.

I tried to override TrackCategory.delete() to do some checks before calling
the parent delete() but the method seems not to be called when deleting from
the change_list in admin.

Any idea?


PS: I'm using Django 1.2

-- 
Alessandro Pasotti
w3:   www.itopen.it

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



Re: How to check for m2m orphans before deleting an object?

2010-08-13 Thread cootetom
Hi, as far as i'm aware, the delete method on models only get's called
if you delete an instance of that modal directly. So if you delete a
modal who has many children, the child delete methods don't get
called. So I suppose the next question would be are you deleting
TrackCategory's directly or are you deleting something that contains
TrackCategory's?




On Aug 13, 4:02 pm, Alessandro Pasotti  wrote:
> Hi,
>
> I have a m2m like this:
>
> class TrackCategory(Model):
>   
>
> class Track(Model):
>   category = models.ManyToManyField(TrackCategory)
>
> I want to avoid that users delete a TrackCategory which contains Tracks, the
> best would be to allow deletion of the TrackCategory if and only the linked
> Tracks belongs to more than one category.
>
> In other words, I want to avoid to have uncategorized Tracks.
>
> I tried to override TrackCategory.delete() to do some checks before calling
> the parent delete() but the method seems not to be called when deleting from
> the change_list in admin.
>
> Any idea?
>
> PS: I'm using Django 1.2
>
> --
> Alessandro Pasotti
> w3:  www.itopen.it

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



Re: How to check for m2m orphans before deleting an object?

2010-08-13 Thread Alessandro Pasotti
2010/8/13 cootetom 

> Hi, as far as i'm aware, the delete method on models only get's called
> if you delete an instance of that modal directly. So if you delete a
> modal who has many children, the child delete methods don't get
> called. So I suppose the next question would be are you deleting
> TrackCategory's directly or are you deleting something that contains
> TrackCategory's?
>

In my test I'm deleting the category directly from the admin panel.

But the other case is also possible because TrackCategories can be nested in
a tree with MPTT (code.google.com/p/django-mptt/), perhaps this app override
delete() ?

In my test the TrackCategory I'm deleting has no subcategories and has no
parent category.

-- 
Alessandro Pasotti
w3:   www.itopen.it

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



Re: javascript

2010-08-13 Thread Daniel Roseman
On Aug 13, 3:50 pm, Imad Elharoussi  wrote:
> I mean can we make operations to the DjangoTemplateVariable in the
> javascript function
>  for example:
> function myJavaScriptFunction( pValue ) {
>
>   {{pValue.getName}}
> ...
>
> }
>

No. How would that be possible? The template is rendered on the
server, but javascript runs on the browser.
--
DR.

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



Book's sample code dl

2010-08-13 Thread Mike W.
Hi,

I was wondering if anybody has a location for the sample code download
for the book/author/publish application in the Django book.

I'm getting hung up on making forms and updating multiple tables
(foreign keys) in a database.  It seems like there's a lot of
tutorials out there that will cover the basics (IE: listing data), but
not a whole lot out there to save data to a db.  At least, not a whole
lot I could find that aren't super advanced, but just advanced enough
to cover relationships.

thanks in advanced.

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



Re: Encoding with {% url %} tag

2010-08-13 Thread shacker
On Aug 12, 9:22 am, aa56280  wrote:
> I'm using the url tag like so: {% url app.views.blah var1, var2 %}
>
> var1 and var2 need to be encoded, using the iriencode filter, so I
> tried this: {% url app.views.blah var1|iriencode, var2|iriencode %}
>
> That doesn't do anything though. I can't find any examples anywhere to
> figure this out.  Any thoughts?

Does the view code in app.views.blah know what to do with the
iriencode'd values?

Remember there are two ways to generate URLs in your templates -
either with the {% url ... %} tag as you're doing now or with a
get_absolute_url() method on the model (you then refer to  in your template).

By using the latter approach, you can write whatever custom python you
need in the model method.

http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#get-absolute-url

./s

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



Re: javascript

2010-08-13 Thread pengwupeng pengwupeng2008
of course ,you can,but you should add ",
function myJavaScriptFunction( pValue ) {

var aa=  “{{pValue.getName}}”;
...
}

2010/8/13 Imad Elharoussi 

> I mean can we make operations to the DjangoTemplateVariable in the
> javascript function
>  for example:
> function myJavaScriptFunction( pValue ) {
>
>   {{pValue.getName}}
> ...
> }
>
> 2010/8/13 Tim Sawyer 
>
> Yes
>>
>> myJavaScriptFunction( {{DjangoTemplateVariable}} );
>>
>> function myJavaScriptFunction( pValue ) {
>>  ...
>> }
>>
>> Tim.
>>
>> > Hi
>> > Is it possible to give a javascript function a django variable as a
>> > parameter?
>> > thank you
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To post to this group, send email to django-us...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com
>> .
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: convert textinput in label or text for a modelform and modelformset_factory

2010-08-13 Thread refreegrata
i'm sorry,but i don't understand the question.
the model is only an example. My idea is a model like this:

--
class Format(models.Model):
code = models.CharField(max_length=10)
name = models.CharField(max_length=30)
weight = models.PositiveSmallIntegerField()
..
--

the field code can only be edited when a new row is inserted. After
that the code must be displayed like a label or information,to inform
at the user the row that is editing.
--
formset

  Code 1 


  Code 2

.
--
I want to know if i can get the code list in the same instance where
the form is filled, or how i can do something like {{ fieldcode|id }}
or {{ fieldcode.id }} in the template?

Best regards

On 13 ago, 02:16, Boguslaw Faja  wrote:
> Hi,
>
> fast question: why fields = ['nombre'] instead of fields = ['name2'] ?
>
> Best regards
>
>
>
> On Wed, Aug 11, 2010 at 3:59 PM, refreegrata  wrote:
> > with a model like this:
> > --
> > class Format(models.Model):
> >    name1 = models.CharField(max_length=5)
> >    name2 = models.CharField(max_length=5)
> > --
>
> > and a modelform like this:
> > -
> > MyForm(forms.ModelForm)
> >   class Meta:
> >        model = Format
> >        fields = ['nombre']
> > -
>
> > this code will generate 2 "input text", the "input text" name1 and the
> > "input text" name2. But for an unique modelform from the model
> > "format" i want an "input text"(name2)  and a "label" or
> > "text"(name1), because the field "name1" can only be edited in the
> > first time.  In any other occasion the field "name1" most be displayed
> > like an info about de field "name2"
>
> > I do not know if you understand my question. basically is ¿ how i can
> > supply info about a row of mi table for a specific form of my formset?
>
> > example
> > normaly my html page is
> > ---
> > formset
> > 
> >   > value="Oscar" name="name2..."/>
> > 
> > 
> >   > value="Jack" name="name2..."/>
> > 
> > .
> > ---
> > but i want something like this
> > ---
> > formset
> > 
> >  "Alex" 
> > 
> > 
> >  "John"
> > 
> > .
> > ---
>
> > Thanks for read
>
> > P.D.: sorry for mi poor english
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Django users" group.
> > To post to this group, send email to django-us...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.
>
> --
> Bogusław Faja
> tel. (+48) 691544955

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



Re: convert textinput in label or text for a modelform and modelformset_factory

2010-08-13 Thread refreegrata
the idea isn't depend of javascript.

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



Re: Django 1.2 modelformset_factory fails with meta: widgets

2010-08-13 Thread Matthew R
I got hit by this same bug and here's the workaround I used, for
future reference. Basically you need to specify a formfield_callback
kwarg to modelformset_factory that just passes along any kwargs it
receives (namely, in this case, the 'widget' argument) to
Field.formfield():

def create_formfield(f, **kwargs):
return f.formfield(**kwargs)

ArticleFormSet = modelformset_factory(Article,
  form = ArticleForm,
  formfield_callback=create_formfield,
  extra=0)


On Jul 29, 11:33 am, Jason  wrote:
> Can anyone confirm that passing in a form with Meta.widgets set to
> modelformset_factory() does in fact work?
>
> I've tried stripping my code down to the basics and still get the same
> exception. Debugging Django code doesn't help me because it fails
> during a lamda function that I don't quite understand.
>
> If anyone else has this problem I'll go ahead and submit a bug report.
>
> On Jul 28, 12:50 pm, Jason  wrote:
>
>
>
> > Traceback:
> > File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
> > get_response
> >   100.                     response = callback(request,
> > *callback_args, **callback_kwargs)
> > File "C:\Documents and Settings\goodrich\PycharmProjects\CCC\Aggregator
> > \newsmail\views.py" in manage_articles
> >   174.                                           form = ArticleForm)
> > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > modelformset_factory
> >   669.
> > formfield_callback=formfield_callback)
> > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > modelform_factory
> >   407.     return ModelFormMetaclass(class_name, (form,),
> > form_class_attrs)
> > File "C:\Python25\lib\site-packages\django\forms\models.py" in __new__
> >   220.                                       opts.exclude,
> > opts.widgets, formfield_callback)
> > File "C:\Python25\lib\site-packages\django\forms\models.py" in
> > fields_for_model
> >   178.         formfield = formfield_callback(f, **kwargs)
>
> > Exception Type: TypeError at /newsmail/manage/
> > Exception Value: () got an unexpected keyword argument
> > 'widget'
>
> > On Jul 28, 12:00 pm, Daniel Roseman  wrote:
>
> > > On Jul 28, 7:08 pm, Jason  wrote:
>
> > > > For example:
>
> > > > class ArticleForm(ModelForm):
> > > >     class Meta:
> > > >         model = Article
> > > >         widgets = {
> > > >              'pub_date': SplitSelectDateTimeWidget(),
> > > >              'expire_date': CalendarWidget(attrs={'class':'date-
> > > > pick'})
> > > >         }
>
> > > > And in a view function:
> > > > ...
> > > >     ArticleFormSet = modelformset_factory(Article,
> > > >                                           form = ArticleForm,
> > > >                                           extra=0)
> > > > ...
>
> > > > Removing 'widgets' from the Meta in ArticleForm fixes the error.
>
> > > > The new widgets convention here is really handy. I don't want to lose
> > > > it!
>
> > > > Any tips?
>
> > > How does it fail? What error do you get? If there's a traceback,
> > > please post it here.
> > > --
> > > DR.

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



Ordering in the admin

2010-08-13 Thread Wendy
I have a many to many field, with the horizontal available and chosen
boxes in the admin.  I wanted to see if there's any way that an admin
can select the order that the chosen objects show up, and have it be
saved and display that way.  Right now, they're not ordered, but seem
to show up based on when the object was created.  So I'm choosing
filmmakers for a film, and the only way I can change the order is to
destroy the filmmaker objects, then recreate and add them in a
different order, something that obviously wouldn't work in the real
world.  Is there any way to save the order in the chosen box in the
admin?

Thanks,
Wendy

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



csv files

2010-08-13 Thread Tony
My script right now basically just reads from a csv file and puts it
into a dictionary for me.  However, when I make my own csv file (just
the same as any I have seen), it acts inconsistently.  For example,
sometimes it starts at the second line and another time it kept
starting at the end of the file.  This isnt after multiple reads in
one script either, just the first read from it.  my question is, has
anyone seen this before and if so how is it corrected?  Also, is there
anyway to tell the script to start from the beginning of the file?

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



Re: Ordering in the admin

2010-08-13 Thread Nick Serra
You can go two directions with this. First, you could use a
intermediate model for the many to many join, which would allow you to
specify extra field on the join, in this case the order. Read up on
this here:
http://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships

The problem with solution one is that the many to many won't be
editable on that page anymore.

Solution two would be to scrap the manytomany and use inline models
instead. You would make an intermediate model, say FilmmakerItem,
which would foreign key to the model you want to join to, and a
foreign key to the filmmaker, and would have a field for order. This
would be editable in the admin under the same page.

Read about inline here:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#inlinemodeladmin-objects

On Aug 13, 12:52 pm, Wendy  wrote:
> I have a many to many field, with the horizontal available and chosen
> boxes in the admin.  I wanted to see if there's any way that an admin
> can select the order that the chosen objects show up, and have it be
> saved and display that way.  Right now, they're not ordered, but seem
> to show up based on when the object was created.  So I'm choosing
> filmmakers for a film, and the only way I can change the order is to
> destroy the filmmaker objects, then recreate and add them in a
> different order, something that obviously wouldn't work in the real
> world.  Is there any way to save the order in the chosen box in the
> admin?
>
> Thanks,
> Wendy

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



Bind variables in Oracle backend - how to use them?

2010-08-13 Thread buddhasystem

Friends,

I'm in need of an implementation which calls for using bind variables (in
Oracle sense, not generic) in my SQL in a Django application.

Any experience with that, anyone?

TIA

-- 
View this message in context: 
http://old.nabble.com/Bind-variables-in-Oracle-backend---how-to-use-them--tp29431038p29431038.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: Programmatically connecting to a database

2010-08-13 Thread buddhasystem

Do you think that implementing the Router class can be helpful as well? It
might save writing some code, not sure.




Your answer is on this blog post:

http://tidbids.posterous.com/saas-with-django-and-postgresql

Good luck



-- 
View this message in context: 
http://old.nabble.com/Programmatically-connecting-to-a-database-tp29428110p29431072.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: How to check for m2m orphans before deleting an object?

2010-08-13 Thread Nick Serra
Look into the clear() method on many to many relations.
Calling .clear() before a delete will remove all relations between the
models and allow you to delete the category only. You might be
fighting the django admin on this though, so this would be best
implemented in a custom solution. Not sure if you could override
delete and call the clear() function, this may trick the admin into
keeping the related objects, or maybe do something in a pre_delete
signal. Check out the clear function here:
http://docs.djangoproject.com/en/dev/topics/db/queries/#following-relationships-backward

On Aug 13, 11:33 am, Alessandro Pasotti  wrote:
> 2010/8/13 cootetom 
>
> > Hi, as far as i'm aware, the delete method on models only get's called
> > if you delete an instance of that modal directly. So if you delete a
> > modal who has many children, the child delete methods don't get
> > called. So I suppose the next question would be are you deleting
> > TrackCategory's directly or are you deleting something that contains
> > TrackCategory's?
>
> In my test I'm deleting the category directly from the admin panel.
>
> But the other case is also possible because TrackCategories can be nested in
> a tree with MPTT (code.google.com/p/django-mptt/), perhaps this app override
> delete() ?
>
> In my test the TrackCategory I'm deleting has no subcategories and has no
> parent category.
>
> --
> Alessandro Pasotti
> w3:  www.itopen.it

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



Re: Different Django instances running on the same server

2010-08-13 Thread buddhasystem

I think it's even simpler than this. When configuring your Apache, you
specify a few different virtual hosts listening on different ports. For each
host, you give a different PYTHONPAH. And that's it.



CLIFFORD ILKAY wrote:
> 
> On 08/12/2010 12:18 PM, Rick Caudill wrote:
>> Hi,
>>
>> Is it possible to run Django 1.1 and Django 1.2 on the same server?  I
>> have some legacy apps that I need to port to 1.2 but until then I would
>> still like to run 1.1 and also at the same time run 1.2 for some new
>> apps.  Is this possible
> 
> If you Google for pip + virtualenv + virtualenvwrapper, you'll find the 
> best way to do this. In short, you can create virtual Python 
> environments in which you can run not just different versions of Django, 
> or any other Python libraries, but even different versions of Python.
> 
> virtualenvwrapper.project is also quite worthwhile.
> -- 
> Regards,
> 
> Clifford Ilkay
> Dinamis
> 1419-3266 Yonge St.
> Toronto, ON
> Canada  M4N 3P6
> 
> 
> +1 416-410-3326
> 
> -- 
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 

-- 
View this message in context: 
http://old.nabble.com/Different-Django-instances-running-on-the-same-server-tp29420477p29431093.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: javascript

2010-08-13 Thread buddhasystem

That's easy as other people explained, but not too flexible.
I like putting hidden divs in my HTML and using jQuery to find this and
parse out the data.
This way, you can store complete structures id needed.



elharoussi wrote:
> 
> Hi
> Is it possible to give a javascript function a django variable as a
> parameter?
> thank you
> 

-- 
View this message in context: 
http://old.nabble.com/javascript-tp29429253p29431126.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: csv files

2010-08-13 Thread Steve Holden
On 8/13/2010 12:59 PM, Tony wrote:
> My script right now basically just reads from a csv file and puts it
> into a dictionary for me.  However, when I make my own csv file (just
> the same as any I have seen), it acts inconsistently.  For example,
> sometimes it starts at the second line and another time it kept
> starting at the end of the file.  This isnt after multiple reads in
> one script either, just the first read from it.  my question is, has
> anyone seen this before and if so how is it corrected?  Also, is there
> anyway to tell the script to start from the beginning of the file?
> 
Start by believing that there is a reason for the behavior :)

Unless you provide fieldnames as a parameter the csv module gobbles the
first line of the file as field names, which might have something to do
with your confusion.

How do you draw your conclusion it was starting at the end of the file -
did you see no data at all?

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

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



Re: Different Django instances running on the same server

2010-08-13 Thread Steve Holden
On 8/13/2010 1:09 PM, buddhasystem wrote:
> CLIFFORD ILKAY wrote:
>>
>> On 08/12/2010 12:18 PM, Rick Caudill wrote:
>>> Hi,
>>>
>>> Is it possible to run Django 1.1 and Django 1.2 on the same server?  I
>>> have some legacy apps that I need to port to 1.2 but until then I would
>>> still like to run 1.1 and also at the same time run 1.2 for some new
>>> apps.  Is this possible
>>
>> If you Google for pip + virtualenv + virtualenvwrapper, you'll find the 
>> best way to do this. In short, you can create virtual Python 
>> environments in which you can run not just different versions of Django, 
>> or any other Python libraries, but even different versions of Python.
>>
>> virtualenvwrapper.project is also quite worthwhile.

>
> I think it's even simpler than this. When configuring your Apache, you
> specify a few different virtual hosts listening on different ports.
For each
> host, you give a different PYTHONPAH. And that's it.
>
>
>
If you want the different hosts to all respond to the same IP address
and port 80, being selected by the Host: header coming on from the
clients then you will have to front-end them with a redirecting server,
in much the way that Web Faction do. It's quite possible, but it needs a
little more work to put that extra layer in.

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

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



Re: Different Django instances running on the same server

2010-08-13 Thread buddhasystem

Hello there,
sure it can also be done, but it's hardly worth the effort imho. Just let
these sit on two different ports and inform the client.

If you are still compelled to redirect requests based on origin while using
one external port, it's doable from inside Django as well -- you look at the
requestor IP, rehash the URL and forward request to same physical Apache,
but on a different port. Doesn't seem difficult either.



Steve Holden-4 wrote:
> 
> If you want the different hosts to all respond to the same IP address
> and port 80, being selected by the Host: header coming on from the
> clients then you will have to front-end them with a redirecting server,
> in much the way that Web Faction do. It's quite possible, but it needs a
> little more work to put that extra layer in.
> 
> regards
>  Steve
> -- 
> 

-- 
View this message in context: 
http://old.nabble.com/Different-Django-instances-running-on-the-same-server-tp29420477p29431251.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: Bind variables in Oracle backend - how to use them?

2010-08-13 Thread Ian
On Aug 13, 11:04 am, buddhasystem  wrote:
> Friends,
>
> I'm in need of an implementation which calls for using bind variables (in
> Oracle sense, not generic) in my SQL in a Django application.
>
> Any experience with that, anyone?

To use raw SQL with Django, see:
http://docs.djangoproject.com/en/1.2/topics/db/sql/#topics-db-sql

To add parameters to an ordinary Django query, use the
QuerySet.extra() method
http://docs.djangoproject.com/en/1.2/ref/models/querysets/#extra-select-none-where-none-params-none-tables-none-order-by-none-select-params-none

Note that Django placeholders always use the %s syntax regardless of
backend, so you'll need to use that rather than the named syntax
normally used with Oracle.

HTH,
Ian

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



Re: Different Django instances running on the same server

2010-08-13 Thread John Pencola
Rick,

Absolutely! You'll want to take a look at installing virtualenv on
that server. By running separate Python virtual environments you can
install different modules and versions of those modules in "isolation"
and then instruct your web server to reference a specific virtualenv.
Here are a couple good related posts that will get you up and running:

http://blog.ianbicking.org/2007/10/10/workingenv-is-dead-long-live-virtualenv/
http://www.saltycrane.com/blog/2009/05/notes-using-pip-and-virtualenv-django/

Hope that helps.
John Pencola

On Aug 12, 12:18 pm, Rick Caudill  wrote:
> Hi,
>
> Is it possible to run Django 1.1 and Django 1.2 on the same server?  I have
> some legacy apps that I need to port to 1.2 but until then I would still
> like to run 1.1 and also at the same time run 1.2 for some new apps.  Is
> this possible
>
> --
> Rick Caudill

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



Inserting a row with x_set or select_related

2010-08-13 Thread Juan Hernandez
Hey there,

Let's say that I have these models:

*from django.contrib.auth.models import User*
*
*
*class Publisher:*
*name = Char(x)*
*
*
*class Author:*
*publisher = FK(Publisher)*
*name = Char(x)*
*
*
*class Book:*
*user = FK(User)*
*author = FK(Author)*
*name = Char(x)*

As we see, Book is relatad to Author and User and Author is related to
Publisher. As we know, to add a record to Book I would have to have a User
and Author instance. Something like this:

*u = User.objects.get(id=1)*
*a = Publisher.objects.get(id=1).author_set.get(id=1237)*

and then insert the book data

*Book(user=u, author=a, name='MyBook').save()*

Now, my question is: Is there any way to insert data in the same statement
as you get the Author? something like:

*Publisher.objects.get(id=1).author_set.get(id=1237).Book(x, x, x).save()*
*
*
The problem I see is that Book needs it's parent instance. Is there any way
to go around this??

Thanks a lot as usual

jhv

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



Django Matrimonial Apps,

2010-08-13 Thread Rizwan Mansuri
Hello all,

 

I am thinking to start writing app for Matrimonial/Dating. If anyone knows
about anyone doing same project could please divert me to him/her/community.


 

I would appreciates if anyone would like to join for this project. I am
aiming to finish this within three month with basic functionality.

 

 

Regards

Riz

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



How can reverse('opensearch') work in the shell, but fail in a Test?

2010-08-13 Thread Bryan
I'm trying to install django-lean into my application.

Open search is used in my app App.

I can reverse('opensearch') in the Python shell. However, in the test,
reverse('opensearch') * NoReverseMatch: Reverse for 'opensearch' with
arguments '()' and keyword arguments

In [47]: reverse('opensearch')
Out[47]: '/opensearch.xml'
In [48]: response = client.get('/opensearch.xml')
In [49]: response.status_code
Out[49]: 200

This is an attempt to do the same from the Test, stopped by
pdb.set_trace()

No fixtures found.
> /usr/local/lib/python2.7/site-packages/django_lean-0.15-
py2.7.egg/django_lean/experiments/tests/
test_tags.py(72)doTestIntegration()
-> response = client.get("confirm_human") # this is where the
Client can't find the url
(Pdb) reverse('opensearch')
*** NoReverseMatch: Reverse for 'opensearch' with arguments '()'
and keyword arguments '{}' not found.

Here is the code from urls.py:

url(r'^opensearch\.xml$', app.meta.opensearch, name='opensearch'),

Finally, here is the traceroute for the failing test:

 
==
ERROR: testIntegrationWithRegisteredUser
(django_lean.experiments.tests.test_tags.ExperimentTagsTest)
 
--
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/django_lean-0.15-
py2.7.egg/django_lean/experiments/tests/test_tags.py", line 55, in
testIntegrationWithRegisteredUser
client_factory=create_registered_user_client)
  File "/usr/local/lib/python2.7/site-packages/django_lean-0.15-
py2.7.egg/django_lean/experiments/tests/test_tags.py", line 71, in
doTestIntegration
response = client.get(confirm_human_url)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/test/client.py", line 290, in get
response = self.request(**r)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/test/client.py", line 230, in request
response = self.handler(environ)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/test/client.py", line 74, in __call__
response = self.get_response(request)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/core/handlers/base.py", line 142, in get_response
return self.handle_uncaught_exception(request, resolver,
exc_info)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/core/handlers/base.py", line 181, in
handle_uncaught_exception
return callback(request, **param_dict)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/views/defaults.py", line 24, in server_error
return http.HttpResponseServerError(t.render(Context({})))
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/template/__init__.py", line 173, in render
return self._render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/test/utils.py", line 29, in instrumented_test_render
return self.nodelist.render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/template/__init__.py", line 796, in render
bits.append(self.render_node(node, context))
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/template/__init__.py", line 809, in render_node
return node.render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/template/loader_tags.py", line 125, in render
return compiled_parent._render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/test/utils.py", line 29, in instrumented_test_render
return self.nodelist.render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/template/__init__.py", line 796, in render
bits.append(self.render_node(node, context))
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/template/__init__.py", line 809, in render_node
return node.render(context)
  File "/usr/local/lib/python2.7/site-packages/Django-1.2.1-
py2.7.egg/django/template/defaulttags.py", line 378, in render
raise e
NoReverseMatch: Reverse for 'opensearch' with arguments '()' and
keyword arguments '{}' not found.

 
--
Ran 1 test in 1736.834s


Finally, here is the test: class ExperimentTagsTest(TestCase): urls =
'django_lean.experiments.tests.urls'

def setUp(self):
self.experiment = Experiment(name="test_experiment")
self.experiment.save()
self.experiment.state = Experiment.ENABLED_STATE
self.experiment.save()

self.other_experiment = Experiment(name="other_test_experiment")
self.other_experiment.save()
s

How to create a dynamic form queryset on using inlineformset_factory?

2010-08-13 Thread carson
hi all,
  i use inlineformset_facotry to edit & save the additional values for
my model.


#model.py

class ListingShippingService(models.Model):
site = models.ForeignKey(Site)
is_international = models.BooleanField(default=False)
is_flat = models.BooleanField(default=False)
is_calculated = models.BooleanField(default=False)
service = models.CharField(max_length=255)
description = models.TextField()

class ListingShippingDomestic(models.Model):
listing = models.ForeignKey(Listing)
service = models.ForeignKey(ListingShippingService)
cost = models.CharField(max_length=255, help_text='("Input 0
for free shipping")')
additional_cost = models.CharField(max_length=255, blank=True,
null=True)
is_free = models.BooleanField(default=False)


class ListingShippingInternational(models.Model):
listing = models.ForeignKey(Listing)
service = models.ForeignKey(ListingShippingService)
cost = models.CharField(max_length=255)
additional_cost = models.CharField(max_length=255, blank=True,
null=True)
ship_to_locations =
models.ManyToManyField(ListingInternationalShippingArea)


#forms.py
class ListingShippingInternationalForm(forms.ModelForm):
def __init__(self, * args, ** kwargs):
site_id = kwargs.get('site_id',None)
del kwargs['site_id']
super(ListingShippingInternationalForm, self).__init__(*args,
** kwargs)
service =
models.ListingShippingService.objects.filter(site=site_id,
is_international=True)
self.fields['service'].queryset = service
self.fields['ship_to_locations'].queryset =
models.ListingInternationalShippingArea.objects.filter(site=site_id)
class Meta:
exclude = ('listing',)
model = models.ListingShippingInternational

#views.py
from django.forms.models import inlineformset_factory
import models,forms
internationalInlineFormSet  = inlineformset_factory(models.Listing,
models.ListingShippingInternational, max_num=3,
form=forms.ListingShippingInternationalForm(site_id='xx'))

### here is my problem the works is:
internationalInlineFormSet  = inlineformset_factory(models.Listing,
models.ListingShippingInternational, max_num=3,
form=forms.ListingShippingInternationalForm)
### once i put (site_id='xx'), it will not work,  how can i
passing the parameter to it for create dynamic form?

can anybody helps? Thx!

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



fixtures with permissions

2010-08-13 Thread Javier Guerra Giraldez
Hi

in my system, i have a few predefined groups, and some custom
permissions.  the predefined groups have a strictly defined set of
these permission; it's a very basic part of the specification.

so, i defined these groups and the required permissions and dumped to
a fixture file.  after cleaning it to remove the basic tables, i set
it as the 'initial_data' fixture.  it worked very well.

to write tests, i use the same fixture and a few more defining test
data and users.  so far, no problem.

the problems arose when i refactored some of the tables.  now the
tests fail because the test users have wrong permissions.  after
checking a little, i found the auth_permissions records are generated
in a different order, so the number-based relationship in the
initial_data fixture is all wrong.

even worse, it's wrong in different ways in the 'real' database and
the test database, i guess because the real database has been growing
with each syncdb, while the test database is generated from scratch
each time.

there was some work about non-pk relationships in fixtures. i don't
know if it ended up in Django 1.2; but this is to be deployed on
Django 1.1

is there a better way to express permissions in fixtures? or if not,
can i run some python code after fixture loading to setup the
relationships?

-- 
Javier

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



Re: Overriding the widget of a custom form field in admin

2010-08-13 Thread Bill Freeman
I suspect that you must refrain from setting self.widget if widget is in kwargs.

On Thu, Aug 12, 2010 at 1:22 PM, omat  wrote:
> Hi All,
>
> I have a custom TagField form field.
>
> class TagField(forms.CharField):
>    def __init__(self, *args, **kwargs):
>        super(TagField, self).__init__(*args, **kwargs)
>        self.widget = forms.TextInput(attrs={'class':'tag_field'})
>
> As seen above, it uses a TextInput form field widget. But in admin I
> would like it to be displayed using Textarea widget. For this, there
> is formfield_overrides hook but it does not work for this case.
>
> The admin declaration is:
>
> class ProductAdmin(admin.ModelAdmin):
>    ...
>    formfield_overrides = {
>        TagField: {'widget': admin.widgets.AdminTextareaWidget},
>    }
>
> This has no effect on the form field widget and tags are still
> rendered with a TextInput widget.
>
> Any help is much appreciated.
>
> --
> omat
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



generating random keys/passwords

2010-08-13 Thread bagheera
Hi, i'm looking for python module to generate random strings used as  
activation keys to being sent to newsletter subscribers in order to  
activate their subscription.

Any suggestions?


--
Linux user

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



Re: generating random keys/passwords

2010-08-13 Thread Greg Pelly
have a look at Django Command Extensions:
http://code.google.com/p/django-command-extensions/

sample usage:

$ ./manage.py generate_secret_key
xr7+43ak=i^2+ommc_e6xn$6vph)_$ffb$n3kp#o1!675euxdu

Greg


On Fri, Aug 13, 2010 at 3:32 PM, bagheera  wrote:

> Hi, i'm looking for python module to generate random strings used as
> activation keys to being sent to newsletter subscribers in order to activate
> their subscription.
> Any suggestions?
>
>
> --
> Linux user
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: generating random keys/passwords

2010-08-13 Thread Greg Pelly
And to answer your more general question about email signups, have a look at
Django Registration. It should have everything you need.

http://bitbucket.org/ubernostrum/django-registration/wiki/Home

On Fri, Aug 13, 2010 at 3:44 PM, Greg Pelly  wrote:

> have a look at Django Command Extensions:
> http://code.google.com/p/django-command-extensions/
>
> sample usage:
>
> $ ./manage.py generate_secret_key
> xr7+43ak=i^2+ommc_e6xn$6vph)_$ffb$n3kp#o1!675euxdu
>
> Greg
>
>
> On Fri, Aug 13, 2010 at 3:32 PM, bagheera  wrote:
>
>> Hi, i'm looking for python module to generate random strings used as
>> activation keys to being sent to newsletter subscribers in order to activate
>> their subscription.
>> Any suggestions?
>>
>>
>> --
>> Linux user
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>

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



Re: generating random keys/passwords

2010-08-13 Thread Shawn Milochik
The auth module in contrib uses the make_token method of
default_token_generator in django.contrib.auth.tokens for the standard
password reset, so that sounds like a good choice.

Another good way to get a unique, random string is uuid.uuid4().

Shawn

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



Re: new Django-Python can't get to sqlite

2010-08-13 Thread Tom
The opsys is rhel AS5.2.  I couldn't find "yolk" on it (that's a
program, right?).
The machine has rpms for Python 2.4 & sqlite, but I was unable to get
Django working with them.  I thought Python 2.5 & later versions
included sqlite, so I started installing all the software (Python,
Django) in new locations under /opt.

I don't have a good grasp on installing stuff for Python. Is the link
of the django dir in Pythons's site-packages all I need to install
Django?  How do I install sqlite and/or pysqlite2, so that Django's
"syncdb" will work?  The "syncdb" error appears to say that
django/db/backends/sqlite3/base.py can't find pysqlite2 or sqlite3.
Where/how do I install them so DJango can find them?
 . . . . . . .
  File "/opt/Python-2.7/lib/python2.7/site-packages/django/db/backends/
sqlite3/base.py", line 34, in 
raise ImproperlyConfigured("Error loading %s: %s" % (module, exc))
django.core.exceptions.ImproperlyConfigured: Error loading either
pysqlite2 or sqlite3 modules (tried in that order): No module named
_sqlite3


[myserver]$ ll /opt
drwxr-xr-x 8 502  502 4096 Aug 11 20:44 Django-1.2.1
drwxr-xr-x 6 501   20 4096 Aug 11 22:00 pysqlite-2.6.0
drwxr-xr-x 6 simonst root 4096 Aug 11 20:10 Python-2.7
[caadmin]$ ll /opt/Python-2.7/lib/python2.7/site-packages
lrwxrwxrwx 1 root root  25 Aug 11 21:09 django -> /opt/Django-1.2.1/
django
-rw-r--r-- 1 root root 119 Aug 11 20:09 README
[caadmin]$ ll /opt/Django-1.2.1/django
drwxr-xr-x  3  502  502 4096 Aug 11 20:44 bin
drwxr-xr-x  6  502  502 4096 Aug 11 20:44 conf
drwxr-xr-x 22  502  502 4096 Aug 11 20:44 contrib
drwxr-xr-x  9  502  502 4096 Aug 11 20:44 core
drwxr-xr-x  4  502  502 4096 Aug 11 20:44 db
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 dispatch
drwxr-xr-x  3  502  502 4096 Aug 11 20:44 forms
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 http
-rw-r--r--  1  502  502  549 May 24 12:10 __init__.py
-rw-r--r--  1 root root  757 Aug 11 20:44 __init__.pyc
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 middleware
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 shortcuts
drwxr-xr-x  3  502  502 4096 Aug 11 20:44 template
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 templatetags
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 test
drwxr-xr-x  4  502  502 4096 Aug 11 20:44 utils
drwxr-xr-x  4  502  502 4096 Aug 11 20:44 views

On Aug 13, 1:08 am, Piotr Zalewa  wrote:
> Google "install sqlite/mysql $your_operating_system"
> If you provide more info (result of running yolk and your operating
> system) we will be able to help you a bit more.
>
> zalun
>
> On 10-08-13 03:15, Tom wrote:
>
> > It's my first time using Django&  I'm unable to get the demo going. I
> > would like to use sqlite (ultimately mysql).
> > Python 2.7 installed ok.  Then I installed (I think) Django 1.2.1.
> > The "manage.py runserver" works, but the "syncdb" fails.  How do I
> > "install" sqlite or pysqlite2 (or even mysql)?  I thought Python 2.5+
> > came with sqlite installed.
>

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



Ordering groups with aggregated field

2010-08-13 Thread MG
Hello,
I'm trying to order a list with aggregations. For a restaurant, I have
a visit list and i generate a customer list using
customer_list=visit_list.values('customer_no').annotate(Sum('totalbill')).order_by('totalbill_sum')
(visit class has visit no, customer no and totalbill models)

I want to order the visit_list in line with the aggregate field
totalbill_sum.For example:
visit no   customer no:   totalbill:
V1 C510
V2 C512
V3 C120
V4 C230
V5 C210
V6 C25

This gives customer list as
C2 ,totalbill_sum=45
C5 ,totalbill_sum=22
C1 ,totalbill_sum=20

In need Visit_list to be ordered as
V4
V5
V6
V1
V2
V3

Is there a way to do this?Thanks

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



Django psycopg2 installation issue

2010-08-13 Thread Nick
This is actually related to psycopg2, OS X and Postgres but I was
hoping someone in here has seen the same issue.

I recently installed PostgresPlus 8.4, Django dev (1.4?), and psycop2
version 2.2.0 on my imac OS X 10.6.4

When i try to run dbshell from the command line I get an error that
reads

raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2
module: dlopen(/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/psycopg2/_psycopg.so, 2): Library not loaded: /
usr/local/pgsql/lib/libpq.4.dylib
  Referenced from: /Library/Frameworks/Python.framework/Versions/2.5/
lib/python2.5/site-packages/psycopg2/_psycopg.so
  Reason: image not found

I've tracked the problem down to this line:

ibrary not loaded: /usr/local/pgsql/lib/libpq.4.dylib

The reason that library didn't load is because it doesn't exist
anywhere. I installed psycop via these instructions:

http://blog.jonypawks.net/2008/06/20/installing-psycopg2-on-os-x/

I've been through several threads and have still not been able to
figure out the issue

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



Django template compilation

2010-08-13 Thread Antoni Aloy
Hello!

Today I have been benchmarking a Django template to PHP compilar
called Haanga http://github.com/crodas/Haanga/ a development sponsored
by meneame.net a Digg like spanish site. Ricardo has made some sort of
benchmark http://gallir.wordpress.com/2010/08/13/haanga-vs-django-vs-h2o.
With my own benchmarks, using just the template part, Haanga it's
about 80% faster than Django. The post is in Spanish but you can see
the results.

I know template speed is not a real problem in most sites but I'm
quite impressed abut Haanga speed. My feelings are that the examples
as most benchmarks tends to show where the product shines (samples are
using lots of loops) but I haven't found any similar project for
Django or reasons about why Django does not uses the same approach.

I can guess some of the reasons: maitanibility, work split between
developers and designers, custom template filters, ... But I'd like to
know other's thoughts.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: new Django-Python can't get to sqlite

2010-08-13 Thread Piotr Zalewa

there us many ways to do so

I'd install pip from the package (rpm, right?)
and then run "pip install pysqlite3"
but the best would be o read about virtualenv and prepare djsngo 
environment for the project (not globally)


zalun

On 10-08-14 00:11, Tom wrote:

The opsys is rhel AS5.2.  I couldn't find "yolk" on it (that's a
program, right?).
The machine has rpms for Python 2.4&  sqlite, but I was unable to get
Django working with them.  I thought Python 2.5&  later versions
included sqlite, so I started installing all the software (Python,
Django) in new locations under /opt.

I don't have a good grasp on installing stuff for Python. Is the link
of the django dir in Pythons's site-packages all I need to install
Django?  How do I install sqlite and/or pysqlite2, so that Django's
"syncdb" will work?  The "syncdb" error appears to say that
django/db/backends/sqlite3/base.py can't find pysqlite2 or sqlite3.
Where/how do I install them so DJango can find them?
  . . . . . . .
   File "/opt/Python-2.7/lib/python2.7/site-packages/django/db/backends/
sqlite3/base.py", line 34, in
 raise ImproperlyConfigured("Error loading %s: %s" % (module, exc))
django.core.exceptions.ImproperlyConfigured: Error loading either
pysqlite2 or sqlite3 modules (tried in that order): No module named
_sqlite3


[myserver]$ ll /opt
drwxr-xr-x 8 502  502 4096 Aug 11 20:44 Django-1.2.1
drwxr-xr-x 6 501   20 4096 Aug 11 22:00 pysqlite-2.6.0
drwxr-xr-x 6 simonst root 4096 Aug 11 20:10 Python-2.7
[caadmin]$ ll /opt/Python-2.7/lib/python2.7/site-packages
lrwxrwxrwx 1 root root  25 Aug 11 21:09 django ->  /opt/Django-1.2.1/
django
-rw-r--r-- 1 root root 119 Aug 11 20:09 README
[caadmin]$ ll /opt/Django-1.2.1/django
drwxr-xr-x  3  502  502 4096 Aug 11 20:44 bin
drwxr-xr-x  6  502  502 4096 Aug 11 20:44 conf
drwxr-xr-x 22  502  502 4096 Aug 11 20:44 contrib
drwxr-xr-x  9  502  502 4096 Aug 11 20:44 core
drwxr-xr-x  4  502  502 4096 Aug 11 20:44 db
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 dispatch
drwxr-xr-x  3  502  502 4096 Aug 11 20:44 forms
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 http
-rw-r--r--  1  502  502  549 May 24 12:10 __init__.py
-rw-r--r--  1 root root  757 Aug 11 20:44 __init__.pyc
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 middleware
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 shortcuts
drwxr-xr-x  3  502  502 4096 Aug 11 20:44 template
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 templatetags
drwxr-xr-x  2  502  502 4096 Aug 11 20:44 test
drwxr-xr-x  4  502  502 4096 Aug 11 20:44 utils
drwxr-xr-x  4  502  502 4096 Aug 11 20:44 views

On Aug 13, 1:08 am, Piotr Zalewa  wrote:
   

Google "install sqlite/mysql $your_operating_system"
If you provide more info (result of running yolk and your operating
system) we will be able to help you a bit more.

zalun

On 10-08-13 03:15, Tom wrote:

 

It's my first time using Django&I'm unable to get the demo going. I
would like to use sqlite (ultimately mysql).
Python 2.7 installed ok.  Then I installed (I think) Django 1.2.1.
The "manage.py runserver" works, but the "syncdb" fails.  How do I
"install" sqlite or pysqlite2 (or even mysql)?  I thought Python 2.5+
came with sqlite installed.
   
 
   



--
blog http://piotr.zalewa.info
jobs http://webdev.zalewa.info
twit http://twitter.com/zalun
face http://www.facebook.com/zaloon

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



mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread John Yeukhon Wong
Hi, I know most of you work on Linux, but I do need this to be done on
Windows for a very personal reason.

I mainly followed this tutorial here, except that I use mod_wsgi over
mod_python.
http://wiki.thinkhole.org/howto:django_on_windows

I had my python 2.7, apache, mod_wsgi and postreg all installed under
my F drive.
This is the folder:  F:/public, and I created a project called
testproject, so I have F:/public/testproject

I am stuck at configuration Django with Apache (and mod_wsgi).
I spent 5 hours searching and reading the documentation and still
can't figure out how to do it right.

I read this
http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

I created two files:  apache_django_wsgi.conf and django.wsgi under F:/
public/testproject/apache, where apache is a manual created folder.
The actual Apache is installed under F:/Apache Software Foundation/
Apache2.2

I did these for Apache2.2/conf/httpd.conf

LoadModule wsgi_module modules/mod_wsgi.so
Include "f:/public/testproject/apache/apache_django_wsgi.conf"

So good so far. No error after restart ApACHE.

Now, I have to setup those two files.

I had this for the conf (I just copied it from the google doc)

# Code begin here
Alias /media/ f:/public/testproject/media/


Order deny,allow
Allow from all


WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"


Order deny,allow
Allow from all

#Code ends here

However, I was suspecting something bad to happen...

OKay. For django.wsgi

// code begins here
import os, sys
sys.path.append("f:/public")

os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

// code ends here

This one is better - I know the info is good and correct.


Now I restarted the apache again, no error.

But when I try to access to my localhost or localhost/testproject I
received this message

Forbidden:   You don't have permission to access /testproject/ on this
server.

I was denied, I don't know why we need that script anyway...

How should I set it up? How do I test if everything is working well?


Thank you!

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



Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread Graham Dumpleton


On Aug 14, 11:26 am, John Yeukhon Wong  wrote:
> Hi, I know most of you work on Linux, but I do need this to be done on
> Windows for a very personal reason.
>
> I mainly followed this tutorial here, except that I use mod_wsgi over
> mod_python.http://wiki.thinkhole.org/howto:django_on_windows
>
> I had my python 2.7, apache, mod_wsgi and postreg all installed under
> my F drive.
> This is the folder:  F:/public, and I created a project called
> testproject, so I have F:/public/testproject
>
> I am stuck at configuration Django with Apache (and mod_wsgi).
> I spent 5 hours searching and reading the documentation and still
> can't figure out how to do it right.
>
> I read thishttp://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>
> I created two files:  apache_django_wsgi.conf and django.wsgi under F:/
> public/testproject/apache, where apache is a manual created folder.
> The actual Apache is installed under F:/Apache Software Foundation/
> Apache2.2
>
> I did these for Apache2.2/conf/httpd.conf
>
> LoadModule wsgi_module modules/mod_wsgi.so
> Include "f:/public/testproject/apache/apache_django_wsgi.conf"
>
> So good so far. No error after restart ApACHE.
>
> Now, I have to setup those two files.
>
> I had this for the conf (I just copied it from the google doc)
>
> # Code begin here
> Alias /media/ f:/public/testproject/media/
>
> 
> Order deny,allow
> Allow from all
> 
>
> WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"
>
> 
> Order deny,allow
> Allow from all
> 
> #Code ends here
>
> However, I was suspecting something bad to happen...
>
> OKay. For django.wsgi
>
> // code begins here
> import os, sys
> sys.path.append("f:/public")
>
> os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> // code ends here
>
> This one is better - I know the info is good and correct.
>
> Now I restarted the apache again, no error.
>
> But when I try to access to my localhost or localhost/testproject I
> received this message
>
> Forbidden:   You don't have permission to access /testproject/ on this
> server.
>
> I was denied, I don't know why we need that script anyway...
>
> How should I set it up? How do I test if everything is working well?

Did you try and walk before you ran? ;-)

That is, did you try getting a WSGI hello world program working before
you decided to try and get Django site to work?

Anyway, you need to look at the Apache error logs to find out the
actual reason why Apache has given you a 403 error.

I suggest you also go watch my mod_wsgi talk where it references
exactly why you get some of these problems, including Forbidden
errors, with examples of the errors you will see in Apache error log.
Links to talk at:

  
http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_Presentations

Graham

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



Re: Django template compilation

2010-08-13 Thread Russell Keith-Magee
On Sat, Aug 14, 2010 at 7:40 AM, Antoni Aloy  wrote:
> Hello!
>
> Today I have been benchmarking a Django template to PHP compilar
> called Haanga http://github.com/crodas/Haanga/ a development sponsored
> by meneame.net a Digg like spanish site. Ricardo has made some sort of
> benchmark http://gallir.wordpress.com/2010/08/13/haanga-vs-django-vs-h2o.
> With my own benchmarks, using just the template part, Haanga it's
> about 80% faster than Django. The post is in Spanish but you can see
> the results.
>
> I know template speed is not a real problem in most sites but I'm
> quite impressed abut Haanga speed. My feelings are that the examples
> as most benchmarks tends to show where the product shines (samples are
> using lots of loops) but I haven't found any similar project for
> Django or reasons about why Django does not uses the same approach.
>
> I can guess some of the reasons: maitanibility, work split between
> developers and designers, custom template filters, ... But I'd like to
> know other's thoughts.

Template rendering speed may not be a problem for many sites, but any
improvement in rendering speed would have benefits.

One of the GSoC proposals for this year was to look at introducing a
'compiled' template loader -- rendering templates directly into Python
bytecode, which has the potential to significantly improve rendering
speed. This proposal was made by Alex Gaynor, who ultimately retracted
that proposal in favor of his noSQL proposal,

I would be very interested in seeing this sort of optimization added
to Django, so if anyone is looking for a non-trivial project, dig up
Alex's GSoC proposal and see what you can do!

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django Matrimonial Apps,

2010-08-13 Thread Kenneth Gonsalves
On Fri, 2010-08-13 at 20:08 +0100, Rizwan Mansuri wrote:
> I would appreciates if anyone would like to join for this project. I
> am
> aiming to finish this within three month with basic functionality. 

is it to be open source?
-- 
regards
Kenneth Gonsalves

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



Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread John Yeukhon Wong
Hi, Graham.

I watched the video and your pdf up until the point you ran the wsgi
successfully.

I restarted the apache and bottom of the apache monitor said "Apache/
2.2.16(Win32) mod_wsgi/3.3Python/2.7", and also I could see localhost
again. I can see the blue page.

I am sorry if I sound too stupid, but I am pretty new...

1. Don't put the hello.wsgi and any wsgi app under the home directory.
Is it F:/public (where my django project testproject is located)? So I
should create a folder outside public right?
2. If so, do I add this following code to the wsgi conf file ?

Order deny,allow
Allow from all


3. I try to access to localhost/hello.wsgi but it's still giving me
the same blue django default page

Thank you for the help






On Aug 13, 10:01 pm, Graham Dumpleton 
wrote:
> On Aug 14, 11:26 am, John Yeukhon Wong  wrote:
>
>
>
> > Hi, I know most of you work on Linux, but I do need this to be done on
> > Windows for a very personal reason.
>
> > I mainly followed this tutorial here, except that I use mod_wsgi over
> > mod_python.http://wiki.thinkhole.org/howto:django_on_windows
>
> > I had my python 2.7, apache, mod_wsgi and postreg all installed under
> > my F drive.
> > This is the folder:  F:/public, and I created a project called
> > testproject, so I have F:/public/testproject
>
> > I am stuck at configuration Django with Apache (and mod_wsgi).
> > I spent 5 hours searching and reading the documentation and still
> > can't figure out how to do it right.
>
> > I read thishttp://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>
> > I created two files:  apache_django_wsgi.conf and django.wsgi under F:/
> > public/testproject/apache, where apache is a manual created folder.
> > The actual Apache is installed under F:/Apache Software Foundation/
> > Apache2.2
>
> > I did these for Apache2.2/conf/httpd.conf
>
> > LoadModule wsgi_module modules/mod_wsgi.so
> > Include "f:/public/testproject/apache/apache_django_wsgi.conf"
>
> > So good so far. No error after restart ApACHE.
>
> > Now, I have to setup those two files.
>
> > I had this for the conf (I just copied it from the google doc)
>
> > # Code begin here
> > Alias /media/ f:/public/testproject/media/
>
> > 
> > Order deny,allow
> > Allow from all
> > 
>
> > WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"
>
> > 
> > Order deny,allow
> > Allow from all
> > 
> > #Code ends here
>
> > However, I was suspecting something bad to happen...
>
> > OKay. For django.wsgi
>
> > // code begins here
> > import os, sys
> > sys.path.append("f:/public")
>
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > // code ends here
>
> > This one is better - I know the info is good and correct.
>
> > Now I restarted the apache again, no error.
>
> > But when I try to access to my localhost or localhost/testproject I
> > received this message
>
> > Forbidden:   You don't have permission to access /testproject/ on this
> > server.
>
> > I was denied, I don't know why we need that script anyway...
>
> > How should I set it up? How do I test if everything is working well?
>
> Did you try and walk before you ran? ;-)
>
> That is, did you try getting a WSGI hello world program working before
> you decided to try and get Django site to work?
>
> Anyway, you need to look at the Apache error logs to find out the
> actual reason why Apache has given you a 403 error.
>
> I suggest you also go watch my mod_wsgi talk where it references
> exactly why you get some of these problems, including Forbidden
> errors, with examples of the errors you will see in Apache error log.
> Links to talk at:
>
>  http://code.google.com/p/modwsgi/wiki/WhereToGetHelp?tm=6#Conference_...
>
> Graham

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



Re: Best practice for maintaining the "Django stack"

2010-08-13 Thread hcarvalhoalves
This is a common issue with South: it sometimes swallows some import
errors from other apps. In my case, I get this error with ImageKit
when PIL is not installed, or not compiled correctly.

About managing Django stack: the best thing you have is virtualenv +
virtualenvwrapper and PIP with requirements files. This allows you to
virtualize an entire Python environment, test the interaction between
different Python modules and reproduce the results in a production
environment.

On 13 ago, 09:43, Oivvio Polite  wrote:
> I started playing around with Django sometime early 2009, did the
> tutorial and got started on a toy project. Then something came inbetween
> and now, coming back to my toy project I notice that the unit test spit
> out a lot of errors relating to the migration tool South. I've haven't
> written any test relating to South. My project isn't importing South and
> when I remove South from INSTALLED_APPS the errors go away.
>
> So I guess these errors are relating to some testing Django and/or
> South does per default and that the errors might be due to some version
> incompatibility between the Django/South versions I had installed last
> year and the ones that are installed now.
>
> My question isn't really about how to resolve this particular issue but
> rather about best practices for maintaining a consistent "Django stack",
> so that similar errors will not happen in the future.
>
> Oivvio
>
> --http://pipedreams.polite.se/about/

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



Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread John Yeukhon Wong
According to this post
http://www.rkblog.rk.edu.pl/w/p/mod_wsgi/

I used the similar approach, and had localhost/hello.py and worked.

But what about the WSCI way that you showed us in the video?

Thank you.

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



Can't build Django documentation

2010-08-13 Thread Kevin
I tried to build the Django docs and got an error.

$ cd django/docs/
$ make html
sphinx-build -b djangohtml -d _build/doctrees   . _build/html
Running Sphinx v1.0.1
loading pickled environment... not yet created
building [djangohtml]: targets for 427 source files that are out of
date
updating environment: 427 added, 0 changed, 0 removed
/Users/haitran/Desktop/obnob_project/src/django_docs/_ext/
djangodocs.py:91: DeprecationWarning: xfileref_role is deprecated, use
XRefRole
  xrefs = sphinx.roles.xfileref_role('ref', linktext, linktext,
lineno, state)
reading sources... [ 73%] ref/contrib/gis/
commands
Exception occurred:
  File "/Users/src/django_docs/_ext/djangodocs.py", line 215, in
parse_django_adminopt_node
from sphinx.directives.desc import option_desc_re
ImportError: No module named desc
The full traceback has been saved in /var/folders/od/
odl44I41FT0yZPHQw8kT8E+++TM/-Tmp-/sphinx-err-RgDvku.log, if you want
to report the issue to the developers.
Please also report this if it was a user error, so that a better error
message can be provided next time.
Either send bugs to the mailing list at ,
or report them in the tracker at . Thanks!
make: *** [html] Error 1

The process fails when it tries to do an import:

from sphinx.directives.desc import option_desc_re

Why is there no module named desc?

I am using:
Python 2.6
Sphinx 1.0.1
Django 1.2.1
Mac OS X 10.5.8

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



dashboard question

2010-08-13 Thread ionut cristian cucu
Hello list,
I customized my first dashboard like so: http://paste.pocoo.org/show/250028/,
but when I added Group, the site gets rendered weird:
http://img705.imageshack.us/img705/8148/djangositeadmin12817724.png.
Could you please help me find what have I done wrong?
Thanks!

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



Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread Graham Dumpleton


On Aug 14, 12:52 pm, John Yeukhon Wong  wrote:
> Hi, Graham.
>
> I watched the video and your pdf up until the point you ran the wsgi
> successfully.
>
> I restarted the apache and bottom of the apache monitor said "Apache/
> 2.2.16(Win32) mod_wsgi/3.3Python/2.7", and also I could see localhost
> again. I can see the blue page.
>
> I am sorry if I sound too stupid, but I am pretty new...
>
> 1. Don't put the hello.wsgi and any wsgi app under the home directory.
> Is it F:/public (where my django project testproject is located)? So I
> should create a folder outside public right?

The example directories in the talk were based on a UNIX system being
used, not Windows. The naming of the directories is not important. The
lesson to be learnt from that part is that directories/files have
access permissions. The Apache web server runs as a special user and
that special user needs to have adequate privileges to access where
you put stuff. How you change permissions on directories/files will be
different on Windows to Linux, but it is still an issue you need to be
mindful off.

Anyway, you are missing the point. My original message said to look at
the Apache error log file, which is possibly different to the Apache
monitor you are using as I don't know what you are referring to there.
In the Apache error log you would have found an error from Apache as
to what caused the 403, on the basis that your original quoted message
was from the browser and matched what Apache would produce.

What was that error message? From that you would have a clue as to
what you haven't configured properly.

> 2. If so, do I add this following code to the wsgi conf file ?
> 
> Order deny,allow
> Allow from all
> 

You will something like that, but the directory path depends on where
you are putting your files. That part of your original quoted
configuration looked fine, yet problems with that can be the cause for
a 403, which is why I asked you to go find the error message in the
Apache error logs.

> 3. I try to access to localhost/hello.wsgi but it's still giving me

If you were following the configuration like in the talks, you
wouldn't be accessing 'localhost/hello.wsgi'. This is because the
examples did not use the name of the script file in the URL.

> the same blue django default page

Well, if you have blue Django default page then you must have
something working, but can't say I know what or how cause you never
responded with the details for why the 403 error occurred from the
logs. You must have just lucked onto the right thing.

Graham

> Thank you for the help
>
> On Aug 13, 10:01 pm, Graham Dumpleton 
> wrote:
>
>
>
> > On Aug 14, 11:26 am, John Yeukhon Wong  wrote:
>
> > > Hi, I know most of you work on Linux, but I do need this to be done on
> > > Windows for a very personal reason.
>
> > > I mainly followed this tutorial here, except that I use mod_wsgi over
> > > mod_python.http://wiki.thinkhole.org/howto:django_on_windows
>
> > > I had my python 2.7, apache, mod_wsgi and postreg all installed under
> > > my F drive.
> > > This is the folder:  F:/public, and I created a project called
> > > testproject, so I have F:/public/testproject
>
> > > I am stuck at configuration Django with Apache (and mod_wsgi).
> > > I spent 5 hours searching and reading the documentation and still
> > > can't figure out how to do it right.
>
> > > I read thishttp://code.google.com/p/modwsgi/wiki/IntegrationWithDjango
>
> > > I created two files:  apache_django_wsgi.conf and django.wsgi under F:/
> > > public/testproject/apache, where apache is a manual created folder.
> > > The actual Apache is installed under F:/Apache Software Foundation/
> > > Apache2.2
>
> > > I did these for Apache2.2/conf/httpd.conf
>
> > > LoadModule wsgi_module modules/mod_wsgi.so
> > > Include "f:/public/testproject/apache/apache_django_wsgi.conf"
>
> > > So good so far. No error after restart ApACHE.
>
> > > Now, I have to setup those two files.
>
> > > I had this for the conf (I just copied it from the google doc)
>
> > > # Code begin here
> > > Alias /media/ f:/public/testproject/media/
>
> > > 
> > > Order deny,allow
> > > Allow from all
> > > 
>
> > > WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"
>
> > > 
> > > Order deny,allow
> > > Allow from all
> > > 
> > > #Code ends here
>
> > > However, I was suspecting something bad to happen...
>
> > > OKay. For django.wsgi
>
> > > // code begins here
> > > import os, sys
> > > sys.path.append("f:/public")
>
> > > os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'
>
> > > import django.core.handlers.wsgi
> > > application = django.core.handlers.wsgi.WSGIHandler()
>
> > > // code ends here
>
> > > This one is better - I know the info is good and correct.
>
> > > Now I restarted the apache again, no error.
>
> > > But when I try to access to my localhost or localhost/testproject I
> > > received this message
>
> > > Forbidden:   You don't have permission to access /testproject/ on t

Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread John Yeukhon Wong
Hi, Graham

I looked at the error log and I fully understood the problem.

I spent an hour trying different ways to understand the whole thing.
Here is the result.

f:/public/testproject/apache/django.wsgi

//code begins here
import os, sys
sys.path.append("f:/public")

os.environ['DJANGO_SETTINGS_MODULE'] = 'testproject.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

//code ends here


if I add your hello world code in this file, and restarted the apache,
I will have hello world.
I created a hello.wsgi (and hello.py). For each, I had to manually set
up an alias
For example this works
WSGIScriptAlias /hello "f:/public/testproject/apache/hello.wsgi"

I noticed that if I have two of them co-exist simultaneously
WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"
WSGIScriptAlias /testproject "f:/public/testproject/apache/hello.wsgi"

I will get nothing but the same default blue page. I looked the error
log, nothing showed up. The access log, however, is interesting, but I
couldn't get any information from the web.

// portion of the log
127.0.0.1 - - [14/Aug/2010:00:48:45 -0400] "GET / HTTP/1.1" 200 12
127.0.0.1 - - [14/Aug/2010:00:48:46 -0400] "GET / HTTP/1.1" 200 12
127.0.0.1 - - [14/Aug/2010:00:49:02 -0400] "GET / HTTP/1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:17 -0400] "GET / HTTP/1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:18 -0400] "GET / HTTP/1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:19 -0400] "GET / HTTP/1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:25 -0400] "GET /testproject/ HTTP/
1.1" 200 2061
127.0.0.1 - - [14/Aug/2010:01:27:26 -0400] "GET /testproject/ HTTP/
1.1" 200 2061


The one with 200 12 happened long before 200 2061 did. The 200 12 was
the access record of only having one alias (either one, and not both).
The 200 2061 is when both exist, and I reqest to access them. There is
no error, but this 2061 code probably suggest something. Do you know
by any chance?

Anyway. These tests conclude that I have my mod_wsgi working
correctly.


I understand that there are a few disadvantage of working on a MS, for
example: lack of daemon mode, and a bit more complicated to handle
users and file permission than on a UNIX.

I do plan to deploy the project on a UNIX server in the future, and I
still do want to follow up with the previous discussion:

So in general,

1. When I write a django project, for each project I need a different /
apache/ and the content within? I know mod_wgics is a module we use to
allow apache to run python but I am not clear how we actually use
it.


2. If I am going to work on a UNIX, let say a linux distro, if I
create a wsgi folder outside /home/ (now i am clear which one you are
referring to...), where do you prefer? How do I link it again? I am
not very clear from the video because I am raised in United States,
and your Australian accent troubled me a little...I am sorry...

Thank you.

John

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



Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread Sam Lai
On 14 August 2010 15:39, John Yeukhon Wong  wrote:
> I noticed that if I have two of them co-exist simultaneously
> WSGIScriptAlias / "f:/public/testproject/apache/django.wsgi"
> WSGIScriptAlias /testproject "f:/public/testproject/apache/hello.wsgi"
>
> I will get nothing but the same default blue page. I looked the error
> log, nothing showed up. The access log, however, is interesting, but I
> couldn't get any information from the web.

The problem I think is when you request /testproject, it also matches
/ (with the testproject part passed to the WSGI handler). Try swapping
them around so the more specific one matches first, before the more
generic one.

I would be using separate config sections to do what you're doing
though, using either ServerName or port to differentiate between
sections.

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



Re: mod_wsgi+Apache+Postregsql on Windows

2010-08-13 Thread Sam Lai
I haven't watched Graham's video, but here's what I typically do.

On 14 August 2010 15:39, John Yeukhon Wong  wrote:
> I do plan to deploy the project on a UNIX server in the future, and I
> still do want to follow up with the previous discussion:
>
> So in general,
>
> 1. When I write a django project, for each project I need a different /
> apache/ and the content within? I know mod_wgics is a module we use to
> allow apache to run python but I am not clear how we actually use
> it.

On *nix, I typically create a separate user for each project, and
store the Django code, media, templates, and WSGI handler file in
there. Otherwise you can just create them in a single user's home.

I would then take advantage of the sites-available / sites-enabled
directory structure that is usually created by default inside
/etc/apache2 to configure rules for each website.

On Windows, I'd probably create C:\wwwroot (or something meaningful;
IIS uses inetpub), then create a directory for each project in there.
I would store the WSGI handler file inside the project directory. You
need to ensure the Apache user has read rights to access that
directory and its children.

I'm not sure where Apache settings are stored or how they are
structured though on Windows; easiest would probably be to store all
Apache config inside apache2.conf.

There is really no fixed structure necessary; apart from the directory
structure inside the Django project directory, it doesn't matter where
you put projects and the WSGI handler file.

All mod_wsgi is is a connector that Apache calls on when the
particular config rules are matched. mod_wsgi will then call load and
execute the WSGI handler file, which will in turn fire up Django and
process the request.

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