Hidding form field based on logged on user

2008-09-28 Thread Paddy Joy

I have a model with a 'User' foreign key.

class Domain(models.Model):
.
owner = models.ForeignKey(User)

I have a requirement to only allow superuers to change the 'owner'
field.

I can do this by creating two model forms and excluding the 'owner'
field from one:

class DomainForm_superuser(ModelForm):
class Meta:
model = Domain

class DomainForm(ModelForm):
class Meta:
model = Domain
exclude = ('owner',)

and then in my view I check if the current user is a superuser

@login_required()
def update_domain(request, domain_id):

d = Domain.objects.get(id=domain_id)

if request.method == 'POST':
if request.user.is_superuser:
form = DomainForm_superuser(data=request.POST,
instance=d)
else:
form = DomainForm(data=request.POST,
instance=d)

if form.is_valid():
form.save()
return HttpResponseRedirect("/")
else:
if request.user.is_superuser:
form = DomainForm_superuser(instance=d)
else:
form = DomainForm(instance=d)

return render_to_response('domain_form.html', {"form": form},
context_instance=RequestContext(request))


This works but can anyone suggest a better/more efficient way of doing
this?

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



Re: forms.DecimalField ... min_value=0.01 not honored

2008-09-28 Thread Gerard Petersen

Malcom,

This seems so obvious, I'm working on an invoice system and already passed the 
chapter on rounding decimals. I still am somewhat overwhelmed I guess by all 
that Django does. Nevertheless, it's impressive how good Django keeps to 
(python) conventions.

Thanx a lot.

Regards,

Gerard.


Malcolm Tredinnick wrote:
> 
> On Sat, 2008-09-27 at 18:07 +0200, Gerard Petersen wrote:
>> Dear Django team,
>>
>> It seems, but since I'm human it could be me, that in a modelform with a 
>> forms.DecimalField declaration the min_value is not picked up when it has 
>> decimals in it. The snippet:
>>
>> per_price = forms.DecimalField(
>> label='Per Price',
>> min_value=0.01,
>> decimal_places=2
>> )
>>
>> I want to force a 'value > 0'. A value of '1' works but that defies the 
>> purpose of having 2 decimal_places. Note: a value of 0.01 for "initial=.." 
>> does work.
> 
> It's kind of a small inconsistency that a float is allowed for an
> initial value there. The fact is, this is a DecimalField, so using
> floats is something you should avoid doing. In Python, the following
> holds:
> 
> >>> Decimal('0.05') < 0.1
> False
> 
> In other words, decimals and floats do not compare as you might expect
> (since you cannot reliably convert a float to an exact decimal value).
> 
> Instead, you should be passing in a Decimal instance for the minimum
> value:
> 
> min_val = Decimal('0.01')
> 
> and then it will work. Internally, Django has already converted the
> input value to a Decimal instance and is then using '<' and '>' to
> compare against min_value and max_value, so it needs to be comparing
> similar types.
> 
> Regards,
> Malcolm
> 
> 
> 
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: admin.site.register breaks unittests

2008-09-28 Thread Gerard Petersen

Russell,

Is it correct to say that the admin.autodiscover statement should register the 
models in 'myapp', and therefore I don't need the individual 
admin.site.register statement for each model?

Without the register statements I don't see the group of models (for myapp) and 
myapp itself in the main admin gui. With the register statements (originally) 
in models.py (and the autodiscover disabled) the command "manage.py test myapp" 
complains about the models already being registered.

Below some snippets of possible influence. Since I don't know where to look I 
did no paste to much yet.

## taken from settings.py
#(it contains no import statements)

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.admindocs',
'djapp.myapp',
)

I have a admin dir. in the templates dir. that contain almost unmodified copies 
of admin's index.html and base_site.html.
## A snippet from admin template index.html

{% for app in app_list %}

-- snip--
{% for model in app.models %}

It safe to say the app_list contains nothing.


Thanx a lot for your effort.

Regards,

Gerard.



Russell Keith-Magee wrote:
> On Sat, Sep 27, 2008 at 9:54 PM, Gerard Petersen <[EMAIL PROTECTED]> wrote:
>> Russel,
>>
>> The example from the docs somehow doesn't work. I've turned on the 
>> autodiscover but under admin it stays empty. I don't know if this is 
>> related, but putting the register statements in urls.py does stop breaking 
>> my tests.
> 
> You're going to have to help me out here. "The example from the docs"
> works fine for me - that's why it's in the docs. If you're not seeing
> models registered in the admin, I'm going to guess you're doing
> something wrong, but without an example, its impossible to tell what.
> Which docs? Can you provide a simple example (not just a dump of your
> full application)?
> 
> Yours,
> Russ Magee %-)
> 
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: unable to resolve URL in template

2008-09-28 Thread Keith Eberle
i the same problem the other day...  i was using the name "search" for my
named url.  i dropped in the the python interpreter and tried it there,
failed.  i tried some other named urls in the same urls.py, and they
worked.  i didn't look at it long and just moved onto another piece of the
project...

keith


On Sat, Sep 27, 2008 at 2:21 PM, Chuck Bai <[EMAIL PROTECTED]> wrote:

>
> In my url.py, I define the root my site is like this:
> urlpatterns = patterns('',
>url(r'^$', 'views.index', name="index"),
>...)
>
> in my template, I have a link defined as follows:
> Home
>
> I got this error:
>
>
>  TemplateSyntaxError at /
>
> Home
>
> Caught an exception while rendering: Reverse for 'testproject.index' with
> arguments '()' and keyword arguments '{}' not found.
>
>
> It seems that Django can not resolve the URL index. Can anyone point to
> me what is wrong and how to fix 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin.site.register breaks unittests

2008-09-28 Thread Russell Keith-Magee

On Sun, Sep 28, 2008 at 4:39 PM, Gerard Petersen <[EMAIL PROTECTED]> wrote:
>
> Russell,
>
> Is it correct to say that the admin.autodiscover statement should register 
> the models in 'myapp', and therefore I don't need the individual 
> admin.site.register statement for each model?

No - that isn't correct.

The purpose of admin.autodiscover is to discover all the admin.py
files in your project. Each admin.py file will then need to contain
the ModelAdmin definitions and site.register() calls required.

> I have a admin dir. in the templates dir. that contain almost unmodified 
> copies of admin's index.html and base_site.html.

This possibly points at a source of confusion - when I say admin.py, I
don't mean templates - I mean a python file called admin.py. It sits
next to models.py in your application directory, and contains the
admin registrations for the models in the application.

Yours,
Russ Magee %-)

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



Re: actual django stack

2008-09-28 Thread Graham Dumpleton



