Re: Date format in modelform.

2009-08-04 Thread zayatzz

Thanks Karen!

That was one awesome explanation of how datetime field and its widgets
work.

Could it be made sticky for all the future django beginners to read
who have this kind of problems? I for one will certainly bookmark it
so i can thrown this link to anybody who has similar problem.

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



Re: hosting a django application

2009-08-04 Thread Benjamin Sergeant

You can also look at mod_wsgi or spawning (the last one does not
require any configuration nor apache).

On Tue, Aug 4, 2009 at 9:53 PM, Kenneth Gonsalves wrote:
>
> On Wednesday 05 Aug 2009 10:00:37 am rekha wrote:
>> How can i host a django application (virtual hosting in apache) using
>> apache server. I should be able to access my application remotely and
>> do some changes.. what are the things i need to install.. and give me
>> the steps to do that..
>
> please look up using mod_python with apache in the install documentation
> --
> regards
> kg
> http://lawgon.livejournal.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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using email instead of username in extended "User" model?

2009-08-04 Thread Dana Woodman
Yeah that seems like the option Ill go with since it is probably the most
clean and future compatible. My user's dont need to log into django admin
anyways so that should suffice. Thanks everyone for the feedback!

Cheers,
Dana


On Mon, Aug 3, 2009 at 4:23 PM, Malcolm Tredinnick  wrote:

>
> On Mon, 2009-08-03 at 13:13 -0700, Dana wrote:
> > Ok, I understand the login part but what about registration? Wouldn't
> > the user's need a username still? Or am I misunderstanding... And what
> > about Django admin, it would still need a username correct?
>
> Nothing stops you from creating a random string to populate the username
> field with. It has to contain a unique identifier and it's often useful
> if that is actually identifiable -- perhaps created from an amalgam of
> the user's first and last names or something -- but it could be entirely
> random, providing it is unique.
>
> So when you are registering the user, just create a username string
> however you like. The user themselves doesn't have to know or care what
> it is. The thing is, their username won't change, their email address
> might (one of the many small problems with email addresses as unique and
> unchanging identifiers).
>
> Regards,
> Malcolm
>
>
>
> >
>

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



Re: hosting a django application

2009-08-04 Thread Kenneth Gonsalves

On Wednesday 05 Aug 2009 10:00:37 am rekha wrote:
> How can i host a django application (virtual hosting in apache) using
> apache server. I should be able to access my application remotely and
> do some changes.. what are the things i need to install.. and give me
> the steps to do that..

please look up using mod_python with apache in the install documentation
-- 
regards
kg
http://lawgon.livejournal.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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



hosting a django application

2009-08-04 Thread rekha

Hi,
How can i host a django application (virtual hosting in apache) using
apache server. I should be able to access my application remotely and
do some changes.. what are the things i need to install.. and give me
the steps to do that..

Thanks in advance..
Rekha

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



Change Admin Field Defaults or Attributes outside of the Model Field Definitions (for inherited models and the like)

2009-08-04 Thread ZebraShaSha

Not sure if anyone else has figured this out yet, but say you have an
Entry model with categories and then a bunch of models that subclass
it. When you define your Admin.ModelAdmin for the subclass, you can do
the following:

class SubclassModelForm(admin.ModelAdmin):
 opts = Entry._meta
 opts.get_field('title').default = "New default value"

This should work for anything that's available to your model fields:
help_text, editable, unique, anything. Really helpful!

(Also, thanks to James Bennet for the article here:
http://www.b-list.org/weblog/2007/nov/04/working-models/ for the help
in figuring this out!.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Specifying a join table for a customized query

2009-08-04 Thread Malcolm Tredinnick

On Tue, 2009-08-04 at 18:41 -0700, Daybreaker wrote:
> See a recent thread here:
> 
> http://groups.google.com/group/django-users/browse_thread/thread/0ee03167b7b5e873/850ac8304bf952b4#850ac8304bf952b4
> 
> and this query:
> 
> mymodel.objects.extra(select={'ordering_field': 'IF(STRCMP
> (bbs_tag.name, 'notice'), '',bbs_tag.name)'},
> order_by=['ordering_field'])
> 
> bbs_tag (=Tag._meta.db_table) should exist in the queryset, so I added
> a filter condition: tags__name__contains='' to make Django to perform
> a join.

Urgh. Not pretty or particularly robust. It would be entirely fine for
Django to hypothetically optimise away that filter condition, for
example (it doesn't now, but that's not to say it will never do so).

The extra() method already takes "tables" and "where" parameters, so you
can use those to set up the join in a more self-contained fashion (all
the custom stuff is in extra()).

Or look into writing a custom Q-like filter. That isn't documented,
since it's not really public API, but it's fairly easy to work out from
starting at django.db.models.sql.query.Query.add_q() to see what the API
looks like and it isn't going to change significantly in the near future
-- in fact, it will probably become public API pretty soon by virtue of
getting documented. We have enough experience now to know how that
particular API shoudl work.

> 
> Article.objects.filter(belongs_to=board, tags__name__contains='').extra
> (
> select={
> '_ordering':"CASE bbs_tag.name WHEN 'notice' THEN '' END",
> 'is_notice2':"bbs_tag.name = 'notice'",
> },
> order_by=['-_ordering', '-written_at']
> 
> But this query produces 7 objects with one duplicated.
> (Note that IF clause is a mysql-specific extension, so it's better to
> use CASE clause that is standard.)
> 
> The result set is a list of Article instances, but inside the query,
> tags should be joined and processed.
> How do I do this in more clear way?

Write the SQL directly. If you want ultimate control over the SQL, then
write SQL. If you want to and can express your query using the Python
models and other Python objects, use Django's ORM. However, the ORM is
not intended to be a 100% replacement for SQL; we already have SQL for
that. In particular, the ORM does not work in terms of specifying joins
between tables. It allows you to follow relations between models, which
translates to joins (sometimes), but it's not a one-to-one relationship.

Regards,
Malcolm



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



Re: Date format in modelform.

2009-08-04 Thread Karen Tracey
On Tue, Aug 4, 2009 at 2:05 PM, zayatzz  wrote:

>
> Thanks everybody.
>
> I changed this :
> birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
> required=False ),
>
> for this :
> birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
> required=False, widget=forms.DateInput(format='%d/%m/%Y') )
>
> And it all works very good.
>
> But there's something else fishy here.
>
> If i tried this:
>birth_date = forms.DateField(label='Birth Date', required=False,
> widget=forms.DateInput(format='%d/%m/%Y') )
>
> Then it did not save in correct format again. But guess in which
> format did it save?
> %m/%d/%Y
>
> Why the hell though? could this be a minor bug in django code?
>

No, it's not a bug in Django.  You removed the parameter that told the Field
how to properly interpret the date-value-as-string and turn it into a Python
date.

There are two format-type parameters.

The first, the one passed to the Field, tells the field what formats to try
when converting form a date-formatted-as-string (as will be present in POST
data) to a Python date object.  This format parameter is a sequence, and the
formats in it are tried in order until Python is able to parse the string
into a date value (or, until the sequence of formats is exhausted, in which
case a ValidationError is raised).

The second, the one passed to the Widget, tells the Widget in what format to
output existing dates. This is not a list, it is just a single value: your
preferred way of formatting dates for output.

If you want things to work properly, you need to make sure that your Field
is going to properly recognize the format you have asked the Widget to
output.  So your Field has to have the format you have specified for the
Widget in its list of allowed input formats.  But when you removed the
('%d/%m/%Y',) parameter to the Field, you changed things so that the Field
will use the default list of input formats:

http://docs.djangoproject.com/en/dev/ref/forms/fields/#django.forms.DateField.input_formats

None of the formats in the default list are "%d/%m/%Y".  Worse, one of the
default formats is "%m/%d/%Y" which will succeed in parsing some dates that
are actually in "%d/%m/%Y" format, only the values for day and month will
get swapped.  Which is what you saw, I gather.  The fix is to put back the
format parameter you had been passing to the DateField: it's necessary for
the format you are trying to use, as that is not a format that DateField
will be attempting to interpret dates with by default.

Karen

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



Re: mysqldb help! Can't connect to MySQL server error...

2009-08-04 Thread mdsmoker


> Why have you specified port 3036?

-cause i'm partially retarded, that's all...thanks for your help

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



Re: Intermediate Table question

2009-08-04 Thread Russell Keith-Magee

On Wed, Aug 5, 2009 at 12:58 AM, LeeRisq wrote:
>
> Does anyone know if an intermediate table can be specified on more
> than two models? For instance:
>
> class A(m.Model):
>       B = ManyToManyField(B, through='D')
>       C = ManyToManyField(C, through='D')
>
> Will this validate and actually work?

As long as D has a foreign Key FK relations with both B and C, it
should validate. What you will end up with is a ternary relation
between A, B, and C. Whether this is what you want is between you and
your requirements :-)

Yours,
Russ Magee %-)

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



Re: Template and substitute

2009-08-04 Thread David

Thanks for your replies.



On Aug 4, 4:16 am, David De La Harpe Golden
 wrote:
> Malcolm Tredinnick wrote:
> > You seem to be trying to create raw SQL using Django's template system.
> > Please don't do that. It's like trying to use a shovel to hammer in a
> > nail, but less effective.
>
> Pybatis, FWIW, is an sql templating thingy. Using jinja2 rather than
> django templates, just mentioning as an example of someone using
> templates for sql:
>
> http://www.cystemstechnology.com/pybatis/doc.html
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help building a custom RadioSelect widget.

2009-08-04 Thread Sam Walters

Thanks David

This example is exactly what i was hoping for.
I hope something like this gets put into a tutorial because i guess
many people would need to control exactly what their form looks like.

Cheers

-Sam

On Tue, Aug 4, 2009 at 11:00 PM, David De La Harpe
Golden wrote:
>
> Sam Walters wrote:
>
>> Any help completing/explaining this would be greatly appreciated and
>> open the floodgates towards understanding how to do this for all sorts
>> of pythonic/django overloading scenarios.
>>
>
> I had to do something similar a while back -
> http://python.pastebin.com/f7a905977
>
> Proved unexpectedly involved because also wanted to use it for model
> fields with choices specified - the form field used if you supply
> choices on modelfields is hardcoded in django.  Was going to
> raise a bug about it, but turns out it's bug #9245 ...
>
>
> >
>

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



Re: syncdb does not find app on the PYTHONPATH

2009-08-04 Thread Kenneth Gonsalves

On Wednesday 05 Aug 2009 6:14:48 am Matthew wrote:
> Also of note, when I ran python manage.py reset coltrane, I got this
> error:
>
> Error: App with label coltrane could not be found. Are you sure your
> INSTALLED_APPS setting is correct?

on the python shell try:
import coltrane

and if that succeeds

from coltrane import * - you may find an import error in coltrane.
-- 
regards
kg
http://lawgon.livejournal.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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: problem: TemplateDoesNotExist at /admin/ (linux)

2009-08-04 Thread LuXo Jarufe

Only reinstaling the last version of django this error dissapear,
'cause I had problems with the css too, in the stable version the css
didn't work, in windows the things are different beacuse the
installation is incomplete in some cases and you must copy manually
the templates directories (admin), if you're in linux the developrs
latest version is the best to don't have any error
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Specifying a join table for a customized query

2009-08-04 Thread Daybreaker

See a recent thread here:

http://groups.google.com/group/django-users/browse_thread/thread/0ee03167b7b5e873/850ac8304bf952b4#850ac8304bf952b4

and this query:

mymodel.objects.extra(select={'ordering_field': 'IF(STRCMP
(bbs_tag.name, 'notice'), '',bbs_tag.name)'},
order_by=['ordering_field'])

bbs_tag (=Tag._meta.db_table) should exist in the queryset, so I added
a filter condition: tags__name__contains='' to make Django to perform
a join.

Article.objects.filter(belongs_to=board, tags__name__contains='').extra
(
select={
'_ordering':"CASE bbs_tag.name WHEN 'notice' THEN '' END",
'is_notice2':"bbs_tag.name = 'notice'",
},
order_by=['-_ordering', '-written_at']

But this query produces 7 objects with one duplicated.
(Note that IF clause is a mysql-specific extension, so it's better to
use CASE clause that is standard.)

The result set is a list of Article instances, but inside the query,
tags should be joined and processed.
How do I do this in more clear way?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A custom ordering SQL and Django models

2009-08-04 Thread Daybreaker

Thanks, that works! (but I already changed my implementation not to
use tag-based ordering...)
For more generality, you could replace bbs_tag with Tag._meta.db_table
value.

On 8월4일, 오후11시25분, krylatij  wrote:
> Use extra() method of query set with little hack ;)
>
> mymodel.objects.extra(select={'ordering_field': 'IF(STRCMP
> (bbs_tag.name, 'notice'), '',bbs_tag.name)'},
> order_by=['ordering_field'])
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Apache and mod_wsgi on Ubuntu

2009-08-04 Thread Graham Dumpleton



On Aug 5, 10:27 am, Malcolm Tredinnick 
wrote:
> On Tue, 2009-08-04 at 17:12 -0700, Steve1234 wrote:
> > I am trying to setup Apache and mod_wsgi on Ubuntu to run Django
> > content. I generated a minimum project using "django-admin.py
> > startproject mysite" creating the project in my home folder. Running
> > the development server works and shows the "get started" page.  But
> > the "production" setup returns "Internal Server Error".  The Apache
> > error.log file reports:
>
> > ImportError: Could not import settings 'mysite.settings' (Is it on
> > sys.path? Does it have syntax errors?): No module named
> > mysite.settings
>
> > My /etc/apache2/httpd.conf file has one line:
> > WSGIScriptAlias / /home/steve/mysite/apache/django.wsgi
>
> > And the file /home/steve/mysite/apache/django.wsgi has 6 lines:
> > import os
> > import sys
> > sys.path.append('/home/steve/mysite')
> > os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
> > import django.core.handlers.wsgi
> > application = django.core.handlers.wsgi.WSGIHandler()
>
> > Any idea what I am doing wrong?
>
> You've set the Python path incorrectly.
>
> This is easily the most common error people make and I'm surprised you
> didn't find it in the searches you did in the archives before posting.
> This isn't anything Django specific. The Python path contains the
> directories from which imports are started. So if you want to import
> something called "mysite" it has to exist inside one of the directories
> on the Python path.

