Re: Django-like PHP framework?

2009-01-05 Thread makoto tsuyuki

How about rhaco?

http://translate.google.com/translate?hl=en=UTF-8=http%3A%2F%2Frhaco-users.jp%2F=ja=en_state0=

rhaco has...
* Template Inheritance
* Model based validation
* URLMapper
* admin
* doctest
* Made in Japan...(No english document)

openpear, Japanese Pear Channel, is made with rhaco.
http://translate.google.com/translate?hl=en=UTF-8=http%3A%2F%2Fopenpear.org%2F=ja=en_state0=

On 1月5日, 午後10:31, "thi.l...@gmail.com"  wrote:
> Hi,
>
> I have a hard time getting Django adopted as web framework in the
> office.
> Mostly because the boss paid for PHP-based trainings, and our current
> infrastructure leaves little room for mod_python/wsgi/fastcgi...
>
> I was wondering if some fo you know about competitor PHP frameworks
> that "look like" Django, or at least try to reach that level of
> purity.
>
> Thanks for any comment (and sorry about this unfair request :-P)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Shouldn't blank=True imply null=True?

2009-01-05 Thread Jeff Anderson
Malcolm Tredinnick wrote:
> On Mon, 2009-01-05 at 23:39 -0700, Jeff Anderson wrote:
>   
>> Malcolm Tredinnick wrote:
>> 
>>> The way to think about this problem is whether there's a situation where
>>> blank=True, null=False makes sense or is even possible for non-text
>>> fields and Mike quite possibly has a valid point there: you cannot store
>>> a blank value in a non-NULL integer field, for example.
>>>   
>>>   
>> I was trying to think of a way that a non-NULL "blank" integer would be
>> useful. I can't even think of how it would exist– it just doesn't make
>> sense. This thread may do well on the dev list. I believe that there is
>> a valid point here, and that at least Integer fields (and quite possibly
>> other non-text fields) should behave the way that Mike is describing.
>> 
>
> I don't think we'd want to get too subtle here. Either it makes sense
> for all non-text fields, or it doesn't.
Agreed– I simply haven't spent any time thinking about this particular
problem in respect to any field other than an IntegerField. I can't
think of any non-text field that it may not make sense with.

I have a hunch that a DateField could cause some confusion. Say I'm
going to write a model, and I put in a date field. Is it a number? Is it
a string? If it's a string, I have to explicitly include null=True. The
way that one thinks of a datefield may vary from person to person,
depending on their database experience and expectations. Without
consulting any documentation, I'd be willing to bet that dates are more
like numbers in this respect. I just set blank=True and hope that the
null=True is set. What is a blank date anyway? "-00-00" might count
as a 'blank date', as the month and day are invalid. To be sure, I'd
have to look it up in a table in the documentation. I probably don't
write models often enough to learn this answer and store it in my
long-term memory. I might end up putting both blank=True and null=True
just to be safe, and I've just defeated the purpose of the magic that
we're proposing to put in anyway.

What happens/should happen if I set blank=True and null=False? The
"right answer" will probably vary based on who you ask, and it's one of
those things that you just have to make room for on the Django cheat
sheet and pencil in. Subtle magic is bad.

A counter-argument against changing this behavior is "why are you
setting blank=True on a field that simply can't be blank in the first
place?" On an IntegerField (and friends) it just doesn't make sense, so
it's likely that what I really mean is null=True, so that's what I
should put in. Setting blank=True on an IntegerField doesn't cause any
problems as far as I can tell, so the current behavior isn't at all
destructive. The option is basically ignored. Django generally tries to
stay away from "magic" as a rule of thumb, so leaving the behavior alone
makes sense, and keeps things sweet and simple. It does catch a couple
people off guard occasionally, which prompted this thread.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: Shouldn't blank=True imply null=True?

2009-01-05 Thread Malcolm Tredinnick

On Mon, 2009-01-05 at 23:39 -0700, Jeff Anderson wrote:
> Malcolm Tredinnick wrote:
> > The way to think about this problem is whether there's a situation where
> > blank=True, null=False makes sense or is even possible for non-text
> > fields and Mike quite possibly has a valid point there: you cannot store
> > a blank value in a non-NULL integer field, for example.
> >   
> I was trying to think of a way that a non-NULL "blank" integer would be
> useful. I can't even think of how it would exist– it just doesn't make
> sense. This thread may do well on the dev list. I believe that there is
> a valid point here, and that at least Integer fields (and quite possibly
> other non-text fields) should behave the way that Mike is describing.

I don't think we'd want to get too subtle here. Either it makes sense
for all non-text fields, or it doesn't. We already have null being
special for text-based fields (in the sense that it has no effect), so
this wouldn't be introducing extra cases. But I'd be reluctant to go too
fine-grained and end up with having to check a table in the docs to work
out when blank => null and when it doesn't. That just makes things more
confusing. After all, if we do nothing, it's hardly a tragedy. Fingers
can handle typing null=True every now and again. But if there's a
consistent solution, it'd make sense to use it.

Regards,
Malcolm



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



Re: Shouldn't blank=True imply null=True?

2009-01-05 Thread Jeff Anderson
Malcolm Tredinnick wrote:
> The way to think about this problem is whether there's a situation where
> blank=True, null=False makes sense or is even possible for non-text
> fields and Mike quite possibly has a valid point there: you cannot store
> a blank value in a non-NULL integer field, for example.
>   
I was trying to think of a way that a non-NULL "blank" integer would be
useful. I can't even think of how it would exist– it just doesn't make
sense. This thread may do well on the dev list. I believe that there is
a valid point here, and that at least Integer fields (and quite possibly
other non-text fields) should behave the way that Mike is describing.


Jeff Anderson



signature.asc
Description: OpenPGP digital signature


Re: Access Control Lists implementation for Django?

2009-01-05 Thread Mir Nazim

Thanks guys

Will check out both. And let you know my reactions

On Tue, Jan 6, 2009 at 1:16 AM, bruno desthuilliers
 wrote:
>
> On 5 jan, 10:55, "Mir Nazim"  wrote:
>> Hello Guys
>>
>> I was wondering that is there any 3rd party ACL implementation for
>> django. Django's permission system is a bit limited for the app we are
>> working on.
>> Actually, a per object access control is needed.
>
> There's a granular_permissions app, but it requires a couple patches
> (submitted but not applied so far...) to work correctly with current
> django versions. It could at least get you started.
>
> http://code.google.com/p/django-granular-permissions/
> >
>



-- 
Mir Nazim
Cell: +91 9469071855
Blog: http://saunzal.org
Company:http://www.ikraftsoft.com

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



Django forms usage with mutliple rows

2009-01-05 Thread Kottiyath Nair
Hi,
Since I am a newbie in HTML and Django, there might be a completely
different way to do this. If somebody can point that also, it would be
helpful.

I want to send multiple rows of data from a datagrid to a django server.

Currently, I am doing it in a single form inside a page with the
parameters as array. Please note that this value can change from 1 row to 25
rows.
The example get statement for 3 rows would look like:
../send_multiple_values_through_one_form.html?foo[secret]=my+hidden+value[product-id]=1[secret]=my+hidden+value[product-id]=2[secret]=my+hidden+value[product-id]=3

Now, I want to use Django forms to validate this data.
class UploadQueryForm(forms.Form):
secret = forms.IntegerField()
product_id = forms.CharField(max_length=50)

But this can be used to handle only one row . How can I use this for
multiple rows? Is Django Formsets used for this purpose?
Please note that I am not averse to other ideas - (say multiple forms etc),
but I cannot think of any other way to implement this from HTML perspective
itself.

Regards
K

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



Re: Django-like PHP framework?

2009-01-05 Thread Dave Dash

I did a lot of symfony stuff on the side about a year ago, and now
it's the framework that I we use for our frontend servers at
Delicious.com.  It was through symfony that I found out about Django,
and started using it quite a bit... so I know a bit about the two
frameworks.  Or rather, I know a lot about symfony, but much of that
is being replaced with stuff I'm learning about Django.

As PHP MVC frameworks go, symfony is great.  It borrows from where it
needs to, to give you a good suite of tools.  The direction it is
heading in is also nice.

The new 1.1/1.2 series supports Doctrine which was a lot nicer than
Propel when Iast looked at the two.

The nice thing about using symfony is the developer of symfony uses
Django from time to time, and borrows from it where appropriate.  I'd
wage that you'd see more in common with Django and symfony than any
other PHP framework.

Cheers,

-d

On Jan 5, 5:31 am, "thi.l...@gmail.com"  wrote:
> Hi,
>
> I have a hard time getting Django adopted as web framework in the
> office.
> Mostly because the boss paid for PHP-based trainings, and our current
> infrastructure leaves little room for mod_python/wsgi/fastcgi...
>
> I was wondering if some fo you know about competitor PHP frameworks
> that "look like" Django, or at least try to reach that level of
> purity.
>
> Thanks for any comment (and sorry about this unfair request :-P)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Import models from CSV files?

2009-01-05 Thread Victor Hooi

heya,

This question might seem a bit simple, but what's the best way to
instantiate models from .csv files?

Essentially, I have two .csv files. One contains a list of people, and
their access rights (one-to-many). The second .csv file contains a log
of doorway access (just a bunch of sequential lines). I have a simple
python script which imports these two .csv files, does some processing
(the files are quite messy), creates user and access-entry objects,
and produces a reconciliation with a list of exceptions (basically
door entries which aren't in the list of user/access rights). Each
user is just a dictionary, with their username as key, and a tuple of
dictionary objects for their various access rights.

I would like a simple django project to import these logs, instantiate
models, and then basically manage it via the in-built admin interface,
hopefully saving a lot of time =). (will also need to deal with
duplicates). Is there a smart way to go about doing this project, or
any existing addons I can leverage off?

Thanks,
Victor

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



Re: Shouldn't blank=True imply null=True?

2009-01-05 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 07:58 +0530, Kenneth Gonsalves wrote:
> On Tuesday 06 Jan 2009 12:50:24 am Mike wrote:
> > If the type is not a string, and blank=True is set, shouldn't
> > null=True be implied?
> 
> no - blank=True is enforced at django level whereas null=True is enforced at 
> DB level and blank != null.

That's how things are implemented, not how the behaviour should/could
work.

The way to think about this problem is whether there's a situation where
blank=True, null=False makes sense or is even possible for non-text
fields and Mike quite possibly has a valid point there: you cannot store
a blank value in a non-NULL integer field, for example.

Malcolm


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



Re: Do you recommend "Practical Django Projects"?

2009-01-05 Thread Ben

I recently read both and went thru all the examples in Pracitical
Django Projects.  It was a bit tough at first because some of it is a
little dated, but actually figuring out how to adapt it to 1.0 is
actually a good exercise in itself (learning how to debug and actually
understanding how things work).  I found learned a lot more this way
than if everything went smoothly by coping the examples.

There is also a doc that specifically points out what are backwards
incompatible changes 
http://code.djangoproject.com/wiki/BackwardsIncompatibleChanges

-Ben



On Jan 5, 5:16 pm, "David Zhou"  wrote:
> On Mon, Jan 5, 2009 at 3:57 AM, Kenneth Gonsalves
>
>  wrote:
>
> > On Monday 05 Jan 2009 2:10:34 pm David Zhou wrote:
> >> >> and covers a lot of materials.
> >> >> What do you think?
>
> >> > As the author, I recommend waiting a couple months.
>
> >> Are you planning to update Practical Django Projects to 1.0?
>
> > isnt that obvious from the answer?
>
> Your perpetual grouchiness aside, not in any substantial way.
>
> Will the update be new online errata? Or a brand new printed version?
> Or perhaps a brand new volume?  A vague "wait a couple months" doesn't
> impart any real detail -- hence the further prompting.
>
> Perhaps there is no more detail to give at this stage.
>
> But then, that's not really for you to decide, is it?
>
> ---
> David Zhou
> da...@nodnod.net

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



Re: Shouldn't blank=True imply null=True?

2009-01-05 Thread Kenneth Gonsalves

On Tuesday 06 Jan 2009 12:50:24 am Mike wrote:
> If the type is not a string, and blank=True is set, shouldn't
> null=True be implied?

no - blank=True is enforced at django level whereas null=True is enforced at 
DB level and blank != null.

-- 
regards
KG
http://lawgon.livejournal.com

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



Re: Change name of imagefield files before they are saved

2009-01-05 Thread garagefan

I may be able to offer some assistance here :)

i used the follow bit to create a thumbnail image and changed the name
of the file to include _tn.

def save(self):
super(ImageUpload, self).save()
if self.image:
   tsize = 150,150
   path = settings.MEDIA_ROOT + self.image.name
   img2 = Image.open(path)
   img2.thumbnail(tsize, Image.ANTIALIAS)
   img2.save(self.get_thumbnail_path())

def get_thumbnail_path(self):
path = settings.MEDIA_ROOT + self.image.name
return self.convert_path_to_thumbnail(path)

def convert_path_to_thumbnail(self, path):
basedir = os.path.dirname(path) + '/'
base, ext = os.path.splitext(os.path.basename(path))
th_name = base + "_tn"
th_name += ext
return urlparse.urljoin(basedir,th_name)


On Jan 5, 8:41 pm, geirr  wrote:
> Hello!
>
> I'm trying to make a simple photo album application.
>
> I can't figure out how to change the name of photos that are uploaded
> to something different than the name they have locally on my computer.
> I want to give the files new names, before they are saved. I am using
> the
> ImageField model field for the images.
>
> It looks like I have to override the save function? If this is
> correct, how do
> I do so? Which variable decides the name of the file? Can anyone point
> me in the right direction?
>
> Thanks,
>
> -geir
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Change name of imagefield files before they are saved

2009-01-05 Thread geirr

Hello!

I'm trying to make a simple photo album application.

I can't figure out how to change the name of photos that are uploaded
to something different than the name they have locally on my computer.
I want to give the files new names, before they are saved. I am using
the
ImageField model field for the images.

It looks like I have to override the save function? If this is
correct, how do
I do so? Which variable decides the name of the file? Can anyone point
me in the right direction?