On Sep 28, 10:47 am, Jeremy Sandell <[EMAIL PROTECTED]> wrote:
> On Sep 26, 1:25 pm, David Zhou <[EMAIL PROTECTED]> wrote:
>
>
>
> > I've also heard good things about WSGI -- though I haven't heavily  
> > tested its stability compared to, say,mod_python.
> > ---
> > David Zhou
> > [EMAIL PROTECTED]
>
> FWIW, WSGI has thus far worked wonderfully for me, and using daemon
> mode has solved numerous issues of running Django in a shared hosting
> environment. Being able to simply "touch /path/to/project/django.wsgi"
> instead of restarting Apache is a nice bonus, as well. (:

You do realise that 'WSGI' is a specification only and not a piece of
software.

The Apache module which provides support for WSGI is called
'mod_wsgi', you shouldn't be referring to it as just WSGI and it is
starting to get quite annoying that people continue to just refer to
it as WSGI instead. In some respect, because the nginx guy also
confusingly refers to his part port of mod_wsgi for Apache to nginx as
mod_wsgi as well and didn't give it a different name, then you
probably want to be explicit and say Apache/mod_wsgi or nginx/mod_wsgi
so people know what you are talking about.

BTW, as WSGI is just a specification, you can also run WSGI
applications on other hosting mechanisms such as CGI, FASTCGI, SCGI,
AJP, Passenger, mod_python etc, etc.

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



Designing the model of a website

2008-09-28 Thread Caisys

Hi,
I am new to django and mvc. I have php and asp experience. I followed
the tutorial and would like to create a site that will act as as a
sort of city guide. to Simplify things I will assume the site will
have 5 types of information:

1-Hotels
2- Monuments
3-Venues
4-Peformers
5-Concerts (have to be attached to a venue and a performer)

I would like the urls to be http://mysite/hotels/name-of-hotel-one,
http://mysite/monuments/name-of-monument etc and for the events
http://mysite/YYY-MM-DD/name-of-event etc.

I have a couple questions for now:

1- the first three items have the same data structure, text, address,
description, picture. Should they be in one model or should I create a
separate model for each type of records.
2- .Will the primary key for each model be the text name in order to
pass the key from the url to the view?

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



Re: Designing the model of a website

2008-09-28 Thread Ray Smith

Caisys wrote:
> Hi,
> I am new to django and mvc. I have php and asp experience. I followed
> the tutorial and would like to create a site that will act as as a
> sort of city guide. to Simplify things I will assume the site will
> have 5 types of information:
>
> 1-Hotels
> 2- Monuments
> 3-Venues
> 4-Peformers
> 5-Concerts (have to be attached to a venue and a performer)
>
> I would like the urls to be http://mysite/hotels/name-of-hotel-one,
> http://mysite/monuments/name-of-monument etc and for the events
> http://mysite/YYY-MM-DD/name-of-event etc.
>
> I have a couple questions for now:
>
> 1- the first three items have the same data structure, text, address,
> description, picture. Should they be in one model or should I create a
> separate model for each type of records.
> 2- .Will the primary key for each model be the text name in order to
> pass the key from the url to the view?
>
> Thanks
> Ahmed
>   


1.  The answer to your model question is "either way".
If you combine different types into 1 model you will need a new field 
called "type" or something similar. This "may" be a good idea if you 
think you may be adding new types in the future.
To be consistent though, it "may" be better to have a model for each 
type.  The correct answer to this decision will only be known in time as 
you start to implement different parts of your site.

2.  Django will add an "id" field to each of your tables which will be 
the primary key (this is the default behavior but can be changed).

The names of your URL's are defined in the URL dispatcher, see 
http://docs.djangoproject.com/en/dev/topics/http/urls/

Regards,

Ray Smith
http://RaymondSmith.com
P.S. I'm just a newbie as well so I "may" not be 100% correct :)


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



Re: Designing the model of a website

2008-09-28 Thread Daniel Roseman

On Sep 28, 12:21 pm, Caisys <[EMAIL PROTECTED]> wrote:
> Hi,
> I am new to django and mvc. I have php and asp experience. I followed
> the tutorial and would like to create a site that will act as as a
> sort of city guide. to Simplify things I will assume the site will
> have 5 types of information:
>
> 1-Hotels
> 2- Monuments
> 3-Venues
> 4-Peformers
> 5-Concerts (have to be attached to a venue and a performer)
>
> I would like the urls to 
> behttp://mysite/hotels/name-of-hotel-one,http://mysite/monuments/name-of-monumentetc
>  and for the eventshttp://mysite/YYY-MM-DD/name-of-eventetc.
>
> I have a couple questions for now:
>
> 1- the first three items have the same data structure, text, address,
> description, picture. Should they be in one model or should I create a
> separate model for each type of records.

I would put them in separate models. As time goes on, you might want
to add more data which differs by type - eg opening times for
monuments, facilities for hotels - and that will be more difficult if
everything is in one model.

However, you can save work by having all three as subclasses from a
common model type. See here:
http://docs.djangoproject.com/en/dev/topics/db/models/#id4


> 2- .Will the primary key for each model be the text name in order to
> pass the key from the url to the view?

No need for that - you can pass anything from the URL to the view,
although obviously it helps if it uniquely identifies the instance.
Best to leave Django to manage the primary key (via the automatically-
created id field), and use a SlugField with unique=True to be the
value passed from the URL.

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



Where to put signals?

2008-09-28 Thread Benjamin Buch
Hi,

I'm using the new comments framework, and I'd like to get notified by  
mail when someone posts a comment.
How to di it I think I know, but I'm not quite sure where the code  
should live.
The website has several kinds of entries where users can comment on,  
so it would feel a little odd to put the comments' signal-code in just  
one models.py.
As I have even more signals, I thought it would be great to have a  
file signals.py, where all signal handling is done.

But where should signals.py live?
Documentation says to signals:
"Where should this code live?
You can put signal handling and registration code anywhere you like.  
However, you'll need to make sure that the module it's in gets  
imported early on so that the signal handling gets registered before  
any signals need to be sent. This makes your app's models.py a good  
place to put registration of signal handlers."
What means "the module it's in gets imported early"?
I suppose it's not enough to put my signals.py right there in my  
projects' root folder?
-benjamin


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



FormWizard and @login_required

2008-09-28 Thread Knut Nesheim
Hi!

We're trying to build a multi-page form using FormWizard. We need to  
authorize the user first. In other views we use the user_passes_test  
decorator, however the documented way of using FormWizard is to  
include it directly in the urlconf:

(r'^contact/$', ContactWizard([ContactForm1, ContactForm2])),

How can we use decorators with this?

We've tried

(r'^contact/$', @login_required(ContactWizard([ContactForm1,  
ContactForm2]))),

But it only gives

Exception Type: TypeError at /order/add/
Exception Value: 'type' object is unsubscriptable

Any help is appreciated.

Regards
-- 
Knut Nesheim







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



"inline" change list in admin

2008-09-28 Thread Walter K

I'm wondering if there's a relatively simple way to have an "inline"
change list in the admin site.  I have a parent-child relationship
where the children have way too many fields to do inline editing, so
I'd prefer to have an non-editable list of links to the children
instead.  It'd be great if this could duplicate the functionality of
the change list (filters), but simply having a list of links is the
main priority.

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



Re: "inline" change list in admin

2008-09-28 Thread Walter K

Ignore this post.  I just realized that this is easily achieved by
overriding admin templates.

On Sep 28, 8:32 am, Walter K <[EMAIL PROTECTED]> wrote:
> I'm wondering if there's a relatively simple way to have an "inline"
> change list in the admin site.  I have a parent-child relationship
> where the children have way too many fields to do inline editing, so
> I'd prefer to have an non-editable list of links to the children
> instead.  It'd be great if this could duplicate the functionality of
> the change list (filters), but simply having a list of links is the
> main priority.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Hidding form field based on logged on user

2008-09-28 Thread Steve Holden

Paddy Joy wrote:
> I have a model with a 'User' foreign key.
>
> class Domain(models.Model):
>   .
> owner = models.ForeignKey(User)
>
> I have a requirement to only allow superuers to change the 'owner'
> field.
>
> I can do this by creating two model forms and excluding the 'owner'
> field from one:
>
> class DomainForm_superuser(ModelForm):
> class Meta:
> model = Domain
>
> class DomainForm(ModelForm):
> class Meta:
> model = Domain
> exclude = ('owner',)
>
> and then in my view I check if the current user is a superuser
>
> @login_required()
> def update_domain(request, domain_id):
>
> d = Domain.objects.get(id=domain_id)
>
> if request.method == 'POST':
> if request.user.is_superuser:
> form = DomainForm_superuser(data=request.POST,
> instance=d)
> else:
> form = DomainForm(data=request.POST,
> instance=d)
>
> if form.is_valid():
> form.save()
> return HttpResponseRedirect("/")
> else:
> if request.user.is_superuser:
> form = DomainForm_superuser(instance=d)
> else:
> form = DomainForm(instance=d)
>
> return render_to_response('domain_form.html', {"form": form},
> context_instance=RequestContext(request))
>
>
> This works but can anyone suggest a better/more efficient way of doing
> this?
>   

You could make your code slightly more readable by setting the form
class initially according to the user's type and then using it without
decisions lower down. This should work because the two forms have
exactly the same signatures:

@login_required()
def update_domain(request, domain_id):

d = Domain.objects.get(id=domain_id)

if request.user.is_superuser:
formclass = DomainForm_superuser
else:
formclass = DomainForm

if request.method == 'POST':
form = formclass(data=request.POST, instance=d)
if form.is_valid():
form.save()
return HttpResponseRedirect("/")
else:
if request.user.is_superuser:
form = formclass(instance=d)

return render_to_response('domain_form.html', {"form": form},
context_instance=RequestContext(request))

I've tried to adjust your code's indentation to 4-per-level, so pardon me if 
I've screwed up the logic at the same time. I find 8 spaces makes the code much 
more difficult to read (especially after being wrapped by an email client).

regards
 Steve




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



Re: Hidding form field based on logged on user

2008-09-28 Thread Steve Holden

Steve Holden wrote:
> Paddy Joy wrote:
>   
>> I have a model with a 'User' foreign key.
>>
>> class Domain(models.Model):
>>  .
>> owner = models.ForeignKey(User)
>>
>> I have a requirement to only allow superuers to change the 'owner'
>> field.
>>
>> I can do this by creating two model forms and excluding the 'owner'
>> field from one:
>>
>> class DomainForm_superuser(ModelForm):
>> class Meta:
>> model = Domain
>>
>> class DomainForm(ModelForm):
>> class Meta:
>> model = Domain
>> exclude = ('owner',)
>>
>> and then in my view I check if the current user is a superuser
>>
>> @login_required()
>> def update_domain(request, domain_id):
>>
>> d = Domain.objects.get(id=domain_id)
>>
>> if request.method == 'POST':
>> if request.user.is_superuser:
>> form = DomainForm_superuser(data=request.POST,
>> instance=d)
>> else:
>> form = DomainForm(data=request.POST,
>> instance=d)
>>
>> if form.is_valid():
>> form.save()
>> return HttpResponseRedirect("/")
>> else:
>> if request.user.is_superuser:
>> form = DomainForm_superuser(instance=d)
>> else:
>> form = DomainForm(instance=d)
>>
>> return render_to_response('domain_form.html', {"form": form},
>> context_instance=RequestContext(request))
>>
>>
>> This works but can anyone suggest a better/more efficient way of doing
>> this?
>>   
>> 
>
> You could make your code slightly more readable by setting the form
> class initially according to the user's type and then using it without
> decisions lower down. This should work because the two forms have
> exactly the same signatures:
>
> @login_required()
> def update_domain(request, domain_id):
>
> d = Domain.objects.get(id=domain_id)
>
> if request.user.is_superuser:
> formclass = DomainForm_superuser
> else:
> formclass = DomainForm
>
> if request.method == 'POST':
> form = formclass(data=request.POST, instance=d)
> if form.is_valid():
> form.save()
> return HttpResponseRedirect("/")
> else:
> if request.user.is_superuser:
> form = formclass(instance=d)
>
>   
The above should, of course, have read

else:
form = formclass(instance=d)

Sorry about that.

regards
 Steve
> return render_to_response('domain_form.html', {"form": form},
> context_instance=RequestContext(request))
>
> I've tried to adjust your code's indentation to 4-per-level, so pardon me if 
> I've screwed up the logic at the same time. I find 8 spaces makes the code 
> much more difficult to read (especially after being wrapped by an email 
> client).
>
> regards
>  Steve
>
>
>
>
> >
>
>   



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



Re: Django vs. Liferay

2008-09-28 Thread Nic Jordan

Dear List,

thank you Malcolm for your reply. I don't have anything really
specific, but I *think* I know so much now:
We have some static sites, those are already ported to the dcms
(language support) pluggable, so the cms part is pretty much solved.
That is true for Liferay as well, since it has a cms built in.
We have to deal very much with surveys, and there is nothing out of
the box for Django nor Liferay, so writing something like that is (as
far as I know) easier with Django. Database models, automatic admin
interface etc. But there is also the goal to have an "internal",
meaning intranet, file-system, unlike a normal file-system with "just"
directories, but something like a "general" and a user directory. As
far as my knowledge goes (and it isn't very far), neither Liferay nor
Django provide such means.

On all the other points a completely agree with you, but maybe that's
the reason why I have so much trouble finding a solution, because
there's lacking the "specificity" for this new project. So I really
have to digg into Django (*JOY*) and Liferay (*not so much joy*).

I'll try to resume what I've got so far (thanks to Malcolm's answers):
-neither Django nor Liferay are "better", they both focus on different
things
-There is a need for more specificity to be able to decide, best way
is to digg into both systems end evaluating
-API are possible in Django, also authentication is "simpel" to write
-Any other points need further investigation and to be more specific
or less "abstract"

If I'm wrong on this, please correct me.

Thank a lot for the support,
Nicola Jordan


On Sep 28, 4:15 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sat, 2008-09-27 at 10:16 -0700, Nic Jordan wrote:
> > Dear List,
>
> > I'm currently involved in a project for building en entirely new site.
> > The choice of our informatics-advisor is Liferay. I now volunteered to
> > try to convince him, that "Django" is the better choice.
> > Unfortunately, I don't know anything about Liferay, and I'm still
> > fairly new to Django as well. I know that these are two completely
> > different "systems".
>
> Yeah, no kidding. :-)
>
>
>
> > To be a bit more specific about what is wanted (what we really need is
> > another topic):
> > -JSR-168 (or similar specification) and SOA;
>
> Oeople from the Java side of town always seem to assume that everybody
> else knows what each particular JSR is (you're not the first to do
> this). I got as far as getting to the Sun Java site to read JSR-168, but
> the license says I can only use it for internal evaluation and since
> there's a greater than zero chance I might one day want to implement
> something "portlet" related in Django and it might even have a large
> overlap with something Sun have previously done, I can't agree to that
> license, so I can't read the document. What does the "portlet API" do?
>
> Similarly, SOA is an architecture style. It's not the one Django is
> normally used for (since REST-style architecture is more useful for the
> types of things Django was built for), but it wouldn't be impossible to
> do things in that style. After all, you're still sending data to a URL
> that is then processed by a view and in your (Python) view functions you
> can do whatever you like, including running that data through SOAPy or
> ZSI or any other library that can be used
>
> > -Capable to handle more than one programming language in data
> > activities as well as in application activities;
>
> What does this mean? Can you give an example, please, since "data and
> application activities" just means "code" when I use the normal meanings
> of the words. Django requires writing code in Python. You could just
> Django on Jython and then call to Java code (modulo running a
> non-released version of Jython at the moment, but that will change early
> next year).
>
> > -Independent of Hardware, Software, programming language, operating
> > system (as much as possible)
>
> Django is a Python framework. Liferay doesn't meet this requires,
> either, since it's totally Java based. That being said, you can run
> Python on more platforms than you can run Java on, so it's more
> independent of hardware and OS in that respect.
>
> > Has some sort of a software library which is expandable and has
> > already enough basic business logics in a framework to quickly develop
> > a new application on top of it;
>
> You can see from djangosites.org, random browsing of this mailing and a
> few quick Google searches that Django is designed to build a variety of
> simple and complex applications quickly. But "quickly" is a very loaded
> term, since it depends on the available skillset and complexity of the
> task, for example. There are no doubt some seemingly very simple
> applications for which Django would be inappropriate, but there are
> complex ones for which it is highly appropriate. So looking for a
> definitive answer here is a bit of a fool's errand.
>
> I would be suspicious of choosing or reject

Re: Where to put signals?

2008-09-28 Thread Erik Allik
The way I see it is that your comment notification is not tied to any  
particular application that has commentable models but instead is more  
like a project related thing. So depending on your source layout, I'd  
put them somewhere in the project. Basically this relates to the  
application reuse topic -- when you connect the handler to the comment  
signal, is it something you want to reuse in the future or it's just a  
one time thing for the current project?

Erik

On 28.09.2008, at 14:58, Benjamin Buch wrote:

> Hi,
>
> I'm using the new comments framework, and I'd like to get notified  
> by mail when someone posts a comment.
> How to di it I think I know, but I'm not quite sure where the code  
> should live.
> The website has several kinds of entries where users can comment on,  
> so it would feel a little odd to put the comments' signal-code in  
> just one models.py.
> As I have even more signals, I thought it would be great to have a  
> file signals.py, where all signal handling is done.
>
> But where should signals.py live?
> Documentation says to signals:
> "Where should this code live?
> You can put signal handling and registration code anywhere you like.  
> However, you'll need to make sure that the module it's in gets  
> imported early on so that the signal handling gets registered before  
> any signals need to be sent. This makes your app's models.py a good  
> place to put registration of signal handlers."
> What means "the module it's in gets imported early"?
> I suppose it's not enough to put my signals.py right there in my  
> projects' root folder?
> -benjamin
>
>
> >


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



Weird upload error (image file is truncated)

2008-09-28 Thread kire

Hi

Since friday I get this error for EVERY upload on a page. I thought it
was my latest change so reverted, but error stayed. This is, the least
to be said, irritating:

"IOError: image file is truncated (10 bytes not processed)"

The miracle continues: when I Reload my apache, the file is actually
uploaded. However the custom binding of foreign keys (as you'll be
able to see in my view) won't happen since the script crashes before
that binding. Very stupid. Also after trying that upload members can't
visit that page again (since we 'try' to display that image there
again).

I hope (really) someone can help me on this one since I try everything
already :(.

View: http://dpaste.com/81050/
template: http://dpaste.com/81049/
traceback: http://dpaste.com/81051/

Locally on windows I also had the error, I switched to ubuntu
saterday, checked out and here everything worked fine (server is
ubuntu feisty, laptop hardy).

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



Re: Where to put signals?

2008-09-28 Thread Benjamin Buch
Hi Erik,

thanks for your reply.
You are right, the comments are not tied to a particular model, but to  
three of them.
Instead of wiring up all three models, I thought I could do this in  
one place.
As I write this reply, I realize that it is perhaps not such a good  
idea to do so.
It would be good to have some information in the mail that says on  
exactly which model instance the comment was made on,
so it will be better to  wire up each model.

Thanks again anyway,
benjamin

Am 28.09.2008 um 17:14 schrieb Erik Allik:

> The way I see it is that your comment notification is not tied to  
> any particular application that has commentable models but instead  
> is more like a project related thing. So depending on your source  
> layout, I'd put them somewhere in the project. Basically this  
> relates to the application reuse topic -- when you connect the  
> handler to the comment signal, is it something you want to reuse in  
> the future or it's just a one time thing for the current project?
>
> Erik
>
> On 28.09.2008, at 14:58, Benjamin Buch wrote:
>
>> Hi,
>>
>> I'm using the new comments framework, and I'd like to get notified  
>> by mail when someone posts a comment.
>> How to di it I think I know, but I'm not quite sure where the code  
>> should live.
>> The website has several kinds of entries where users can comment  
>> on, so it would feel a little odd to put the comments' signal-code  
>> in just one models.py.
>> As I have even more signals, I thought it would be great to have a  
>> file signals.py, where all signal handling is done.
>>
>> But where should signals.py live?
>> Documentation says to signals:
>> "Where should this code live?
>> You can put signal handling and registration code anywhere you  
>> like. However, you'll need to make sure that the module it's in  
>> gets imported early on so that the signal handling gets registered  
>> before any signals need to be sent. This makes your app's models.py  
>> a good place to put registration of signal handlers."
>> What means "the module it's in gets imported early"?
>> I suppose it's not enough to put my signals.py right there in my  
>> projects' root folder?
>> -benjamin
>>
>>
>>


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



Re: Where to put signals?

2008-09-28 Thread Erik Allik
But you only have a single comment model to wire to, unless I'm  
missing something.

Erik

On 28.09.2008, at 19:03, Benjamin Buch wrote:

> Hi Erik,
>
> thanks for your reply.
> You are right, the comments are not tied to a particular model, but  
> to three of them.
> Instead of wiring up all three models, I thought I could do this in  
> one place.
> As I write this reply, I realize that it is perhaps not such a good  
> idea to do so.
> It would be good to have some information in the mail that says on  
> exactly which model instance the comment was made on,
> so it will be better to  wire up each model.
>
> Thanks again anyway,
> benjamin
>
> Am 28.09.2008 um 17:14 schrieb Erik Allik:
>
>> The way I see it is that your comment notification is not tied to  
>> any particular application that has commentable models but instead  
>> is more like a project related thing. So depending on your source  
>> layout, I'd put them somewhere in the project. Basically this  
>> relates to the application reuse topic -- when you connect the  
>> handler to the comment signal, is it something you want to reuse in  
>> the future or it's just a one time thing for the current project?
>>
>> Erik
>>
>> On 28.09.2008, at 14:58, Benjamin Buch wrote:
>>
>>> Hi,
>>>
>>> I'm using the new comments framework, and I'd like to get notified  
>>> by mail when someone posts a comment.
>>> How to di it I think I know, but I'm not quite sure where the code  
>>> should live.
>>> The website has several kinds of entries where users can comment  
>>> on, so it would feel a little odd to put the comments' signal-code  
>>> in just one models.py.
>>> As I have even more signals, I thought it would be great to have a  
>>> file signals.py, where all signal handling is done.
>>>
>>> But where should signals.py live?
>>> Documentation says to signals:
>>> "Where should this code live?
>>> You can put signal handling and registration code anywhere you  
>>> like. However, you'll need to make sure that the module it's in  
>>> gets imported early on so that the signal handling gets registered  
>>> before any signals need to be sent. This makes your app's  
>>> models.py a good place to put registration of signal handlers."
>>> What means "the module it's in gets imported early"?
>>> I suppose it's not enough to put my signals.py right there in my  
>>> projects' root folder?
>>> -benjamin
>>>
>>>
>>>
>
>
> >


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



Re: validation problems in inline admin form

2008-09-28 Thread Munhitsu

Hi,
I have the same, so I've decided to live with the following
workaround.

Form.clean() is not reported properly for inlines but
Form.clean_() works fine.
In theory only Form.clean() is recommended for cross field validation
but in fact Form.clean_() can also refer to the other
fields.
However there is one condition. They all shall be defined prior to the
specific field in the model.
It's thanks to sequential processing of fields.
In such situation you can refer to them using cleaned_data hash. If
you need to refer to field which is defined later that there is data
hash but you'll end up in mess in case of Inlines.

Here goes the example. I hope it helps.

class UserProfile(models.Model):
"""
Place to store extra user information. Editable from Users.
"""
user = models.ForeignKey(User, verbose_name=_("User"),
unique=True)
price_variant = models.CharField(_('Price variant'),max_length=1,
choices=PRICE_CHOICES, default='R')
phone_number = models.CharField(_('Phone number'),max_length=20)
address_street = models.CharField(_('Address Street'),
max_length=30)
address_code = models.CharField(_('Address Code'),max_length=6)
address_city = models.CharField(_('Address City'),max_length=20)
address_state = models.ForeignKey(State)
address_country = models.ForeignKey(Country, default=1)
company_name = models.CharField(_('Company
name'),max_length=20,blank=True)
euvat = models.CharField(_('EU VAT'),max_length=16,blank=True)

class UserProfileAdminForm(forms.ModelForm):
class Meta:
model = UserProfile

def clean_euvat(self):
if self.cleaned_data["company_name"] and not
self.cleaned_data["euvat"].strip():
raise forms.ValidationError('Please provide EU VAT since
you have provided company name.')
# do something that validates your data
return self.cleaned_data["euvat"]


Regards,
Mateusz


On Sep 10, 5:19 pm, Wintoon <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I cant seem to figure out if this is working correctly:
>
> In admin.py I put some code (end of message) to validate an inline
> entry. The validation works just fine, however the error message is
> not shown in the appropriate place inline. Is this a bug I should file
> or is there something wrong with my implementation?
>
> .
>
> class InlineForm(forms.ModelForm):
>     class Meta:
>         model = Inline
>     def clean(self):
>         if ...
>             raise forms.ValidationError('Error message here.')
>         return self.cleaned_data
>
> class StuffInline(admin.TabularInline):
>     model = Inline
>     form = InlineForm
>     extra = 6
>
> class FormAdmin(admin.ModelAdmin):
>    inlines = [StuffInline]
> admin.site.register(Form, FormAdmin)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django developer need ASAP

2008-09-28 Thread KnoxvilleDjangoDev

Apologies if I am not asking this question correctly, but i need some
assistance. I have a site that was developed in Django and bottom
line, my developer is nowhere to be found at the last minute. So, I am
looking for a Django developer that can crank out some last minute
tweaks in the code, migrate the site over to our server and post it
live in an emergency time frame. Pay will be strong.

If you can get this done and you are in the Knoxville, TN area Sunday,
September 28th, send me an email to:

[EMAIL PROTECTED]

Again, my apologies if I went outside the norm on this, but I need the
help.

Thanks.

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



Add error to form field

2008-09-28 Thread [EMAIL PROTECTED]

Hi all,

Can I in any way add an error to a form field?
I have a controller method (in views.py) which needs information from
the session and information from the form (a CharField) to validate
some logic. If this fails, I want to add an error to the form field
saying its value is invalid, but can I do this? Ive tried accessing
form._errors['field_name'] = [u'Invalid'] and such, but its doesnt
really seem like an ideal solution..  Anyone?

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



Re: Djangobook Revisions for 1.0 release

2008-09-28 Thread Alex Polite

2008/9/8 Adrian Holovaty <[EMAIL PROTECTED]>:
>
> On Sun, Aug 31, 2008 at 10:07 PM, Benoit <[EMAIL PROTECTED]> wrote:
>> 1) Will The Django Book (online) be updated to comply with Django 1.0
>> API changes?
>
> I'd like for it to be updated, indeed -- but I'm not making any

Maybe you could at least put something in the header stating that the
book is not up to date? I've been starting out with Django this
weekend, using the Djangobook and it took me a while to understand
that it's not up to date.

Alex

-- 
http://polite.se

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



faking a cron job

2008-09-28 Thread Julian

hi there,

i have written a middleware-class wich is doing what a cronjob should
do. it is doing some backup-stuff, and repeats that every 12 hours. it
is a thread and is placed in the list of middleware-classes, but not
processing any request or overwriting any typical method for a
middleware class.

my problem is: with the devlopment-server it's created once. with
mod_python and _three_ apache instances, there are three instances of
my backup-thread, but i want to have only one.

how can i start a thread (without having an extra cronjob) in my
django-app only once on the whole server??? the hackish solution would
be to store the actual PID on a special place.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: faking a cron job

2008-09-28 Thread Tom Badran
The obvious solution seems to be use a cron job, instead of trying to
strongarm django/apache into doing something that they aren't for.

There is no reason your cron job couldnt be a python script that uses django
classes/your model etc. if you want.

Tom

On Sun, Sep 28, 2008 at 8:11 PM, Julian <[EMAIL PROTECTED]> wrote:

>
> hi there,
>
> i have written a middleware-class wich is doing what a cronjob should
> do. it is doing some backup-stuff, and repeats that every 12 hours. it
> is a thread and is placed in the list of middleware-classes, but not
> processing any request or overwriting any typical method for a
> middleware class.
>
> my problem is: with the devlopment-server it's created once. with
> mod_python and _three_ apache instances, there are three instances of
> my backup-thread, but i want to have only one.
>
> how can i start a thread (without having an extra cronjob) in my
> django-app only once on the whole server??? the hackish solution would
> be to store the actual PID on a special place.
> >
>

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



Re: admin.site.register breaks unittests

2008-09-28 Thread Gerard Petersen

Russel,

Replies inline ...

> The purpose of admin.autodiscover is to discover all the admin.py
> files in your project. Each admin.py file will then need to contain
> the ModelAdmin definitions and site.register() calls required.
Ok, so the autodiscover is a recursive functionality that gathers all (admin 
registered) models from all apps in a project?

> This possibly points at a source of confusion - when I say admin.py, I
> don't mean templates - I mean a python file called admin.py. It sits
> next to models.py in your application directory, and contains the
> admin registrations for the models in the application.
I had my admin model definitions in models.py. I now moved them to admin.py in 
my myapp directory. My fuzzy-ness starts to clear up. 
There's admin urls in both project and myapp urls.py however:

# project
urlpatterns = patterns('djapp.gpadmin.views',
(r'^admin/(.*)', admin.site.root),
(r'^/', include('djapp.myapp.urls')),
)

# myapp
urlpatterns = patterns('djapp.myapp.views',
(r'^$', 'main'),
# Customers
(r'^customer/$', 'customer_list'),
-- snip --

urlpatterns += patterns('',
(r'^admin/doc/', include('django.contrib.admindocs.urls')),
(r'^admin/(.*)', admin.site.root),
)

Does this 'level' of admin access (when in a app instead of a project) shield 
of the models of the other apps? Looks like something I want to test for 
security reasons. Or does one put an app behind a different (for instance) 
apache vhost or location directive anyway?

I'll stop with the questions now ... rtfm and all that ... ;-)

Thanx again.

Regards,

Gerard.



> 
> Yours,
> Russ Magee %-)
> 
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: How to stop internal django server

2008-09-28 Thread Alessandro Ronchi
2008/9/28 Hingarajiya,Ravi <[EMAIL PROTECTED]>:
> Hi All,
>
> I am very new in Django Framework.
>
> I want to know how to stop internal server without ctrl+c.
>
> For start command : python manage.py runserver
> What is stop command ?
>
> Ravi Hingarajiya

It's a process, so you can stop it like any other linux process:
killall python
ps aux | grep python  and then kill #numproc
ctrl + c

and so on

-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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



Re: How to stop internal django server

2008-09-28 Thread Alessandro
2008/9/28 Alessandro Ronchi <[EMAIL PROTECTED]>:
> 2008/9/28 Hingarajiya,Ravi <[EMAIL PROTECTED]>:
>> Hi All,
>>
>> I am very new in Django Framework.
>>
>> I want to know how to stop internal server without ctrl+c.
>>
>> For start command : python manage.py runserver
>> What is stop command ?
>>
>> Ravi Hingarajiya

It's a process, so you can stop it like any other linux process:
killall python
ps aux | grep python  and then kill #numproc
ctrl + c

and so on


-- 
Alessandro Ronchi
Skype: aronchi
http://www.alessandroronchi.net

SOASI Soc.Coop. - www.soasi.com
Sviluppo Software e Sistemi Open Source
Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
Tel.: +39 0543 798985 - Fax: +39 0543 579928

Rispetta l'ambiente: se non ti è necessario, non stampare questa mail

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



Re: faking a cron job

2008-09-28 Thread Jeff Anderson
Julian wrote:
> hi there,
>
> i have written a middleware-class wich is doing what a cronjob should
> do. it is doing some backup-stuff, and repeats that every 12 hours. it
> is a thread and is placed in the list of middleware-classes, but not
> processing any request or overwriting any typical method for a
> middleware class.
>
> my problem is: with the devlopment-server it's created once. with
> mod_python and _three_ apache instances, there are three instances of
> my backup-thread, but i want to have only one.
>
> how can i start a thread (without having an extra cronjob) in my
> django-app only once on the whole server??? the hackish solution would
> be to store the actual PID on a special place.
>   
Doing a cronjob's job in a middleware-spawned thread is hackish to begin
with-- storing a PID is the best way to do what you want done given your
constraints.

Another implementation you might consider, is to create a view that
executes the backup job when called. Do a check when it is called to see
if it's been at least twelve hours. Set up a cronjob on your local
machine that uses curl or wget to make a request that executes the
backup job. The check to see if its been at least twelve hours would
prevent the job from being abused if someone finds it. If you want to
hide it, make a view that starts the backup job, and then raises a 404--
the code will still get through, but anyone that visits the URL would
have no way of knowing that it was doing something.

If a cronjob is really what fits the bill, consider switching your
hosting provider or plan to something that includes cronjobs-- its worth
it to not be hackish. :)


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: streaming file uploads not working with Django 1.0

2008-09-28 Thread Faheem Mitha

On Sat, 27 Sep 2008 01:56:53 -0400 (EDT), Faheem Mitha
<[EMAIL PROTECTED]> wrote:

> Hi,
>
> I just upgraded to Django 1.0, and I've just finished fixing all my unit 
> tests. However, streaming file uploads are still broken. The behaviour I'm 
> seeing is as follows:
>
> When I start the upload of the file, a file which looks like eg. 
> /tmp/tmpGjWpee.upload appears almost immediately, but does not change in 
> size thereafter. The size is either empty or 16M. I haven't seen any other 
> values appear. The file upload completes some of the time, regardless, but 
> is very slow. For very large files, like 1g, it took so long I stopped it.
>
> A model I'm using for testing purposes appears below.
>
> I've seen this behavior on two independent installations of 1.0, with the 
> same project/application. I have a different installation with a pre-1.0 
> snapshot with a patch from #2070 applied, and that works fine with an 
> earlier version of the same model/application, with the temporary file in 
> /tmp appearing and growing in size as the upload progresses, as expected.
>
> Suggestions for debugging would be appreciated. Please CC me on any reply. 

I've now created an issue for this, including a test
case. http://code.djangoproject.com/ticket/9232
Faheem.


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



Re: faking a cron job

2008-09-28 Thread Julian

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



Re: How to stop internal django server

2008-09-28 Thread Jeff Anderson
Hingarajiya,Ravi wrote:
> Hi Alessandro,
>  
>Thanks for your reply.I know kill command.
>   
>   But  we are developing IDE for Django. So We want to know that how
> to stop internal server using any command (example : /etc/init.d/httpd
> stop in apache web server ).
/etc/init.d/httpd stop is just a wrapper script that uses the kill
command. You need to do the same thing to kill any process. ctrl+c sends
signal 2 to the running process. kill  is exactly what you need to use.

Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: Add error to form field

2008-09-28 Thread Karen Tracey
On Sun, Sep 28, 2008 at 2:35 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:

>
> Hi all,
>
> Can I in any way add an error to a form field?
> I have a controller method (in views.py) which needs information from
> the session and information from the form (a CharField) to validate
> some logic. If this fails, I want to add an error to the form field
> saying its value is invalid, but can I do this? Ive tried accessing
> form._errors['field_name'] = [u'Invalid'] and such, but its doesnt
> really seem like an ideal solution..  Anyone?
>

Why does it not seem like an ideal solution?  Does it not work?  Every time
this question has come up (how to set an error on a field outside of raising
ValidationError in a clean method) the answer has been "access _errors
directly".  (Yes, if this is the recommended approach then perhaps it should
be documented better...I think there's a ticket open on that somewhere.)
Anyway, the broad approach you are using is what has been recommended in the
past.  I cannot tell from what you have said if there is some detail in what
you are doing that is making it not work or if you just don't like something
about it.

Karen

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



Re: How to stop internal django server

2008-09-28 Thread Hingarajiya,Ravi
Jeff :

  Thanks for reply.

Ravi Hingarajiya

On Sun, Sep 28, 2008 at 2:41 PM, Jeff Anderson <[EMAIL PROTECTED]>wrote:

> Hingarajiya,Ravi wrote:
> > Hi Alessandro,
> >
> >Thanks for your reply.I know kill command.
> >
> >   But  we are developing IDE for Django. So We want to know that how
> > to stop internal server using any command (example : /etc/init.d/httpd
> > stop in apache web server ).
> /etc/init.d/httpd stop is just a wrapper script that uses the kill
> command. You need to do the same thing to kill any process. ctrl+c sends
> signal 2 to the running process. kill  is exactly what you need to
> use.
>
> Jeff Anderson
>
>

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



Re: How to stop internal django server

2008-09-28 Thread Hingarajiya,Ravi
Hi Alessandro,

   Thanks for your reply.I know kill command.

  But  we are developing IDE for Django. So We want to know that how to stop
internal server using any command (example : /etc/init.d/httpd stop in
apache web server ).

Ravi Hingarajiya.



On Sun, Sep 28, 2008 at 1:25 PM, Alessandro Ronchi <
[EMAIL PROTECTED]> wrote:

> 2008/9/28 Hingarajiya,Ravi <[EMAIL PROTECTED]>:
> > Hi All,
> >
> > I am very new in Django Framework.
> >
> > I want to know how to stop internal server without ctrl+c.
> >
> > For start command : python manage.py runserver
> > What is stop command ?
> >
> > Ravi Hingarajiya
>
> It's a process, so you can stop it like any other linux process:
> killall python
> ps aux | grep python  and then kill #numproc
> ctrl + c
>
> and so on
>
> --
> Alessandro Ronchi
> Skype: aronchi
> http://www.alessandroronchi.net
>
> SOASI Soc.Coop. - www.soasi.com
> Sviluppo Software e Sistemi Open Source
> Sede: Via Poggiali 2/bis, 47100 Forlì (FC)
> Tel.: +39 0543 798985 - Fax: +39 0543 579928
>
> Rispetta l'ambiente: se non ti è necessario, non stampare questa mail
>
> >
>

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



Re: Q - returning a data to the template. (many models).

2008-09-28 Thread Tom MacKenzie
If anyone could have a look it would be much appreciated.

-Tom

On Sat, Sep 27, 2008 at 6:40 PM, Tom MacKenzie <[EMAIL PROTECTED]>wrote:

> http://django.pastebin.com/d1c579dbf
>
> Thanks!
>
>
> On Sat, Sep 27, 2008 at 5:48 PM, Ovnicraft <[EMAIL PROTECTED]> wrote:
>
>> is posible use pastebin? http://django.pastebin.com/
>>
>> 2008/9/27 [EMAIL PROTECTED] <[EMAIL PROTECTED]>
>>
>>>
>>> my view is below.
>>> 
>>> 
>>> 
>>>Search{% if query %} Results{% endif %}
>>> 
>>> 
>>>  Search
>>>  
>>>Search: 
>>>
>>>
>>>  
>>>
>>>  {% if query %}
>>>Results for "{{ query|escape }}":
>>>
>>>{% if results %}
>>>  
>>>  {% for company in results %}
>>>{{ company|escape }}
>>>  {% endfor %}
>>>  
>>>{% else %}
>>>  No companys found
>>>{% endif %}
>>>  {% endif %}
>>> 
>>> 
>>>
>>>
>>>
>>> On Sep 27, 4:45 pm, "[EMAIL PROTECTED]"
>>>
>>> <[EMAIL PROTECTED]> wrote:
>>> > I have a company model which relates to a product model 1-> M.
>>> >
>>> > My goal is to search both models and return a result set set that will
>>> > show the company name and product name that are results of the query.
>>> > The implementation below only shows the company name.
>>> >
>>> > 1. Can I send back the product as well?
>>> > 2. Should I call a function from the template to retrieve the product?
>>> >
>>> > any help appreciated!
>>> >
>>> > my models are:
>>> > class Product(models.Model):
>>> >   co   = models.ForeignKey(Company)
>>> >   key  = models.ForeignKey(Keyword)
>>> >   name = models.CharField(max_length=100)
>>> >   pub_date = models.DateTimeField(default=datetime.datetime.now())
>>> >
>>> >   def __unicode__(self):
>>> > return self.name
>>> >
>>> > class Product(models.Model):
>>> >   co   = models.ForeignKey(Company)
>>> >   key  = models.ForeignKey(Keyword)
>>> >   name = models.CharField(max_length=100)
>>> >   pub_date = models.DateTimeField(default=datetime.datetime.now())
>>> >
>>> >   def __unicode__(self):
>>> > return self.name
>>> >
>>> > My view is...
>>> >
>>> > from django.db.models import Q
>>> > from django.shortcuts import render_to_response
>>> > from models import Company
>>> >
>>> > def search(request):
>>> > query = request.GET.get('q', '')
>>> > if query:
>>> > qset = (
>>> > Q(name__icontains=query) |
>>> > Q(url__icontains=query) |
>>> > Q(product__name__icontains=query) |
>>> > Q(product__key__name__icontains=query)
>>> > )
>>> > results = Company.objects.filter(qset).distinct()
>>> > else:
>>> > results = []
>>> > return render_to_response("foods/search.html", {
>>> > "results": results,
>>> > "query": query
>>> > })
>>> >
>>> > My template is...
>>> > from django.db.models import Q
>>> > from django.shortcuts import render_to_response
>>> > from models import Company
>>> >
>>> > def search(request):
>>> > query = request.GET.get('q', '')
>>> > if query:
>>> > qset = (
>>> > Q(name__icontains=query) |
>>> > Q(url__icontains=query) |
>>> > Q(product__name__icontains=query) |
>>> > Q(product__key__name__icontains=query)
>>> > )
>>> > results = Company.objects.filter(qset).distinct()
>>> > else:
>>> > results = []
>>> > return render_to_response("foods/search.html", {
>>> > "results": results,
>>> > "query": query
>>> > })
>>>
>>>
>>
>>
>> --
>> [b]question = (to) ? be : !be; .[/b]
>>
>> >>
>>
>

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



Re: Q - returning a data to the template. (many models).

2008-09-28 Thread Erik Allik
Since a Company could have multiple Products, it's not really possible  
to show the product as well with the way you do the querying.

I would instead do a search on the Product model and then simply  
iterate over the resulting products displaying the company for each of  
them, too:

def search(request):
   q = request.GET.get('q', '')
   if q:
 qset = (
   Q(co__name__icontains=q) |
   Q(co__url__icontains=q) |
   Q(name__icontains=q) |
   Q(key__name__icontains=q)
 )
 results = Product.objects.filter(qset).distinct()
   else:
 results = []
   return render_to_response(...)

In the template:
{% for product in results %}
   Product: {{ product }}, company: {{ product.co }}
{% endfor %}

As a sidenote, I'd use readable column names such as "company" instead  
of "co". If you need to map to a legacy database which has "co_id" as  
the name of the column, simply do:

company = models.ForeignKey(Company, dbcolumn='co_id')

Erik

On 29.09.2008, at 1:29, Tom MacKenzie wrote:

> If anyone could have a look it would be much appreciated.
>
> -Tom
>
> On Sat, Sep 27, 2008 at 6:40 PM, Tom MacKenzie <[EMAIL PROTECTED] 
> > wrote:
> http://django.pastebin.com/d1c579dbf
>
> Thanks!
>
>
> On Sat, Sep 27, 2008 at 5:48 PM, Ovnicraft <[EMAIL PROTECTED]>  
> wrote:
> is posible use pastebin? http://django.pastebin.com/
>
> 2008/9/27 [EMAIL PROTECTED] <[EMAIL PROTECTED]>
>
> my view is below.
> 
> 
> 
>Search{% if query %} Results{% endif %}
> 
> 
>  Search
>  
>Search: 
>
>
>  
>
>  {% if query %}
>Results for "{{ query|escape }}":
>
>{% if results %}
>  
>  {% for company in results %}
>{{ company|escape }}
>  {% endfor %}
>  
>{% else %}
>  No companys found
>{% endif %}
>  {% endif %}
> 
> 
>
>
>
> On Sep 27, 4:45 pm, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > I have a company model which relates to a product model 1-> M.
> >
> > My goal is to search both models and return a result set set that  
> will
> > show the company name and product name that are results of the  
> query.
> > The implementation below only shows the company name.
> >
> > 1. Can I send back the product as well?
> > 2. Should I call a function from the template to retrieve the  
> product?
> >
> > any help appreciated!
> >
> > my models are:
> > class Product(models.Model):
> >   co   = models.ForeignKey(Company)
> >   key  = models.ForeignKey(Keyword)
> >   name = models.CharField(max_length=100)
> >   pub_date = models.DateTimeField(default=datetime.datetime.now())
> >
> >   def __unicode__(self):
> > return self.name
> >
> > class Product(models.Model):
> >   co   = models.ForeignKey(Company)
> >   key  = models.ForeignKey(Keyword)
> >   name = models.CharField(max_length=100)
> >   pub_date = models.DateTimeField(default=datetime.datetime.now())
> >
> >   def __unicode__(self):
> > return self.name
> >
> > My view is...
> >
> > from django.db.models import Q
> > from django.shortcuts import render_to_response
> > from models import Company
> >
> > def search(request):
> > query = request.GET.get('q', '')
> > if query:
> > qset = (
> > Q(name__icontains=query) |
> > Q(url__icontains=query) |
> > Q(product__name__icontains=query) |
> > Q(product__key__name__icontains=query)
> > )
> > results = Company.objects.filter(qset).distinct()
> > else:
> > results = []
> > return render_to_response("foods/search.html", {
> > "results": results,
> > "query": query
> > })
> >
> > My template is...
> > from django.db.models import Q
> > from django.shortcuts import render_to_response
> > from models import Company
> >
> > def search(request):
> > query = request.GET.get('q', '')
> > if query:
> > qset = (
> > Q(name__icontains=query) |
> > Q(url__icontains=query) |
> > Q(product__name__icontains=query) |
> > Q(product__key__name__icontains=query)
> > )
> > results = Company.objects.filter(qset).distinct()
> > else:
> > results = []
> > return render_to_response("foods/search.html", {
> > "results": results,
> > "query": query
> > })
>
>
>
>
> -- 
> [b]question = (to) ? be : !be; .[/b]
>
>
>
>
>
> >


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



trunk or 1.0?

2008-09-28 Thread chiggsy

Just wondering if trunk is still stable?  I've been using 1.0 and was
debating switching back to trunk. What is the best practice?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trunk or 1.0?

2008-09-28 Thread Ovnicraft
2008/9/28 chiggsy <[EMAIL PROTECTED]>

>
> Just wondering if trunk is still stable?  I've been using 1.0 and was
> debating switching back to trunk. What is the best practice?

1.0 is stable

>
> >
>


-- 
[b]question = (to) ? be : !be; .[/b]

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



Re: trunk or 1.0?

2008-09-28 Thread chiggsy

thanks.

On Sep 28, 7:28 pm, Ovnicraft <[EMAIL PROTECTED]> wrote:
> 2008/9/28 chiggsy <[EMAIL PROTECTED]>
>
>
>
> > Just wondering if trunk is still stable?  I've been using 1.0 and was
> > debating switching back to trunk. What is the best practice?
>
> 1.0 is stable
>
>
>
> --
> [b]question = (to) ? be : !be; .[/b]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: trunk or 1.0?

2008-09-28 Thread Russell Keith-Magee

On Mon, Sep 29, 2008 at 7:27 AM, chiggsy <[EMAIL PROTECTED]> wrote:
>
> Just wondering if trunk is still stable?  I've been using 1.0 and was
> debating switching back to trunk. What is the best practice?

Best practice depends on your requirements. Our intention is to keep
trunk as stable as it has been historically. This means you won't see
any massive breakages, and since v1.0 has been released, you shouldn't
see less backwards incompatibility issues as well.

However, the trunk is where new feature development will occur, so
there will inevitably be some periods of instability when new features
land. We will aim to keep these instabilities to a minimum, but if
you're relying upon stability for your project, it's worth keeping
taking into consideration.

The v1.0 release (and the v1.0 branch that will be created in the near
future) will be rock solid. Nothing will go into that branch except
bug fixes. If you can hold off on adopting new features, using v1.0
will be your safest bet.

Yours,
Russ Magee %-)

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



Filtering a queryset with arrays of IDs

2008-09-28 Thread Brandon Taylor

Hi everyone,

I have a search form where I have multi-selects that contain foreign
key values. When I post to my results page, I get a QueryDict object
and can get the data out of the post into lists.

My question is, what's the best way to go about filtering objects
where the foreign keys are arrays (the lists from the post)? I know
the raw SQL syntax, but how can this be accomplished using Django's
ORM?

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



Re: admin.site.register breaks unittests

2008-09-28 Thread Malcolm Tredinnick


On Sun, 2008-09-28 at 21:25 +0200, Gerard Petersen wrote:
> Russel,
> 
> Replies inline ...
> 
> > The purpose of admin.autodiscover is to discover all the admin.py
> > files in your project. Each admin.py file will then need to contain
> > the ModelAdmin definitions and site.register() calls required.
> Ok, so the autodiscover is a recursive functionality that gathers all (admin 
> registered) models from all apps in a project?

All that autodiscover() does is look in the admin module for each of
your applications and imports it. Which has the effect of executing the
register() calls. So autodiscover() saves you from having to manually
import the admin module for each app independently. Nothing more,
nothing less. It doesn't go hunting around looking in every possible
place. Only in admin.py.

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



apache PythonPath problem + solution

2008-09-28 Thread felix


Hello,
I wrote up this big problem to ask you kind folx for help, and in the
course of that I figured it out.
But I'm still going to post it just to share the experience.

I have an apache config problem, maybe someone can help.

I am setting up the production version on my site :

apache conf


PythonPath "['/home/crucial/gitpo/djapps','/home/crucial/gitpo/
pluggables','/home/crucial/gitpo/sustain'] + sys.path"

Order allow,deny
Allow from all
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
PythonOption django.root /sustain/
PythonDebug On

PythonAutoReload On




the files:

/home/crucial/gitpo/sustain
settings_sus_live.py
urls.py
etc. ...

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


The python path appears to be correct, right ? (hint ... no )


But if I change:
SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
to
SetEnv DJANGO_SETTINGS_MODULE settings_sus_live

django will run !

but then it fails (with that soothing django exception display):

No module named sustain.urls

it does show that the python path is correct:

Python Path: ['/home/crucial/gitpo/djapps', '/home/crucial/gitpo/
pluggables', '/home/crucial/gitpo/sustain', etc

The solution is that '/home/crucial/gitpo/sustain' is not the
immediate PARENT of the sustain module, it IS the sustain module

'/home/crucial/gitpo/' is the correct path to add.  that's the
immediate parent folder of the module.


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



Re: apache PythonPath problem + solution

2008-09-28 Thread Graham Dumpleton

Your solution was what the documentation tells you to do.

I still contend that the documentation could better explain this, but
when I pushed that in the past others felt it was clear enough
already. Despite that, people still have problems, that or people
don't actually read the documentation. :-)

Graham

On Sep 29, 10:39 am, felix <[EMAIL PROTECTED]> wrote:
> Hello,
> I wrote up this big problem to ask you kind folx for help, and in the
> course of that I figured it out.
> But I'm still going to post it just to share the experience.
>
> I have an apache config problem, maybe someone can help.
>
> I am setting up the production version on my site :
>
> apache conf
>
> 
>     PythonPath "['/home/crucial/gitpo/djapps','/home/crucial/gitpo/
> pluggables','/home/crucial/gitpo/sustain'] + sys.path"
>
>     Order allow,deny
>     Allow from all
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
>     PythonOption django.root /sustain/
>     PythonDebug On
>
>     PythonAutoReload On
>
> 
>
> the files:
>
> /home/crucial/gitpo/sustain
>         settings_sus_live.py
>         urls.py
>         etc. ...
>
> This gives :
> ImportError: Could not import settings 'sustain.settings_sus_live' (Is
> it on sys.path? Does it have syntax errors?): No module named
> sustain.settings_sus_live
>
> The python path appears to be correct, right ? (hint ... no )
>
> But if I change:
>     SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
> to
>     SetEnv DJANGO_SETTINGS_MODULE settings_sus_live
>
> django will run !
>
> but then it fails (with that soothing django exception display):
>
> No module named sustain.urls
>
> it does show that the python path is correct:
>
> Python Path: ['/home/crucial/gitpo/djapps', '/home/crucial/gitpo/
> pluggables', '/home/crucial/gitpo/sustain', etc
>
> The solution is that '/home/crucial/gitpo/sustain' is not the
> immediate PARENT of the sustain module, it IS the sustain module
>
> '/home/crucial/gitpo/' is the correct path to add.  that's the
> immediate parent folder of the module.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unable to resolve URL in template

2008-09-28 Thread Chuck22

Anyone has any clue? The problem has not been resolved yet. Any
referrence are welcome. Thanks.

chuck

On Sep 27, 2:21 pm, Chuck Bai <[EMAIL PROTECTED]> wrote:
> In my url.py, I define the root my site is like this:
> urlpatterns = patterns('',
>     url(r'^$', 'views.index', name="index"),
>     ...)
>
> in my template, I have a link defined as follows:
> Home
>
> I got this error:
>
>   TemplateSyntaxError at /
>
> Home
>
> Caught an exception while rendering: Reverse for 'testproject.index' with 
> arguments '()' and keyword arguments '{}' not found.
>
> It seems that Django can not resolve the URL index. Can anyone point to
> me what is wrong and how to fix 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: unable to resolve URL in template

2008-09-28 Thread Malcolm Tredinnick


On Sun, 2008-09-28 at 17:54 -0700, Chuck22 wrote:
> Anyone has any clue? The problem has not been resolved yet. Any
> referrence are welcome. Thanks.

I tried to repeat the problem from the information you provided, but I
couldn't do so. Do you have a small complete example that reliably
replicates the problem (I'm thinking of something like one url pattern
in a file and a view or something like that)? You should certainly be
trying to trim down your situation to a single pattern and single view
in any case to rule out an side-effects. At that point we'll have
something we can debug.

Every variation on the theme you've indicated has reliably reversed the
URL for me.

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



Re: Filtering a queryset with arrays of IDs

2008-09-28 Thread Malcolm Tredinnick


On Sun, 2008-09-28 at 17:15 -0700, Brandon Taylor wrote:
> Hi everyone,
> 
> I have a search form where I have multi-selects that contain foreign
> key values. When I post to my results page, I get a QueryDict object
> and can get the data out of the post into lists.
> 
> My question is, what's the best way to go about filtering objects
> where the foreign keys are arrays (the lists from the post)? I know
> the raw SQL syntax, but how can this be accomplished using Django's
> ORM?

This is probably one of those cases where a small example of the type of
model you have would probably make things clearer, since I'm going to
have to guess a bit here. But, basically, if you have a list of ids

status_ids = [1, 2, 3, 4]

and you want to find all the entries that have relations to those, say
an Entry model with a ForeignKey to Status, you could write

Entry.objects.filter(status__in=status_ids)

If that's not at all what you're after, please post a short example
model that has a few more details about what data you have and what data
you're seeking. Emphasis on short -- trim down you real-world situation
to just the pertinent bits.

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



Integrating into PHP-based site...

2008-09-28 Thread megrez80

Hello,
I'm currently prototyping a web application using Django which
must be integrated into an existing PHP-based site. Can anyone comment
on, or provider a pointer to documentation for, the issues involved.
In particularly, how to go about inheriting the existing look-and-
feel.

Thanks.

Ken


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



Best way to preserve a queryset across GETs?

2008-09-28 Thread Brandon Taylor

Hi everyone,

I have a search results page and need to be able to go to a detail
page for any result. I would like to provide the user a way to return
to their search results and not clutter the querystring with search
parameters.

What's the best approach for this using Django? Should I stuff the
queryset into a session?

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



Re: apache PythonPath problem + solution

2008-09-28 Thread felix


well yes, I have to admit that I've been doing quite a bit of django
and I hadn't yet realized that it must always be the direct parent.

but in this case I was kind of just staring at the problem and not
seeing it.

and I think my dev environment python path is too loose or something.
now that its ready to be deployed I'm getting all kinds of differences
in the way modules are resolved.

I would have to say these issues have been the largest time wasters
for me.

when you get a 404  you then see a very helpful display of all the url
patterns.

maybe when a module fails to be found it could print a tree of
reachable modules.
(could be a lot)
you would have to isolate it to an area of interest.

say urls.py fails to resolve,
so since it only has one level, list out all top level modules
then I would have seen each of my djapps, each of my pluggables, but
would have noticed that all the files in the root level of my website
were missing and only the next level down were visible.



On Sep 29, 2:44 am, Graham Dumpleton <[EMAIL PROTECTED]>
wrote:
> Your solution was what the documentation tells you to do.
>
> I still contend that the documentation could better explain this, but
> when I pushed that in the past others felt it was clear enough
> already. Despite that, people still have problems, that or people
> don't actually read the documentation. :-)
>
> Graham
>
> On Sep 29, 10:39 am, felix <[EMAIL PROTECTED]> wrote:
>
> > Hello,
> > I wrote up this big problem to ask you kind folx for help, and in the
> > course of that I figured it out.
> > But I'm still going to post it just to share the experience.
>
> > I have an apache config problem, maybe someone can help.
>
> > I am setting up the production version on my site :
>
> > apache conf
>
> > 
> >     PythonPath "['/home/crucial/gitpo/djapps','/home/crucial/gitpo/
> > pluggables','/home/crucial/gitpo/sustain'] + sys.path"
>
> >     Order allow,deny
> >     Allow from all
> >     SetHandler python-program
> >     PythonHandler django.core.handlers.modpython
> >     SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
> >     PythonOption django.root /sustain/
> >     PythonDebug On
>
> >     PythonAutoReload On
>
> > 
>
> > the files:
>
> > /home/crucial/gitpo/sustain
> >         settings_sus_live.py
> >         urls.py
> >         etc. ...
>
> > This gives :
> > ImportError: Could not import settings 'sustain.settings_sus_live' (Is
> > it on sys.path? Does it have syntax errors?): No module named
> > sustain.settings_sus_live
>
> > The python path appears to be correct, right ? (hint ... no )
>
> > But if I change:
> >     SetEnv DJANGO_SETTINGS_MODULE sustain.settings_sus_live
> > to
> >     SetEnv DJANGO_SETTINGS_MODULE settings_sus_live
>
> > django will run !
>
> > but then it fails (with that soothing django exception display):
>
> > No module named sustain.urls
>
> > it does show that the python path is correct:
>
> > Python Path: ['/home/crucial/gitpo/djapps', '/home/crucial/gitpo/
> > pluggables', '/home/crucial/gitpo/sustain', etc
>
> > The solution is that '/home/crucial/gitpo/sustain' is not the
> > immediate PARENT of the sustain module, it IS the sustain module
>
> > '/home/crucial/gitpo/' is the correct path to add.  that's the
> > immediate parent folder of the module.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Integrating into PHP-based site...

2008-09-28 Thread Jeff Anderson
megrez80 wrote:
> Hello,
> I'm currently prototyping a web application using Django which
> must be integrated into an existing PHP-based site. Can anyone comment
> on, or provider a pointer to documentation for, the issues involved.
> In particularly, how to go about inheriting the existing look-and-
> feel.
>   
The look and feel will be the easiest part-- you just need to take the
HTML generated by your PHP app, and repurpose it as a Django template.
This shouldn't take long.

Things like changing a menu bar that need to be common between the PHP
and the Django side would probably need to be maintained and updated in
tandem.

You'll probably run into issues other than the look and feel, but there
is no reason that you can't have both Django and PHP running on one server.

If you need to have both Django and PHP access the same database, you
can do that. Look in the Django documentation for "legacy db" stuff to
get Django working with your existing tables.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: unable to resolve URL in template

2008-09-28 Thread felix

is it actually called url.py or urls.py ?

maybe you don't have the urls file in there that you are assuming you
do.

try inserting an egregious syntax error in there just to see if its
even being loaded.


On Sep 27, 8:21 pm, Chuck Bai <[EMAIL PROTECTED]> wrote:
> In my url.py, I define the root my site is like this:
> urlpatterns = patterns('',
>     url(r'^$', 'views.index', name="index"),
>     ...)
>
> in my template, I have a link defined as follows:
> Home
>
> I got this error:
>
>   TemplateSyntaxError at /
>
> Home
>
> Caught an exception while rendering: Reverse for 'testproject.index' with 
> arguments '()' and keyword arguments '{}' not found.
>
> It seems that Django can not resolve the URL index. Can anyone point to
> me what is wrong and how to fix 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django developer need ASAP

2008-09-28 Thread James Matthews
You may also want to post this on djangogigs.com.

Good Luck

James

On Sun, Sep 28, 2008 at 9:38 AM, KnoxvilleDjangoDev <[EMAIL PROTECTED]> wrote:

>
> Apologies if I am not asking this question correctly, but i need some
> assistance. I have a site that was developed in Django and bottom
> line, my developer is nowhere to be found at the last minute. So, I am
> looking for a Django developer that can crank out some last minute
> tweaks in the code, migrate the site over to our server and post it
> live in an emergency time frame. Pay will be strong.
>
> If you can get this done and you are in the Knoxville, TN area Sunday,
> September 28th, send me an email to:
>
> [EMAIL PROTECTED]
>
> Again, my apologies if I went outside the norm on this, but I need the
> help.
>
> Thanks.
>
> >
>


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



blank vs. exclude

2008-09-28 Thread johnny

I have a question about the exclude property in ModelForm.  When I
have a Model and the ModelForm for it excludes a field from that
Model, shouldn't the ModelForm validation excludes that field as well?

It seems the only way to exclude the field from validation is to make
it blank=True in the Model.  However,
to me, the blank=True/False on Model seems to be in the wrong place.
The model is suppose to define the model, and blank defines the form
validation, so I don't believe it's in the right place and thus like
not to set it there and like to use exclude=('field1', etc.) instead
in the ModelForm level.  But that doesn't seem to work and complain
that the excluded fields are required..

An example of this is a timestamp.  The model defines a timestamp
field but the ModelForm for it should exclude the field since it needs
to be auto-generated.  When the field is excluded from the ModelForm,
it should be excluded from the form validation as well, but it doesn't
and requires me to set blank=True in the Model instead, which again
seems wrong to me since the Model should have nothing to do with form
validation.

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



relating auth user to company model

2008-09-28 Thread MilesTogoe

I've seen the docs on how to relate the user with a 1-1 relationship (ie 
profile) but is there a way to have another model relate in a 1:many  
(ie one company with many users) - this would require user to have a 
company 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Incorrect string value in Admin

2008-09-28 Thread Bo Gu
Hi,
I was testing fill some chinese strings to the text field in the Django
admin page, and I got the Incorrect string value Error. I tried two models
which are defined in my app, and the strange thing is that the "for column"
fields are different in these two errors, one is 'change_message' and the
other is 'object_repr' neither is defined in my models. I defined
__unicode__ and did not define __str__ in my models. The mysql tables'
charsets are utf-8, and I did not define DEFAULT_CHARSET in my settings.py
file thus it should be utf-8 too. I can successfully save the no-ascii
strings  in manage.py shell !!!

   What on earth caused this? And how could I save the non-ascii strings?

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



Re: blank vs. exclude

2008-09-28 Thread Gerard Petersen

John,

Looking at your exclude syntax, that might be the problem. This would be the 
correct code (assuming modelform is used):

class OrderForm(ModelForm):
class Meta:
model = Order
exclude = ['number', 'state', 'state_since']

nb: The excluded fields have no null/blank/editable options set in the model 
itself.

Regards,

Gerard.

johnny wrote:
> I have a question about the exclude property in ModelForm.  When I
> have a Model and the ModelForm for it excludes a field from that
> Model, shouldn't the ModelForm validation excludes that field as well?
> 
> It seems the only way to exclude the field from validation is to make
> it blank=True in the Model.  However,
> to me, the blank=True/False on Model seems to be in the wrong place.
> The model is suppose to define the model, and blank defines the form
> validation, so I don't believe it's in the right place and thus like
> not to set it there and like to use exclude=('field1', etc.) instead
> in the ModelForm level.  But that doesn't seem to work and complain
> that the excluded fields are required..
> 
> An example of this is a timestamp.  The model defines a timestamp
> field but the ModelForm for it should exclude the field since it needs
> to be auto-generated.  When the field is excluded from the ModelForm,
> it should be excluded from the form validation as well, but it doesn't
> and requires me to set blank=True in the Model instead, which again
> seems wrong to me since the Model should have nothing to do with form
> validation.
> 
> thoughts?
> john
> > 

-- 
urls = { 'fun':  'www.zonderbroodje.nl',  'tech':  'www.gp-net.nl' }


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



Re: Add error to form field

2008-09-28 Thread [EMAIL PROTECTED]

Hi Karen,

Thank you for your answer, but when i access the _errors att in a
controller methods, and
adds a new array containing a unicode string, it is not rendered like
the other error messages.
I see an output like

[u'Stuff happened']

where I put {{ form.field.errors }} in my template. I expected it to
be rendered as a normal error message (ul, li)

What am I doing wrong?

Regards, Lars Borup Jensen


On 28 Sep., 23:44, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Sun, Sep 28, 2008 at 2:35 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:
>
>
>
> > Hi all,
>
> > Can I in any way add an error to a form field?
> > I have a controller method (in views.py) which needs information from
> > the session and information from the form (a CharField) to validate
> > some logic. If this fails, I want to add an error to the form field
> > saying its value is invalid, but can I do this? Ive tried accessing
> > form._errors['field_name'] = [u'Invalid'] and such, but its doesnt
> > really seem like an ideal solution..  Anyone?
>
> Why does it not seem like an ideal solution?  Does it not work?  Every time
> this question has come up (how to set an error on a field outside of raising
> ValidationError in a clean method) the answer has been "access _errors
> directly".  (Yes, if this is the recommended approach then perhaps it should
> be documented better...I think there's a ticket open on that somewhere.)
> Anyway, the broad approach you are using is what has been recommended in the
> past.  I cannot tell from what you have said if there is some detail in what
> you are doing that is making it not work or if you just don't like something
> about it.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to get a magnifier in an image

2008-09-28 Thread Kenneth Gonsalves

hi,
when I open a jpg file directly in firefox, I get a magnifying glass cursor, 
which on clicking gives me a bigger more detailed image. The same file when 
served through the get_photo_url in a django template does not give this - 
how can I achieve this?
-- 
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---