And it is highlighted in:

  http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango

What seems to happen though is people only look at the page in Django
documentation which isn't so clear, or rely on some arbitrary persons
blog to work out how to set it up. :-(

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



syncdb does not find app on the PYTHONPATH

2009-08-04 Thread Matthew

I am working through Chapter 4 of Practical Django Projects for Django
1.1.  After creating a new app, "coltrane", and adding a Category
class to its models.py file, I ran syncdb and everything worked.
Tables were added to the database and the admin interface included the
new Category model.

After completing the steps through page 62, adding a new Entry class
to the same models.py file, syncdb would not update.  I tried to
flush, reset, and even deleted the entire sqlite3 database file (and
even a postgresql version which was also working), then ran it again.
Only the Django core tables were created (like "auth") and the
directory's custom models (from the "cms" project).  Nothing on the
PYTHONPATH was created.

The offending app, "coltrane" lives in /home/matthew/dev/source.  An
third-party "tagging" app lives in /home/matthew/dev/
external_source.

Here is my PYTHONPATH:
/home/matthew/dev/source:/home/matthew/dev/external_source

Here is my INSTALLED_APPS:

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.flatpages',
'cms.search',
'coltrane',
'tagging',
)

Also of note, when I ran python manage.py reset coltrane, I got this
error:

Error: App with label coltrane could not be found. Are you sure your
INSTALLED_APPS setting is correct?

Any help is greatly appreciated!

Thanks,
Matt

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



Re: Apache and mod_wsgi on Ubuntu

2009-08-04 Thread Malcolm Tredinnick

On Tue, 2009-08-04 at 17:12 -0700, Steve1234 wrote:
> I am trying to setup Apache and mod_wsgi on Ubuntu to run Django
> content. I generated a minimum project using "django-admin.py
> startproject mysite" creating the project in my home folder. Running
> the development server works and shows the "get started" page.  But
> the "production" setup returns "Internal Server Error".  The Apache
> error.log file reports:
> 
> ImportError: Could not import settings 'mysite.settings' (Is it on
> sys.path? Does it have syntax errors?): No module named
> mysite.settings
> 
> My /etc/apache2/httpd.conf file has one line:
> WSGIScriptAlias / /home/steve/mysite/apache/django.wsgi
> 
> And the file /home/steve/mysite/apache/django.wsgi has 6 lines:
> import os
> import sys
> sys.path.append('/home/steve/mysite')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
> 
> Any idea what I am doing wrong?

You've set the Python path incorrectly.

This is easily the most common error people make and I'm surprised you
didn't find it in the searches you did in the archives before posting.
This isn't anything Django specific. The Python path contains the
directories from which imports are started. So if you want to import
something called "mysite" it has to exist inside one of the directories
on the Python path.

Regards,
Malcolm


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



Apache and mod_wsgi on Ubuntu

2009-08-04 Thread Steve1234

I am trying to setup Apache and mod_wsgi on Ubuntu to run Django
content. I generated a minimum project using "django-admin.py
startproject mysite" creating the project in my home folder. Running
the development server works and shows the "get started" page.  But
the "production" setup returns "Internal Server Error".  The Apache
error.log file reports:

ImportError: Could not import settings 'mysite.settings' (Is it on
sys.path? Does it have syntax errors?): No module named
mysite.settings

My /etc/apache2/httpd.conf file has one line:
WSGIScriptAlias / /home/steve/mysite/apache/django.wsgi