Thanks,

-geir

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



Re: Newb needs help with tracking variables in Templates

2009-01-05 Thread Daniel Roseman

On Jan 5, 5:39 pm, "django_fo...@codechimp.net" 
wrote:
> I have a pretty simple template that needs to print some data in a
> bunch of table rows.  I have done something like this:
>
> 
> {% if my_art_list %}
>         {% count = 0 %}
>         {% for art in my_art_list %}
>                 {% if count%3 = 0 %}
>                 
>                 {% endif %}
>                         
>                                 
>                         
>                 {% if count%3 = 2 %}
>                 
>                 {% endif %}
>         {% endfor %}
>         
> {% else %}
>         You have no art pieces to view.  Would you like to add some?
> {% endif %}
> 
>
> However, as you probably suspect, the "count" variables cause all
> sorts of trouble.  Is there a way to have tracking variables in the
> template code?  I was under the impression that the {%  %} tags were
> just straight Python code and would execute as such, but apparently my
> understanding is a little less than adequate.
>
> Please help me sort this out...

It always helps to actually read the documentation. Especially the bit
which says "the Django template system is not simply Python embedded
into HTML", in the third paragraph of the introduction to templates
here:
http://docs.djangoproject.com/en/dev/topics/templates/

What you probably need is the forloop.counter variables, detailed
here:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ttag-for

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



Re: Newb needs help with tracking variables in Templates

2009-01-05 Thread django_fo...@codechimp.net



On Jan 5, 5:56 pm, bruno desthuilliers 
wrote:
> On 5 jan, 23:39, "django_fo...@codechimp.net" 
> wrote:
>
> > I have a pretty simple template that needs to print some data in a
> > bunch of table rows.  I have done something like this:
>
> > 
> > {% if my_art_list %}
> >         {% count = 0 %}
>
> This just won't work

Obviously...

>
> >         {% for art in my_art_list %}
> >                 {% if count%3 = 0 %}
>
> idem
>
> >                 
> >                 {% endif %}
> >                         
> >                                 
> >                         
> >                 {% if count%3 = 2 %}
>
> idem
>
> >                 
> >                 {% endif %}
> >         {% endfor %}
> >         
> > {% else %}
> >         You have no art pieces to view.  Would you like to add some?
> > {% endif %}
> > 
>
> > However, as you probably suspect, the "count" variables cause all
> > sorts of trouble.
>
> The first one being it's not valid.

Again, figured this out from the variable...

>
> >  Is there a way to have tracking variables in the
> > template code?
>
> Read the documentation for the {% for %} template tag - it sets a
> {{ forloop.counter }} variable.
>
> http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for
>
> You may also want to have a look at the {% cycle %} tag (same page as
> above), and / or be interested in the "partition" filters on
> djangosnippets:http://www.djangosnippets.org/snippets/6/http://www.djangosnippets.org/snippets/401/

Thanks for pointing me to the right place...

>
> > I was under the impression that the {%  %} tags were
> > just straight Python code
>
> I don't know where you got this impression from. Oh, wait : you didn't
> read the doc, did you ?

Read below...

>
> > and would execute as such, but apparently my
> > understanding is a little less than adequate.
>
> I do confirm !-)
>
> > Please help me sort this out...
>
> Well... What about reading the online documentation first ?-)
>
> HTH

First, let me take some Motrin for my very sore rear end.  I have been
reading documentation.  In fact, I started with the tutorials on the
site that walks you through writing the polling application, then
moved on to some docs at http://www.djangobook.com.  It's sometimes
hard to find the one mention of a certain subject when you don't know
what it is you are really looking for.  The page I found on template
blocks, located here http://www.djangobook.com/en/beta/chapter04/,
didn't really tell me much.

I think the biggest problem is that I have some overlap of experience
with JSPs, PHP, and Ruby, all of which use an in-line server side
include tag similar to the one here.  I guess in my reading it just
seemed to make sense that these where server side includes and not
just some template replace thing, but again that just shows my age on
the product.

I do sincerely thank you for helping me get it straight.  I know that
sometimes the newbs ask very dumb questions.  As someone that has had
to deal with them in other languages I know it can be frustrating and
repetitive.  You sometimes have to remember that the skills you have
had to start somewhere, and that you probably made your own stupid
mistakes and got stuck on something just as us who are starting out
have.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Newb needs help with tracking variables in Templates

2009-01-05 Thread django_fo...@codechimp.net

I am very new to Django and Python.  I have been working on a pet
project that has a table of rows.  My thought was to have a counter in
the template, and use modulus to write out the row start/stops out.
The code looks like this:


{% if my_art_list %}
{% count = 0 %}
{% for art in my_art_list %}
{% if count%3 = 0 %}

{% endif %}



{% if count%3 = 2 %}

{% endif %}
{% endfor %}

{% else %}
You have no art pieces to view.  Would you like to add some?
{% endif %}


Unfortunately this does not work.  The problem is with the counter
variables.  I was under the impression the {%  %} tags were just
python code that was executed, but it seems that it is not.  Can
someone point out the errors of my ways and set me on the correct path?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and database views

2009-01-05 Thread drakkan



On 6 Gen, 00:41, drakkan  wrote:
> On 6 Gen, 00:32, Malcolm Tredinnick  wrote:
>
>
>
> > On Mon, 2009-01-05 at 06:31 -0800, drakkan wrote:
> > > however if i delete an user with records associated in the view I have
> > > this error:
>
> > > NotSupportedError: cannot delete from a view
> > > HINT:  You need an unconditional ON DELETE DO INSTEAD rule.
>
> > > django try to delete record from the view and this obviously fails,
>
> > > there is a know workaround for this? any way to declare read only the
> > > model?
>
> > There's no way to say a model is read only. But the solution is easy:
> > don't try to delete anything on it. You are in complete control of your
> > code. It's entirely up to you whether you try to delete or save things
> > on a model, so if it hurts when you do that, just don't do it.
>
> Malcolm, I try to delete an user from the auth_user table; the user is
> referenced as foreign key in the view and the delete cascade django
> default try to delete all the reference,
>
> I need a foreign key like in the view to write code such as:
>
> databaseview.user.username
>
> so I can use select_related and get all needed database object with
> only one query (I use the database view to aggregate some many to many
> tables)
>
> so a possible solution is delete the referenced foreign key from the
> table on which the views is based on and then delete the target object
> (an user object in my example),
>
> however this is error prone, I'm searching a more clean solution such
> as redefine delete() or some hack with custom manager,
>
> thanks
> drakkan
>
>

Ok, I'll try to explain with an example, with user objects I mean
standard django users (django.contrib.auth)


table1:

class table1(models.Model):
field1=
field2=...
user=models.ForeignKey(User)

I have a database view with fileds from table1 and some others
database tables:

class databaseview(models.Model):
  field1table1=
  field1table2=...
  
  user=models.ForeignKey(User)

I defined foreignkey relation in the models mapped to database view
too. This works fine when I access related objects and with
select_related I can load a full graph of object with only one
database query.

Suppose I want to delete an user. This user is in table1 and so in
databaseview too. Django default is to do a delete cascade so it tries
to remove the user from table1, databaseview and auth_user: it fails
when try to remove user from databaseview.

A possible solution would be :

- before issue user.delete(), issue something like
table1.objects.filter(user=u).delete() (this way user reference
disappear from databaseview too) and then u.delete()

however in my application I have several foreign key defined in the
model for the database view so this solution can be error prone, would
be really useful a way to define my mapped view read only or override
the delete cascade for this table,

is this possible with django or I need to find some other solution?

thanks
drakkan

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



Re: Is there an easy way to test ssl protected pages in development server??

2009-01-05 Thread Graham Dumpleton



On Jan 6, 3:02 am, madhav  wrote:
> Is there an easy way to test ssl protected pages in development
> server? Normally I will be doing the testing by accessing the same
> urls with http and not https in dev server. Is this the only way?

You may be better of setting up a instance of Apache with mod_wsgi and
run Django instance in mod_wsgi daemon process. As explained in:

  http://blog.dscpl.com.au/2008/12/using-modwsgi-when-developing-django.html

one can also set things up so code reloads are automatic per
development server. So, a bit more work involved in setup, but an
environment which is then closer to what your production system will
be.

Having that working, then you can properly configure Apache instance
to accept HTTP/HTTPS connections on 80/443 and route them both to the
same Django instance handled by mod_wsgi.

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



Re: Redirect User on First Log In

2009-01-05 Thread Eric Abrahamsen


On Jan 6, 2009, at 6:41 AM, Aruna wrote:

>
> I'm trying to redirect a user on their first log in, to a special
> welcome page. Subsequent logins will go to a regular page. Is there a
> way to do that in the templates? Does Django have a way to check if
> it's a users first login?

User instances have both a last_login and a date_joined attribute.  
Check how these defaults are filled for new users – if last_login  
equals date_joined, you can assume it's their first login. Check all  
the User attributes in the source code, and something will probably  
become evident.

Eric


>
> >


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



Re: File upload failing occasionally

2009-01-05 Thread Karen Tracey
On Mon, Jan 5, 2009 at 5:30 PM, ppdo  wrote:

>
> I tried to monitor the interface using WireShark and the communication
> just hangs during a data transfer: Apache is just acknowledging the
> receipt of some packets and then just seems to hang. The suspicious
> bit is a fairly long series of http RST about 20ms before the server
> hangs. Though I'm not knowledgeable enough on http, to me this clearly
> points in the direction of an Apache problem, though I'm not sure if
> and how it can be solved.
>

I don't know what an http RST is.  Do you mean TCP RST?  You see a long
series of TCP resets?  That would indicate a problem.  Which machine sends
them?  If you put a formatted trace somewhere I could see it I might be able
to do some diagnosis, but it sounds like you may have a pretty low-level
network problem going on.

Karen

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



Re: Port large webapp from PHP to Django: tips, experiences, links needed

2009-01-05 Thread Alexey Moskvin

Hello!
Perhaps, there is no answers to your questions because of some of them
are already discussed here and in other django-related places (like
cache perfomance e t.c.), some of them are closed to holywar :) (like
to use or not to use of the ORM), and some of them like "How about
Django in that regard" contain lack of information, we don't know your
requirements.
In my mind, it is better to perform some refactoring of your PHP code,
maybe switch it to one of the PHP framework. Total reimplimentation of
the large system with unknown technologies is very risky and time-
consiming.
But if your customers allows you, maybe it is a nice choise to move to
django.
Good luck!

On 6 янв, 01:40, Berco Beute  wrote:
> Still looking for some feedback. :)
> In the meantime I've collected a few links that might be useful for
> others with the same questions:
>
> http://www.egenix.com/library/presentations/EuroPython2008-Designing-...http://highscalability.com/ebay-architecturehttp://highscalability.com/http://www.infoq.com/articles/ebay-scalability-best-practiceshttp://highscalability.com/unorthodox-approach-database-design-coming...http://www.scribd.com/doc/429986/Scaling-an-early-stage-startuphttp://www.coggeshall.org/resources/slideshow/id/530124http://www.slideshare.net/directi/building-a-scalable-architecture-fo...http://www.slideshare.net/davemitz/7-stages-of-scaling-web-applicationshttp://www.facebook.com/note.php?note_id=39391378919
>
> 2B
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: birth date in a model form

2009-01-05 Thread DragonSlayre

Oh, cool thanks :)

I never went into the code part of djangoproject before, always just
the documentation.  That's great, thanks.

On Jan 6, 12:53 pm, Brot  wrote:
> from django import forms
> from django.forms.extras import widgets
>
> class FiremanForm(forms.ModelForm):
>     birth_date = forms.DateField(widget=widgets.SelectDateWidget())
>
> On Jan 6, 12:11 am, DragonSlayre  wrote:
>
> > I've tried using it, but I'm still quite new to django - I put it into
> > my model file for now, and made my model form looks like this:
>
> > class FiremanForm(ModelForm):
> >     birth_date = models.DateField(widget=SelectDateWidget())
>
> > But I get an error "got an unexpected keyword argument 'widget' "
> > From this I gather that I must be writing the wrong thing, but I'm not
> > sure what I should be writing?
>
> > Thanks a lot
>
> > On Jan 6, 11:29 am, Brot  wrote:
>
> > > Hello,
>
> > > I have the same issue in my app and there is a widget. You can find it
> > > here:http://code.djangoproject.com/browser/django/trunk/django/forms/extra...
>
> > > But for me this widget misses a few features and there are open
> > > tickets with patches, but they are not in trunk yet 
> > > :-(http://code.djangoproject.com/ticket/9124http://code.djangoproject.co...
>
> > > I am working with the latest patch from #6231 and so the widget is now
> > > useful for me. But I hope that this patch find it's way into django
> > > trunk!
>
> > > ~Bernd
>
> > > On Jan 5, 11:00 pm, DragonSlayre  wrote:
>
> > > > Hi,
>
> > > > I've got a ModelForm, and the model for it contains a birth date field
> > > > (as a DateField):
>
> > > > class FiremanForm(ModelForm):
> > > >     class Meta:
> > > >         model = Fireman
>
> > > > Currently a single text box is rendered to enter the date, but I'd
> > > > like to have a drop down list for day, month, year.
>
> > > > I'm guessing that lots of people have come across this, and I was
> > > > wondering what the best way is to get these drop down lists on the
> > > > page ?
>
> > > > Are there any widgets that I don't know about that I should be using,
> > > > or should I be creating my own, or should I be breaking my Fireman's
> > > > birthdate up into day, month year. or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Does PhoneNumberField for models exist?

2009-01-05 Thread Malcolm Tredinnick

On Tue, 2009-01-06 at 10:45 +1100, Malcolm Tredinnick wrote:
> On Mon, 2009-01-05 at 14:33 -0800, DragonSlayre wrote:
> > http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
> > 
> > This lists PhoneNumberField as being a field type, but in the models
> > documentation, 
> > http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fields
> > there is no such field.
> > 
> > Does anybody know if this field exists? I'd quite like to use it.
> 
> There's no phone number field for models. Just use a character field.

Sorry, I hit "send" before finishing my post. There's much more to it
than this:

The model field PhoneNumberField is an historical holdover from the days
when Django supported the entire world as known to people in Kansas --
the USA (yes, I'm joking. They also knew Canada existed because they
liked music and ... hey... Celine Dion and Bryan Adams! :-)). Since it's
release, it's become clear that there are countries outside the US and
they also have discovered this telephone-like device and have their own
numbering system. So whilst PhoneNumberField did exist at one point, it
was more trouble than it was worth, as it only supported North American
style phone numbers. Thus, it has been moved to
django.contrib.localflavor.us.

Long-term, we don't really need a special phone number field, since it
is just a text field. Probably with some validation rules, but since we
don't have model-level validation in Django 1.0, that's a moot point.
Adding an appropriate phone number validator to a text field will be
easy in Django 1.1 (or whenever model-level validation lands).

At the *form* level, however, we have 473 different phone number fields,
it seems. Many of the django.contrib.localflavor.* packages contain some
kind of phone number validation and one day, in the distant future,
making things less messy there is something I'm going to take a week to
do. 

The reason for the extra form-level fields is that forms do validation
and data normalisation, which models don't do (at the moment, at least).
Thus there are lots of formats handled for the data input. By the time
it gets to the model to be stored in the database, things are much more
uniform: a string of digits and, possibly, letters.

Hopefully that explains some of the background and helps understand
what's going on a bit beyond the documentation.

You've kind of identified that we do need to fix that table a little
bit, however. Removing things that don't exist any longer.

Regards,
Malcolm


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



Re: birth date in a model form

2009-01-05 Thread Brot

from django import forms
from django.forms.extras import widgets

class FiremanForm(forms.ModelForm):
birth_date = forms.DateField(widget=widgets.SelectDateWidget())

On Jan 6, 12:11 am, DragonSlayre  wrote:
> I've tried using it, but I'm still quite new to django - I put it into
> my model file for now, and made my model form looks like this:
>
> class FiremanForm(ModelForm):
>     birth_date = models.DateField(widget=SelectDateWidget())
>
> But I get an error "got an unexpected keyword argument 'widget' "
> From this I gather that I must be writing the wrong thing, but I'm not
> sure what I should be writing?
>
> Thanks a lot
>
> On Jan 6, 11:29 am, Brot  wrote:
>
> > Hello,
>
> > I have the same issue in my app and there is a widget. You can find it
> > here:http://code.djangoproject.com/browser/django/trunk/django/forms/extra...
>
> > But for me this widget misses a few features and there are open
> > tickets with patches, but they are not in trunk yet 
> > :-(http://code.djangoproject.com/ticket/9124http://code.djangoproject.co...
>
> > I am working with the latest patch from #6231 and so the widget is now
> > useful for me. But I hope that this patch find it's way into django
> > trunk!
>
> > ~Bernd
>
> > On Jan 5, 11:00 pm, DragonSlayre  wrote:
>
> > > Hi,
>
> > > I've got a ModelForm, and the model for it contains a birth date field
> > > (as a DateField):
>
> > > class FiremanForm(ModelForm):
> > >     class Meta:
> > >         model = Fireman
>
> > > Currently a single text box is rendered to enter the date, but I'd
> > > like to have a drop down list for day, month, year.
>
> > > I'm guessing that lots of people have come across this, and I was
> > > wondering what the best way is to get these drop down lists on the
> > > page ?
>
> > > Are there any widgets that I don't know about that I should be using,
> > > or should I be creating my own, or should I be breaking my Fireman's
> > > birthdate up into day, month year. or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Does PhoneNumberField for models exist?

2009-01-05 Thread DragonSlayre

Thanks :)

On Jan 6, 12:46 pm, "Karen Tracey"  wrote:
> On Mon, Jan 5, 2009 at 5:33 PM, DragonSlayre  wrote:
>
> >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> > This lists PhoneNumberField as being a field type, but in the models
> > documentation,
> >http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fi...
> > there is no such field.
>
> > Does anybody know if this field exists? I'd quite like to use it.
>
> It's in the US localflavor, just as the associated formfield is:
>
> http://docs.djangoproject.com/en/dev/ref/contrib/localflavor/#django
>
> (Moving that and the US state field out of the general fields and into the
> appropriate localflavor looks to have been a fairly late fixup for 1.0,
> which is probably why mention of it is leftover in the general docs.)
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Does PhoneNumberField for models exist?

2009-01-05 Thread Karen Tracey
On Mon, Jan 5, 2009 at 5:33 PM, DragonSlayre  wrote:

>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> This lists PhoneNumberField as being a field type, but in the models
> documentation,
> http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fields
> there is no such field.
>
> Does anybody know if this field exists? I'd quite like to use it.


It's in the US localflavor, just as the associated formfield is:

http://docs.djangoproject.com/en/dev/ref/contrib/localflavor/#django.contrib.localflavor.us.models.PhoneNumberField

(Moving that and the US state field out of the general fields and into the
appropriate localflavor looks to have been a fairly late fixup for 1.0,
which is probably why mention of it is leftover in the general docs.)

Karen

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



Re: Does PhoneNumberField for models exist?

2009-01-05 Thread Malcolm Tredinnick

On Mon, 2009-01-05 at 14:33 -0800, DragonSlayre wrote:
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
> 
> This lists PhoneNumberField as being a field type, but in the models
> documentation, 
> http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fields
> there is no such field.
> 
> Does anybody know if this field exists? I'd quite like to use it.

There's no phone number field for models. Just use a character field.

Regards,
Malcolm



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



Re: django discarding MySQL results for "in" operator

2009-01-05 Thread Malcolm Tredinnick

On Mon, 2009-01-05 at 12:37 -0800, JonUK wrote:
[...]
> I'm using django 1.0.2 and the tagging app to retrieve a tag via a
> database "in" query, and something is causing the query results to be
> discarded.
> 
> In particular, this line of code from tagging.utils.get_tag_list()
> executes:
> 
> return Tag.objects.filter(name__in=[force_unicode(tag)
>   for tag in tags])
> 
> and at this point:
> (Pdb) p tags
> [u'sea']
> 
> The thread of execution can be traced into the method
> django.db.models.sql.query.execute_sql(self, result_type=MULTI), and
> to this line of code:
> 
> cursor.execute(sql, params)
> 
> and over here:
> >
> c:\python26\lib\site-packages\django\db\models\sql\query.py(1735)
> execute_sql()
> 
> -> cursor.execute(sql, params)
> (Pdb) p sql
> 'SELECT "tagging_tag"."id", "tagging_tag"."name" FROM "tagging_tag"
> WHERE "tagging_tag"."name" IN (%s) ORDER BY "tagging_tag"."name" ASC'
> (Pdb) p params
> (u'sea',)
> (Pdb)
> 
> If I audit what's submitted to MySQL via MySQL logging, it reports:
> SELECT `tagging_tag`.`id`, `tagging_tag`.`name` FROM `tagging_tag`
> WHERE `tagging_tag`.`name` IN ('sea') ORDER BY `tagging_tag`.`name`
> ASC
> 
> which looks correct - however django returns an empty list.
> 
> If I execute the query interactively in MySQL, I get the expected
> (correct) result:
> 
> ++--+
> | id | name |
> ++--+
> | 28 | Sea  |
> ++--+
> 1 row in set (0.00 sec)
> 
> I suspect this is a configuration problem but have no idea where to
> look - can anyone help?

First off, let's be clear: Django isn't throwing away results or
anything like. The database simply isn't returning them. So we need to
work out why that is happening.

One thing that immediately jumps out is that the "name" column is "Sea",
not "sea" (different capitalisation). Have you configured your database
to be case-sensitive in comparisons (and perhaps the MySQL shell is
case-insensitive or something?). Rule that in or out as a start.

A second step would be to start simplifying the query to work out how
simple it has to be before it starts working. For example, remove the
dynamically generated "in" list and replace it with a hard-coded string
(e.g. "sea"). That shouldn't change anything, but it removes one layer
of complexity and is the first step of many towards creating the
simplest possible example. Test that out and see if it still fails.

What happens when you evaluate that queryset from the "manage.py shell"
prompt? That is, import the Tag model and type in the
Tag.objects.filter(...) line and see what happens. If you don't see the
same result as when the code is executed in the program, you now have a
difference to work with. Again, that's trying to simplify things as much
as possible -- we're now down to just the line in question.

If that still doesn't generate any results, see if the most basic
queryset Tag.objects.all() returns something. Then make a much simple
filter -- such as Tag.objects.filter(id=28), which should return the row
you indicate. Then try Tag.objects.filter(name="sea") and
Tag.objects.filter(name="Sea").

Hopefully you can see where this is going: start from something that
doesn't work and remove bits. Start from something that works and add
bits. Eventually you'll meet in the middle and we'll have a better idea
of what the critical piece is.

Regards,
Malcolm



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



Re: django and database views

2009-01-05 Thread drakkan



On 6 Gen, 00:32, Malcolm Tredinnick  wrote:
> On Mon, 2009-01-05 at 06:31 -0800, drakkan wrote:
> > however if i delete an user with records associated in the view I have
> > this error:
>
> > NotSupportedError: cannot delete from a view
> > HINT:  You need an unconditional ON DELETE DO INSTEAD rule.
>
> > django try to delete record from the view and this obviously fails,
>
> > there is a know workaround for this? any way to declare read only the
> > model?
>
> There's no way to say a model is read only. But the solution is easy:
> don't try to delete anything on it. You are in complete control of your
> code. It's entirely up to you whether you try to delete or save things
> on a model, so if it hurts when you do that, just don't do it.

Malcolm, I try to delete an user from the auth_user table; the user is
referenced as foreign key in the view and the delete cascade django
default try to delete all the reference,

I need a foreign key like in the view to write code such as:

databaseview.user.username

so I can use select_related and get all needed database object with
only one query (I use the database view to aggregate some many to many
tables)

so a possible solution is delete the referenced foreign key from the
table on which the views is based on and then delete the target object
(an user object in my example),

however this is error prone, I'm searching a more clean solution such
as redefine delete() or some hack with custom manager,

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



Re: IOError: request data read error

2009-01-05 Thread Graham Dumpleton



On Jan 6, 4:41 am, Chunlei  Wu  wrote:
> Hi,
>
>        We have a web app running on Django 1.0 / modwsgi 2.0 / Apache

Latest mod_wsgi is 2.3, you should really think about upgrading. :-)

> 2.2.3. Sparsely, about 2~3 times a week, I receive emails about
> IOError as below:
>
> ...
>   File "/projects/prod/python/2.5.1/lib/python2.5/site-packages/django/
> core/handlers/wsgi.py", line 69, in safe_copyfileobj
>     buf = fsrc.read(min(length, size))
>
> IOError: request data read error
>
> Mostly it happens on the root URL, but there is a case from other URL.
> I suspect that it is related to the network connection problem, but I
> can not re-produce it. Can anybody explain what  doe this error mean
> exactly? Thanks.

It means that low level Apache functions returned an error when trying
to read request content.

Unfortunately, the particular Apache function used to get the request
content is one that effectively looses the even lower level Apache
error number which would be useful in qualifying what caused the
problem. In other words, the Apache function just says there was an
error and not what it was. Technically some different set of Apache
functions could be used to do the same thing, without loss of the
error code when a problem does occur, but that is a bit trickier and
involves more work. Changing how it is done might occur, but not soon.

More than likely though, it is a variation on another error that can
come back when reading request content as described in:

  http://code.google.com/p/modwsgi/issues/detail?id=29

That one can occur when user/client aborts the connection. This can
occur when they are trigger happy on the reload button.

To try and reproduce it, perhaps perform a file upload and before it
has completed keep pressing the reload button for the page.

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



Re: django discarding MySQL results for "in" operator

2009-01-05 Thread Karen Tracey
On Mon, Jan 5, 2009 at 3:37 PM, JonUK  wrote:

>
> Apologies as this is a repost, but I'm completely stuck!
>
> I'm using django 1.0.2 and the tagging app to retrieve a tag via a
> database "in" query, and something is causing the query results to be
> discarded.
>
> In particular, this line of code from tagging.utils.get_tag_list()
> executes:
>
> return Tag.objects.filter(name__in=[force_unicode(tag)
>  for tag in tags])
>
> and at this point:
> (Pdb) p tags
> [u'sea']
>
> The thread of execution can be traced into the method
> django.db.models.sql.query.execute_sql(self, result_type=MULTI), and
> to this line of code:
>
>cursor.execute(sql, params)
>
> and over here:
> >
> c:\python26\lib\site-packages\django\db\models\sql\query.py(1735)
> execute_sql()
>
> -> cursor.execute(sql, params)
> (Pdb) p sql
> 'SELECT "tagging_tag"."id", "tagging_tag"."name" FROM "tagging_tag"
> WHERE "tagging_tag"."name" IN (%s) ORDER BY "tagging_tag"."name" ASC'
> (Pdb) p params
> (u'sea',)
> (Pdb)
>
> If I audit what's submitted to MySQL via MySQL logging, it reports:
> SELECT `tagging_tag`.`id`, `tagging_tag`.`name` FROM `tagging_tag`
> WHERE `tagging_tag`.`name` IN ('sea') ORDER BY `tagging_tag`.`name`
> ASC
>
> which looks correct - however django returns an empty list.
>
> If I execute the query interactively in MySQL, I get the expected
> (correct) result:
>
> ++--+
> | id | name |
> ++--+
> | 28 | Sea  |
> ++--+
> 1 row in set (0.00 sec)
>
> I suspect this is a configuration problem but have no idea where to
> look - can anyone help?
>

I can't recreate with a similar (though without tagging, just doing a
similar in query for one of my models) query on my MySQL DB/django app.  The
.filter(__in=[...]) returns case-insensitive results as expected.  As
you've traced it down to where the SQL executes, have you gone farther to
determine if somehow that SQL query when issued by Django isn't returning
any results while the one you issue in the mysql command does?  It'd be
pretty bizarre, but maybe the SQL is returning the same result but somehow
it's getting lost before the .filter() is returning?  The alternative seems
to be that the same SQL query is returning different results, which seems
equally bizarre.  (There is no configuration option to change what collation
is used for the query, which is all I could think would change the result as
you have described -- Django always uses the default collation.)