And the file /home/steve/mysite/apache/django.wsgi has 6 lines:
import os
import sys
sys.path.append('/home/steve/mysite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

Any idea what I am doing wrong?

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



Re: apache

2009-08-04 Thread Graham Dumpleton

You must recompile mod_python to use a different Python version.
Changing the symlink like that will not make a difference and you
could break other stuff on your system which assumed default Python is
a specific version.

You should also not go blindly changing permissions to 777 as that
makes it world writable which is bad practice and disastrous on a
shared host as other users can then change stuff in your directories.
Please go read documentation on file permissions on UNIX systems.

Graham

On Aug 5, 12:44 am, alexarsh  wrote:
> I think your default python is 2.6. What you can try is:
> "ls -a /usr/bin/python"
> You will see that it's a link to python2.6. You can change the link to
> point to python2.5.
> (ln -sf  /usr/bin/python)
> Then you will have to install mod_python with python2.5.
> If you install mod_python from source (by running configure, make,
> sudo make install), there is an option to tell mod_python your python
> version:
>
> --with-python=PATH      Path to specific Python binary
>
> So just run:
> configure --with-python  (from mod_python source
> directory)
> make
> sudo make install
>
> and it should work.
>
> Regards, Alex A.
>
> On Aug 4, 3:48 pm, Salvatore Leone 
> wrote:
>
>
>
> > > chmod -R 777 /home/testpec/public_html/pecwizard
>
> > I think you were right!
>
> > but now I've got an error due to mod_python using python2.6 insteal fo 2.5:
>
> > ImproperlyConfigured: Error loading MySQLdb module: No module named sets
>
> > I've always had this error with the manage.py until I run it with
> > "python2.5 manage.py .
>
> > Is there a way to tell mod_python to user python2.5 instead of 2.6??
>
> > -Salvatore
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Populating a form from the database

2009-08-04 Thread Magnus Valle

Short:
How do I populate a form with data from the database?
Fx. if I want to let users edit the data they have entered.

Long:
Currently, I have a form where the user(if logged in) will enter data 
and when it is submitted some extra data is entered to the form before 
it is saved, a time-stamp and the request.user .

But is there a way to open the form, looking to see if the user already 
has entered some data, then populate the form with that data. But if the 
user does not have a entry in the database, then presenting an empty form. ?

--
MV

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



Re: Can i rise 404 from my middleware ?

2009-08-04 Thread Alex Gaynor

On Tue, Aug 4, 2009 at 4:45 PM, Mirat Can
Bayrak wrote:
>
> Question is simple. i tried to use raise Http404 from middleware and that is 
> not working.
>
> My middleware is :
>
> import urlparse
> from django.contrib.sites.models import Site
> from django.http import Http404
>
> class GetSubdomainMiddleware:
>        def process_request(self, request):
>                site = Site.objects.filter(domain__exact = 
> request.META['HTTP_HOST'])
>                if site:
>                        bits = 
> urlparse.urlsplit(request.META['HTTP_HOST'])[2].split('.')
>                        request.subdomain = bits[0]
>                else:
>                        raise Http404
>
> --
> Mirat Can Bayrak 
>
> >
>

Right now there is a bug in django's middleware where it doesn't
correct catch exceptions: http://code.djangoproject.com/ticket/6094.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Can i rise 404 from my middleware ?

2009-08-04 Thread Mirat Can Bayrak

Question is simple. i tried to use raise Http404 from middleware and that is 
not working.

My middleware is :

import urlparse
from django.contrib.sites.models import Site
from django.http import Http404

class GetSubdomainMiddleware:
def process_request(self, request):
site = Site.objects.filter(domain__exact = 
request.META['HTTP_HOST'])
if site:
bits = 
urlparse.urlsplit(request.META['HTTP_HOST'])[2].split('.')
request.subdomain = bits[0]
else:
raise Http404

-- 
Mirat Can Bayrak 

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



Getting at the fields querysets of a form in a formset

2009-08-04 Thread bnl

Hi Folks

I'm trying to move up from a complex form based on a model declaration
to a model formset built on the same idea.

I have a model which has some stuff that looks something like

class Vocab(models.Model):
''' Holds the values of a choice list aka vocabulary '''
name=models.CharField(max_length=64)
class Value(models.Model):
''' Vocabulary Values '''
value=models.CharField(max_length=64)
vocab=models.ForeignKey(Vocab)
class Coupling:
couplingType=model.ForeignKey(Vocab)
class CouplingForm(form.modelForm):
class Meta:
model=Coupling
class MyCouplingForm(CouplingForm):
def __init__(self,*args,**kwargs):
CouplingForm.__init__(self,*args,**kwargs)
vocab=Vocab.objects.get(name='couplingType')
self.fields['couplingType].queryset=Value.objects.filter
(vocab=vocab)

It's a bit more complex than that (understatement, I hope I haven't
mucked up the actuality in simplifying it), but I hope you get the
picture ...

Anyway, that works fine ... but now I want to build a formset not just
a form ...

Ideally, I want to apply the same logic to the formset that I do to
the form (via subclassing). However, I can't quite work out how to do
it.

I was thinking I should try

CouplingFormSet=modelformset_factory(Coupling)

and somehow subclass CouplingFormSet or pass some arguments to the
formset factory method, but I can't find any docs on how to  replicate
the above functionality (I can see that I can limit the queryset for
the Couplings, but not for the attributes, like couplingType).

How does one get to the fields of the underlying forms in a formset?

I've had a nosy at the django code, but reckon I'd be days
understanding it enough to work this out.

Has anyone done anything like this that could give me some advice, or
point me to a prevoius discussion on something like this?

Thanks in advance,
Bryan

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



JSON Serialization with ImageField

2009-08-04 Thread scuzz

Hi,

I'm trying to receive a file encoded in a json string and store it in
an ImageField. I was hoping to use the standard Django deserialisation
like:

serializers.deserialize("json", "...snip..., \"myImageField\":
\"base64encodedimage\", ...snip...)

however it tries to store the image content string directly in the
field rather than going through the imagefield file storage mechanism.
has anyone solved this?

i've got control of the creation of the json string, so i can encode
the image however works best. i wasn't expecting base64 strings to
just work but that's a separate though related problem. i'm guessing i
need a hook into the deserialization to handle images specially but i
don't see how to go about it.

thanks for any help






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



Re: need help with model design and table relationship

2009-08-04 Thread Unnamed_Hero


> And you still haven't reduced it to a simple case that fails with a
> specific piece of data at the interactive prompt. You are trying to
> debug through three layers of curtains here. Why not remove the extra
> layers and work directly with the ORM to debug an ORM problem, as I
> suggested in the first piece of email?

I have tried to work in interactive shell, re-read django docs, but
still -
relation "C12B_boss" does not exist. (I'm using postres, and it is
error not from django, but from DB)

It seems to me solution is simple, but I can't find it.




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



Re: model upload_to

2009-08-04 Thread Paulo Almeida
For what it's worth, if all you want to do is change the upload folder, you
can also do it by overriding the form's __init__.

- Paulo

On Tue, Aug 4, 2009 at 9:28 PM, Stefan Hjelm wrote:

>
> ok don't know what typo I made yesterday but it works now, maybe
> backslash in path. Thanks.
>
> for you who want to know how:
>
> def get_path(instance, filename):
>return instance._folder
>
> My model:
> class File(models.Model):
>type = models.CharField(max_length=10)
> the_file = models.FileField(upload_to=get_path)
> def __unicode__(self):
>return self.file.name
> def save(self, force_insert=False, force_update=False):
> self._folder = "new_folder/"+self.the_file.name
> super(File, self).save(force_insert, force_update)
>
>
> On 4 Aug, 22:02, Daniel Roseman  wrote:
> > On Aug 4, 8:53 pm, caliman  wrote:
> >
> >
> >
> > > Hi!
> >
> > > I'm trying to change upload_to dynamically.
> >
> > > My model:
> > > class File(models.Model):
> > > type = models.CharField(max_length=10)
> > > the_file = models.FileField(upload_to="folder")
> > > def __unicode__(self):
> > > return self.file.name
> >
> > > Tried following:
> >
> > > 1, overwrite upload_to in save:
> > > def save(self, force_insert=False, force_update=False):
> > > the_file.upload = "new_folder"
> > > super(File, self).save(force_insert, force_update)
> >
> > > This gives:
> > > Exception Type: NameError
> > > Exception Value:global name 'the_file' is not defined
> >
> > > Also tried with slug fields and setting a function and set value in
> > > runtime with:
> > > the_file = models.FileField(upload_to=get_path)
> >
> > > that works great if I just want to change the filename but I can't
> > > change folder.
> >
> > > So what am I doing wrong?
> >
> > > Stefan
> >
> > Alex has given you the answer regarding why you're getting that
> > exception, but even when you've fixed that it won't do what you want -
> > by then it's far too late, the file has already been uploaded.
> >
> > Your second approach is the right one, making upload_to a function -
> > as explained in the documentation:
> http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield
> > But I don't understand why you say you can't change the folder there.
> > On the contrary, you can return a complete file path from your
> > upload_to function and that will be used as the file location. What
> > happens when you try?
> > --
> > DR
> >
>

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



Re: is it possible to do a monkey patch on django.contrib.atuh.models.User to make the email field unique?

2009-08-04 Thread Vasil Vangelovski

Thanks Alex, that worked.

Alex Koshelev wrote:
> Hi, Vasil!
>
> `Field.unique` is the read only property. If you want to set 
> uniqueness you have to assign field's `_unique` attribute to True.
>
> ---
> Alex Koshelev
>
>
> On Wed, Aug 5, 2009 at 12:54 AM, Vasil Vangelovski 
> > wrote:
>
>
> Having this line of code:
>
> User._meta.get_field('is_staff').default = True
> in the models.py for one of my apps works without problems.
> I wonder if it's possible to make email unique and
> first_name,last_name
> unique_together by using this technique.
>
> This:
>
> User._meta.get_field('email').unique = True
> fails with  AttributeError: can't set attribute.
>
> I know I can enforce uniqueness in forms but it would be nice if this
> can be done by modifying the User class and have the database field be
> unique because the same database may need to be accessed from
> outside of
> a django project.
>
>
>
>
> >


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



Re: is it possible to do a monkey patch on django.contrib.atuh.models.User to make the email field unique?

2009-08-04 Thread Alex Koshelev
Hi, Vasil!

`Field.unique` is the read only property. If you want to set uniqueness you
have to assign field's `_unique` attribute to True.

---
Alex Koshelev


On Wed, Aug 5, 2009 at 12:54 AM, Vasil Vangelovski
wrote:

>
> Having this line of code:
>
> User._meta.get_field('is_staff').default = True
> in the models.py for one of my apps works without problems.
> I wonder if it's possible to make email unique and first_name,last_name
> unique_together by using this technique.
>
> This:
>
> User._meta.get_field('email').unique = True
> fails with  AttributeError: can't set attribute.
>
> I know I can enforce uniqueness in forms but it would be nice if this
> can be done by modifying the User class and have the database field be
> unique because the same database may need to be accessed from outside of
> a django project.
>
> >
>

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



Re: Login screen is always shown, i dont like it :/

2009-08-04 Thread Paulo Almeida
Hi,

If you redirect users to your login screen in views that require login (for
instance, using the login_required decorator), you don't have to give out
your /accounts/login URL to users. Of course they can still go there if they
want, but there's no reason why they should. Your login can redirect to your
start page and the 'next' variable will take care of redirecting to the
original  page, if any, so that situation you don't like would never arise.

That said, I don't know if it's possible to do what you asked without
writing your own view.

- Paulo

On Tue, Aug 4, 2009 at 7:41 PM, MiratCanBayrak wrote:

>
> hi, i am using django.contrib.auth.views.login view  at /account/login
> url, to show login screen ( as explained here :
>
> http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.views.login
> )
>
> But, when user already logged in, form is not showing any error.
> Displaying a login form to already logged user is not giving
> professional sense i think. Can i change that behaviour or should i re-
> write login view myself?
> >
>

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



is it possible to do a monkey patch on django.contrib.atuh.models.User to make the email field unique?

2009-08-04 Thread Vasil Vangelovski

Having this line of code:

User._meta.get_field('is_staff').default = True
in the models.py for one of my apps works without problems.
I wonder if it's possible to make email unique and first_name,last_name 
unique_together by using this technique.

This:

User._meta.get_field('email').unique = True
fails with  AttributeError: can't set attribute.

I know I can enforce uniqueness in forms but it would be nice if this 
can be done by modifying the User class and have the database field be 
unique because the same database may need to be accessed from outside of 
a django project.

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



Re: model upload_to

2009-08-04 Thread Stefan Hjelm

ok don't know what typo I made yesterday but it works now, maybe
backslash in path. Thanks.

for you who want to know how:

def get_path(instance, filename):
return instance._folder

My model:
class File(models.Model):
type = models.CharField(max_length=10)
the_file = models.FileField(upload_to=get_path)
def __unicode__(self):
return self.file.name
def save(self, force_insert=False, force_update=False):
self._folder = "new_folder/"+self.the_file.name
super(File, self).save(force_insert, force_update)


On 4 Aug, 22:02, Daniel Roseman  wrote:
> On Aug 4, 8:53 pm, caliman  wrote:
>
>
>
> > Hi!
>
> > I'm trying to change upload_to dynamically.
>
> > My model:
> > class File(models.Model):
> >     type = models.CharField(max_length=10)
> >     the_file = models.FileField(upload_to="folder")
> > def __unicode__(self):
> >         return self.file.name
>
> > Tried following:
>
> > 1, overwrite upload_to in save:
> > def save(self, force_insert=False, force_update=False):
> >         the_file.upload = "new_folder"
> >         super(File, self).save(force_insert, force_update)
>
> > This gives:
> > Exception Type:         NameError
> > Exception Value:        global name 'the_file' is not defined
>
> > Also tried with slug fields and setting a function and set value in
> > runtime with:
> > the_file = models.FileField(upload_to=get_path)
>
> > that works great if I just want to change the filename but I can't
> > change folder.
>
> > So what am I doing wrong?
>
> > Stefan
>
> Alex has given you the answer regarding why you're getting that
> exception, but even when you've fixed that it won't do what you want -
> by then it's far too late, the file has already been uploaded.
>
> Your second approach is the right one, making upload_to a function -
> as explained in the 
> documentation:http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield
> But I don't understand why you say you can't change the folder there.
> On the contrary, you can return a complete file path from your
> upload_to function and that will be used as the file location. What
> happens when you try?
> --
> DR
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Paulo Almeida
Hi,

The myflow part comes from the parent urls.py, which includes myflow/urls.py
when matching ^myflow (sorry, didn't think of that). I did try to comment
out the CommonMiddleware line, in settings.py, and the error persisted, but
maybe I should try adding APPEND_SLASH = False. I will then look at
response['location'] with and without APPEND_SLASH to see if that is doing
anything.

Thanks again,
Paulo

On Tue, Aug 4, 2009 at 6:45 PM, Karen Tracey  wrote:

> On Tue, Aug 4, 2009 at 1:33 PM, Paulo Almeida  > wrote:
>
>> Hi Karen,
>>
>> You're right, I had some unnecessary lines that I used only for unittest.
>> I commented them out now. Printing response['location'] gives me this:
>>
>> http://testserver/myflow/experiment/1/
>>
>> You're also right that there is no Redirect in my view, so I don't know
>> where that is coming from. I guess I'll have to figure it out, because it
>> seems to be the key to the problem.
>>
>
> So it does appear to be APPEND_SLASH that is causing the redirect, since
> the only difference between that and what you requested is the added slash
> on the end.  Which implies the version without the added slash is not
> matching the url pattern you cited:
>
>  (r'^experiment/(?P\d+)$',
> 'bioinformatics.myflow.views.view_experiment'),
>
> even though that pattern doesn't require a trailing slash.  That pattern,
> though, also has no 'myflow' component.  Where is that coming from?  There
> seems to be more to your url configuration than you have made clear here.
>
> Karen
>
> >
>

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



Re: model upload_to

2009-08-04 Thread Stefan Hjelm

sorry, my last post was answer to the first reply :-)

I'll the second now. Thanks.

On 4 Aug, 22:08, Stefan Hjelm  wrote:
> thanks, forgot to say I tried that aswell but then nothing happens.
> It's just as it ignores that line. It still saves the file under
> "folder" and not under "new_folder"
>
> On 4 Aug, 21:55, Alex Gaynor  wrote:
>
> > On Tue, Aug 4, 2009 at 2:53 PM, caliman wrote:
>
> > > Hi!
>
> > > I'm trying to change upload_to dynamically.
>
> > > My model:
> > > class File(models.Model):
> > >    type = models.CharField(max_length=10)
> > >    the_file = models.FileField(upload_to="folder")
> > > def __unicode__(self):
> > >        return self.file.name
>
> > > Tried following:
>
> > > 1, overwrite upload_to in save:
> > > def save(self, force_insert=False, force_update=False):
> > >        the_file.upload = "new_folder"
> > >        super(File, self).save(force_insert, force_update)
>
> > > This gives:
> > > Exception Type:         NameError
> > > Exception Value:        global name 'the_file' is not defined
>
> > > Also tried with slug fields and setting a function and set value in
> > > runtime with:
> > > the_file = models.FileField(upload_to=get_path)
>
> > > that works great if I just want to change the filename but I can't
> > > change folder.
>
> > > So what am I doing wrong?
>
> > > Stefan
>
> > You needed to do self.the_file.  In python member variables aren't
> > automatically accessible, you have to get them from self.
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your
> > right to say it." -- Voltaire
> > "The people's good is the highest law." -- Cicero
> > "Code can always be simpler than you think, but never as simple as you
> > want" -- Me
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Intermediate Table question

2009-08-04 Thread Alex Gaynor

On Tue, Aug 4, 2009 at 3:06 PM, LeeRisq wrote:
>
>> I don't believe it would work, but even if it did, what would this do?
>>  What's the expecected behavior?
>
>
> class A defines an consumer order
>
> class B and C both define different lines of product
>
> I'd like to store all the ordering info in one intermediate table
> while maintaining different tables for the porducts
>
> Lee
> >
>

Bah, this is what I get for reading too quickly.  The answer is maybe,
you'd have to try it.  I see no obvious reason it wouldn't work
though.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Re: model upload_to

2009-08-04 Thread Stefan Hjelm

thanks, forgot to say I tried that aswell but then nothing happens.
It's just as it ignores that line. It still saves the file under
"folder" and not under "new_folder"

On 4 Aug, 21:55, Alex Gaynor  wrote:
> On Tue, Aug 4, 2009 at 2:53 PM, caliman wrote:
>
> > Hi!
>
> > I'm trying to change upload_to dynamically.
>
> > My model:
> > class File(models.Model):
> >    type = models.CharField(max_length=10)
> >    the_file = models.FileField(upload_to="folder")
> > def __unicode__(self):
> >        return self.file.name
>
> > Tried following:
>
> > 1, overwrite upload_to in save:
> > def save(self, force_insert=False, force_update=False):
> >        the_file.upload = "new_folder"
> >        super(File, self).save(force_insert, force_update)
>
> > This gives:
> > Exception Type:         NameError
> > Exception Value:        global name 'the_file' is not defined
>
> > Also tried with slug fields and setting a function and set value in
> > runtime with:
> > the_file = models.FileField(upload_to=get_path)
>
> > that works great if I just want to change the filename but I can't
> > change folder.
>
> > So what am I doing wrong?
>
> > Stefan
>
> You needed to do self.the_file.  In python member variables aren't
> automatically accessible, you have to get them from self.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Intermediate Table question

2009-08-04 Thread LeeRisq

> I don't believe it would work, but even if it did, what would this do?
>  What's the expecected behavior?


class A defines an consumer order

class B and C both define different lines of product

I'd like to store all the ordering info in one intermediate table
while maintaining different tables for the porducts

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



Re: model upload_to

2009-08-04 Thread Daniel Roseman

On Aug 4, 8:53 pm, caliman  wrote:
> Hi!
>
> I'm trying to change upload_to dynamically.
>
> My model:
> class File(models.Model):
>     type = models.CharField(max_length=10)
>     the_file = models.FileField(upload_to="folder")
> def __unicode__(self):
>         return self.file.name
>
> Tried following:
>
> 1, overwrite upload_to in save:
> def save(self, force_insert=False, force_update=False):
>         the_file.upload = "new_folder"
>         super(File, self).save(force_insert, force_update)
>
> This gives:
> Exception Type:         NameError
> Exception Value:        global name 'the_file' is not defined
>
> Also tried with slug fields and setting a function and set value in
> runtime with:
> the_file = models.FileField(upload_to=get_path)
>
> that works great if I just want to change the filename but I can't
> change folder.
>
> So what am I doing wrong?
>
> Stefan

Alex has given you the answer regarding why you're getting that
exception, but even when you've fixed that it won't do what you want -
by then it's far too late, the file has already been uploaded.

Your second approach is the right one, making upload_to a function -
as explained in the documentation:
http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield
But I don't understand why you say you can't change the folder there.
On the contrary, you can return a complete file path from your
upload_to function and that will be used as the file location. What
happens when you try?
--
DR
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'RelatedManager' object is not iterable

2009-08-04 Thread british.assassin

Yeah, that did it, thanks. I didn't even notice that, lol

Thanks again.

On Aug 4, 8:56 pm, Daniel Roseman  wrote:
> On Aug 4, 8:15 pm, "british.assassin" 
> wrote:
>
>
>
>
>
> > {% extends "base.html" %}
>
> > {% block title %}EvoWebs{% endblock %}
>
> > {% block body %}
> > {% if categories %}
> > {% for category in categories %}
> > 
> > {{category.name}}
> > {% for forum in category.forums %}
> > {{forum.name}}
> > {% endfor %}
> > 
> > {% endfor %}
> > {% else %}
> > This forum has no categories
> > {% endif %}
> > {% endblock %}
>
> It seems more likely that the error is coming from this line:
> {% for forum in category.forums %}
>
> It should be
> {% for forum in category.forums.all %}
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'RelatedManager' object is not iterable

2009-08-04 Thread Daniel Roseman

On Aug 4, 8:15 pm, "british.assassin" 
wrote:
>
> {% extends "base.html" %}
>
> {% block title %}EvoWebs{% endblock %}
>
> {% block body %}
> {% if categories %}
> {% for category in categories %}
> 
> {{category.name}}
> {% for forum in category.forums %}
> {{forum.name}}
> {% endfor %}
> 
> {% endfor %}
> {% else %}
> This forum has no categories
> {% endif %}
> {% endblock %}
>

It seems more likely that the error is coming from this line:
{% for forum in category.forums %}

It should be
{% for forum in category.forums.all %}
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: model upload_to

2009-08-04 Thread Alex Gaynor

On Tue, Aug 4, 2009 at 2:53 PM, caliman wrote:
>
> Hi!
>
> I'm trying to change upload_to dynamically.
>
> My model:
> class File(models.Model):
>    type = models.CharField(max_length=10)
>    the_file = models.FileField(upload_to="folder")
> def __unicode__(self):
>        return self.file.name
>
> Tried following:
>
> 1, overwrite upload_to in save:
> def save(self, force_insert=False, force_update=False):
>        the_file.upload = "new_folder"
>        super(File, self).save(force_insert, force_update)
>
> This gives:
> Exception Type:         NameError
> Exception Value:        global name 'the_file' is not defined
>
> Also tried with slug fields and setting a function and set value in
> runtime with:
> the_file = models.FileField(upload_to=get_path)
>
> that works great if I just want to change the filename but I can't
> change folder.
>
> So what am I doing wrong?
>
> Stefan
>
>
>
>
>
> >
>

You needed to do self.the_file.  In python member variables aren't
automatically accessible, you have to get them from self.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



model upload_to

2009-08-04 Thread caliman

Hi!

I'm trying to change upload_to dynamically.

My model:
class File(models.Model):
type = models.CharField(max_length=10)
the_file = models.FileField(upload_to="folder")
def __unicode__(self):
return self.file.name

Tried following:

1, overwrite upload_to in save:
def save(self, force_insert=False, force_update=False):
the_file.upload = "new_folder"
super(File, self).save(force_insert, force_update)

This gives:
Exception Type: NameError
Exception Value:global name 'the_file' is not defined

Also tried with slug fields and setting a function and set value in
runtime with:
the_file = models.FileField(upload_to=get_path)

that works great if I just want to change the filename but I can't
change folder.

So what am I doing wrong?

Stefan





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



Re: Email interface to django app

2009-08-04 Thread CLIFFORD ILKAY

On 04/08/09 03:29 PM, Margie wrote:
> I have an app that is similar in many ways to the django admin app.
> My users are requesting access via email.  IE, when an object (task in
> my case) gets created, they want it to send them an email and then
> they want to be able to respond to that email to update various fields
> associated with the task.
> 
> I'm interested in any insights folks have as to the preferable way to
> implement this.

Roundup  and Trac
 with the MailToTrac plugin
 both have ways of doing
this. You may be able to incorporate them into your code, or at least
borrow ideas.
-- 
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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Email interface to django app

2009-08-04 Thread Margie

I have an app that is similar in many ways to the django admin app.
My users are requesting access via email.  IE, when an object (task in
my case) gets created, they want it to send them an email and then
they want to be able to respond to that email to update various fields
associated with the task.

I'm interested in any insights folks have as to the preferable way to
implement this.

It seems to me there are a few obvious choices:

1. The guy that manages our IT side of things says I can have a script
get executed whenever an email request comes in.  This sendmail
interface would provide my program with the contents of the email, and
my program could be a 'manage.py shell' program that processes the
request, opening my database and modifying it accordingly.

2.  Similar to 1 above, I could have a script get executed whenever an
email request comes in,  but instead of actually doing the processing
and modifying the database, it could contact the server via a POST and
have the server do the work

3. I saw an example of the way jutda does it - they seem to use cron
to run their script, and the script is basically in line with 1)
above.  The cron job runs the script periodically it grabs the email
(eithe rvia pop or imap) and them modifies the db via the standard
django ORM interface.

Maybe there are other ways.  Can anyone comment on the pros/cons of
these methods of interfacing to my django web app via email?  Is there
anything I am missing here that I should be looking into?

Thanks for any insights,

Margie

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



Re: Non-intrusive way to authenticate phpBB against Django

2009-08-04 Thread Greg Fuller

Thanks!  I suspect I will need this soon.

On Aug 4, 12:25 pm, Chris McCormick  wrote:
> Hi All,
>
> Just uploaded this:http://code.google.com/p/phpbb-json-auth/
>
> Hope it's useful to someone else.
>
> Best,
>
> Chris.
>
> ---http://mccormick.cx
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'RelatedManager' object is not iterable

2009-08-04 Thread british.assassin

Yeah sure.

Models.py:

from django.db import models
from django.contrib.auth.models import User

class Category(models.Model):
name = models.CharField(max_length=100)

class Meta:
verbose_name_plural = 'categories'

def __unicode__(self):
return self.name

class Forum(models.Model):
category = models.ForeignKey(Category,related_name='forums')
name = models.CharField(max_length=100)

def __unicode__(self):
return self.name

class Topic(models.Model):
forum = models.ForeignKey(Forum,related_name='topics')
subject = models.CharField(max_length=100)
views = models.IntegerField()

def __unicode__(self):
return self.subject()

class Post(models.Model):
topic = models.ForeignKey(Topic,related_name='posts')
created = models.DateTimeField(auto_now_add=True)
body = models.TextField()
author = models.ForeignKey(User,related_name='posts')

def __unicode__(self):
return self.subject

Views.py:

from django.shortcuts import render_to_response
import models

def index(request):
categories = models.Category.objects.all()
return render_to_response("forum/index.html",
{'categories':categories})

Index.html:

{% extends "base.html" %}

{% block title %}EvoWebs{% endblock %}

{% block body %}
{% if categories %}
{% for category in categories %}

{{category.name}}
{% for forum in category.forums %}
{{forum.name}}
{% endfor %}

{% endfor %}
{% else %}
This forum has no categories
{% endif %}
{% endblock %}

Base.html:


http://www.w3.org/1999/
xhtml">

{% block title %}{% endblock %}


{% block body %}{% endblock %}



On Aug 4, 7:29 pm, Alex Gaynor  wrote:
> On Tue, Aug 4, 2009 at 1:16 PM,
>
>
>
> british.assassin wrote:
>
> > Hi,
>
> > In the views.py for my app I have the following:
>
> > def index(request):
> >    categories = models.Category.objects.all()
> >    return render_to_response("forum/index.html",
> > {'categories':categories})
>
> > And in the template file I am trying to iterate through these via
> > doing:
>
> > {% for category in categories %}
>
> > But every time I try this I get an exception saying: 'RelatedManager'
> > object is not iterable.
>
> > I was under the impression that the output from obkects.all() was
> > iterable?
>
> > I would appreciate any help anyone can give.
>
> > Thanks
>
> It is, you've done something, either in your template or in your
> models that's somehow causing the issue.  If you could show us those
> we'd have a better idea of what the issue is.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django on Hostmonster shared hosting

2009-08-04 Thread Gene

I am currently running a django site successfully on HM shared
hosting.
As far as I can tell I am using the same setup as you- except that I
haven't yet upgraded to flup 1.0.3.
It looks like your troubles are just with the path, though the WSGI
errors trouble me.

I'll let you know if my site breaks after I upgrade flup later today.

Dj Gilcrease' experience with HM troubles me as well :/

On Aug 2, 12:10 pm, Tim  wrote:
> Hello
>
> I have been trying to get Django working with Hostmonster.com shared
> webhosting with FCGI.
>
> From what I gather from the HM forums, this is possible, but I've been
> hitting some issues.
>
> I've installed Python 2.6.2 in my home directory, and by all accounts,
> its working.
>
> I've downloaded Django from SVN (revision 11375)
>
> If I create a project, and an app, I can run it by
>
> >> ~/local/bin/python manage.py runserver
>
> This gives me a server running at 127.0.0.1:8000 ..  which I can get
> to if I telnet locally (lynx is b0rked, dunno why, not really part of
> this problem here).
>
> Configure the FCGI app, and .htaccess, as described 
> athttp://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#runnin...
> and elaborated on 
> athttp://www.hostmonsterforum.com/showpost.php?p=15030=4,
> I can get it to generate an internal exception.
>
> Run the fgci script at a shell, and I get:
> timat...@host280:~/public_html/django$ ./mysite.fcgi
> WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
> WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
> WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
> WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
> Traceback (most recent call last):
>   File "/home2/timatlee/local/lib/python2.6/site-packages/
> flup-1.0.3.dev_20090716-py2.6.egg/flup/server/fcgi_base.py", line 558,
> in run
>     protocolStatus, appStatus = self.server.handler(self)
>   File "/home2/timatlee/local/lib/python2.6/site-packages/
> flup-1.0.3.dev_20090716-py2.6.egg/flup/server/fcgi_base.py", line
> 1118, in handler
>     result = self.application(environ, start_response)
>   File "/home2/timatlee/djtrunk/django/core/handlers/wsgi.py", line
> 230, in __call__
>     self.load_middleware()
>   File "/home2/timatlee/djtrunk/django/core/handlers/base.py", line
> 33, in load_middleware
>     for middleware_path in settings.MIDDLEWARE_CLASSES:
>   File "/home2/timatlee/djtrunk/django/utils/functional.py", line 269,
> in __getattr__
>     self._setup()
>   File "/home2/timatlee/djtrunk/django/conf/__init__.py", line 40, in
> _setup
>     self._wrapped = Settings(settings_module)
>   File "/home2/timatlee/djtrunk/django/conf/__init__.py", line 75, in
> __init__
>     raise ImportError, "Could not import settings '%s' (Is it on
> sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE,
> e)
> ImportError: Could not import settings 'myproject.settings' (Is it on
> sys.path? Does it have syntax errors?): No module named
> myproject.settings
>
> ..  which is to say, it fails just the same as if I went to the
> website.
>
> mysite.fcgi looks like:
> #!/home2/timatlee/local/bin/python
> import sys, os
>
> # Add a custom Python path.
> # sys.path.insert(0, "/home/user/python")
> sys.path.insert(0, "/home2/timatlee/local/bin/python")
> sys.path.insert(0, "/home2/timatlee/local/lib/python2.6/site-packages/
> flup-1.0.3.dev_20090716-py2.6.egg")
> sys.path.insert(0, "/home2/timatlee/local/lib/python2.6")
> sys.path.insert(0, "/home2/timatlee/djcode")
> sys.path.insert(0, "/home2/timatlee/djcode/mysite")
> sys.path.insert(0, "/home2/timatlee/djtrunk")
>
> # Switch to the directory of your project. (Optional.)
> os.chdir("/home2/timatlee/djcode/mysite")
>
> # Set the DJANGO_SETTINGS_MODULE environment variable.
> os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
>
> from django.core.servers.fastcgi import runfastcgi
> runfastcgi(method="threaded", daemonize="false")
>
> myproject.settings exists in /home2/timatlee/djcode/mysite, which from
> what I can tell is on the path.
>
> If I set os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
> to be the absolute path of the file, I get the following as an error:
> ImportError: Could not import settings '/home2/timatlee/djcode/mysite/
> myproject.settings' (Is it on sys.path? Does it have syntax errors?):
> Import by filename is not supported.
>
> So if I truncate myproject.settings, I see no change.  If I make
> myproject.settings a copy of settings.py (which is what I thought this
> file was supposed to be), I'm at where I am right now.
>
> I'm sure it's something plainly obvious, but I've overlooked...
>
> Any help would be appreciated.
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 

Login screen is always shown, i dont like it :/

2009-08-04 Thread MiratCanBayrak

hi, i am using django.contrib.auth.views.login view  at /account/login
url, to show login screen ( as explained here :
http://docs.djangoproject.com/en/dev/topics/auth/#django.contrib.auth.views.login)

But, when user already logged in, form is not showing any error.
Displaying a login form to already logged user is not giving
professional sense i think. Can i change that behaviour or should i re-
write login view myself?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Inserting into existing tables

2009-08-04 Thread Sean Brown

I have existing tables in a postgresql database created with existing  
sequences as the default values for their primary key. I am trying to  
interface with the database with django (i have tried with 1.0.2, 1.1  
and now have django-trunk) and while it seems the model works  
(runserver complains if I have a typo in a column name) I can not  
insert into the table.

If I define the primary key field as follows:

id = models.AutoField(primary_key=True)

an insert (with the save() method) throws:

relation "tablename_id_seq" does not exist

If I define the primary key field like this:

id = models.IntegerField(primary_key=True)

an insert fails with null value in column "id" violates not-null  
constraint

Obviously, I am not specifying a value for the id in my forms as I  
want it to auto increment. How am I supposed to use django with  
existing tables in existing DB'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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'RelatedManager' object is not iterable

2009-08-04 Thread Alex Gaynor

On Tue, Aug 4, 2009 at 1:16 PM,
british.assassin wrote:
>
> Hi,
>
> In the views.py for my app I have the following:
>
> def index(request):
>    categories = models.Category.objects.all()
>    return render_to_response("forum/index.html",
> {'categories':categories})
>
> And in the template file I am trying to iterate through these via
> doing:
>
> {% for category in categories %}
>
> But every time I try this I get an exception saying: 'RelatedManager'
> object is not iterable.
>
> I was under the impression that the output from obkects.all() was
> iterable?
>
> I would appreciate any help anyone can give.
>
> Thanks
>
> >
>

It is, you've done something, either in your template or in your
models that's somehow causing the issue.  If you could show us those
we'd have a better idea of what the issue is.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



'RelatedManager' object is not iterable

2009-08-04 Thread british.assassin

Hi,

In the views.py for my app I have the following:

def index(request):
categories = models.Category.objects.all()
return render_to_response("forum/index.html",
{'categories':categories})

And in the template file I am trying to iterate through these via
doing:

{% for category in categories %}

But every time I try this I get an exception saying: 'RelatedManager'
object is not iterable.

I was under the impression that the output from obkects.all() was
iterable?

I would appreciate any help anyone can give.

Thanks

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



Re: Date format in modelform.

2009-08-04 Thread zayatzz

Oh and i will not fix problem in server application with a code in
browser script.

As i understand, javascript should be as unobtrusive as possible and
fixing things that way:
1) is not unobtrusive
2) makes you write too much unnecessary code.