Karen

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



Re: django and database views

2009-01-05 Thread Malcolm Tredinnick

On Mon, 2009-01-05 at 06:31 -0800, drakkan wrote:

> however if i delete an user with records associated in the view I have
> this error:
> 
> NotSupportedError: cannot delete from a view
> HINT:  You need an unconditional ON DELETE DO INSTEAD rule.
> 
> django try to delete record from the view and this obviously fails,
> 
> there is a know workaround for this? any way to declare read only the
> model?

There's no way to say a model is read only. But the solution is easy:
don't try to delete anything on it. You are in complete control of your
code. It's entirely up to you whether you try to delete or save things
on a model, so if it hurts when you do that, just don't do it.

Regards,
Malcolm



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



Re: license problem

2009-01-05 Thread Russell Keith-Magee

On Tue, Jan 6, 2009 at 7:46 AM, Sebastian Bauer  wrote:
>
> Hello, i want to release some code, but i have one problem:
>
> how impel peoples to send me back patches?
>
> Any suggestions are welcome :)

First, participate in the dark arts until to ascend to the level of
minor god. Then, use your newfound ability to fling lightning bolts at
the mortals to compel people to contribute patches. You will probably
need to make an example of a few developers before the rest catch on;
please try to avoid the important people (Linus, Guido, Malcolm etc).
The remaining survivors shall call you Sebastian, God of Keeping Open
Source Developers Honest.

Seriously - Aint no such thing. If you're open sourcing code, you can
_hope_ that people contribute back, but no license terms in the world
will _compel_ them to do so. All you can do is work on developing a
community so that it is obvious that there is a benefit to
contributing code back to you. This means setting up a community where
end users feel welcome and able to contribute, and feel ownership of
the code themselves so that they are encouraged to keep coming back to
the community and helping the project to grow.

Yours
Russ Magee %-)

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



Re: File upload failing occasionally

2009-01-05 Thread Graham Dumpleton



On Jan 6, 9:30 am, ppdo  wrote:
> I tried to monitor the interface using WireShark and the communication
> just hangs during a data transfer: Apache is just acknowledging the
> receipt of some packets and then just seems to hang. The suspicious
> bit is a fairly long series of http RST about 20ms before the server
> hangs. Though I'm not knowledgeable enough on http, to me this clearly
> points in the direction of an Apache problem, though I'm not sure if
> and how it can be solved.
>
> I will try the following:
> 1. Check whether there is a known problem in my version of Apache
> (it's the Leopard standard version, so it might be old enough)
> 2. Reconfigure/recompile the server, to make it work in 32-bit mode
>
> Any idea additional is welcome, of course!

AFAIK Apache itself wouldn't be generating those packets directly. It
just uses a socket and the standard operating system network library
socket functions. If there is an issue with packets at the TCP/IP
level, it would be an operating system level issue.

FWIW, when I am doing benchmarking on MacOSX I often see 'ab' stall
when trying to do even moderate size test runs of 1 requests. I
have never bothered to go into it enough detail to work out the cause,
although for that case also don't believe it was Apache. If anything
was blaming 'ab', but wouldn't be surprised if it was a network level
issue, even though I was doing it against server on same box.

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



Re: Distinct users ordered by remote field

2009-01-05 Thread Malcolm Tredinnick

On Mon, 2009-01-05 at 04:42 -0800, coan wrote:
> I have a model that looks something like this:
> 
> class Collection(models.Model):
>  user = models.ForeignKey(User)
>  item = models.ForeignKey(Items)
>  date = models.DateTimeField()
> 
> I'm trying to retrieve a list of unique users ordered by the last time
> they added something to their collection.
> I would expect this to work:
> distinct_users = User.objects.order_by('collection__date').distinct()[:
> 5]
> This query returns a list of users, but the users are not distinct.

There can be more than one date associated with a particular user, so
whilst the user + date combinations are all unique, the users on their
own may not be.

> How do I do this the right way?

Right now, with trunk or Django 1.0, it's not particularly easy without
using custom SQL or extra(). Without looking too hard at the details, I
suspect it's probably possible with the aggregates code that will be in
Django 1.1, though (it's currently on track to be merged into trunk in
about a week).

One practical solution is to use the result set you're getting now and
filter it further in Python. Or do a filter on the User table and use
extra(select=, order_by=...) to also select the maximum creation
date for each user and order by that.

Regards,
Malcolm



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



Re: django and database views

2009-01-05 Thread Russell Keith-Magee

On Tue, Jan 6, 2009 at 8:11 AM, drakkan  wrote:
>
>
>
> On 6 Gen, 00:06, "Russell Keith-Magee"  wrote:
>> On Mon, Jan 5, 2009 at 11:31 PM, drakkan  wrote:
>>
>> > Hi all,
>>
>> > I mapped a database view in django model as a normal database table,
>> ...
>> > there is a know workaround for this? any way to declare read only the
>> > model?
>>
>> In short, no. Django doesn't currently provide any support for database 
>> views.
>>
>> There might be a few tricks you could do (such as redefining delete()
>
> thanks but this didn't work I already redefined delete as follow:
>
>
> def delete(self):
>pass
>
> but the error is the same
>
>
>> to be a no-op on the view model and on a custom default manager), but
>> these certainly aren't tested or proven suggestions.

Did you redefine just on the model class, or did you do the default
manager change as well? Thinking about this a little more, you will
also need to define your own custom QuerySet class that disables
delete().

In short, this isn't going to be easy unless you're willing to get
your hands dirty and dig into the code a little.

Yours,
Russ Magee %-)

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



Re: to understand MEDIA_URL

2009-01-05 Thread Alan
Thanks Mark for your reply.

On Mon, Jan 5, 2009 at 14:25, Mark Jones  wrote:

>
> Are you closing the file after you write to it and before you try to
> send it?


Pretty sure about it. In fact, after try and error I found out that
restarting the server and my static folder gets refreshed and aware of this
particular file and code works.


> Why do you have to write it to a file to deliver it as a
> static file, why not just render it to a response directly?


But it was like that, however, the file content I want to show is 'report',
without extension, so mimetype is unknown for most browsers, so instead of
showing the content, it prompted for download (which I don't want). If I
could only set the mimetype to 'text/html', but then I couldn't find a way
then reading the content and rendering with  using a view and
template.


> On Jan 5, 4:13 am, Alan  wrote:
> > Hi List,
> > Because I couldn't find any idea better I am using "MEDIA_URL =
> '/static/'"
> > as a repository for the output of my application so I can see the results
> in
> > the web interface and download them.
> >
> > However, I noticed for a particular case where I open and read a file
> > content to be viewed in a web page that I get this error:
> >
> > -
> > IOError at /ccpngrid/call_status_func
> >
> > [Errno 2] No such file or directory:
> >
> '/Users/alan/workspace/webapps/static/grid/alan_20090105T094321/static/grid/alan_20090105T093444/Results_1brv_ccpngrid/DOCS/last_it/report'
> >
> > Request Method: POST
> > Request URL:http://localhost:8000/ccpngrid/call_status_func
> > Exception Type: IOError
> > Exception Value:
> >
> > [Errno 2] No such file or directory:
> >
> '/Users/alan/workspace/webapps/static/grid/alan_20090105T094321/static/grid/alan_20090105T093444/Results_1brv_ccpngrid/DOCS/last_it/report'
> >
> > Exception Location: /Users/alan/workspace/webapps/src/webAppsRoutines.py
> in
> > callStatusFunc, line 518
> > -
> >
> > If I stop and restart the sever (manager.py runserver) it seems that my
> > static folder gets refreshed and then the server is now aware of this
> > 'report' file and then I can see it. If during this runserver session, I
> > submit another job, the new report will failed as show above.
> >
> > So, is it possible to "refresh" my "MEDIA_URL = '/static/'" in runserver
> > session without needing to restart it, or better rethink all the way I
> did
> > for presenting results (not using "MEDIA_URL = '/static/'" basically)?
> > Suggestions are welcome.
> >
> > Many thanks in advance.
> >
> > Alan
> >
> > --
> > Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> > Department of Biochemistry, University of Cambridge.
> > 80 Tennis Court Road, Cambridge CB2 1GA, UK.
> >
> > >>http://www.bio.cam.ac.uk/~awd28<<
> >
>


-- 
Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
Department of Biochemistry, University of Cambridge.
80 Tennis Court Road, Cambridge CB2 1GA, UK.
>>http://www.bio.cam.ac.uk/~awd28<<

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



Re: django and database views

2009-01-05 Thread drakkan



On 6 Gen, 00:06, "Russell Keith-Magee"  wrote:
> On Mon, Jan 5, 2009 at 11:31 PM, drakkan  wrote:
>
> > Hi all,
>
> > I mapped a database view in django model as a normal database table,
> ...
> > there is a know workaround for this? any way to declare read only the
> > model?
>
> In short, no. Django doesn't currently provide any support for database views.
>
> There might be a few tricks you could do (such as redefining delete()

thanks but this didn't work I already redefined delete as follow:


def delete(self):
pass

but the error is the same


> to be a no-op on the view model and on a custom default manager), but
> these certainly aren't tested or proven suggestions.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: birth date in a model form

2009-01-05 Thread DragonSlayre

I've tried using it, but I'm still quite new to django - I put it into
my model file for now, and made my model form looks like this:

class FiremanForm(ModelForm):
birth_date = models.DateField(widget=SelectDateWidget())

But I get an error "got an unexpected keyword argument 'widget' "
>From this I gather that I must be writing the wrong thing, but I'm not
sure what I should be writing?


Thanks a lot

On Jan 6, 11:29 am, Brot  wrote:
> Hello,
>
> I have the same issue in my app and there is a widget. You can find it
> here:http://code.djangoproject.com/browser/django/trunk/django/forms/extra...
>
> But for me this widget misses a few features and there are open
> tickets with patches, but they are not in trunk yet 
> :-(http://code.djangoproject.com/ticket/9124http://code.djangoproject.com/ticket/6231
>
> I am working with the latest patch from #6231 and so the widget is now
> useful for me. But I hope that this patch find it's way into django
> trunk!
>
> ~Bernd
>
> On Jan 5, 11:00 pm, DragonSlayre  wrote:
>
> > Hi,
>
> > I've got a ModelForm, and the model for it contains a birth date field
> > (as a DateField):
>
> > class FiremanForm(ModelForm):
> >     class Meta:
> >         model = Fireman
>
> > Currently a single text box is rendered to enter the date, but I'd
> > like to have a drop down list for day, month, year.
>
> > I'm guessing that lots of people have come across this, and I was
> > wondering what the best way is to get these drop down lists on the
> > page ?
>
> > Are there any widgets that I don't know about that I should be using,
> > or should I be creating my own, or should I be breaking my Fireman's
> > birthdate up into day, month year. or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django and database views

2009-01-05 Thread Russell Keith-Magee

On Mon, Jan 5, 2009 at 11:31 PM, drakkan  wrote:
>
> Hi all,
>
> I mapped a database view in django model as a normal database table,
...
> there is a know workaround for this? any way to declare read only the
> model?

In short, no. Django doesn't currently provide any support for database views.

There might be a few tricks you could do (such as redefining delete()
to be a no-op on the view model and on a custom default manager), but
these certainly aren't tested or proven suggestions.

Yours,
Russ Magee %-)

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



Re: StringList Field Type

2009-01-05 Thread bruno desthuilliers

On 5 jan, 22:52, "Tiago S."  wrote:
> Hi Bruno,
>
> > Then how do you store the number of votes per choice ?
>
> My app is really a quiz with 5 answers per Question and multiples
> Question per Quiz. I used the Poll analogy to make easier to explain
> what I really need, as the django tutorial is about a Poll app.

Ok.

(snip rant about language-specific serialized stuff in db columns)

> I agree with you that serialized arrays in a db field is generally a
> PITA,
> but in this case the quiz, each question can have at most 5 answers,
> and
> that's it. So I didn't see the need of normalization in this case,
> because I would
> went with 5 rows in the Answers table for each Question, and the
> latter would have
> only three fields: id, question_id, and answer_text.

Well, then there's another simple denormalization:

class Question(models.model):
question = models.TextField(...)
answer1 = models.TextField(...)
answer2 = models.TextField(...)
answer3 = models.TextField(...)
answer4 = models.TextField(...)
answer5 = models.TextField(...)

   # Then if you want a list-like read access to answers
   # (which I guess is the case), just add a property:
   @property
   def answers(self):
   return [getattr(self, "answer%s" % i for i in xrange(1, 6)]

NB : if you want read/write access, this is a bit more involved but
still doable - I posted a possible solution here a couple days ago.

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



Re: Redirect parent from within iframe without losing session

2009-01-05 Thread Berco Beute

This one still has me flabbergasted. It may be a browser restriction
(firefox 3), but there is no way I can have the iFrame redirect the
parent page to another page in the same domain (as the previous parent
page) without invalidating the session. Is there maybe another common
solution for iFrames to give back control to the parent page?

2B



On Jan 5, 10:43 am, Berco Beute  wrote:
> The iFrame is from a different domain, which is likely causing the
> problem. I can see that the session is lost since the logged in user
> is suddenly logged out.
>
> 2B
>
> On Jan 5, 1:15 am, Daniel Roseman 
> wrote:
>
> > Personally, I can't see how that redirect could be causing a session
> > to be 'lost'. As long as you stay within the same domain, your session
> > should remain valid. Are you sure that you are using 'localhost:8000'
> > as the original address as well as the redirected one? How are you
> > ascertaining that the session is being lost?
> > --
> > DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Newb needs help with tracking variables in Templates

2009-01-05 Thread bruno desthuilliers

On 5 jan, 23:39, "django_fo...@codechimp.net" 
wrote:
> I have a pretty simple template that needs to print some data in a
> bunch of table rows.  I have done something like this:
>
> 
> {% if my_art_list %}
> {% count = 0 %}

This just won't work

> {% for art in my_art_list %}
> {% if count%3 = 0 %}

idem

> 
> {% endif %}
> 
> 
> 
> {% if count%3 = 2 %}

idem

> 
> {% endif %}
> {% endfor %}
> 
> {% else %}
> You have no art pieces to view.  Would you like to add some?
> {% endif %}
> 
>
> However, as you probably suspect, the "count" variables cause all
> sorts of trouble.

The first one being it's not valid.

>  Is there a way to have tracking variables in the
> template code?

Read the documentation for the {% for %} template tag - it sets a
{{ forloop.counter }} variable.

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for

You may also want to have a look at the {% cycle %} tag (same page as
above), and / or be interested in the "partition" filters on
djangosnippets:
http://www.djangosnippets.org/snippets/6/
http://www.djangosnippets.org/snippets/401/

> I was under the impression that the {%  %} tags were
> just straight Python code

I don't know where you got this impression from. Oh, wait : you didn't
read the doc, did you ?

> and would execute as such, but apparently my
> understanding is a little less than adequate.

I do confirm !-)

> Please help me sort this out...

Well... What about reading the online documentation first ?-)

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



license problem

2009-01-05 Thread Sebastian Bauer

Hello, i want to release some code, but i have one problem:

how impel peoples to send me back patches?

Any suggestions are welcome :)

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



Redirect User on First Log In

2009-01-05 Thread Aruna

I'm trying to redirect a user on their first log in, to a special
welcome page. Subsequent logins will go to a regular page. Is there a
way to do that in the templates? Does Django have a way to check if
it's a users first login?


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



Newb needs help with tracking variables in Templates

2009-01-05 Thread django_fo...@codechimp.net

I have a pretty simple template that needs to print some data in a
bunch of table rows.  I have done something like this:


{% if my_art_list %}
{% count = 0 %}
{% for art in my_art_list %}
{% if count%3 = 0 %}

{% endif %}



{% if count%3 = 2 %}

{% endif %}
{% endfor %}

{% else %}
You have no art pieces to view.  Would you like to add some?
{% endif %}


However, as you probably suspect, the "count" variables cause all
sorts of trouble.  Is there a way to have tracking variables in the
template code?  I was under the impression that the {%  %} tags were
just straight Python code and would execute as such, but apparently my
understanding is a little less than adequate.

Please help me sort this out...

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



Shouldn't blank=True imply null=True?

2009-01-05 Thread Mike

Hi.  Hopefully this has a quick answer; I tried searching the list but
didn't come up with an answer.

Context:
I'm extending django.contrib.auth.models.User with some extra fields,
for instance IntegerField() and ForeignKey().

For non-string fields, whenever you use blank=True you also currently
need null=True.  (null=True causes django to insert a null instead of
an empty string)

If the type is not a string, and blank=True is set, shouldn't
null=True be implied?

Thanks,
Mike

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



Re: Port large webapp from PHP to Django: tips, experiences, links needed

2009-01-05 Thread Berco Beute

Still looking for some feedback. :)
In the meantime I've collected a few links that might be useful for
others with the same questions:

http://www.egenix.com/library/presentations/EuroPython2008-Designing-Large-Scale-Applications-in-Python/
http://highscalability.com/ebay-architecture
http://highscalability.com/
http://www.infoq.com/articles/ebay-scalability-best-practices
http://highscalability.com/unorthodox-approach-database-design-coming-shard
http://www.scribd.com/doc/429986/Scaling-an-early-stage-startup
http://www.coggeshall.org/resources/slideshow/id/530124
http://www.slideshare.net/directi/building-a-scalable-architecture-for-web-apps?src=embed
http://www.slideshare.net/davemitz/7-stages-of-scaling-web-applications
http://www.facebook.com/note.php?note_id=39391378919

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



Does PhoneNumberField for models exist?

2009-01-05 Thread DragonSlayre

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

This lists PhoneNumberField as being a field type, but in the models
documentation, 
http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fields
there is no such field.

Does anybody know if this field exists? I'd quite like to use it.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: File upload failing occasionally

2009-01-05 Thread ppdo

I tried to monitor the interface using WireShark and the communication
just hangs during a data transfer: Apache is just acknowledging the
receipt of some packets and then just seems to hang. The suspicious
bit is a fairly long series of http RST about 20ms before the server
hangs. Though I'm not knowledgeable enough on http, to me this clearly
points in the direction of an Apache problem, though I'm not sure if
and how it can be solved.