Alan.

On Aug 4, 9:05 pm, zayatzz  wrote:
> Thanks everybody.
>
> I changed this :
> birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
> required=False ),
>
> for this :
>         birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
> required=False, widget=forms.DateInput(format='%d/%m/%Y') )
>
> And it all works very good.
>
> But there's something else fishy here.
>
> If i tried this:
>         birth_date = forms.DateField(label='Birth Date', required=False,
> widget=forms.DateInput(format='%d/%m/%Y') )
>
> Then it did not save in correct format again. But guess in which
> format did it save?
> %m/%d/%Y
>
> Why the hell though? could this be a minor bug in django code?
>
> Alan
> On Aug 4, 5:19 am, Margie  wrote:
>
> > I did this with a combination of a DateWidget and a small .js file
> > that calls the jquery datepicker on each widget.  I don't use the same
> > date format as you, but you should be able to modify it to fit your
> > need.
>
> > It's amazing how easy the code below looks, but I can tell you it took
> > me most of a day to figure out how to use the jquery datepicker, how
> > to create widgets, and how to just put it all together so that it
> > works!
>
> > class DateWidget(widgets.DateInput):
> >     class Media:
> >         js = ('js/jquery.js',
> >               "js/date.js",
> >               "js/jquery.datePicker.min-2.1.2.js",
> >               "js_custom/date_widget.js",
> >               )
>
> >         css = {'all' : ('css/date_picker.css', 'css/
> > date_picker_chipvision.css') }
>
> >     def __init__(self, attrs={}):
> >         attrs['class']  = 'my_class_to_identify_datewidget'
> >         super(DateWidget, self).__init__(format='%m/%d/%Y',
> > attrs=attrs)
>
> > Then I have a small .js file (js_custom/date_widget.js) that has this:
> >   $(document).ready(function() {
> >                       Date.firstDayOfWeek = 0;
> >                       Date.format = 'mm/dd/';
> >                       $('.my_class_to_identify_datewidget').datePicker();
> >                     });
>
> > I'm not sure if settings Date.firstDayOfWeek and Date.format the way I
> > do is the best way to do it, but I could not figure out how to do it
> > via params to datePicker.
>
> > Anyway, hope this helps.
>
> > Margie
>
> > On Aug 3, 11:08 am, zayatzz  wrote:
>
> > > Hello.
>
> > > I have this in my form (modelform) for birth_date field:
> > > birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
> > > required=False ), which overrides this in model:
>
> > > birth_date = models.DateField(help_text="birth date",
> > > verbose_name="Birth date", blank=True, null=True, )
>
> > > I also have jquery datepicker on the page which sets date in the same
> > > format (%d/%m/%Y). But the form saves date in %Y-%m-%d format in
> > > database, which means that when user returns to reedit the data, the
> > > form wont validate and the user has to set the date again.
>
> > > Can anyone tell me what causes such behaviour and how to fix/change
> > > it? My database in mysql - no idea if this is relevant.
>
> > > Alan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Date format in modelform.

2009-08-04 Thread zayatzz

Thanks everybody.

I changed this :
birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
required=False ),