I will try the following:
1. Check whether there is a known problem in my version of Apache
(it's the Leopard standard version, so it might be old enough)
2. Reconfigure/recompile the server, to make it work in 32-bit mode

Any idea additional is welcome, of course!

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



Re: birth date in a model form

2009-01-05 Thread Brot

Hello,

I have the same issue in my app and there is a widget. You can find it
here:
http://code.djangoproject.com/browser/django/trunk/django/forms/extras/widgets.py

But for me this widget misses a few features and there are open
tickets with patches, but they are not in trunk yet :-(
http://code.djangoproject.com/ticket/9124
http://code.djangoproject.com/ticket/6231

I am working with the latest patch from #6231 and so the widget is now
useful for me. But I hope that this patch find it's way into django
trunk!

~Bernd

On Jan 5, 11:00 pm, DragonSlayre  wrote:
> Hi,
>
> I've got a ModelForm, and the model for it contains a birth date field
> (as a DateField):
>
> class FiremanForm(ModelForm):
>     class Meta:
>         model = Fireman
>
> Currently a single text box is rendered to enter the date, but I'd
> like to have a drop down list for day, month, year.
>
> I'm guessing that lots of people have come across this, and I was
> wondering what the best way is to get these drop down lists on the
> page ?
>
> Are there any widgets that I don't know about that I should be using,
> or should I be creating my own, or should I be breaking my Fireman's
> birthdate up into day, month year. or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: exception while rendering: 'utf8' codec can't decode byte 0x92 in position 2911

2009-01-05 Thread adrian

Answering myself, there was an illegal character in site_base.html .

On Jan 5, 3:30 pm, adrian  wrote:
> I'm getting this message on line 1 of the template:
>
> {% extends "site_base.html" %}
>
> Which looks ok to me.   I got this while refactoring things.
> Pretty sure the template was working as is in another location.
>
> Any idea how I can debug this, I have no clue.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



birth date in a model form

2009-01-05 Thread DragonSlayre

Hi,

I've got a ModelForm, and the model for it contains a birth date field
(as a DateField):

class FiremanForm(ModelForm):
class Meta:
model = Fireman

Currently a single text box is rendered to enter the date, but I'd
like to have a drop down list for day, month, year.

I'm guessing that lots of people have come across this, and I was
wondering what the best way is to get these drop down lists on the
page ?

Are there any widgets that I don't know about that I should be using,
or should I be creating my own, or should I be breaking my Fireman's
birthdate up into day, month year. or something else?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: StringList Field Type

2009-01-05 Thread Tiago S.

Hi Bruno,

>
> Then how do you store the number of votes per choice ?
>
My app is really a quiz with 5 answers per Question and multiples
Question per Quiz. I used the Poll analogy to make easier to explain
what I really need, as the django tutorial is about a Poll app.

>
> Overkill, nope. But how are you going to use this with a non-python
> client program?
>
> I've seen this (serialized arrays in a db field) in quite a few php
> apps, and I can tell you it always ended being a PITA. A SQL database
> is not a dumb bits bucket, so if you use one, better to use it
> properly IMHO. Note that Google storage is *not* relational - by
> design - so trying to forcefit Google storage concepts in a relational
> database may not be a good idea, quite on the contrary - you'll just
> get the worst of both worlds
>
> Now if you really insist on giving up on normalization, at least use a
> cross-language serialisation format like json. At least you'll have a
> chance to make the data accessible to non-python programs.
>
> My 2 cents

I agree with you that serialized arrays in a db field is generally a
PITA,
but in this case the quiz, each question can have at most 5 answers,
and
that's it. So I didn't see the need of normalization in this case,
because I would
went with 5 rows in the Answers table for each Question, and the
latter would have
only three fields: id, question_id, and answer_text.

Thanks for your opinion, Bruno.. I dug a little more and found a
custom Field that does
JSON serialization: http://www.djangosnippets.org/snippets/377/

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



exception while rendering: 'utf8' codec can't decode byte 0x92 in position 2911

2009-01-05 Thread adrian


I'm getting this message on line 1 of the template:

{% extends "site_base.html" %}

Which looks ok to me.   I got this while refactoring things.
Pretty sure the template was working as is in another location.

Any idea how I can debug this, I have no clue.


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



Re: manage.py test without using a database?

2009-01-05 Thread Bo Shi

Thanks Russell, the former works great (I was hoping, in my infinite
laziness, that there was an undocumented command line switch :-P).

Regards,
Bo

On Jan 1, 1:50 am, "Russell Keith-Magee" 
wrote:
> On Wed, Dec 31, 2008 at 7:08 AM, Bo Shi  wrote:
>
> > Hi,
>
> > One of our django applications does not use django's ORM.  Is there a
> > way to run
>
> > ./manage.py test my_app
>
> > Such that it does not perform test database setup?
>
> There are two ways that you could do this.
>
> The first would be to define a custom test runner that skipped the
> database setup phase. django/test/simple/run_tests() will give you a
> model for what needs to be in a test runner; take a copy of this
> method (removing the database setup portions) and follow the
> instructions in [1]
>
> The second approach would be to define a dummy database backend that
> didn't complain about a database not being defined.
> django/db/backends/dummy gives you a starting point for this.
>
> Either way, you will need to make changes to your settings file.
> Neither of these approaches will fall in to the "if I'm only testing
> my_app, don't bother setting up the database, otherwise set up the
> database as normal" category.
>
> [1]http://docs.djangoproject.com/en/dev/topics/testing/#using-different-...
>
> Yours
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: request.FILES always empty

2009-01-05 Thread Marc Boivin
Thank you

On Mon, Jan 5, 2009 at 3:39 PM, Alex Koshelev  wrote:

>
> You don't set proper `enctype` to the form [1]
>
> [1]:
> http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form
>
>
> On Mon, Jan 5, 2009 at 11:34 PM, Glimps  wrote:
> >
> > I'm using ModelForm to render my form. I have a FileField in my model
> > that shows up as a type="file" on my page. Thing is, even if I select
> > a file to upload Django always complains about the field being empty
> > and my form never validates.
> >
> > Here's my model:
> >
> > class IOs(models.Model):
> >name= models.CharField(max_length=50)
> >desc   = models.TextField()
> >target = models.FileField(upload_to="io/uploads/", max_length=40)
> >ident = models.CharField(max_length=255)
> >
> > My model form:
> > class IOsForm(ModelForm):
> >class Meta:
> >model = IOs
> >
> > here's my snippet to validate the form:
> >
> >if request.method == 'POST':
> >form = IOsForm(request.POST, request.FILES)
> >if form.is_valid():
> >form.ident = getNewID()
> >form.save()
> >
> > When I check for request.FILES after posting I get " >>"
> > This is the code I use to render the template
> >
> > id="new_io_form">
> >
> >{{ html_form.as_ul }}
> >
> >
> > value="Submit" name="btn_submit"
> > id="bnt_submit" />
> >
> >
> >
> > I'm quite sure I'm doing a newbie mistake, just can't figure out what.
> > >
> >
>
> >
>


-- 
Marc Boivin
Dévelopeur/Intégrateur Web
MA14.com
418-803-7139

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



Re: request.FILES always empty

2009-01-05 Thread Alex Koshelev

You don't set proper `enctype` to the form [1]

[1]: 
http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form


On Mon, Jan 5, 2009 at 11:34 PM, Glimps  wrote:
>
> I'm using ModelForm to render my form. I have a FileField in my model
> that shows up as a type="file" on my page. Thing is, even if I select
> a file to upload Django always complains about the field being empty
> and my form never validates.
>
> Here's my model:
>
> class IOs(models.Model):
>name= models.CharField(max_length=50)
>desc   = models.TextField()
>target = models.FileField(upload_to="io/uploads/", max_length=40)
>ident = models.CharField(max_length=255)
>
> My model form:
> class IOsForm(ModelForm):
>class Meta:
>model = IOs
>
> here's my snippet to validate the form:
>
>if request.method == 'POST':
>form = IOsForm(request.POST, request.FILES)
>if form.is_valid():
>form.ident = getNewID()
>form.save()
>
> When I check for request.FILES after posting I get ">"
> This is the code I use to render the template
>
> id="new_io_form">
>
>{{ html_form.as_ul }}
>
>
> value="Submit" name="btn_submit"
> id="bnt_submit" />
>
>
>
> I'm quite sure I'm doing a newbie mistake, just can't figure out what.
> >
>

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



django discarding MySQL results for "in" operator

2009-01-05 Thread JonUK

Apologies as this is a repost, but I'm completely stuck!

I'm using django 1.0.2 and the tagging app to retrieve a tag via a
database "in" query, and something is causing the query results to be
discarded.

In particular, this line of code from tagging.utils.get_tag_list()
executes:

return Tag.objects.filter(name__in=[force_unicode(tag)
  for tag in tags])

and at this point:
(Pdb) p tags
[u'sea']

The thread of execution can be traced into the method
django.db.models.sql.query.execute_sql(self, result_type=MULTI), and
to this line of code:

cursor.execute(sql, params)

and over here:
>
c:\python26\lib\site-packages\django\db\models\sql\query.py(1735)
execute_sql()

-> cursor.execute(sql, params)
(Pdb) p sql
'SELECT "tagging_tag"."id", "tagging_tag"."name" FROM "tagging_tag"
WHERE "tagging_tag"."name" IN (%s) ORDER BY "tagging_tag"."name" ASC'
(Pdb) p params
(u'sea',)
(Pdb)

If I audit what's submitted to MySQL via MySQL logging, it reports:
SELECT `tagging_tag`.`id`, `tagging_tag`.`name` FROM `tagging_tag`
WHERE `tagging_tag`.`name` IN ('sea') ORDER BY `tagging_tag`.`name`
ASC

which looks correct - however django returns an empty list.

If I execute the query interactively in MySQL, I get the expected
(correct) result:

++--+
| id | name |
++--+
| 28 | Sea  |
++--+
1 row in set (0.00 sec)

I suspect this is a configuration problem but have no idea where to
look - can anyone 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



request.FILES always empty

2009-01-05 Thread Glimps

I'm using ModelForm to render my form. I have a FileField in my model
that shows up as a type="file" on my page. Thing is, even if I select
a file to upload Django always complains about the field being empty
and my form never validates.

Here's my model:

class IOs(models.Model):
name= models.CharField(max_length=50)
desc   = models.TextField()
target = models.FileField(upload_to="io/uploads/", max_length=40)
ident = models.CharField(max_length=255)

My model form:
class IOsForm(ModelForm):
class Meta:
model = IOs

here's my snippet to validate the form:

if request.method == 'POST':
form = IOsForm(request.POST, request.FILES)
if form.is_valid():
form.ident = getNewID()
form.save()

When I check for request.FILES after posting I get ""
This is the code I use to render the template



{{ html_form.as_ul }}






I'm quite sure I'm doing a newbie mistake, just can't figure out what.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Do you recommend "Practical Django Projects"?

2009-01-05 Thread waltbrad



On Jan 5, 3:21 am, HB  wrote:
> Hey,
> I'm reading "The Definitive Guide To Django" but it is too out dated.
> Do you recommend "Practical Django Projects" instead?
> It seems to me that "The Definitive Guide To Django" is more organized
> and covers a lot of materials.
> What do you think?
> Thanks.

I'm in the boat of going through "PDP".   I first went through instant-
django and then the django tutorial.  Reading "Practical" I found a
lot of help from this site:

http://tinyurl.com/4y6saw

I generally found that if I had a problem with the book, reading
Brett's comments made me see why I was having that problem.

Although even that didn't really help with writing the templates for
tagging. But I learned a lot from helping myself.

All the broken code aside, this book gives a lot of great examples of
django in action. Just be prepared to be frustrated and learn to
peruse the django documentation.

I intend to do a comprehensive reading of the django topic guides
after I'm done with this book.

http://tinyurl.com/7b9hoc


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



Re: Dynamic OR statements

2009-01-05 Thread bruno desthuilliers



On 5 jan, 18:09, "alex.gay...@gmail.com" 
wrote:
> You need to build up the Q object and then filter on it so:
> results = RelatedModel.objects.all()
> q = Q()
> for category in category_list:
> q |= Q(categories__slug = category.slug)
> results = results.filter(q)

Or create a sequence of Q objects and apply reduce on it

from operator import or_
queries = (Q(category__slug=c.slug) for c in category_list)
results = RelatedModel.objects.filter(reduce(or_, queries))


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



Re: Same form with dropdown on all pages

2009-01-05 Thread ydjango

Thanks I will look into that.
I am thinking  may decorators can also help.

having 2 html forms on one page is turning out to be very tricky.


On Jan 4, 3:16 pm, Justin Myers  wrote:
> It sounds like you're after a custom template 
> tag:http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
>
> On Jan 4, 2:31 pm, Ashish  wrote:
>
> > I want to have a common html form with only a dropdown and a submit
> > button on all pages.
> > It will placed in one corner and user can select say a particular
> > account from the drop down and press submit. I will save the selection
> > in session.
> > All screens then will display the data related to that customer
> > account till user changes the account again from that drop down.
> > the screens can have other html forms on the pages.
>
> > any suggestions on how do I best implement this common form with
> > dropdown without replicating the code for it in all views for all the
> > screens.
>
> > thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Outdated data in django page rendering w/ cacheing disabled

2009-01-05 Thread Malinka Rellikwodahs

On Fri, Jan 2, 2009 at 09:56, Rajesh Dhawan  wrote:
>>
>> As far as I can tell there is no reason for this data to be outdated
>> on browser refresh, I've tried looking through the documentation and
>> other places to find what could be causing this
>
> You didn't include a code snippet of how you actually retrieve data in
> your views. Perhaps include the snippet for your index view for
> example so people can see if anything there might be causing this
> problem.

Sorry for the late response, due to other issues this got pushed down
in the priority list here, but here is some code examples of how I'm
retrieving my data etc.

views.py (cropped for index):

from django.views.decorators.cache import never_cache
from django.shortcuts import render_to_response
from django.http import Http404
from Client import GetClients

@never_cache
def index(request):
clients = GetClients()
pend = [cl for cl in clients if len(cl.Stops()) != 0 or 
len(cl.Limits()) != 0]
pos = [cl for cl in clients if cl.Position() != 0 or not cl.MatchPos()]
return render_to_response(
'Clients/index.html', {
'ReloadRate': 120,
'pending': pend,
'position': pos,
}
)

Client.py (cropped for GetClients):

from MySQLdb import connect

def GetClients():
avail_db = 
connect(user=AVAIL_USER,db=AVAIL_DB,host=AVAIL_HOST,port=AVAIL_PORT)
c = avail_db.cursor()
c.execute("SELECT acct_pk FROM t_acct")
return [Client(cl[0]) for cl in c.fetchall()]

where the Client object is a series of functions and private data that
gets pulled from the DB either on construction or on request depending
on how troublesome it is to get from the DB

now like I said before I've ran the code to get the data from the DB
outside of django and it gets the data on request fine w/o being
outdated, it's just when i use django to get html out of the data

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



Re: StringList Field Type

2009-01-05 Thread bruno desthuilliers

On 5 jan, 19:25, "Tiago S."  wrote:
> Hi,
>
> I'm porting a app from GAE, which uses the StringList[1] property to
> store choices(simple strings) in the Poll model.
>
> I've read the django tutorial and there they make use of two models
> with a relationship between Choices and Polls.

This is the recommended way to use a relational database.

>  With my app, I don't
> see the need of an extra model, as a simple list within the Poll model
> would suffice.

Then how do you store the number of votes per choice ?

> I've also checked the docs, this group and djangosnippets, and I
> couldn't find any reference to something similar to what I need.
>
> Maybe I didn't do the right search... So I decided to ask here first
> instead of writing a custom Model Field and maybe reinvent the wheel.
>
> Does anyone have some clue on how to achieve that? Maybe I should
> piclke the list, or that would be a overkill?

Overkill, nope. But how are you going to use this with a non-python
client program?

I've seen this (serialized arrays in a db field) in quite a few php
apps, and I can tell you it always ended being a PITA. A SQL database
is not a dumb bits bucket, so if you use one, better to use it
properly IMHO. Note that Google storage is *not* relational - by
design - so trying to forcefit Google storage concepts in a relational
database may not be a good idea, quite on the contrary - you'll just
get the worst of both worlds

Now if you really insist on giving up on normalization, at least use a
cross-language serialisation format like json. At least you'll have a
chance to make the data accessible to non-python programs.

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



Re: Access Control Lists implementation for Django?

2009-01-05 Thread bruno desthuilliers

On 5 jan, 10:55, "Mir Nazim"  wrote:
> Hello Guys
>
> I was wondering that is there any 3rd party ACL implementation for
> django. Django's permission system is a bit limited for the app we are
> working on.
> Actually, a per object access control is needed.

There's a granular_permissions app, but it requires a couple patches
(submitted but not applied so far...) to work correctly with current
django versions. It could at least get you started.

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



Re: Do you recommend "Practical Django Projects"?

2009-01-05 Thread Margie

I was a total web framework newbie and got started with the SAMS
book.  I think it's called "learn Django in 24 hours" or something
like that.  It has a ton of errors and from that standpoint, it not a
good book.  However, it is the only book I've found that really leads
you step by step through creating a vey basic site.  I was able to
figure out the errors by searching around on the web.  Creating their
basic web site and having that hands on, practical code to refer to
was very helpful, in my opinion.  It definitely goes into much more
depth than the online tutorial.

I am now reading "Python Web Development with Django", by Forcier,
Bissex and Chun.  It is a better book, but since I was very
inexperienced in this area to start with, I don't think I really would
have understood it without first doing something more hands-on.



On Jan 5, 10:38 am, Benjamin Buch  wrote:
> I agree, Practical Django Projects is a great book!
> Altough I would only recommend it if you've read the docs and worked  
> you way through the tutorial (which are both excellent as someone  
> mentioned earlier...)
> It's full of best practices and a lot of bits and pieces that are not  
> covered by the tutorial.
> Which is good by the way because the tutorial is clearly for  
> beginners, and Practical Django Projects is more towards the  
> intermediate djangonaut I would say.
> As brad says, it gives you more of the big picture.
>
> I've learned a lot from it!
>
> So if you've got some time, wait a few months, if you are to eager or  
> to curious to learn django, just go and get it.
> Altough it's a little bit outdated, the biggest part of it (especially  
> best practices) is still up to date.
> If you know some django, you will recognize the parts where it's  
> behind django 1.0.2.
>
> benjamin
>
> Am 05.01.2009 um 15:42 schrieb brad:
>
>
>
>
>
> > On Jan 5, 2:21 am, HB  wrote:
> >> Do you recommend "Practical Django Projects" instead?
>
> > I got this book as soon as it came out, and very soon after Django hit
> > 1.0.  It's a good book, and I learned a few "big picture" ideas from
> > the sample apps, but I really had to read the docs to figure out how
> > to do the specifics.
>
> > If you're looking for the "big picture", grab it from a library or
> > borrow it from a friend.. otherwise, wait for the next edition or just
> > read the docs (which are very excellent, btw).- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Permissions: is something wrong with them?

2009-01-05 Thread Artem Skvira

Can I get Russell's comment on that?

On Jan 2, 6:26 pm, Artem Skvira  wrote:
> Well,
>
> it's not the usage I'm not clear on but rather architecture.
> Would anyone be able to comment on the issues raised?
>
> Thanks
>
> On Jan 2, 2:20 pm, Jeff Anderson  wrote:
>
> >ArtemSkvira wrote:
> > > Is it worth asking this question is dev group?
>
> > No. Your usage question does not belong on the dev group. It belongs
> > here, on the user group.
>
> >  signature.asc
> > < 1KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Access Control Lists implementation for Django?

2009-01-05 Thread Ramdas S
Perhaps this will give you some ideas

http://www.b-list.org/weblog/2008/dec/24/admin/



On Mon, Jan 5, 2009 at 3:25 PM, Mir Nazim  wrote:

>
> Hello Guys
>
> I was wondering that is there any 3rd party ACL implementation for
> django. Django's permission system is a bit limited for the app we are
> working on.
> Actually, a per object access control is needed.
>
> Thank you in advance for any suggestions.
>
> --
> Mir Nazim
> Cell: +91 9469071855
> Blog: http://saunzal.org
> Company:http://www.ikraftsoft.com
>
> >
>


-- 
Ramdas S
+91 9342 583 065

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



Re: Do you recommend "Practical Django Projects"?

2009-01-05 Thread Benjamin Buch

I agree, Practical Django Projects is a great book!
Altough I would only recommend it if you've read the docs and worked  
you way through the tutorial (which are both excellent as someone  
mentioned earlier...)
It's full of best practices and a lot of bits and pieces that are not  
covered by the tutorial.
Which is good by the way because the tutorial is clearly for  
beginners, and Practical Django Projects is more towards the  
intermediate djangonaut I would say.
As brad says, it gives you more of the big picture.

I've learned a lot from it!

So if you've got some time, wait a few months, if you are to eager or  
to curious to learn django, just go and get it.
Altough it's a little bit outdated, the biggest part of it (especially  
best practices) is still up to date.
If you know some django, you will recognize the parts where it's  
behind django 1.0.2.

benjamin

Am 05.01.2009 um 15:42 schrieb brad:

>
>
> On Jan 5, 2:21 am, HB  wrote:
>> Do you recommend "Practical Django Projects" instead?
>
> I got this book as soon as it came out, and very soon after Django hit
> 1.0.  It's a good book, and I learned a few "big picture" ideas from
> the sample apps, but I really had to read the docs to figure out how
> to do the specifics.
>
> If you're looking for the "big picture", grab it from a library or
> borrow it from a friend.. otherwise, wait for the next edition or just
> read the docs (which are very excellent, btw).


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



StringList Field Type

2009-01-05 Thread Tiago S.

Hi,

I'm porting a app from GAE, which uses the StringList[1] property to
store choices(simple strings) in the Poll model.

I've read the django tutorial and there they make use of two models
with a relationship between Choices and Polls. With my app, I don't
see the need of an extra model, as a simple list within the Poll model
would suffice.

I've also checked the docs, this group and djangosnippets, and I
couldn't find any reference to something similar to what I need.

Maybe I didn't do the right search... So I decided to ask here first
instead of writing a custom Model Field and maybe reinvent the wheel.

Does anyone have some clue on how to achieve that? Maybe I should
piclke the list, or that would be a overkill?

Thanks in advance,
Tiago

[1] 
http://code.google.com/appengine/docs/datastore/typesandpropertyclasses.html#StringListProperty


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



IOError: request data read error

2009-01-05 Thread Chunlei Wu

Hi,

   We have a web app running on Django 1.0 / modwsgi 2.0 / Apache
2.2.3. Sparsely, about 2~3 times a week, I receive emails about
IOError as below:

Traceback (most recent call last):

  File "/projects/prod/python/2.5.1/lib/python2.5/site-packages/django/
core/handlers/base.py", line 86, in get_response
response = callback(request, *callback_args, **callback_kwargs)

  File "/projects/prod/www/views.py", line 159, in index
searchby = request.POST.get('searchby', 'searchbyanno').lower()
# valid values: searchbyanno or searchbyinterval

  File "/projects/prod/python/2.5.1/lib/python2.5/site-packages/django/
core/handlers/wsgi.py", line 169, in _get_post
self._load_post_and_files()

  File "/projects/prod/python/2.5.1/lib/python2.5/site-packages/django/
core/handlers/wsgi.py", line 149, in _load_post_and_files
self._post, self._files = http.QueryDict(self.raw_post_data,
encoding=self._encoding), datastructures.MultiValueDict()

  File "/projects/prod/python/2.5.1/lib/python2.5/site-packages/django/