for this :
birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
required=False, widget=forms.DateInput(format='%d/%m/%Y') )

And it all works very good.

But there's something else fishy here.

If i tried this:
birth_date = forms.DateField(label='Birth Date', required=False,
widget=forms.DateInput(format='%d/%m/%Y') )

Then it did not save in correct format again. But guess in which
format did it save?
%m/%d/%Y

Why the hell though? could this be a minor bug in django code?

Alan
On Aug 4, 5:19 am, Margie  wrote:
> I did this with a combination of a DateWidget and a small .js file
> that calls the jquery datepicker on each widget.  I don't use the same
> date format as you, but you should be able to modify it to fit your
> need.
>
> It's amazing how easy the code below looks, but I can tell you it took
> me most of a day to figure out how to use the jquery datepicker, how
> to create widgets, and how to just put it all together so that it
> works!
>
> class DateWidget(widgets.DateInput):
>     class Media:
>         js = ('js/jquery.js',
>               "js/date.js",
>               "js/jquery.datePicker.min-2.1.2.js",
>               "js_custom/date_widget.js",
>               )
>
>         css = {'all' : ('css/date_picker.css', 'css/
> date_picker_chipvision.css') }
>
>     def __init__(self, attrs={}):
>         attrs['class']  = 'my_class_to_identify_datewidget'
>         super(DateWidget, self).__init__(format='%m/%d/%Y',
> attrs=attrs)
>
> Then I have a small .js file (js_custom/date_widget.js) that has this:
>   $(document).ready(function() {
>                       Date.firstDayOfWeek = 0;
>                       Date.format = 'mm/dd/';
>                       $('.my_class_to_identify_datewidget').datePicker();
>                     });
>
> I'm not sure if settings Date.firstDayOfWeek and Date.format the way I
> do is the best way to do it, but I could not figure out how to do it
> via params to datePicker.
>
> Anyway, hope this helps.
>
> Margie
>
> On Aug 3, 11:08 am, zayatzz  wrote:
>
> > Hello.
>
> > I have this in my form (modelform) for birth_date field:
> > birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date',
> > required=False ), which overrides this in model:
>
> > birth_date = models.DateField(help_text="birth date",
> > verbose_name="Birth date", blank=True, null=True, )
>
> > I also have jquery datepicker on the page which sets date in the same
> > format (%d/%m/%Y). But the form saves date in %Y-%m-%d format in
> > database, which means that when user returns to reedit the data, the
> > form wont validate and the user has to set the date again.
>
> > Can anyone tell me what causes such behaviour and how to fix/change
> > it? My database in mysql - no idea if this is relevant.
>
> > Alan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Karen Tracey
On Tue, Aug 4, 2009 at 1:33 PM, Paulo Almeida
wrote:

> Hi Karen,
>
> You're right, I had some unnecessary lines that I used only for unittest. I
> commented them out now. Printing response['location'] gives me this:
>
> http://testserver/myflow/experiment/1/
>
> You're also right that there is no Redirect in my view, so I don't know
> where that is coming from. I guess I'll have to figure it out, because it
> seems to be the key to the problem.
>

So it does appear to be APPEND_SLASH that is causing the redirect, since the
only difference between that and what you requested is the added slash on
the end.  Which implies the version without the added slash is not matching
the url pattern you cited:

 (r'^experiment/(?P\d+)$',
'bioinformatics.myflow.views.view_experiment'),

even though that pattern doesn't require a trailing slash.  That pattern,
though, also has no 'myflow' component.  Where is that coming from?  There
seems to be more to your url configuration than you have made clear here.

Karen

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



Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Paulo Almeida
Hi Karen,

You're right, I had some unnecessary lines that I used only for unittest. I
commented them out now. Printing response['location'] gives me this:

http://testserver/myflow/experiment/1/

You're also right that there is no Redirect in my view, so I don't know
where that is coming from. I guess I'll have to figure it out, because it
seems to be the key to the problem.

Thanks for the reply,
Paulo Almeida

On Tue, Aug 4, 2009 at 6:18 PM, Karen Tracey  wrote:

> On Tue, Aug 4, 2009 at 12:26 PM, palmeida wrote:
>
>>
>> Hi,
>>
>> I'm running a test that fails when using Django's TestCase class, but
>> not when running TestCase from unittest. This is my test class:
>>
>
>> class LoggedInUser(TestCase):
>>fixtures = ['myflow']
>
>
> Note fixtures will not be loaded when you run this as a unittest.TestCase.
>
>
>>
>>def setUp(self):
>>self.client = Client()
>>try:
>>User.objects.create_user('user', 'm...@nowhere.com', 'user')
>>except IntegrityError:
>>pass
>>self.client.login(username='user', password='user')
>>
>
> Is there a reason, other than to allow this to run as a unittest.TestCase,
> why are you setting client yourself in setUp()?  That's done for you by
> Django's TestCase.  If you are going to be using fixtures and the test
> Client, this really should be a django.test.TestCase.  I am not sure that
> going down the road of seeing if you can't get it to run as a
> unittest.TestCase by manually doing in the test things that
> django.test.TestCase also does is the best way of debugging whatever issue
> the test is having when running as a django.test.TestCase.  I would back up
> and take out anything you have added that allows this to run as a
> unittest.TestCase and start over with trying to debug the real issue
> directly.
>
>
>>
>>def test_experiment_view(self):
>>response = self.client.get('/myflow/experiment/1')
>>print response.context
>>self.failUnlessEqual(response.status_code, 200)
>>
>> It fails with:
>>
>> AssertionError: 302 != 200
>>
>> when using Django's TestCase class, but everything is fine when using
>> unittest.
>
>
> 302 is a redirect.  It would be useful to know where it's trying to
> redirect to.  For that, you could put a:
>
> print response['location']
>
> into the test.
>
>
>> Also, when it fails everything in response seems fine except
>> for response.context (and response.content, of course).
>> response.context gets lots of variables, like MEDIA_URL, LANGUAGES and
>> others. I have no idea where that is coming from.
>>
>
> Since your view below, from a quick scan, doesn't ever return a redirect
> your GET is apparently being routed to some other view entirely.  I'd guess
> that view is including all of this other stuff in its context.
>
>
>>
>> This is the relevant line from urls.py:
>>
>> (r'^experiment/(?P\d+)$',
>> 'bioinformatics.myflow.views.view_experiment'),
>>
>
> I cannot recreate what you are seeing based on just this information.  I
> suspect there is more to your urls.py, or something, that is coming into
> play.  Finding out where you are getting redirected to would be a first step
> in figuring out what is going wrong.
>
> Karen
>
>
>> And this is the view:
>>
>> def view_experiment(request, experiment_id):
>>contact = request.user.id
>># Filtering on contact and pk to ensure users can only see their
>> own data
>>exp = get_object_or_404(Experiment.objects.filter
>> (exp_contact=contact),
>>pk=experiment_id)
>>
>>list = generate_list()
>>
>>files = exp.fcs_set.exclude(name__startswith='myflow_meta')
>>num_files = len(files)
>>files = files.order_by('btim')
>>fcs_list = paginate(files,'fcs_per_page',request)
>># Create variable to include (or not) subset column in fcs file
>> list
>>if len(subsets) > 1:
>>subset_header = True
>>else:
>>subset_header = False
>>return render_to_response('myflow/view_experiment.html',
>>  {'experiment': exp,
>>   'subsets': subsets,
>>   'parameters': list,
>>   'num_files': num_files,
>>   'fcs_list': fcs_list,
>>   'subset_header': subset_header
>>  }
>> )
>>
>> Thanks for any help. I'm not sure what I can do next to find out what
>> is going on.
>> Paulo Almeida
>>
>>
> >
>

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

Non-intrusive way to authenticate phpBB against Django

2009-08-04 Thread Chris McCormick

Hi All,

Just uploaded this:
http://code.google.com/p/phpbb-json-auth/

Hope it's useful to someone else.

Best,

Chris.

---
http://mccormick.cx

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



Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Karen Tracey
On Tue, Aug 4, 2009 at 12:26 PM, palmeida wrote:

>
> Hi,
>
> I'm running a test that fails when using Django's TestCase class, but
> not when running TestCase from unittest. This is my test class:
>

> class LoggedInUser(TestCase):
>fixtures = ['myflow']


Note fixtures will not be loaded when you run this as a unittest.TestCase.


>
>def setUp(self):
>self.client = Client()
>try:
>User.objects.create_user('user', 'm...@nowhere.com', 'user')
>except IntegrityError:
>pass
>self.client.login(username='user', password='user')
>

Is there a reason, other than to allow this to run as a unittest.TestCase,
why are you setting client yourself in setUp()?  That's done for you by
Django's TestCase.  If you are going to be using fixtures and the test
Client, this really should be a django.test.TestCase.  I am not sure that
going down the road of seeing if you can't get it to run as a
unittest.TestCase by manually doing in the test things that
django.test.TestCase also does is the best way of debugging whatever issue
the test is having when running as a django.test.TestCase.  I would back up
and take out anything you have added that allows this to run as a
unittest.TestCase and start over with trying to debug the real issue
directly.


>
>def test_experiment_view(self):
>response = self.client.get('/myflow/experiment/1')
>print response.context
>self.failUnlessEqual(response.status_code, 200)
>
> It fails with:
>
> AssertionError: 302 != 200
>
> when using Django's TestCase class, but everything is fine when using
> unittest.


302 is a redirect.  It would be useful to know where it's trying to redirect
to.  For that, you could put a:

print response['location']

into the test.


> Also, when it fails everything in response seems fine except
> for response.context (and response.content, of course).
> response.context gets lots of variables, like MEDIA_URL, LANGUAGES and
> others. I have no idea where that is coming from.
>

Since your view below, from a quick scan, doesn't ever return a redirect
your GET is apparently being routed to some other view entirely.  I'd guess
that view is including all of this other stuff in its context.


>
> This is the relevant line from urls.py:
>
> (r'^experiment/(?P\d+)$',
> 'bioinformatics.myflow.views.view_experiment'),
>

I cannot recreate what you are seeing based on just this information.  I
suspect there is more to your urls.py, or something, that is coming into
play.  Finding out where you are getting redirected to would be a first step
in figuring out what is going wrong.

Karen


> And this is the view:
>
> def view_experiment(request, experiment_id):
>contact = request.user.id
># Filtering on contact and pk to ensure users can only see their
> own data
>exp = get_object_or_404(Experiment.objects.filter
> (exp_contact=contact),
>pk=experiment_id)
>
>list = generate_list()
>
>files = exp.fcs_set.exclude(name__startswith='myflow_meta')
>num_files = len(files)
>files = files.order_by('btim')
>fcs_list = paginate(files,'fcs_per_page',request)
># Create variable to include (or not) subset column in fcs file
> list
>if len(subsets) > 1:
>subset_header = True
>else:
>subset_header = False
>return render_to_response('myflow/view_experiment.html',
>  {'experiment': exp,
>   'subsets': subsets,
>   'parameters': list,
>   'num_files': num_files,
>   'fcs_list': fcs_list,
>   'subset_header': subset_header
>  }
> )
>
> Thanks for any help. I'm not sure what I can do next to find out what
> is going on.
> Paulo Almeida
>
>

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



Re: Date/time field styling?

2009-08-04 Thread mhulse

For those interested, I found this link via browsing the django-html
git source:

Django Developers:
Proposal: Form rendering with filters


Looks interesting.

Unfortunately, I am still a noob, so I probably won't be able to cross
that bridge for a while. :)

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



Re: Intermediate Table question

2009-08-04 Thread Alex Gaynor

On Tue, Aug 4, 2009 at 11:58 AM, LeeRisq wrote:
>
> Does anyone know if an intermediate table can be specified on more
> than two models? For instance:
>
> class A(m.Model):
>       B = ManyToManyField(B, through='D')
>       C = ManyToManyField(C, through='D')
>
> Will this validate and actually work?
> >
>

I don't believe it would work, but even if it did, what would this do?
 What's the expecected behavior?

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Intermediate Table question

2009-08-04 Thread LeeRisq

Does anyone know if an intermediate table can be specified on more
than two models? For instance:

class A(m.Model):
   B = ManyToManyField(B, through='D')
   C = ManyToManyField(C, through='D')

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



Re: buildung query with ORM

2009-08-04 Thread krylatij

It's difficult to even imagine such query (possible but very
inefficient),
i think you need to change your architecture
or do this grouping in bussines layer
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



error in using naturalday

2009-08-04 Thread Sumanth

I am using dajngo template filters for humanize data . When I was
using naturalday I observe the following

when the date is 07-2-2009 given in (mm-dd- format) , the
naturalday changes it to June 2 2009 and displays the date one month
previous to date .

Has anyone else faced the same problem ? Is there a way to correct
this ? or could this be a error in django humanize module ?

Thanks
--Sumanth

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



Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Paulo Almeida
Hi Alex,

When I do that I get a 404 instead of a 302. I also tried changing urls.py
to have a trailing slash but that also gives me a 404. Byt the way, one of
the variables I get in response.context is:

{'request_path': u'/myflow/experiment/1/'}

Thanks for the reply,
Paulo
On Tue, Aug 4, 2009 at 5:31 PM, Alex Gaynor  wrote:

>
> On Tue, Aug 4, 2009 at 11:26 AM, palmeida
> wrote:
> >
> > Hi,
> >
> > I'm running a test that fails when using Django's TestCase class, but
> > not when running TestCase from unittest. This is my test class:
> >
> > class LoggedInUser(TestCase):
> >fixtures = ['myflow']
> >def setUp(self):
> >self.client = Client()
> >try:
> >User.objects.create_user('user', 'm...@nowhere.com', 'user')
> >except IntegrityError:
> >pass
> >self.client.login(username='user', password='user')
> >
> >def test_experiment_view(self):
> >response = self.client.get('/myflow/experiment/1')
> >print response.context
> >self.failUnlessEqual(response.status_code, 200)
> >
> > It fails with:
> >
> > AssertionError: 302 != 200
> >
> > when using Django's TestCase class, but everything is fine when using
> > unittest. Also, when it fails everything in response seems fine except
> > for response.context (and response.content, of course).
> > response.context gets lots of variables, like MEDIA_URL, LANGUAGES and
> > others. I have no idea where that is coming from.
> >
> > This is the relevant line from urls.py:
> >
> > (r'^experiment/(?P\d+)$',
> > 'bioinformatics.myflow.views.view_experiment'),
> >
> > And this is the view:
> >
> > def view_experiment(request, experiment_id):
> >contact = request.user.id
> ># Filtering on contact and pk to ensure users can only see their
> > own data
> >exp = get_object_or_404(Experiment.objects.filter
> > (exp_contact=contact),
> >pk=experiment_id)
> >
> >list = generate_list()
> >
> >files = exp.fcs_set.exclude(name__startswith='myflow_meta')
> >num_files = len(files)
> >files = files.order_by('btim')
> >fcs_list = paginate(files,'fcs_per_page',request)
> ># Create variable to include (or not) subset column in fcs file
> > list
> >if len(subsets) > 1:
> >subset_header = True
> >else:
> >subset_header = False
> >return render_to_response('myflow/view_experiment.html',
> >  {'experiment': exp,
> >   'subsets': subsets,
> >   'parameters': list,
> >   'num_files': num_files,
> >   'fcs_list': fcs_list,
> >   'subset_header': subset_header
> >  }
> > )
> >
> > Thanks for any help. I'm not sure what I can do next to find out what
> > is going on.
> > Paulo Almeida
> >
> > >
> >
>
> It looks like you have teh APPEND_SLASH setting set to True (the
> default), so Django adds a / to the end of that URL.  Try righting the
> test to that URL with a trailing slash and see if it works.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
>
> >
>

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



Re: standalone script

2009-08-04 Thread Vitaly

I have found where our mistake was, it was inside __init__.py of our
application.

Thanks anyway

On 4 Сер, 18:45, Michael  wrote:
> > On Tue, Aug 4, 2009 at 11:29 AM, Vitaly  wrote:
> > I did cut of our settings
>
> > Here it ishttp://dpaste.com/75091/
>
> > Using your method I got no error but app_settings and INSTALLED_APPS
> > were cleaned up and contains nothing. Strange.
>
> > Thanks
> > Vitaly
>
> Why not just:
>
> from django.conf import settings
>
> from fg import settings as my_settings
>
> settings.configure(my_settings)
>
> Could make your life easier.
>
> Hope that helps,
>
> Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread Alex Gaynor

On Tue, Aug 4, 2009 at 11:26 AM, palmeida wrote:
>
> Hi,
>
> I'm running a test that fails when using Django's TestCase class, but
> not when running TestCase from unittest. This is my test class:
>
> class LoggedInUser(TestCase):
>    fixtures = ['myflow']
>    def setUp(self):
>        self.client = Client()
>        try:
>            User.objects.create_user('user', 'm...@nowhere.com', 'user')
>        except IntegrityError:
>            pass
>        self.client.login(username='user', password='user')
>
>    def test_experiment_view(self):
>        response = self.client.get('/myflow/experiment/1')
>        print response.context
>        self.failUnlessEqual(response.status_code, 200)
>
> It fails with:
>
> AssertionError: 302 != 200
>
> when using Django's TestCase class, but everything is fine when using
> unittest. Also, when it fails everything in response seems fine except
> for response.context (and response.content, of course).
> response.context gets lots of variables, like MEDIA_URL, LANGUAGES and
> others. I have no idea where that is coming from.
>
> This is the relevant line from urls.py:
>
> (r'^experiment/(?P\d+)$',
>     'bioinformatics.myflow.views.view_experiment'),
>
> And this is the view:
>
> def view_experiment(request, experiment_id):
>    contact = request.user.id
>    # Filtering on contact and pk to ensure users can only see their
> own data
>    exp = get_object_or_404(Experiment.objects.filter
> (exp_contact=contact),
>                            pk=experiment_id)
>
>    list = generate_list()
>
>    files = exp.fcs_set.exclude(name__startswith='myflow_meta')
>    num_files = len(files)
>    files = files.order_by('btim')
>    fcs_list = paginate(files,'fcs_per_page',request)
>    # Create variable to include (or not) subset column in fcs file
> list
>    if len(subsets) > 1:
>        subset_header = True
>    else:
>        subset_header = False
>    return render_to_response('myflow/view_experiment.html',
>                              {'experiment': exp,
>                               'subsets': subsets,
>                               'parameters': list,
>                               'num_files': num_files,
>                               'fcs_list': fcs_list,
>                               'subset_header': subset_header
>                              }
>                             )
>
> Thanks for any help. I'm not sure what I can do next to find out what
> is going on.
> Paulo Almeida
>
> >
>

It looks like you have teh APPEND_SLASH setting set to True (the
default), so Django adds a / to the end of that URL.  Try righting the
test to that URL with a trailing slash and see if it works.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Re: Django admin panel how add extra function in form processing?

2009-08-04 Thread Asinox

Sorry krylatij, im new with django,

i will try :)

thanks

On 4 ago, 11:22, krylatij  wrote:
> Why do you need admin here?
> You can generate it in the save() method of your model.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-04 Thread palmeida

Hi,

I'm running a test that fails when using Django's TestCase class, but
not when running TestCase from unittest. This is my test class:

class LoggedInUser(TestCase):
fixtures = ['myflow']
def setUp(self):
self.client = Client()
try:
User.objects.create_user('user', 'm...@nowhere.com', 'user')
except IntegrityError:
pass
self.client.login(username='user', password='user')

def test_experiment_view(self):
response = self.client.get('/myflow/experiment/1')
print response.context
self.failUnlessEqual(response.status_code, 200)

It fails with:

AssertionError: 302 != 200

when using Django's TestCase class, but everything is fine when using
unittest. Also, when it fails everything in response seems fine except
for response.context (and response.content, of course).
response.context gets lots of variables, like MEDIA_URL, LANGUAGES and
others. I have no idea where that is coming from.

This is the relevant line from urls.py:

(r'^experiment/(?P\d+)$',
 'bioinformatics.myflow.views.view_experiment'),

And this is the view:

def view_experiment(request, experiment_id):
contact = request.user.id
# Filtering on contact and pk to ensure users can only see their
own data
exp = get_object_or_404(Experiment.objects.filter
(exp_contact=contact),
pk=experiment_id)

list = generate_list()

files = exp.fcs_set.exclude(name__startswith='myflow_meta')
num_files = len(files)
files = files.order_by('btim')
fcs_list = paginate(files,'fcs_per_page',request)
# Create variable to include (or not) subset column in fcs file
list
if len(subsets) > 1:
subset_header = True
else:
subset_header = False
return render_to_response('myflow/view_experiment.html',
  {'experiment': exp,
   'subsets': subsets,
   'parameters': list,
   'num_files': num_files,
   'fcs_list': fcs_list,
   'subset_header': subset_header
  }
 )

Thanks for any help. I'm not sure what I can do next to find out what
is going on.
Paulo Almeida

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



Re: Django admin panel how add extra function in form processing?

2009-08-04 Thread krylatij

Why do you need admin here?
You can generate it in the save() method of your model.

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



Re: Adding errors

2009-08-04 Thread Alex Gaynor

On Tue, Aug 4, 2009 at 11:17 AM, CrabbyPete wrote:
>
> I want to return an error that a user was not found. I wanted to add
> the error and have it formatted using errorlist as happens with a
> required field. So I did the following
>
> lform._errors['username']  = ErrorList("User does not exist or wrong
> password")
>
> The result in lform.errors is
>
> ErrorDict: username class="errorlist">User  li>does no li>t exist li> or wro li>ng pass li>word ...
>
>
> instead of :
> usernameUser does
> not exist or wrong password
>
> What am I doing wrong?
>
>
>
>
>
> >
>


Do ErrorList(["User does"]).

Alex
-- 
"I disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
"The people's good is the highest law." -- Cicero
"Code can always be simpler than you think, but never as simple as you
want" -- Me

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



Adding errors

2009-08-04 Thread CrabbyPete

I want to return an error that a user was not found. I wanted to add
the error and have it formatted using errorlist as happens with a
required field. So I did the following

lform._errors['username']  = ErrorList("User does not exist or wrong
password")

The result in lform.errors is

ErrorDict: usernameUser does not exist or wrong password ...


instead of :
usernameUser does
not exist or wrong password

What am I doing wrong?





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



Re: standalone script

2009-08-04 Thread Vitaly

It should be, but not :)
The matter is that I changed some code

from django.conf import settings
from fg import settings as app_settings


settings.configure(app_settings, **{'DATABASE_NAME': ':memory:',
'DATABASE_ENGINE':
'sqlite3',
'DATABASE_HOST': '',
'DATABASE_OPTIONS': '',
'DATABASE_PASSWORD': '',
'DATABASE_PORT': '',
'DATABASE_USER': '',
'TIME_ZONE': 'GMT',
'DEBUG': True,
 
'URL_VALIDATOR_USER_AGENT': ''})
# Reload DB
module
from django import
db
reload
(db)

# Install
Models
from django.core.management import call_command

call_command("syncdb")

This code raises another error

  File "/usr/local/lib/python2.6/dist-packages/django/utils/
functional.py", line 273, in __getattr__
return getattr(self._wrapped, name)
  File "/usr/local/lib/python2.6/dist-packages/django/conf/
__init__.py", line 130, in __getattr__
return getattr(self.default_settings, name)

maximum recursion depth exceeded in cmp
(, RuntimeError('maximum recursion
depth exceeded',), )

Vitaly

On 4 Сер, 18:45, Michael  wrote:
> > On Tue, Aug 4, 2009 at 11:29 AM, Vitaly  wrote:
> > I did cut of our settings
>
> > Here it ishttp://dpaste.com/75091/
>
> > Using your method I got no error but app_settings and INSTALLED_APPS
> > were cleaned up and contains nothing. Strange.
>
> > Thanks
> > Vitaly
>
> Why not just:
>
> from django.conf import settings
>
> from fg import settings as my_settings
>
> settings.configure(my_settings)
>
> Could make your life easier.
>
> Hope that helps,
>
> Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Does Django fit this application?

2009-08-04 Thread Martje

This is possible with Django.

Check out the auth app :-).

On 4 aug, 16:30, xerophyte  wrote:
> Yes, you can use the django, but you need to verify all the commands
> before you execute .. ( having secure daemon to do it for you ???)
>
> On Aug 4, 8:45 am, HB  wrote:
>
> > Hey,
> > We have a couple of command that run over SSH.
> > I have been asked to develop a web application to let the non
> > technical departments to use the commands.
> > For example, display a list of the current logged users and provide a
> > link to log out him.
> > The application should have a login facility.
> > Can I use Django for this application?
> > I'm familiar with Django but not a ninja yet :)
> > Thanks for help and time.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Select_related and foreign keys

2009-08-04 Thread Joe LB

Hi all,

I'm trying to access the related objects in the template by using

 {{  _set.select_related}}

this works but as its not an instance and it's a query object I get

[]

What do I use to just display the string not the object code.


Thanks,

Joseph

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



Re: Django file upload. 'None'

2009-08-04 Thread Martje

Ah, thanks :-).

On 4 aug, 17:18, Lakshman Prasad  wrote:
> You need to set the form with the request file, which I think you may have
> missed:
> from appname.forms import ImageForm
> form = ImageForm(request.POST,request.FILES)
>
> From the 
> documentation:http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#basic-...
>
>
>
> On Tue, Aug 4, 2009 at 8:30 PM, Martje  wrote:
>
> > One question though. Even when it is in request.FILES, it doesn't get
> > saved like I expected it would.
>
> > I expected Django to upload my image to "media/afbeeldingen/
> > gastenboek/" ánd validate if it is an image or not (I've change
> > FileField to ImageField).
>
> > Why doesn't Django do this?
>
> > On 4 aug, 15:19, Martje  wrote:
> > > You're right, that was the problem. Thanks!
>
> > > On Aug 4, 2:18 pm, James Bennett  wrote:
>
> > > > On Tue, Aug 4, 2009 at 7:08 AM, Martje
> > wrote:
> > > > > This seem ok, since I only used field 3 and 1. But when I look at
> > > > > request.FILES, I get:
>
> > > > > 
>
> > > > > It shouldn't be empty, should it?
>
> > > > If you've forgotten to set the 'enctype' attribute of the HTML 
> > > > element properly, you won't get any files sent. The documentation
> > > > covers this and how to programmatically detect forms which need it:
>
> > > >http://docs.djangoproject.com/en/dev/ref/forms/api/#testing-for-multi.
> > ..
>
> > > > --
> > > > "Bureaucrat Conrad, you are technically correct -- the best kind of
> > correct."
>
> --
> Regards,
> Lakshman
> becomingguru.com
> lakshmanprasad.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-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django admin panel how add extra function in form processing?