core/handlers/wsgi.py", line 203, in _get_raw_post_data
size=content_length)

  File "/projects/prod/python/2.5.1/lib/python2.5/site-packages/django/
core/handlers/wsgi.py", line 69, in safe_copyfileobj
buf = fsrc.read(min(length, size))

IOError: request data read error


Mostly it happens on the root URL, but there is a case from other URL.
I suspect that it is related to the network connection problem, but I
can not re-produce it. Can anybody explain what  doe this error mean
exactly? Thanks.

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



Re: Django-like PHP framework?

2009-01-05 Thread Masklinn

On 5 Jan 2009, at 14:31 , thi.l...@gmail.com wrote:
> Hi,
>
> I have a hard time getting Django adopted as web framework in the
> office.
> Mostly because the boss paid for PHP-based trainings, and our current
> infrastructure leaves little room for mod_python/wsgi/fastcgi...
>
> I was wondering if some fo you know about competitor PHP frameworks
> that "look like" Django, or at least try to reach that level of
> purity.
>
> Thanks for any comment (and sorry about this unfair request :-P)

There are quite a few PHP frameworks, but as far as I know the only  
one that really drew inspiration from Django is Symfony.

Didn't do it for everything either, but they at least ported Django's  
newforms as Symfony 1.1's forms. They don't look anywhere as sexy as  
Django's in my opinion and I don't know the rest of the framework, but  
I have a few friends who code in PHP for a living and swear by it. YMMV.

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



Re: Dynamic OR statements

2009-01-05 Thread Enrico

Hi Mark,

I think you could use the Q object like this:

q_filter = Q()
for category in category_list:
q_filter = q_filter | Q(categories__slug=category.slug)
results = RelatedModel.objects.filter(q_filter)

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



Re: Dynamic OR statements

2009-01-05 Thread alex.gay...@gmail.com

You need to build up the Q object and then filter on it so:
results = RelatedModel.objects.all()
q = Q()
for category in category_list:
q |= Q(categories__slug = category.slug)
results = results.filter(q)

On Jan 5, 10:52 am, Bluemilkshake 
wrote:
> Hello. Django noob here, pretty much.
>
> I understand how one can use Q objects to construct OR statements
> within a QuerySet, but (how) is it possible to do this dynamically?
>
> I have a list of categories, and I want to find items that match ANY
> of those categories. The current solution doesn't work too well as it
> lists items that match ALL of the categories in the list. This is done
> in this way:
>
> results = RelatedModel.objects
> for category in category_list:
>     results = results.filter(categories__slug = category.slug)
>
> So as you can see this is building an initial resultset of
> RelatedModel objects, then narrowing it down with each iteration
> through my category list (maybe not the most efficient way to do it,
> but the one that made sense to me). Is it possible to do something
> similar, but where Django produces OR statements instead of AND ones,
> or should I just use the extra() function and supply the SQL myself?
>
> Thanks a lot for your help.
> -Mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Dynamic OR statements

2009-01-05 Thread Ronny Haryanto

On Mon, Jan 5, 2009 at 11:59 PM, Ronny Haryanto  wrote:
> On Mon, Jan 5, 2009 at 11:52 PM, Bluemilkshake
>  wrote:
>> for category in category_list:
>>results = results.filter(categories__slug = category.slug)
>
> How about results.filter(category__in=category_list)?

Whoops. Never mind. Replied too fast. Sorry.

Ronny

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



Re: inlineformset_factory KeyError after updating

2009-01-05 Thread Alistair Marshall

2009/1/5 Alistair Marshall :
Upgraded to 1.0.2

I'll try and create a cut down version-that may take some time (it is
getting to be a large project)

Thanks

-- 
Alistair Marshall

www.thatscottishengineer.co.uk

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



Re: Dynamic OR statements

2009-01-05 Thread Ronny Haryanto

On Mon, Jan 5, 2009 at 11:52 PM, Bluemilkshake
 wrote:
> for category in category_list:
>results = results.filter(categories__slug = category.slug)

How about results.filter(category__in=category_list)?

Ronny

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



Dynamic OR statements

2009-01-05 Thread Bluemilkshake

Hello. Django noob here, pretty much.

I understand how one can use Q objects to construct OR statements
within a QuerySet, but (how) is it possible to do this dynamically?

I have a list of categories, and I want to find items that match ANY
of those categories. The current solution doesn't work too well as it
lists items that match ALL of the categories in the list. This is done
in this way:

results = RelatedModel.objects
for category in category_list:
results = results.filter(categories__slug = category.slug)

So as you can see this is building an initial resultset of
RelatedModel objects, then narrowing it down with each iteration
through my category list (maybe not the most efficient way to do it,
but the one that made sense to me). Is it possible to do something
similar, but where Django produces OR statements instead of AND ones,
or should I just use the extra() function and supply the SQL myself?

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



Re: inlineformset_factory KeyError after updating

2009-01-05 Thread Karen Tracey
On Mon, Jan 5, 2009 at 11:33 AM, Alistair Marshall <
runninga...@googlemail.com> wrote:

>
> 2009/1/5 Karen Tracey :
> > First, I would try 1.0.2 release or current trunk or 1.0.X branch instead
> of
> > 1.0.  There have been additional fixes in this area that you may need,
> > depending on what you are doing.
> >
> Just upgraded now - no difference
>

Upgraded to which, specifically?


>
> > If that doesn't fix it, please post some specifics of what you are doing
> > exactly.
> >
> Not sure what information you want,
>
> here is a copy of one of the models files:
> http://dpaste.com/105625/
>
> I have a view that displays a form for the sepunit and a formset of
> the split fractions
>
> It is fine when submitting a new sepunit, but updating an old one
> gives the error mentioned in my first email.
>
> What other information is needed?
>

Ideally everything I'd need to easily recreate the problem myseslf -- views,
forms, templates, url mappings, the referenced-by-ForeignKey model missing
from that dpaste (or a cut-down version of things that still exhibits the
problem).  Given time I might be able to fill in all the blanks correctly
myself but it's a whole lot easier and less time-consuming to not have to
guess at the missing pieces when trying to recreate.

Karen

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



Re: unbalanced parenthesis

2009-01-05 Thread mangamonk

thank you!

On Jan 5, 4:32 pm, "Alex Koshelev"  wrote:
> You've forgotten ")" after `(?P\d{4}`
>
> On Mon, Jan 5, 2009 at 7:30 PM, mangamonk  wrote:
>
> > I'm trying to complete the practical django applications tutorial..
>
> > error at /weblog/
> > unbalanced parenthesis
> > Request Method:         GET
> > Request URL:    http://127.0.0.1:8000/weblog/
> > Exception Type:         error
> > Exception Value:        unbalanced parenthesis
>
> > /home/mark/django_projects/coltrane/urls.py in 
>
> >   7. }
> >   8.
> >   9. urlpatterns = patterns('django.views.generic.date_based',
> >  10. (r'^$', 'archive_index',
> > entry_info_dict,'coltrane_entry_archive_index'),
> >  11. (r'^(?P\d{4}/$', 'archive_year', entry_info_dict,
> > 'coltrane_entry_archive_year'),
> >  12. (r'^(?P\d{4}/(?P\w{3})/$', 'archive_month',
> > entry_info_dict, 'coltrane_entry_archive_month'),
> >  13. (r'^(?P\d{4}/(?P\w{3})/(?P\d{2}/)$',
> > 'archive_day', entry_info_dict, 'coltrane_entry_archive_day'),
>
> >  14. (r'^(?P\d{4}/(?P\w{3})/(?P\d{2})/(?P[-\w]
> > +)/$', 'object_detail', entry_info_dict,'coltrane_entry_detail'),
>
> > can anyone see the error here?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Migrating MySQL -> Postgre, any working solutions?

2009-01-05 Thread Szymon

On 4 Sty, 20:23, tofer...@gmail.com wrote:
> On 03.01-02:10, Szymon wrote:
> 3.      you will need to substitute quotation marks, mysql uses ""
> and postgresql uses \".  good old 'sed' to the rescue here.

This is not only difference - MySQL uses 0/1 for BooleanField,
Postgres t/f.

After two days of hard work, I've managed to migrate MySQL -> PgSQL.
That was hard. :)

Thanks for help.

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



Re: inlineformset_factory KeyError after updating

2009-01-05 Thread Alistair Marshall

2009/1/5 Karen Tracey :
> First, I would try 1.0.2 release or current trunk or 1.0.X branch instead of
> 1.0.  There have been additional fixes in this area that you may need,
> depending on what you are doing.
>
Just upgraded now - no difference

> If that doesn't fix it, please post some specifics of what you are doing
> exactly.
>
Not sure what information you want,

here is a copy of one of the models files:
http://dpaste.com/105625/

I have a view that displays a form for the sepunit and a formset of
the split fractions

It is fine when submitting a new sepunit, but updating an old one
gives the error mentioned in my first email.

What other information is needed?

thanks


-- 
Alistair Marshall

www.thatscottishengineer.co.uk

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



Re: unbalanced parenthesis

2009-01-05 Thread Alex Koshelev

You've forgotten ")" after `(?P\d{4}`


On Mon, Jan 5, 2009 at 7:30 PM, mangamonk  wrote:
>
> I'm trying to complete the practical django applications tutorial..
>
> error at /weblog/
> unbalanced parenthesis
> Request Method: GET
> Request URL:http://127.0.0.1:8000/weblog/
> Exception Type: error
> Exception Value:unbalanced parenthesis
>
>
> /home/mark/django_projects/coltrane/urls.py in 
>
>   7. }
>   8.
>   9. urlpatterns = patterns('django.views.generic.date_based',
>  10. (r'^$', 'archive_index',
> entry_info_dict,'coltrane_entry_archive_index'),
>  11. (r'^(?P\d{4}/$', 'archive_year', entry_info_dict,
> 'coltrane_entry_archive_year'),
>  12. (r'^(?P\d{4}/(?P\w{3})/$', 'archive_month',
> entry_info_dict, 'coltrane_entry_archive_month'),
>  13. (r'^(?P\d{4}/(?P\w{3})/(?P\d{2}/)$',
> 'archive_day', entry_info_dict, 'coltrane_entry_archive_day'),
>
>  14. (r'^(?P\d{4}/(?P\w{3})/(?P\d{2})/(?P[-\w]
> +)/$', 'object_detail', entry_info_dict,'coltrane_entry_detail'),
>
>
> can anyone see the error here?
> >
>

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



unbalanced parenthesis

2009-01-05 Thread mangamonk

I'm trying to complete the practical django applications tutorial..

error at /weblog/
unbalanced parenthesis
Request Method: GET
Request URL:http://127.0.0.1:8000/weblog/
Exception Type: error
Exception Value:unbalanced parenthesis


/home/mark/django_projects/coltrane/urls.py in 

   7. }
   8.
   9. urlpatterns = patterns('django.views.generic.date_based',
  10. (r'^$', 'archive_index',
entry_info_dict,'coltrane_entry_archive_index'),
  11. (r'^(?P\d{4}/$', 'archive_year', entry_info_dict,
'coltrane_entry_archive_year'),
  12. (r'^(?P\d{4}/(?P\w{3})/$', 'archive_month',
entry_info_dict, 'coltrane_entry_archive_month'),
  13. (r'^(?P\d{4}/(?P\w{3})/(?P\d{2}/)$',
'archive_day', entry_info_dict, 'coltrane_entry_archive_day'),

  14. (r'^(?P\d{4}/(?P\w{3})/(?P\d{2})/(?P[-\w]
+)/$', 'object_detail', entry_info_dict,'coltrane_entry_detail'),


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



Re: Do you recommend "Practical Django Projects"?

2009-01-05 Thread Peter Herndon

"Practical Django Projects" is a bit dated at the moment -- Django has
been moving very quickly.  However, there's a lot to learn from it,
particularly regarding structuring your applications to be reusable,
and lots of other best practices.

I'm in the middle of "Python Web Development with Django" by Jeff
Forcier, Paul Bissex and Wesley Chun, and while it almost covers 1.0,
it was obviously written mostly before 1.0 and updated as and when
possible.  The lag time between manuscript completion and printing is
long, so it's hard to be current considering Django's velocity.  That
said, it is a very good book, with some really good information in it.

Admittedly I'm something of an infovore, so my response should be
taken with a grain of salt, but if you have the time I'd recommend you
work through Forcier, et al. and refer back to the online
documentation as needed to flesh out individual topics.  *Then* go
back and take in James' book, sifting through it for the
still-relevant pieces.  But, if you've worked through the online
tutorial, your best teacher will be a comprehensive project of your
own.  Pick something that you need, and write it.  Refer back to the
online docs for specifics, and ask questions as needed to fill in the
blanks and keep you headed in the right direction.  Experience is the
best teacher, and if you already know Python reasonably well, Django
will fit your Pythonic expectations well.

On Mon, Jan 5, 2009 at 9:42 AM, brad  wrote:
>
>
> On Jan 5, 2:21 am, HB  wrote:
>> Do you recommend "Practical Django Projects" instead?
>
> I got this book as soon as it came out, and very soon after Django hit
> 1.0.  It's a good book, and I learned a few "big picture" ideas from
> the sample apps, but I really had to read the docs to figure out how
> to do the specifics.
>
> If you're looking for the "big picture", grab it from a library or
> borrow it from a friend.. otherwise, wait for the next edition or just
> read the docs (which are very excellent, btw).
>
> >
>

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



Re: Inheritance question

2009-01-05 Thread carlopires

Ok looks reazonable. But be something like:

p = Person(name='test')
s = Student(person=p, course='test course')

or

s = Student(parent=p)

is desirable and easy to implement a copy data from Person instance to
Student.


On Jan 3, 1:02 am, Malcolm Tredinnick 
wrote:
> On Fri, 2009-01-02 at 16:29 -0800, carlopires wrote:
> > Hi,
>
> > I'm trying Multi Table Inheritance with:
>
> > class Person(models.Model):
> >    name = CharField(max_length=30)
>
> > class Student(Person):
> >    course = CharField(max_length=30)
>
> > on db shell:
>
> > p = Person(name='Carlo')
> > p.save()
>
> > Why I can't:
>
> > s = Student(p)
> > s.save()
>
> > ?
> > How Can I evolute a Person to Student ?
>
> You can't. At least at the moment -- it's a sometimes requested feature,
> but there are arguments against allowing it as well. Maybe one day we'll
> add it.
>
> Realise that you can't do this in Python, either, which is why it's not
> completely weird. If B is a subclass of A and you have an instance of A,
> you cannot create an instance of B that is an evolved version without
> copying all the data from the first instance into a new B instance.
> That's exactly what you need to do here. Copy all the p items into the
> Student constructor. So, in this way, model inheritance behaves like
> Python (which is always the intention, as much as possible -- although
> leaky abstractions interfere in both directions at times).
>
> Regards,
> Malcolm
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Is there an easy way to test ssl protected pages in development server??

2009-01-05 Thread madhav

Is there an easy way to test ssl protected pages in development
server? Normally I will be doing the testing by accessing the same
urls with http and not https in dev server. Is this the only way?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Comments Framework and Authentication

2009-01-05 Thread Tim

Maybe a little brevity is in order - how do I grant temporary
privileges to a user to delete a comment rather than keeping that
power fully in the hands of a comments moderator?

- Tim

On Jan 3, 7:23 pm, Tim  wrote:
> Hi all -
>
> I am having a bit of difficulty with the Django comments framework -
> more specifically, dealing with comment modifications by site users as
> well as moderators.
>
> Basically, I have a site in which users can post comments (using the
> out-of-the-box commenting framework). I'd like to have a flexible
> comment deletion environment in which comments could be deleted by the
> user associated with the model attached to the comment or the original
> poster of the comment - e.g., for a blog posting, I'd like the blog
> writer to be able to delete inappropriate or offensive comments, but
> I'd also like the commenter to be able to delete a comment they made
> if they had second thoughts about it.
>
> The commenting framework supports basic permissions for a user to
> moderate comments via the "perms.comment.can_delete" value. However, I
> obviously don't want to grant this permission to every user; this
> would mean a malicious user could just delete comments at will whether
> they belonged to them or not. I believe it's possible to do all the
> logic to find out if a user is allowed to delete a comment in a custom
> view and then forward the request to the official deletion view - but
> then I still run into the check if the user is authorized to delete
> comments or not. I am really loath to change the core commenting code
> itself. Is there a better way to do it?
>
> Here's a quickly hacked together template that kind of shows what I'm
> trying to do (along with all my debugging junk):
>
> 
>     {% if perms.comment.can_delete %}
>         You can delete comments.
>     {% else %}
>         You cannot delete comments.
>     {% endif %}
>     {% ifequal comment.user_id user_profile_id %}
>         ...display a button to delete...
>     {% endifequal %}
>     {% if my_page %}
>         ...display a button to delete...
>     {% endif %}
> 
>
> - Tim
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: FileSystemStorage content vs PIL Image - **Initial solution**

2009-01-05 Thread Donn

On Monday, 05 January 2009 17:50:09 A Melé wrote:
> Donn, take a look at django-thumbs source code
Many thanks -- it looks familiar now :)

\d

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



Re: FileSystemStorage content vs PIL Image - **Initial solution**

2009-01-05 Thread A Melé

Donn, take a look at django-thumbs source code, it integrates PIL and
SotrageBackend: 
http://code.google.com/p/django-thumbs/source/browse/trunk/thumbs.py
I hope the code helps you.


Regards,

Antonio Melé
http://django.es/blog/


On 5 ene, 13:30, Donn  wrote:
> On Monday, 05 January 2009 14:00:16 Eric Abrahamsen wrote:
>
> > content.write(o.getvalue())
> > super(CustomImageStorage,self).save(name, content)
>
> That gives:
> 'InMemoryUploadedFile' object has no attribute '_mode'
> Exception
> Location:       /usr/lib/python2.5/site-packages/django/core/files/base.py in
> _get_mode, line 39
>
> I recall getting this mode error and went past it to my eventual solution. But
> I'd like to know if it's kosher or crazy.
>
> \d
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: inlineformset_factory KeyError after updating

2009-01-05 Thread Karen Tracey
On Mon, Jan 5, 2009 at 10:01 AM, Alistair Marshall <
runninga...@googlemail.com> wrote:

>
> I appear to be having the same trouble as explained in a previous
> thread [1] (and for some reason cant find the button to reply to the
> last thread ???)
>
> The other thread points to a bug that was fixed before django 1.0
> (which is what I am running)
>
> I am not (intentionally) doing anything funny with the primary keys. I
> have a the formset is for a model created by using a through
> relationship in a many-to-many field.
>
> Any suggestions would be greatly welcomed
> Thanks
>
>
First, I would try 1.0.2 release or current trunk or 1.0.X branch instead of
1.0.  There have been additional fixes in this area that you may need,
depending on what you are doing.

If that doesn't fix it, please post some specifics of what you are doing
exactly.

Karen


> The trackback error : http://dpaste.com/105590/
>
> [1]
> http://groups.google.com/group/django-users/browse_thread/thread/862e60c6b19a5f88
> >
>

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



Re: Backward relation to a subclass in multi-table inheritance

2009-01-05 Thread Torsten Bronger

Hallöchen!

Carsten Reimer writes:

> [...]
>
> This resulted in instances of class B being returned (which is
> probably logical) but I wanted to get the class C-instances. What
> I might be able to do, given the instances of class B as shown
> before, I might loop over them and get the related class C
> instance if there is one like this:
>
>  all_real_c_instances = []
>  for b_inst in all_c_instances:
>  try:
>  all_real_c_instances.append(b_inst.c)
>  except:
>  continue
>
> but that just does not look like the elegant way.

I ran into exactly the same problem.  Malcolm Tredinnick suggested
to use contenttype fields to keep track which db class the object
actually is, see
.

My solution can be found at
.  It
is an ugly monkeypatch at the very end of models.py, but it keeps
the views clean.  It hits the database for each "step down",
however, normally you have very shallow inheritances, so this is no
problem.  The advantage is that it's very easy to use, and it works
great for me.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de


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



Backward relation to a subclass in multi-table inheritance

2009-01-05 Thread Carsten Reimer

Dear all,

I ran into a problem with the following situation:

Given are three models as follows:

class A(models.Model):
 # some sensible fields an methods here


class B(models.Model):
 fk = models.ForeignKey(A)

 # some more stuff here


class C(B)
 # some sensible different fields and methods here


In a method of class A I wanted to access all instances of class C that 
belong to that instance of class A like this

 all_c_instances = self.c_set.all()

This leads to an AttributeError telling me that class A does not have an 
attribute c_set.

Okay then. My next idea was to put a related_name-attribute in the 
ForeignKey-definition of class B like this:
 fk = models.ForeignKey(A, related_name="all_children")

and I tried

 all_c_instances = self.all_children.all()

This resulted in instances of class B being returned (which is probably 
logical) but I wanted to get the class C-instances. What I might be able 
to do, given the instances of class B as shown before, I might loop over 
them and get the related class C instance if there is one like this:
 all_real_c_instances = []
 for b_inst in all_c_instances:
 try:
 all_real_c_instances.append(b_inst.c)
 except:
 continue
but that just does not look like the elegant way. Unfortunately I cannot 
find any different (maybe more elegant way). Maybe anyone on this list 
can show me one. That would be greatly appreciated.

Thanks in advance

Carsten


-- 
Carsten Reimer
Web Developer
carsten.rei...@galileo-press.de
Phone +49.228.42150.73

Galileo Press GmbH
Rheinwerkallee 4 - 53227 Bonn - Germany
Phone +49.228.42150.0 (Zentrale) .77 (Fax)
http://www.galileo-press.de/

Managing Directors: Tomas Wehren, Ralf Kaulisch, Rainer Kaltenecker
HRB 8363 Amtsgericht Bonn


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



inlineformset_factory KeyError after updating

2009-01-05 Thread Alistair Marshall

I appear to be having the same trouble as explained in a previous
thread [1] (and for some reason cant find the button to reply to the
last thread ???)

The other thread points to a bug that was fixed before django 1.0
(which is what I am running)

I am not (intentionally) doing anything funny with the primary keys. I
have a the formset is for a model created by using a through
relationship in a many-to-many field.

Any suggestions would be greatly welcomed
Thanks


The trackback error : http://dpaste.com/105590/

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



Re: Do you recommend "Practical Django Projects"?

2009-01-05 Thread brad


On Jan 5, 2:21 am, HB  wrote:
> Do you recommend "Practical Django Projects" instead?

I got this book as soon as it came out, and very soon after Django hit
1.0.  It's a good book, and I learned a few "big picture" ideas from
the sample apps, but I really had to read the docs to figure out how
to do the specifics.

If you're looking for the "big picture", grab it from a library or
borrow it from a friend.. otherwise, wait for the next edition or just
read the docs (which are very excellent, btw).

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



django and database views

2009-01-05 Thread drakkan

Hi all,

I mapped a database view in django model as a normal database table,

all seems fine and I'm able to follow foreign key too, here is a
sample

class databaseview(models.Model):
  field1=
  
  
  user=models.ForeignKey(User)


however if i delete an user with records associated in the view I have
this error:

NotSupportedError: cannot delete from a view
HINT:  You need an unconditional ON DELETE DO INSTEAD rule.

django try to delete record from the view and this obviously fails,

there is a know workaround for this? any way to declare read only the
model?

regards
drakkan






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



Re: Django-like PHP framework?

2009-01-05 Thread Емил Иванов / Emil Ivanov

Welding together Zend Framework, Doctrine and PHPUnit can give you a
very good stack to work with.
All 3 frameworks are very advanced.
You won't get stuff like automatic model forms and the admin for example.

Doctrine is a very advanced ORM tool (and a big a complex one as well).
ZF is sort of the industry standard for PHP, so is PHPUnit.

ZF has integration with PHPUnit and something that is very similar to
Django's Client.

The communities are also quite good.

P.S. Don't expect to find something as good as Django anywhere else though. :)

2009/1/5 thi.l...@gmail.com :
>
> Hi,
>
> I have a hard time getting Django adopted as web framework in the
> office.
> Mostly because the boss paid for PHP-based trainings, and our current
> infrastructure leaves little room for mod_python/wsgi/fastcgi...
>
> I was wondering if some fo you know about competitor PHP frameworks
> that "look like" Django, or at least try to reach that level of
> purity.
>
> Thanks for any comment (and sorry about this unfair request :-P)
> >
>



-- 
My place to share my ideas:
http://bolddream.com

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



Re: to understand MEDIA_URL

2009-01-05 Thread Mark Jones

Are you closing the file after you write to it and before you try to
send it?  Why do you have to write it to a file to deliver it as a
static file, why not just render it to a response directly?

On Jan 5, 4:13 am, Alan  wrote:
> Hi List,
> Because I couldn't find any idea better I am using "MEDIA_URL = '/static/'"
> as a repository for the output of my application so I can see the results in
> the web interface and download them.
>
> However, I noticed for a particular case where I open and read a file
> content to be viewed in a web page that I get this error:
>
> -
> IOError at /ccpngrid/call_status_func
>
> [Errno 2] No such file or directory:
> '/Users/alan/workspace/webapps/static/grid/alan_20090105T094321/static/grid/alan_20090105T093444/Results_1brv_ccpngrid/DOCS/last_it/report'
>
> Request Method: POST
> Request URL:http://localhost:8000/ccpngrid/call_status_func
> Exception Type: IOError
> Exception Value:
>
> [Errno 2] No such file or directory:
> '/Users/alan/workspace/webapps/static/grid/alan_20090105T094321/static/grid/alan_20090105T093444/Results_1brv_ccpngrid/DOCS/last_it/report'
>
> Exception Location: /Users/alan/workspace/webapps/src/webAppsRoutines.py in
> callStatusFunc, line 518
> -
>
> If I stop and restart the sever (manager.py runserver) it seems that my
> static folder gets refreshed and then the server is now aware of this
> 'report' file and then I can see it. If during this runserver session, I
> submit another job, the new report will failed as show above.
>
> So, is it possible to "refresh" my "MEDIA_URL = '/static/'" in runserver
> session without needing to restart it, or better rethink all the way I did
> for presenting results (not using "MEDIA_URL = '/static/'" basically)?
> Suggestions are welcome.
>
> Many thanks in advance.
>
> Alan
>
> --
> Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate
> Department of Biochemistry, University of Cambridge.
> 80 Tennis Court Road, Cambridge CB2 1GA, UK.
>
> >>http://www.bio.cam.ac.uk/~awd28<<
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django-like PHP framework?

2009-01-05 Thread Tirta K. Untario
I haven't found an MTV framework like Django on PHP and Django has a very 
unique concept behind it.

But if you want and MVC framework like Rails or Pylons, I recommend you Kohana 
framework - http://www.kohanaphp.com. Originally based on CodeIgniter, it has 
evolved a lot, and I vote it as the best framework for PHP :D

--Tirta 
-Original Message-
From: HB 

Date: Mon, 5 Jan 2009 06:16:25 
To: Django users
Subject: Re: Django-like PHP framework?



My PHP friend is really happy with CodeIgnite but I know nothing about
it...

On Jan 5, 4:11 pm, Peter Bailey  wrote:
> You might want to have a look at CakePHP. It follows the MCV pattern I
> believe, although I have not looked closely because it is PHP not
> Python.
>
> http://cakephp.org/
>
> Peter
>
> On Jan 5, 8:31 am, "thi.l...@gmail.com"  wrote:
>
> > Hi,
>
> > I have a hard time getting Django adopted as web framework in the
> > office.
> > Mostly because the boss paid for PHP-based trainings, and our current
> > infrastructure leaves little room for mod_python/wsgi/fastcgi...
>
> > I was wondering if some fo you know about competitor PHP frameworks
> > that "look like" Django, or at least try to reach that level of
> > purity.
>
> > Thanks for any comment (and sorry about this unfair request :-P)


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



  1   2   >