2009-08-04 Thread Asinox

Hi guys, somebody know how ill use a extra function in any form
processing in the Django admin?, the problem is that i need to
generate a encrypted code in the moment that a form is sendinga and
save the code in the database in the user's account panel i did
it... but i dont know how ill make this in the Django Admin... the
problem is that the Administrator person need to generate the
encrypted code too.


Any idea?

Thanks :)

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



Re: standalone script

2009-08-04 Thread Michael
>
> On Tue, Aug 4, 2009 at 11:29 AM, Vitaly  wrote:


> I did cut of our settings
>
> Here it is http://dpaste.com/75091/
>
> Using your method I got no error but app_settings and INSTALLED_APPS
> were cleaned up and contains nothing. Strange.
>
> Thanks
> Vitaly
>

Why not just:

from django.conf import settings

from fg import settings as my_settings



settings.configure(my_settings)


Could make your life easier.

Hope that helps,

Michael

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



Re: standalone script

2009-08-04 Thread Vitaly

I did cut of our settings

Here it is http://dpaste.com/75091/

Using your method I got no error but app_settings and INSTALLED_APPS
were cleaned up and contains nothing. Strange.

Thanks
Vitaly

On 4 Сер, 18:11, Michael  wrote:
> On Tue, Aug 4, 2009 at 11:05 AM, Vitaly  wrote:
>
> > Oh, yeah, there was only place, but when I removed this code nothing
> > changed.
>
> > I do not know about this import
>
> > from django.utils.translation import ugettext_lazy as _
>
> This (and anything from utils ideally) shouldn't need settings top be
> configured.
>
> Try this:
>
> from django.conf import settings
>
> > settings.configure()
> > from fg.settings import INSTALLED_APP
>
> settings.INSTALLED_APP = INSTALLED_APP
>
> That should work, no matter what (Well unless there is a logic error in the
> fg.settings, but it should give you a better error message).
> Let me know how it goes,
>
> Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: buildung query with ORM

2009-08-04 Thread tom



On 4 Aug., 16:40, krylatij  wrote:
> You need to use raw sql. (http://docs.djangoproject.com/en/dev/topics/
> db/sql/#topics-db-sql)

yes. i know that i can use raw sql. but if it's possible, i want to
use ORM.

>
> I don't understand what will be if there are more then 2 channels at
> the same datetime?
> So i can't provide you solutions sample.

for example, one channel (called c1) is the windspeed (in m/s) and the
other channel (called c2) is the winddirection (in degrees). both
channels have the same timestamp. but it's not possible that c1 has 2
entries at the same time.


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



Re: Django file upload. 'None'

2009-08-04 Thread Lakshman Prasad
You need to set the form with the request file, which I think you may have
missed:
from appname.forms import ImageForm
form = ImageForm(request.POST,request.FILES)

>From the documentation:
http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#basic-file-uploads

On Tue, Aug 4, 2009 at 8:30 PM, Martje  wrote:

>
> One question though. Even when it is in request.FILES, it doesn't get
> saved like I expected it would.
>
> I expected Django to upload my image to "media/afbeeldingen/
> gastenboek/" ánd validate if it is an image or not (I've change
> FileField to ImageField).
>
> Why doesn't Django do this?
>
> On 4 aug, 15:19, Martje  wrote:
> > You're right, that was the problem. Thanks!
> >
> > On Aug 4, 2:18 pm, James Bennett  wrote:
> >
> > > On Tue, Aug 4, 2009 at 7:08 AM, Martje
> wrote:
> > > > This seem ok, since I only used field 3 and 1. But when I look at
> > > > request.FILES, I get:
> >
> > > > 
> >
> > > > It shouldn't be empty, should it?
> >
> > > If you've forgotten to set the 'enctype' attribute of the HTML 
> > > element properly, you won't get any files sent. The documentation
> > > covers this and how to programmatically detect forms which need it:
> >
> > >http://docs.djangoproject.com/en/dev/ref/forms/api/#testing-for-multi.
> ..
> >
> > > --
> > > "Bureaucrat Conrad, you are technically correct -- the best kind of
> correct."
> >
> >
> >
>


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



Django authentication for external apache

2009-08-04 Thread rahul

Hello,

I am sure this question would have come up a number of times but I
couldn't find any links to suit my requirements.

I want to run an external apache to serve media. Apache is to serve
media only if the user is logged in. I saw a couple of links for
installing Apache Authentication Handlers but they are using basic
request without the middlewares.

I would need the same request for apache authentication so that I can
check the authentication and decide the permissions. Can someone point
me towards some resources?
pass

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



Re: standalone script

2009-08-04 Thread Michael
On Tue, Aug 4, 2009 at 11:05 AM, Vitaly  wrote:

>
> Oh, yeah, there was only place, but when I removed this code nothing
> changed.
>
> I do not know about this import
>
> from django.utils.translation import ugettext_lazy as _
>
This (and anything from utils ideally) shouldn't need settings top be
configured.

Try this:

from django.conf import settings


> settings.configure()


> from fg.settings import INSTALLED_APP

settings.INSTALLED_APP = INSTALLED_APP


That should work, no matter what (Well unless there is a logic error in the
fg.settings, but it should give you a better error message).
Let me know how it goes,

Michael

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



Re: standalone script

2009-08-04 Thread Vitaly

Oh, yeah, there was only place, but when I removed this code nothing
changed.

I do not know about this import

from django.utils.translation import ugettext_lazy as _



On 4 Сер, 17:59, Michael  wrote:
> On Tue, Aug 4, 2009 at 10:46 AM, Vitaly  wrote:
>
> > Hey there
>
> > For running our test script we are using standalone script.
>
> > Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
> > [GCC 4.3.3] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> from django.conf import settings, global_settings
> > >>> from fg import settings as app_settings
> > >>> settings.configure(
> > ... default_settings = global_settings,
> > ... INSTALLED_APP = app_settings.INSTALLED_APP
> > ... )
> > Traceback (most recent call last):
> >  File "", line 3, in 
> >  File "/usr/local/lib/python2.6/dist-packages/django/utils/
> > functional.py", line 269, in __getattr__
> >    self._setup()
> >  File "/usr/local/lib/python2.6/dist-packages/django/conf/
> > __init__.py", line 38, in _setup
> >    raise ImportError("Settings cannot be imported, because
> > environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
> > ImportError: Settings cannot be imported, because environment variable
> > DJANGO_SETTINGS_MODULE is undefined.
>
> > Here's traceback with code I am using to make our concrete settings
> > for testing. But, it was ignored and raises error.
>
> > What that can be? Thanks
>
> My guess is something in your fg.settings is importing a django model or
> something else that requires Django to be configured, so when you try to
> access the INSTALLED_APP setting it looks for DJANGO_SETTINGS_MODULE, which
> isn't configured yet. What does your fg.settings look like?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: standalone script

2009-08-04 Thread Michael
On Tue, Aug 4, 2009 at 10:46 AM, Vitaly  wrote:

>
> Hey there
>
> For running our test script we are using standalone script.
>
> Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
> [GCC 4.3.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from django.conf import settings, global_settings
> >>> from fg import settings as app_settings
> >>> settings.configure(
> ... default_settings = global_settings,
> ... INSTALLED_APP = app_settings.INSTALLED_APP
> ... )
> Traceback (most recent call last):
>  File "", line 3, in 
>  File "/usr/local/lib/python2.6/dist-packages/django/utils/
> functional.py", line 269, in __getattr__
>self._setup()
>  File "/usr/local/lib/python2.6/dist-packages/django/conf/
> __init__.py", line 38, in _setup
>raise ImportError("Settings cannot be imported, because
> environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
> ImportError: Settings cannot be imported, because environment variable
> DJANGO_SETTINGS_MODULE is undefined.
>
> Here's traceback with code I am using to make our concrete settings
> for testing. But, it was ignored and raises error.
>
> What that can be? Thanks


My guess is something in your fg.settings is importing a django model or
something else that requires Django to be configured, so when you try to
access the INSTALLED_APP setting it looks for DJANGO_SETTINGS_MODULE, which
isn't configured yet. What does your fg.settings look like?

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



Re: Django file upload. 'None'

2009-08-04 Thread Martje

One question though. Even when it is in request.FILES, it doesn't get
saved like I expected it would.

I expected Django to upload my image to "media/afbeeldingen/
gastenboek/" ánd validate if it is an image or not (I've change
FileField to ImageField).

Why doesn't Django do this?

On 4 aug, 15:19, Martje  wrote:
> You're right, that was the problem. Thanks!
>
> On Aug 4, 2:18 pm, James Bennett  wrote:
>
> > On Tue, Aug 4, 2009 at 7:08 AM, Martje wrote:
> > > This seem ok, since I only used field 3 and 1. But when I look at
> > > request.FILES, I get:
>
> > > 
>
> > > It shouldn't be empty, should it?
>
> > If you've forgotten to set the 'enctype' attribute of the HTML 
> > element properly, you won't get any files sent. The documentation
> > covers this and how to programmatically detect forms which need it:
>
> >http://docs.djangoproject.com/en/dev/ref/forms/api/#testing-for-multi...
>
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: standalone script

2009-08-04 Thread krylatij

or there is another way.
create custom command for manage.py
(http://docs.djangoproject.com/en/dev/howto/custom-management-commands/
#howto-custom-management-commands)
it's pretty simple.
then write bash script like this:
#!/bin/bash
export PYTHONPATH=/path/to/django
cd /path/to/project
python manage.py mycustomcommand
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: standalone script

2009-08-04 Thread Vitaly

PYTHONPATH is ok, and application is working, but see that I am
running tests, and it raises exception when tries to configure custom
settings.

On 4 Сер, 17:52, krylatij  wrote:
> I guess you are using SSH?
>
> so before running your script run:
> export PYTHONPATH=/path/to/django
>
> hope this helps
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: standalone script

2009-08-04 Thread krylatij

I guess you are using SSH?

so before running your script run:
export PYTHONPATH=/path/to/django

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



Re: buildung query with ORM

2009-08-04 Thread krylatij

You need to use raw sql. (http://docs.djangoproject.com/en/dev/topics/
db/sql/#topics-db-sql)

I don't understand what will be if there are more then 2 channels at
the same datetime?
So i can't provide you solutions sample.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



standalone script

2009-08-04 Thread Vitaly

Hey there

For running our test script we are using standalone script.

Python 2.6.2 (release26-maint, Apr 19 2009, 01:56:41)
[GCC 4.3.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from django.conf import settings, global_settings
>>> from fg import settings as app_settings
>>> settings.configure(
... default_settings = global_settings,
... INSTALLED_APP = app_settings.INSTALLED_APP
... )
Traceback (most recent call last):
  File "", line 3, in 
  File "/usr/local/lib/python2.6/dist-packages/django/utils/
functional.py", line 269, in __getattr__
self._setup()
  File "/usr/local/lib/python2.6/dist-packages/django/conf/
__init__.py", line 38, in _setup
raise ImportError("Settings cannot be imported, because
environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

Here's traceback with code I am using to make our concrete settings
for testing. But, it was ignored and raises error.

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



Re: apache

2009-08-04 Thread alexarsh

I think your default python is 2.6. What you can try is:
"ls -a /usr/bin/python"
You will see that it's a link to python2.6. You can change the link to
point to python2.5.
(ln -sf  /usr/bin/python)
Then you will have to install mod_python with python2.5.
If you install mod_python from source (by running configure, make,
sudo make install), there is an option to tell mod_python your python
version:

--with-python=PATH  Path to specific Python binary

So just run:
configure --with-python  (from mod_python source
directory)
make
sudo make install

and it should work.

Regards, Alex A.

On Aug 4, 3:48 pm, Salvatore Leone 
wrote:
> > chmod -R 777 /home/testpec/public_html/pecwizard
>
> I think you were right!
>
> but now I've got an error due to mod_python using python2.6 insteal fo 2.5:
>
> ImproperlyConfigured: Error loading MySQLdb module: No module named sets
>
> I've always had this error with the manage.py until I run it with
> "python2.5 manage.py .
>
> Is there a way to tell mod_python to user python2.5 instead of 2.6??
>
> -Salvatore
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Does Django fit this application?

2009-08-04 Thread xerophyte

Yes, you can use the django, but you need to verify all the commands
before you execute .. ( having secure daemon to do it for you ???)

On Aug 4, 8:45 am, HB  wrote:
> Hey,
> We have a couple of command that run over SSH.
> I have been asked to develop a web application to let the non
> technical departments to use the commands.
> For example, display a list of the current logged users and provide a
> link to log out him.
> The application should have a login facility.
> Can I use Django for this application?
> I'm familiar with Django but not a ninja yet :)
> Thanks for help and time.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: A custom ordering SQL and Django models

2009-08-04 Thread krylatij

Use extra() method of query set with little hack ;)

mymodel.objects.extra(select={'ordering_field': 'IF(STRCMP
(bbs_tag.name, 'notice'), '',bbs_tag.name)'},
order_by=['ordering_field'])
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: subclassed ModelForms initial values behavior changed from 1.1beta to 1.1

2009-08-04 Thread Russell Keith-Magee

On Mon, Aug 3, 2009 at 3:46 AM, David Haas wrote:
>
> It looks like the change happened between rev. 10189 & 10190: 10189
> displays the value, 10190 doesn't.
>
> Unfortunately, I don't think I can give you a completely unbiased
> answer as to what behavior I think
> is more correct, because of history and personal use :)
>
> With that out on the table, though, it seems to me that if you are
> using a model form, and you're initializing
> it with a model instance, and that model instance has a current value
> for a field on your form, the form
> ought to get initialized with that value, regardless of whether or not
> you plan on eventually saving the
> field in the database or not.  If you're going to display it, it ought
> to reflect what's currently in the database.
> I think I've read some stuff about eventually making 'read only'
> forms, or marking fields on a form as 'read only', which seems like it
> could tie into this somehow, eventually, maybe.
>
> If you agree with that, though, then currently both ModelForms &
> ModelFormsets initialization is broken, because
> neither fills in the values.

Thanks for taking the time to do the analysis and explanation. I've
now had a closer look at this - unfortunately, I'm inclined to say the
exact opposite. I think ModelForm is doing the right thing.
My reasoning stems from the fact that we are dealing with a ModelForm,
not just a Form, and the 'Meta' definition is the highest source of
authority.

DataParentForm defines a Meta relationship with the DataParent model,
and explicitly defines that only the 'name' field is to be exposed.

DataChildForm inherits from DataParentForm, and while it overrides the
model relationship, it doesn't override the fields definition - so at
this point, we have a ModelForm on DataChild that only exposes the
'name' field.

Then, you have added a 'value' field to the model. While this does
share the name of a field on the model, this is a coincidence - you
have explicitly stated that you don't want the 'value' field from the
model to be involved on the form. The 'value' FloatField could be
called anything else without error - by virtue of the inherited Meta
definition, it bears no relationship to the underlying model.

If, on DataChildForm, you add a fields definition:

fields = ['name','value']

the explicitly defined FloatField becomes an override of the default
form element rather than a standalone form element, and as a result
the initial data is populated.

The behaviour for ModelFormSet is then consistent with that seen in
the ModelForm.

So - to my mind, the v1.1 behaviour of ModelForm is doing the right
thing. I agree that this is a nasty edge case though, and I'd be
interested to hear if anyone has any differing opinions or reasoning.

Yours,
Russ Magee %-)

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



Re: newbie tutorial part 1 startproject doesn't create folder and appropriate files

2009-08-04 Thread ondrey

Hi mdsmoker,

try running the django-admin.py script like this:

   python PATH/django-admin.py startproject mysite

where PATH is the path to directory containing the django-admin.py.


-Ondrej Bohm

On Aug 2, 11:47 pm, mdsmoker  wrote:
> I'm using django 1.1, python 2.5, and windows and i'm brand-spanking
> new to this.  i installed django w/out a problem.  python is in my
> windows path and if i type import django after running python i don't
> get any errors so I'm assuming it is installed correctly.  after i run
> django-admin.py startproject mysite i don't get any errors and i also
> don't get any results :(  no new folder or project files were
> created.  any suggestions?  i can't believe i can't get through the
> very first step in the tutorial!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: annotate() and subsets or related records

2009-08-04 Thread Javier Guerra

On Mon, Aug 3, 2009 at 6:54 PM, Russell
Keith-Magee wrote:
> To achieve this in SQL, you need to add an inner query for each
> summary column you want

this is what i'm doing:

q = Order.objects.all().extra ( select={
'num_items':'SELECT COUNT(*) FROM OT_item WHERE 
order_id=OT_order.id',
'num_notyet' :'SELECT COUNT(*) FROM OT_item WHERE
order_id=OT_order.id AND status=1',
'num_proc' :'SELECT COUNT(*) FROM OT_item WHERE 
order_id=OT_order.id
AND status=2',
'num_ready'  :'SELECT COUNT(*) FROM OT_item WHERE
order_id=OT_order.id AND status_id=3',})

seems reasonably portable SQL (not that i plan to switch DBs), and
lines up nicely in the editor, so any typos are visible enough.  It's
not my usual style on SQL; but it's the server's job to optimize it.
It looks like it's doing the exact same fetches as the equivalent
JOINs

tks a lot

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



Multiple instances of the same form on one page: how to get the right POST data?

2009-08-04 Thread Berco Beute

I'm trying to add multiple instances of the same form on one page,
each with its own submit button. I know how to use the 'prefix'
argument for a form to differentiate between forms, but I can't figure
out how to get the right data when it is POST'ed back (see view.py
below). Somehow the form stays invalid, no matter what I try. Any
suggestions what I may be doing wrong?

Thanks!

=models.py===
class Invite(models.Model):
invitation= models.ForeignKey(Invitation, verbose_name=_
('User'))
email_address = models.EmailField(_('email address'))
status= models.CharField(_('RSVP status'), max_length=1,
choices=settings.INVITE_RESPONSE_CHOICES)



=views.py===
def invite_resp(request):
invites = Invite.objects.all()
if request.method == 'POST':
invite_formz = [InviteForm(request.POST, prefix=str(index),
instance=invite) for index, invite in enumerate(invites)]
if all([invite_form.is_valid() for invite_form in
invite_formz]):
invite = invite_form.save()
return HttpResponseRedirect('/')
invite_forms = [InviteForm(instance=invite) for index, invite in
enumerate(invites)]
return render_to_response('invite_resp.html', {'invite_forms':
invite_forms}, context_instance=RequestContext(request))


=forms.py
class InviteForm(forms.ModelForm):

def __init__(self, label, *args, **kwargs):
super(InviteForm, self).__init__(*args, **kwargs)
self.fields['status'].label = label

class Meta:
model = Invite
exclude = ('invitation', 'email_address')


=page.html===
{% block content %}
{% for invite_form in invite_forms %}



{{ invite_form.status.label }}
{{ invite_form.status }}




{% endfor %}
{% endblock %}






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



Re: Re: Scientific Data Frontend with Django

2009-08-04 Thread Markus Becker
> Hello,
>
> Markus Becker schrieb:
> > Hi,
> >
> > last week I started something in this direction. Similarly to admin.py
> > (which describes how to administrate the data) there is a graph.py,
> > which describes how to graph the data. It is still very rough on the
> > edges, but you can use matplotlib in graph.py to create a plot of the
> > data. Possibly one could also create predefined classes, that create
> > specific matplotlib plots without any code in graph.py except for
> > annotations, e.g. which data to use as x or y data.
> >
> > If you are interested, I could send you a svn diff on trunk and a
> > sample project. I would be interested in hearing comments on this and
> > see whether it could be merged into Django.
>
> I am interested in this. (I am not quite shure it is what i need for
> what i want to do.)

Possibly not. You can interface Django already with matplotlib (see 
http://www.scipy.org/Cookbook/Matplotlib/Django), this is however very 
individual to each graph. I have done this previously as well.

Here, I am trying to create a generic infrastructure for plotting data, more 
or less directly from the model. Assuming you have a model named SampleData: 
Similar to the class SampleDataOptions(admin.ModelAdmin), you could then have 
the class SampleDataGraph(mpl.MplPlot), which describes how to use the data 
for plotting.

Attached are 2 things:
1) django_contrib_graph.svndiff: svn diff from django trunk Revision: 11368 
adding a prototype of a generic plotting infrastructure for Django.
2) dj-mpl.tgz: A sample Django project based on above infrastructure changes.

So, if this helps you: Fine. If not, hopefully it might be of interest to the 
Django developers as a (limited) prototype of such a plotting module, showing 
the viability. I would like to hear about other design options.

BR,
Markus

> I want to create a page that plots data from a lightmeter-network. The aim
> is to monitor lightpollution. So far i have python-skripts (by Dr.
> Wuchterl, an Astronomer in Jena) that can plot this using matplotlib. My
> aim is to make this accesible to regular users that might want to plot how
> light or dark for instance last week was in Berlin.
>
[...]
>
> greetings
>
> jan

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



dj-mpl.tgz
Description: application/compressed-tar
Index: django/contrib/admin/sites.py
===
--- django/contrib/admin/sites.py	(revision 11368)
+++ django/contrib/admin/sites.py	(working copy)
@@ -368,6 +368,7 @@
 'app_list': app_list,
 'root_path': self.root_path,
 }
+print "Extra", extra_context
 context.update(extra_context or {})
 context_instance = template.RequestContext(request, current_app=self.name)
 return render_to_response(self.index_template or 'admin/index.html', context,
Index: django/contrib/graph/MplGraphCreator.py
===
--- django/contrib/graph/MplGraphCreator.py	(revision 0)
+++ django/contrib/graph/MplGraphCreator.py	(revision 0)
@@ -0,0 +1,54 @@
+from django.http import Http404, HttpResponse
+from django.contrib import graph
+
+from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
+from matplotlib.figure import Figure
+
+import random # TODO: remove after debugging
+
+class MplGraphCreator(object):
+def __init__(self):
+pass
+
+def render(self, context):
+"Display stage -- can be called many times"
+
+print "Context", context
+print "Object list", context['object_list']
+
+if context['object_list'][0] != None:
+gm = graph.site.get_graph_for_model(context['object_list'][0].__class__)
+gm.clear_data()
+#print gm
+
+fig = Figure()
+ax = gm.plot_setup(fig)
+
+for obj in context['object_list']:
+gm.add_data(obj)
+
+gm.plot_func(ax)
+
+canvas = FigureCanvas(fig)
+
+hr = HttpResponse(content_type='image/png')
+canvas.print_png(hr)
+
+return hr
+else:
+raise Http404
+
+# fig=Figure()
+# ax=fig.add_subplot(111)
+# x=[]
+# y=[]
+
+# for i in range(10):
+# x.append(i)
+# y.append(random.randint(0, 100))
+# ax.plot(x, y, '-')
+
+# canvas=FigureCanvas(fig)
+# canvas.print_png(hr)
+
+#return hr
Index: django/contrib/graph/__init__.py

Re: buildung query with ORM

2009-08-04 Thread Spajderix

tom pisze:
> Hi group,
>
> i build a model to save measurement data. a measurement entry has
> always a channel (that is the source where the data comes from), a
> value (for example 1.04), a unit (for example m/s or Hz) and a
> timestamp.
> The timestamp and the channel are together unique. every channel can
> only have one data entry for one timestamp.
>
> i have the following model:
>
> class Data(models.Model):
> datetime = models.DateTimeField(help_text='the date and time of
> the measurement value', db_index=True)
> channel = models.CharField(help_text='the channelname',
> max_length=20, db_index=True)
> value = models.FloatField(help_text='the measurement value',
> db_index=True)
> unit = models.CharField(help_text='the unit of the measurement
> value', max_length=20, db_index=True)
> class Meta:
> unique_together = [('datetime', 'channel')]
>
> now, i want to have a query to get the following data-table:
>
> datetimechannel1 unit1channel2
> unit2
> 2009-01-01 00:00:00   10.0m/s 1000  Hz
> 2009-01-01 00:00:10   15.0m/s 1040  Hz
> 2009-01-01 00:00:20   16.0m/s 1563  Hz
>
>
> Is something like this possible with django?
> i know that i can get all data ordered by date and the use python to
> get a datastructure like the described table. but i want to do it with
> the database because i think it's much faster.
>
> any ideas how to do this?
>
>
> Best regards,
>
> tom
>
> >
>   
I would recommend a bit different solution. Instead of one, use two 
tables like this:

class Entry(models.Model):
datetime = models.DateTimeField(help_text='the date and time of the 
measurement value', db_index=True)

class Data(models.Model):
entry = ForeignKey(Entry)
channel = models.CharField(help_text='the channelname', max_length=20, 
db_index=True)
value = models.FloatField(help_text='the measurement value', db_index=True)
unit = models.CharField(help_text='the unit of the measurement value', 
max_length=20, db_index=True)

Then you have one entry element with as many data elements as you like. You 
access it by taking one element object and going through relation, eg:
e = Entry(pk=1)
e.data_set.all()

I don't know if "unique_together" will work with this though


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



Re: creating automatically url for additional column in admin view

2009-08-04 Thread Sławek Tuleja

nice!
thank you krylatij!

On 4 Sie, 14:56, krylatij  wrote:
> Look 
> athttp://docs.djangoproject.com/en/dev/ref/contrib/admin/#reversing-adm...
>
> It will be like this:
>
> from django.core import urlresolvers
>
> my_url = "%s?tender__id__exact=%s" % (
>     urlresolvers.reverse('admin:tender_download_changelist'),
>     self.id
> )
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >