Re: problem with openid

2009-08-12 Thread Kenneth Gonsalves

On Thursday 13 Aug 2009 10:16:19 am Malcolm Tredinnick wrote:
> On Thu, 2009-08-13 at 07:22 +0530, Kenneth Gonsalves wrote:
> > hi,
> >
> > was trying out django_openidconsumer and get this error:
> >
> > complete() takes exactly 3 arguments (2 given) - I cannot figure it out
> > as this is the definition of complete:
> >
> > def complete(request, on_success=None, on_failure=None):
>
> That's certainly one complete() function. But it's not the one in the
> traceback. :-)

thanks - apparently openid.consumer.complete is being called wrongly - that 
has the correct number of arguments.
-- 
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: save as a new entry

2009-08-12 Thread Ali Rıza Keleş

On Wed, 2009-08-12 at 15:55 -0700, Daniel Roseman wrote:
> On Aug 12, 10:40 pm, Ali Rıza KELEŞ  wrote:
> > In admin interface, in editing section of a model, I need a button to
> > save as a new entry. There are four button at the end of the editing
> > form.
> > - Delete,
> > - Save and Add New,
> > - Save And Continue Editing,
> > - Save.
> >
> > I want to save the currently editing entry as a new entry.
> >
> > For example:
> > entry is:
> > id=3, title= 'Some title', text= 'Some text'.
> >
> > I try to edit and changed nothing and press the save as button, a new
> > entry would be created
> >
> > id=4, title= 'Some title', text= 'Some text'.
> >
> > Of course it does not matter to change o not to change entry. It is
> > important to save as a new entry.
> > How can I success?
> >
> > Thanks.
> >
> > --
> > Ali Rıza
> 
> The `save_as` option to the ModelAdmin class does exactly that. See
> here:
> http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_as
> --
> DR.

Really so easy.. Thanks for reply.

And I would like to ask another question. If I would to save this new
entry to another db table, so how? Like modified version of this
original entry. 


> > 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: new session ID is created for every request from IE 7

2009-08-12 Thread Malcolm Tredinnick

On Wed, 2009-08-12 at 19:21 -0700, humble wrote:
> Hi,
> 
> I am writing a web application that involves session management with
> the corporate backend module. I wrote my own authentication backend
> plugin to satisfy the corporate requirement, not the default
> authentication backend. I use file based session engine to avoid
> sqlite crap. Everything works fine in firefox and chrome. But it seems
> to be a problem with IE: response includes a new session ID (actually
> a test cookie) for each request from IE. It seems IE never sends back
> the previous cookie given by the server in subsequent request. Check
> in /tmp/ (where I store all session files), I see the previous session
> file is replaced with a new empty session file.
> 
> Looking in to contrib.session.middleware.py confirms
> "request.session.session_key" is different for each request. However,
> this only happens when I use IE.  I configured IE 7 to allow cookies,
> so it does not reject cookies from django. What might be the problem?
> Has any one seen this issue before?

I've seen it before when the domain being used for the cookie wasn't a
valid domain name. Browsers have blacklists of sets of domains that they
won't accept/send cookies for and they typically won't allow you to set
a cookie for .com, say.

That might be the problem in this case.

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: problem with openid

2009-08-12 Thread Malcolm Tredinnick

On Thu, 2009-08-13 at 07:22 +0530, Kenneth Gonsalves wrote:
> hi,
> 
> was trying out django_openidconsumer and get this error:
> 
> complete() takes exactly 3 arguments (2 given) - I cannot figure it out as 
> this 
> is the definition of complete:
> 
> def complete(request, on_success=None, on_failure=None):

That's certainly one complete() function. But it's not the one in the
traceback. :-)


[...]
> Traceback:
> File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in 
> get_response
>   92. response = callback(request, *callback_args, 
> **callback_kwargs)
> File "/usr/lib/python2.6/site-packages/django_openidconsumer/views.py" in 
> complete
>   111. openid_response = consumer.complete(dict(request.GET.items()))

This is calling the complete() method on the "consumer" instance
(consumer.complete(), not complete()). So find what type of object
"consumer" is and look at the methods on that object.

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: AutoRefresh model field (filled in by a trigger)

2009-08-12 Thread Malcolm Tredinnick

On Wed, 2009-08-12 at 04:55 -0700, Evgeny wrote:
> Hi,
> I have some fields in a model which are filled in by before_insert
> trigger.
> Is there any right way to autorefresh them after the object is
> inserted, besides requesting a new instance of the object by
> model.objects.get() method?

You have one perfectly good method and you want another one instead? :-)

Seriously, use get(pk=my_obj.pk). It's designed to retrieve single
instances from the database. You could do

filter(id=my_obj.pk).values("field_1", "field_2", ...)

but it's not going to be significantly faster unless your model has
massive fields (leading to other problems) and it reads a bit less
comprehensibly in the code.

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
-~--~~~~--~~--~--~---



raw sql Operational Error

2009-08-12 Thread adelaide_mike

Working in Django 1.0.2 with PostgreSQL backend the following produces
an error:
Operational Error at /report/agent_summary/
near "ON": syntax error

The SQL works if run in pgadminIII but with %s replaced by
"2009-01-01".  Must be a newbie error somewhere.

def agent_summary(request):
'''build a report showing the most recent advertisement (listing)
for properties listed within the last 12 weeks'''
startdate = date.today()-timedelta(7*12)
cursor = connection.cursor()

cursor.execute("SELECT DISTINCT ON (property_id) property_id,
date, wha_property.propnum, wha_street.street_name,
wha_suburb.suburb_name, wha_agent.first_name, wha_agent.last_name,
wha_agency.name FROM wha_listing, wha_agent, wha_agency, wha_property,
wha_street, wha_suburb WHERE wha_suburb.id = wha_street.suburb_id AND
wha_street.id = wha_property.street_id AND wha_property.id =
property_id AND wha_agency.id = wha_agent.agency_id AND wha_agent.id =
agent_id AND date > %s ORDER BY property_id, date DESC", [startdate])
listings = cursor.fetchall()
return render_to_response('wha/agent_summary.html', {'listings':
listings})

Any help very much appreciated. Steep learning curve.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Admin Panel: Restrict ForeignKey selections via permissions

2009-08-12 Thread Mark Stahler

Can someone point me in the direction to best solve this problem. It
would easier to show you:

class Profile(models.Model):
status = models.ForeignKey(Status)
...



class Status(models.Model):
status_name = models.CharField(max_length=50)
...

I need to be able to restrict the select box in Add/Change of the
Profile model in the Admin panel to the first 3 entries (with proper
id)  from the Status table. Basically I have 5 values in Status and I
need to have 2 kinds of users, a submitter and a reviewer. Submitter
can only add a 1-3 level status but the reviewer can add/change from 1-
whatever.

What would be the best way to do this? Can I extend the ForeignKey
class? Would it be easier to change my model some how? Any suggestions
would be appreciated, this is my first Django app and I am really
enjoying 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: Need for an internationalization/translation system not request-based

2009-08-12 Thread Malcolm Tredinnick

On Wed, 2009-08-12 at 15:48 +0200, Jarek Zgoda wrote:
[...]
> As translation.activate() is process-wide, this approach is not  
> safe in multithreaded environment if using static translation (not  
> request-based).

This is not correct. The translation.activate() call is thread-specific
and definitely thread-safe. Otherwise Django's entire translation
infrastructure wouldn't work.

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: Inheritance at runtime (per model instance)

2009-08-12 Thread Malcolm Tredinnick

On Wed, 2009-08-12 at 14:24 +0200, Thomas Guettler wrote:
> Hi Malcolm and others,
> 
> Malcolm Tredinnick schrieb:
[...]

 
> > You already have the content type table for referring to other model
> > objects. Why not use that so that you can maintain some referential
> > integrity?
> 
> Content Types use serial keys. Take something like a ticket system:
> Serial keys are good for the tickets. But if you have something like a
> TicketTypeModel it is not a good solution. The customer uses the live
> system and can create new TicketTypes. But during the same time,
> I might create new TicketTypes in my development system. The serial IDs clash.

Ah, ok. So you'll end up with something like your own version of the
content type system. Makes sense. Providing your model names are going
to be different from your customer's developed versions, your plan makes
sense. 

> And the TicketTypes or (Workflow-Models) need to be installable for several 
> customers.

This is the only reason I would be tempted not to just use the import
path. You really want to namespace the identifiers and model names might
clash if they're common enough. I would be very tempted to prefix some
identifier with a customer-specific identifier (as a development
recommendation, not enforced in the code). So you identifiers would be
"tg_" and your customer 1 might use "aa_", etc.
The prefix used to generate the ids could even be a setting if you could
auto-create the ids from the model name/import path.

But I might be over-engineering this. You understand your target
audience -- particularly the number and habits of the target audience --
better than me. So this is just me thinking out loud.

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
-~--~~~~--~~--~--~---



new session ID is created for every request from IE 7

2009-08-12 Thread humble

Hi,

I am writing a web application that involves session management with
the corporate backend module. I wrote my own authentication backend
plugin to satisfy the corporate requirement, not the default
authentication backend. I use file based session engine to avoid
sqlite crap. Everything works fine in firefox and chrome. But it seems
to be a problem with IE: response includes a new session ID (actually
a test cookie) for each request from IE. It seems IE never sends back
the previous cookie given by the server in subsequent request. Check
in /tmp/ (where I store all session files), I see the previous session
file is replaced with a new empty session file.

Looking in to contrib.session.middleware.py confirms
"request.session.session_key" is different for each request. However,
this only happens when I use IE.  I configured IE 7 to allow cookies,
so it does not reject cookies from django. What might be the problem?
Has any one seen this issue before?

Thanks
-h
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



problem with openid

2009-08-12 Thread Kenneth Gonsalves

hi,

was trying out django_openidconsumer and get this error:

complete() takes exactly 3 arguments (2 given) - I cannot figure it out as this 
is the definition of complete:

def complete(request, on_success=None, on_failure=None):

any clues?

the cut-and-paste view of the traceback is here:

Environment:

Request Method: GET
Request URL: 
http://ilugc.web/openid/complete/?janrain_nonce=2009-08-13T01%3A30%3A50ZyN0AZR_claimed_id=http%3A%2F%2Flawgon.livejournal.com%2F=id_res_id=http://lawgon.livejournal.com/=http://lawgon.livejournal.com/_to=http://ilugc.web/openid/complete/%3Fjanrain_nonce%3D2009-08-13T01%253A30%253A50ZyN0AZR%26openid1_claimed_id%3Dhttp%253A%252F%252Flawgon.livejournal.com%252F_nonce=2009-08-13T01:33:40Zdhz2Jv_handle=1250062085:OU8pMnJa2OCTFPjUyT7z:ab7d0893ae=mode,claimed_id,identity,return_to,response_nonce,assoc_handle=Rek809lzX1hQuzbQQTY8LikCkfA%3D
Django Version: 1.2 pre-alpha SVN-11422
Python Version: 2.6.0
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'ilugc.web',
 'django.contrib.comments',
 'django_openidconsumer']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django_openidconsumer.middleware.OpenIDMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.doc.XViewMiddleware',
 'django.middleware.locale.LocaleMiddleware')


Traceback:
File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py" in 
get_response
  92. response = callback(request, *callback_args, 
**callback_kwargs)
File "/usr/lib/python2.6/site-packages/django_openidconsumer/views.py" in 
complete
  111. openid_response = consumer.complete(dict(request.GET.items()))

Exception Type: TypeError at /openid/complete/
Exception Value: complete() takes exactly 3 arguments (2 given)
-- 
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
-~--~~~~--~~--~--~---



Django Filter parser slightly less than intuitive

2009-08-12 Thread Mark Jones

{{ datevar|date: dateformat}}

won't parse.

You get the error:
Could not parse the remainder: ': dateformat' from 'datevar|date:
dateformat'

Turns out that unlike most other places, spaces ARE significant here.
It could be fixed by changing the filter_raw_string on line 448 of
django/template/__init__.py to eat the whitespace before and after the
variable or constant or i18n string with something like

\s* added to this portion of the regex for parsing

 (?:%(arg_sep)s\s*# Added here
 (?:
  %(i18n_open)s"(?P%(str)s)"%(i18n_close)s|
  "(?P%(str)s)"|
  (?P[%(var_chars)s]+)
 )\s*  # and here

It should probably either be fixed or at least documented.

I'm posting this here so that others can find it quickly and
understand the cause of the error message.  I wasted over an hour
because the error message wasn't clear enough to say, hey stupid,
white space all of a sudden matters with filter arguments.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-tinymce not appearing in admin

2009-08-12 Thread Kenneth Gonsalves

On Wednesday 12 Aug 2009 9:35:30 pm diogobaeder wrote:
> Oops, sorry... it's version 1.1 final.
>
> I'll try to create the Media subclass with the media, then, although
> it's not specified in the django-tinymce use documentation.
>
> About dpaste, I'm confused, because in another post I pasted exception
> content and someone advised me to use dpaste to make the thread more
> readable. Are you really sure this is a recommendation for this list?

it is not a recommendation - it is my personal opinion. I have been flamed in 
the past for both not posting enough of the error traceback and also for 
posting too much of the error traceback. I have also been bitten in the 
archives where the dpaste has expired. I suppose the best way would be to 
paste the relevant lines of the traceback inline and the full traceback 
somewhere else. But then one has to know which lines are relevant - and if one 
does know that, usually one can solve the problem himself.
-- 
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: Adding new object using form and inloine formset. Do I do it right?

2009-08-12 Thread Daniel Roseman

On Aug 12, 9:20 pm, Tomek  wrote:
> Hi,
>
> Question: Is there a better way of creating objects from formset
> (children) without having to create and possibly delete object which
> is referenced by them (parent) and which is being created on the same
> page?
>
> Here's my (simplified) models. It's basically an item with some
> pictures. It's just nice to have this on single form - fill
> description and add some pics.
>
> -
> class Item(models.Model):
>    owner = models.ForeignKey(User)
>
> class ItemImage(models.Model):
>     image = ImageField()
>     item = models.ForeignKey(Item)
>
> -
> And here's the view:
>
> -
> def view_item_add(request):
>     ImageFormset = inlineformset_factory(Item, ItemImage,
> fk_name="item")
>     if request.method == 'POST':
>         item_form = ItemCreateForm(data=request.POST)
>         if item_form.is_valid():
>             item = item_form.save(commit=False)
>             item.owner = request.user
>             item.save()
>
>             # creating the 2nd form only now!
>             imageset_form = ImageFormset(data = request.POST,
> prefix='images', instance=item)
>             if imageset_form.is_valid():
>                 imageset_form.save()
>             else:
>                 # deleting item is formset items invalid - could we
> have avoided creating this temporary item in the first place?
>                 item.delete()
>     else:
>         # create empty forms
>
>    return render_to_response(...)
>
> -
>
> Thanks for having a look.
>
> Tomek


If I understand your issue correctly, it is that you want to be sure
that the user has added at least one image before creating the parent
item.

If that's right, I would tackle this via validation on the formset, so
that it is impossible to submit the form without any images. That's
easy to do, just create a custom formset subclass and override the
clean() method, checking that there's at least one form:

class ImageInlineFormset(BaseInlineFormSet):
def clean(self):
# get forms that actually have valid data
count = 0
for form in self.forms:
try:
if form.cleaned_data:
count += 1
except AttributeError:
# annoyingly, if a subform is invalid Django explicity
raises
# an AttributeError for cleaned_data
pass
if not count:
raise forms.ValidationError('You must have at least one
image')

Then use this ImageInlineFormset as the formset parameter to
inlineformset_factory in your view:

ImageFormset = inlineformset_factory(Item, ItemImage, fk_name="item",
 formset=ImageInlineFormset)

Now the user will get an error message if they post the form with no
images.
--
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: save as a new entry

2009-08-12 Thread Daniel Roseman

On Aug 12, 10:40 pm, Ali Rıza KELEŞ  wrote:
> In admin interface, in editing section of a model, I need a button to
> save as a new entry. There are four button at the end of the editing
> form.
> - Delete,
> - Save and Add New,
> - Save And Continue Editing,
> - Save.
>
> I want to save the currently editing entry as a new entry.
>
> For example:
> entry is:
> id=3, title= 'Some title', text= 'Some text'.
>
> I try to edit and changed nothing and press the save as button, a new
> entry would be created
>
> id=4, title= 'Some title', text= 'Some text'.
>
> Of course it does not matter to change o not to change entry. It is
> important to save as a new entry.
> How can I success?
>
> Thanks.
>
> --
> Ali Rıza

The `save_as` option to the ModelAdmin class does exactly that. See
here:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.save_as
--
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
-~--~~~~--~~--~--~---



save as a new entry

2009-08-12 Thread Ali Rıza KELEŞ

In admin interface, in editing section of a model, I need a button to
save as a new entry. There are four button at the end of the editing
form.
- Delete,
- Save and Add New,
- Save And Continue Editing,
- Save.

I want to save the currently editing entry as a new entry.

For example:
entry is:
id=3, title= 'Some title', text= 'Some text'.

I try to edit and changed nothing and press the save as button, a new
entry would be created

id=4, title= 'Some title', text= 'Some text'.

Of course it does not matter to change o not to change entry. It is
important to save as a new entry.
How can I success?

Thanks.

--
Ali Rıza

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



Adding new object using form and inloine formset. Do I do it right?

2009-08-12 Thread Tomek

Hi,

Question: Is there a better way of creating objects from formset
(children) without having to create and possibly delete object which
is referenced by them (parent) and which is being created on the same
page?


Here's my (simplified) models. It's basically an item with some
pictures. It's just nice to have this on single form - fill
description and add some pics.

-
class Item(models.Model):
   owner = models.ForeignKey(User)

class ItemImage(models.Model):
image = ImageField()
item = models.ForeignKey(Item)

-
And here's the view:


-
def view_item_add(request):
ImageFormset = inlineformset_factory(Item, ItemImage,
fk_name="item")
if request.method == 'POST':
item_form = ItemCreateForm(data=request.POST)
if item_form.is_valid():
item = item_form.save(commit=False)
item.owner = request.user
item.save()

# creating the 2nd form only now!
imageset_form = ImageFormset(data = request.POST,
prefix='images', instance=item)
if imageset_form.is_valid():
imageset_form.save()
else:
# deleting item is formset items invalid - could we
have avoided creating this temporary item in the first place?
item.delete()
else:
# create empty forms

   return render_to_response(...)

-

Thanks for having a look.

Tomek

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



optional username registration

2009-08-12 Thread Dhruv Adhia

Hello,

I have a registration system working and most of the code is pulled
out from django code base. I would like to make username optional. Is
there any shorter way?

Thanks
Dhruv
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Image handling - Custom image field?

2009-08-12 Thread TiNo
On Mon, Aug 3, 2009 at 12:53, Peter Bengtsson  wrote:

>
> I would write a management command and let a cron job fire off to run
> it.
> See this for how to write management commands:
> http://docs.djangoproject.com/en/dev/howto/custom-management-commands/
>
> Then your cron job can look something like this:
> */5 * * * * python /path/to/manage.py copyfromftp >> /dev/null 2>&1
>
> But running this as a separate command you'll make sure than for each
> run python will reuse memory it has freed.
> You might also want to write it so that the management command only
> does a limited about of photos in one batch and instead run the
> management command often.


Hi,

This does not really work for me. When I import the photo's, I also add the
creator to the Model, and give the user the option add the photo's to a
specific event. The cronjob would just randomly import the photo's as soon
as they are uploaded.

 So these two questions still stand:
- It would be nice to open the uploaded file as an PIL image, resize it, and
save it to the final destination, therefore saving an extra open() call. It
is probably possible to do this in a subclassed ImageField, but I can't
really get my head around these FileFields with the FieldFile classes. So
what method would I have to override to do this?
- What would be the best way to start a separate python script? And is there
any way to communicate between de fastcgi script and the import script? Say
pass that we are at image 25 of 100?

Does anyone have a solution?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Django a good choice for a LAN app?

2009-08-12 Thread Joseph Le Brech

I think you'll find it's called an intranet.

I making an intranet project myself, the basics require no effort.

it just the last 10% (im sure there's a lot more than 10%) that im getting to 
grips with it.

I find it a lot quicker to develop with than rails, the admin panel kicks 
scaffolding's butt.

> Date: Wed, 12 Aug 2009 20:32:43 +0200
> From: ojiido...@gmail.com
> To: django-users@googlegroups.com
> Subject: Re: is Django a good choice for a LAN app?
> 
> 
> In my opinion writing it in django/html/... is a lot easier and faster 
> than doing it in a real python GUI tool. Also you have the networking in 
> your LAN taken care of by the browser.
> 
> 
> snfctech wrote:
> > One more question:  Any advantage to just using a Python GUI toolkit
> > instead?
> >
> > On Aug 12, 9:18 am, snfctech  wrote:
> >   
> >> Thanks for all of the good feedback!
> >>
> >> At the very least I am enthusiastic about the health of this list! ;-)
> >>
> >> @Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
> >> sales/week).
> >>
> >> Sounds like the community feels Django is a good choice for my type of
> >> project.
> >>
> >> Thanks!
> >>
> >> On Aug 12, 5:18 am, Philippe Raoult  wrote:
> >>
> >> 
> >>> I don't know what you mean by mid-sized but I deployed exactly what
> >>> you're describing in a 45-strong company. We have occasional browser
> >>> incompatibilities with ajax but overall django was very much the right
> >>> tool for the job. As a bonus the company's clients can now access a
> >>> restricted part of the application to monitor their files and dealings
> >>> over https. Employees can also log in from home over https without any
> >>> software/hardware prerequisite. We're also planning on adding some
> >>> smartphone friendly pages for specific tasks (billing when employees
> >>> are working offsite).
> >>>   
> >>> My app is around 25k lines of python+templates
> >>>   
> >>> Hope this helps you make your mind.
> >>>   
> >>> On Aug 11, 9:06 pm, snfctech  wrote:
> >>>   
>  I'm about to start a fairly large project for a mid-sized business
>  with a lot of integration with other systems (POS, accounting,
>  website, inventory, purchasing, etc.) The purpose of the system is to
>  try to reduce current data siloing and give employees role-based
>  access to the specific data entry and reports they need, as well as to
>  replace some manual and redundant business processes. The system needs
>  to be cross-platform (Windows/Linux), open source and is primarily for
>  LAN use.
>  
>  My experience is mostly PHP/web/app development, but I have developed
>  a few LAN apps using Java/Servoy (like Filemaker). I am leaning
>  towards Python/Django - but wondering whether this may be
>  unnecessarily web-specific. I really felt Servoy development was very
>  rapid, and it was cross-paltform, but it was not open source (not to
>  mention that anything custom needed to be Java which I find too
>  verbose/ slow to develop in). Or maybe Open Office Base and some
>  scripting is sufficient to handle my needs.
>  
>  So, my main question is: Does a web framework like Django sound like a
>  reasonable platform to build a LAN Dashboard for a mid-sized company?
>  Or am I thinking too much like a web developer?
>  
>  Any tips or suggestions would be greatly appreciated.
>  
> > >
> >   
> 
> 
> > 

_
Windows Live Messenger: Thanks for 10 great years—enjoy free winks and 
emoticons.
http://clk.atdmt.com/UKM/go/157562755/direct/01/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Django a good choice for a LAN app?

2009-08-12 Thread Torsten Bronger

Hallöchen!

snfctech writes:

> One more question: Any advantage to just using a Python GUI
> toolkit instead?

Imagine you have a bug and you must update all clients ...

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.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: More Than Two Models With inlineformset_factory

2009-08-12 Thread Matthias Kestenholz

On Wed, Aug 12, 2009 at 7:36 PM, Geraldo wrote:
>
> No, I mean two or more different forms.  I'd like Parent, Child1 AND
> Child2 all in the same formset.  What you've suggested though, should
> get me where I want to go.
>

Well, you can easily show the input fields from Formset1 and Formset2
intertwined. You need to output the mangement forms and the individual
fields by hand. It's very similar to outputting form elements by hand
instead of using the as_ul/as_table convenience methods.


Hope it helps,
Matthias




-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Location of Change User admin template

2009-08-12 Thread bfrederi

Thanks for the help. I accomplished my task. All of the links I posted
were exactly what it took to make it work.

-Brandon

On Aug 12, 1:31 pm, bfrederi  wrote:
> I found 
> this:http://code.djangoproject.com/browser/django/trunk/django/contrib/adm...
> So it looks like it will allow me to override the template 
> here:http://code.djangoproject.com/browser/django/trunk/django/contrib/adm...
>
> So if I can override this 
> effectively:http://code.djangoproject.com/browser/django/trunk/django/contrib/aut...
>
> Here is a helpful 
> guide:http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-ena...
>
> This will allow me to override the change_form template. If indeed
> that is the template I am looking to override. I can't really
> understand the template well enough to know how to add a button. But I
> will hack away if my hunch turns out to be 
> right:http://code.djangoproject.com/browser/django/trunk/django/contrib/adm...
>
> Anyway. With any luck, I will accomplish my simple and pathetic little
> button. Seems like it should be more simple than this, but I guess the
> developers of Django had a good reason to make admin much more
> complicated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



ModelForm limit m2m choices

2009-08-12 Thread alain31

Hello,
I have a model with m2m foreign key:

Model1:
field1 = models.ManytoManyField(Model2)
field2 = ...
and a ModelForm

class MyForm(ModelForm)
   class Meta:
   model = Model1

How can I use a custom QuerySet for the choices of field1  ?
I tried to pass a dictionary in
dic = {field: myqueryset}
form = MyForm(dic, instance=m)
without success.

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
-~--~~~~--~~--~--~---



Can't find doc for this - concerning buildout

2009-08-12 Thread LeeRisq

Hi all,

I just want to install buildout for use with my Django app, but I get
an error that I can't find any documentation for.

Here is what I am running:

C:\somedirectory>easy_install zc.buildout

This is what happens:

Searching for zc.buildout
Reading http://pypi.python.org/simple/zc.buildout/
No local packages or download links found for zc.buildout
error: Could not find a suitable distribution for Requirement.parse
('zc.buildout')

I've also tried installing virtualenv the same way and got the same
error. I apologize that it is not directly related to Django, but I
don't want to waste more time looking for an answer to what is
probably obvious to someone else. Thanks for reading.

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



ModelForm limit m2m choices

2009-08-12 Thread alain31

Hello,
I have a model with m2m foreign key:

Model1:
field = models.ManytoManyField(Model2)

and a ModelForm

class MyForm(ModelForm)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Filter based on dates

2009-08-12 Thread When ideas fail

Thanks, i'd just worked that out, was about to come and post it.

Thanks though.

On 12 Aug, 20:23, Dj Gilcrease  wrote:
> On Wed, Aug 12, 2009 at 12:02 PM, When ideas
>
> fail wrote:
> > def months_archive(request, year, month):
> >    blog_posts = Post.objects.all().order_by("-post_date")
>
> blog_posts = Post.objects.filter(post_date__year=year,
> post_date__month=month).order_by("-post_date")
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Django a good choice for a LAN app?

2009-08-12 Thread snfctech

Thanks, Jonas.

And do you think Django's ORM will be able to handle my multiple DB
connections, with read/write fields from different DB producs/ servers
on the same view (most of which will hopefully be ODBC compliant, but
some might not)?


On Aug 12, 11:32 am, Jonas Obrist  wrote:
> In my opinion writing it in django/html/... is a lot easier and faster
> than doing it in a real python GUI tool. Also you have the networking in
> your LAN taken care of by the browser.
>
> snfctech wrote:
> > One more question:  Any advantage to just using a Python GUI toolkit
> > instead?
>
> > On Aug 12, 9:18 am, snfctech  wrote:
>
> >> Thanks for all of the good feedback!
>
> >> At the very least I am enthusiastic about the health of this list! ;-)
>
> >> @Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
> >> sales/week).
>
> >> Sounds like the community feels Django is a good choice for my type of
> >> project.
>
> >> Thanks!
>
> >> On Aug 12, 5:18 am, Philippe Raoult  wrote:
>
> >>> I don't know what you mean by mid-sized but I deployed exactly what
> >>> you're describing in a 45-strong company. We have occasional browser
> >>> incompatibilities with ajax but overall django was very much the right
> >>> tool for the job. As a bonus the company's clients can now access a
> >>> restricted part of the application to monitor their files and dealings
> >>> over https. Employees can also log in from home over https without any
> >>> software/hardware prerequisite. We're also planning on adding some
> >>> smartphone friendly pages for specific tasks (billing when employees
> >>> are working offsite).
>
> >>> My app is around 25k lines of python+templates
>
> >>> Hope this helps you make your mind.
>
> >>> On Aug 11, 9:06 pm, snfctech  wrote:
>
>  I'm about to start a fairly large project for a mid-sized business
>  with a lot of integration with other systems (POS, accounting,
>  website, inventory, purchasing, etc.) The purpose of the system is to
>  try to reduce current data siloing and give employees role-based
>  access to the specific data entry and reports they need, as well as to
>  replace some manual and redundant business processes. The system needs
>  to be cross-platform (Windows/Linux), open source and is primarily for
>  LAN use.
>
>  My experience is mostly PHP/web/app development, but I have developed
>  a few LAN apps using Java/Servoy (like Filemaker). I am leaning
>  towards Python/Django - but wondering whether this may be
>  unnecessarily web-specific. I really felt Servoy development was very
>  rapid, and it was cross-paltform, but it was not open source (not to
>  mention that anything custom needed to be Java which I find too
>  verbose/ slow to develop in). Or maybe Open Office Base and some
>  scripting is sufficient to handle my needs.
>
>  So, my main question is: Does a web framework like Django sound like a
>  reasonable platform to build a LAN Dashboard for a mid-sized company?
>  Or am I thinking too much like a web developer?
>
>  Any tips or suggestions would be greatly appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Filter based on dates

2009-08-12 Thread Dj Gilcrease

On Wed, Aug 12, 2009 at 12:02 PM, When ideas
fail wrote:
> def months_archive(request, year, month):
>    blog_posts = Post.objects.all().order_by("-post_date")

blog_posts = Post.objects.filter(post_date__year=year,
post_date__month=month).order_by("-post_date")

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Django a good choice for a LAN app?

2009-08-12 Thread Jonas Obrist

In my opinion writing it in django/html/... is a lot easier and faster 
than doing it in a real python GUI tool. Also you have the networking in 
your LAN taken care of by the browser.


snfctech wrote:
> One more question:  Any advantage to just using a Python GUI toolkit
> instead?
>
> On Aug 12, 9:18 am, snfctech  wrote:
>   
>> Thanks for all of the good feedback!
>>
>> At the very least I am enthusiastic about the health of this list! ;-)
>>
>> @Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
>> sales/week).
>>
>> Sounds like the community feels Django is a good choice for my type of
>> project.
>>
>> Thanks!
>>
>> On Aug 12, 5:18 am, Philippe Raoult  wrote:
>>
>> 
>>> I don't know what you mean by mid-sized but I deployed exactly what
>>> you're describing in a 45-strong company. We have occasional browser
>>> incompatibilities with ajax but overall django was very much the right
>>> tool for the job. As a bonus the company's clients can now access a
>>> restricted part of the application to monitor their files and dealings
>>> over https. Employees can also log in from home over https without any
>>> software/hardware prerequisite. We're also planning on adding some
>>> smartphone friendly pages for specific tasks (billing when employees
>>> are working offsite).
>>>   
>>> My app is around 25k lines of python+templates
>>>   
>>> Hope this helps you make your mind.
>>>   
>>> On Aug 11, 9:06 pm, snfctech  wrote:
>>>   
 I'm about to start a fairly large project for a mid-sized business
 with a lot of integration with other systems (POS, accounting,
 website, inventory, purchasing, etc.) The purpose of the system is to
 try to reduce current data siloing and give employees role-based
 access to the specific data entry and reports they need, as well as to
 replace some manual and redundant business processes. The system needs
 to be cross-platform (Windows/Linux), open source and is primarily for
 LAN use.
 
 My experience is mostly PHP/web/app development, but I have developed
 a few LAN apps using Java/Servoy (like Filemaker). I am leaning
 towards Python/Django - but wondering whether this may be
 unnecessarily web-specific. I really felt Servoy development was very
 rapid, and it was cross-paltform, but it was not open source (not to
 mention that anything custom needed to be Java which I find too
 verbose/ slow to develop in). Or maybe Open Office Base and some
 scripting is sufficient to handle my needs.
 
 So, my main question is: Does a web framework like Django sound like a
 reasonable platform to build a LAN Dashboard for a mid-sized company?
 Or am I thinking too much like a web developer?
 
 Any tips or suggestions would be greatly appreciated.
 
> >
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Location of Change User admin template

2009-08-12 Thread bfrederi

I found this: 
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L192
So it looks like it will allow me to override the template here:
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L586

So if I can override this effectively:
http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/admin.py

Here is a helpful guide:
http://pyxx.org/2008/08/18/how-to-extend-user-model-in-django-and-enable-new-fields-in-newforms-admin/

This will allow me to override the change_form template. If indeed
that is the template I am looking to override. I can't really
understand the template well enough to know how to add a button. But I
will hack away if my hunch turns out to be right:
http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/templates/admin/change_form.html

Anyway. With any luck, I will accomplish my simple and pathetic little
button. Seems like it should be more simple than this, but I guess the
developers of Django had a good reason to make admin much more
complicated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Django a good choice for a LAN app?

2009-08-12 Thread snfctech

One more question:  Any advantage to just using a Python GUI toolkit
instead?

On Aug 12, 9:18 am, snfctech  wrote:
> Thanks for all of the good feedback!
>
> At the very least I am enthusiastic about the health of this list! ;-)
>
> @Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
> sales/week).
>
> Sounds like the community feels Django is a good choice for my type of
> project.
>
> Thanks!
>
> On Aug 12, 5:18 am, Philippe Raoult  wrote:
>
> > I don't know what you mean by mid-sized but I deployed exactly what
> > you're describing in a 45-strong company. We have occasional browser
> > incompatibilities with ajax but overall django was very much the right
> > tool for the job. As a bonus the company's clients can now access a
> > restricted part of the application to monitor their files and dealings
> > over https. Employees can also log in from home over https without any
> > software/hardware prerequisite. We're also planning on adding some
> > smartphone friendly pages for specific tasks (billing when employees
> > are working offsite).
>
> > My app is around 25k lines of python+templates
>
> > Hope this helps you make your mind.
>
> > On Aug 11, 9:06 pm, snfctech  wrote:
>
> > > I'm about to start a fairly large project for a mid-sized business
> > > with a lot of integration with other systems (POS, accounting,
> > > website, inventory, purchasing, etc.) The purpose of the system is to
> > > try to reduce current data siloing and give employees role-based
> > > access to the specific data entry and reports they need, as well as to
> > > replace some manual and redundant business processes. The system needs
> > > to be cross-platform (Windows/Linux), open source and is primarily for
> > > LAN use.
>
> > > My experience is mostly PHP/web/app development, but I have developed
> > > a few LAN apps using Java/Servoy (like Filemaker). I am leaning
> > > towards Python/Django - but wondering whether this may be
> > > unnecessarily web-specific. I really felt Servoy development was very
> > > rapid, and it was cross-paltform, but it was not open source (not to
> > > mention that anything custom needed to be Java which I find too
> > > verbose/ slow to develop in). Or maybe Open Office Base and some
> > > scripting is sufficient to handle my needs.
>
> > > So, my main question is: Does a web framework like Django sound like a
> > > reasonable platform to build a LAN Dashboard for a mid-sized company?
> > > Or am I thinking too much like a web developer?
>
> > > Any tips or suggestions would be greatly appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Filter based on dates

2009-08-12 Thread When ideas fail

Hello, if i have this view:

def months_archive(request, year, month):
blog_posts = Post.objects.all().order_by("-post_date")
...

how can i filter the post objects by date?

I have a field post_date which is a datetime field, and i need it to
return all the posts written during the specified month in the year. I
had a few goes but i'm stuck. I'd appreciate any 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
-~--~~~~--~~--~--~---



Re: More Than Two Models With inlineformset_factory

2009-08-12 Thread Geraldo

No, I mean two or more different forms.  I'd like Parent, Child1 AND
Child2 all in the same formset.  What you've suggested though, should
get me where I want to go.

Thanks again,
Gerry

On Aug 12, 12:53 am, Matthias Kestenholz
 wrote:
> On Wed, Aug 12, 2009 at 12:51 AM, Geraldo wrote:
>
> > Excellent, Matthias...  That should work nicely.  It does appear,
> > however, that there is no way to have more than 2 forms in a single
> > formset.  If inlineformset_factory had an append method things might
> > be a bit cleaner.
>
> I presume you mean more than two forms of the same type (Child1 or
> Child2)? That's easily possible, and we use it all the time. Take a
> look at the max_num and extra parameters to the factory function.
>
> Matthias
>
> --
> FeinCMS Django CMS building toolkit:http://spinlock.ch/pub/feincms/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: solved: Need help with filter, limit and order_by query

2009-08-12 Thread cerberos

On Aug 13, 12:06 am, cerberos  wrote:
> On Aug 12, 11:52 pm, Alex Gaynor  wrote:
>
>
>
> > On Wed, Aug 12, 2009 at 11:49 AM, cerberos wrote:
>
> > > Say there are 10 records, I want records 3 & 4 in descending order.
>
> > > q1 = ModelName.objects.order_by('id').filter(id__gte=3)[:2] # gives
> > > the records I want but in ascending order
> > > q2 = ModelName.objects.order_by('-id').filter(id__gte=3)[:2] # gives
> > > the last 2 records (9 & 10) in correct order
> > > q3 = ModelName.objects.order_by('id').filter(id__gte=3)[:2].order_by('-
> > > id') # Assertion Error: cannot reorder query once a slice has been
> > > taken
> > > q4 = ModelName.objects.order_by('id').filter(id__gte=3)[:2].reverse()
> > > # Same as q2
>
> > > So can I get the correct records in the wrong order or incorrect
> > > records in the right order. I think I need to use extra() but don't
> > > know how exactly (I have read the docs and had a few attempts but the
> > > results were as above).
>
> > Your best bet would be to take the items you want.  And do
>
> > items = list(items)
> > items.reverse()
>
> > to put them in the correct order in Python, this is going to be easier
> > than mucking around with custom SQL.
>
> > Alex
>
> > --
> > "I disapprove of what you say, but I will defend to the death your
> > right to say it." -- Voltaire
> > "The people's good is the highest law." -- Cicero
> > "Code can always be simpler than you think, but never as simple as you
> > want" -- Me
>
> Thanks, I realised that converting to a list would work just after I
> posted.
>
> That led me to a solution. For some reason I was trying id_gte=3, with
> id_lte=4 this solution works.
>
> ModelName.objects.order_by('id').filter(id__lte=4)[:2]


above should be order_by('-id')

I should add that the solution I'm using works for my situation but it
doesn't solve the originally posted problem - I'm now specifying
record 4 instead of 3.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



solved: Need help with filter, limit and order_by query

2009-08-12 Thread cerberos

On Aug 12, 11:52 pm, Alex Gaynor  wrote:
> On Wed, Aug 12, 2009 at 11:49 AM, cerberos wrote:
>
> > Say there are 10 records, I want records 3 & 4 in descending order.
>
> > q1 = ModelName.objects.order_by('id').filter(id__gte=3)[:2] # gives
> > the records I want but in ascending order
> > q2 = ModelName.objects.order_by('-id').filter(id__gte=3)[:2] # gives
> > the last 2 records (9 & 10) in correct order
> > q3 = ModelName.objects.order_by('id').filter(id__gte=3)[:2].order_by('-
> > id') # Assertion Error: cannot reorder query once a slice has been
> > taken
> > q4 = ModelName.objects.order_by('id').filter(id__gte=3)[:2].reverse()
> > # Same as q2
>
> > So can I get the correct records in the wrong order or incorrect
> > records in the right order. I think I need to use extra() but don't
> > know how exactly (I have read the docs and had a few attempts but the
> > results were as above).
>
> Your best bet would be to take the items you want.  And do
>
> items = list(items)
> items.reverse()
>
> to put them in the correct order in Python, this is going to be easier
> than mucking around with custom SQL.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me

Thanks, I realised that converting to a list would work just after I
posted.

That led me to a solution. For some reason I was trying id_gte=3, with
id_lte=4 this solution works.

ModelName.objects.order_by('id').filter(id__lte=4)[:2]



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Strange problem with LDAP authentication backend

2009-08-12 Thread stupidgeek

David, you are a champ, thank you.
I find it strange that this made the difference, since this line is in
the docs:

"The get_user method takes a user_id -- which could be a username,
database ID or whatever -- and returns a User object."

But, making the change to user_id worked just fine. For eveyone's
reference, here is a working (simple) backend for an open directory
server, using sasl cram_md5, with a self-signed certificate:

from django.contrib.auth.models import
User
import ldap
import
ldap.sasl

class LDAPBackend:
def authenticate(self, username=None,
password=None):
if username and
password:
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,
ldap.OPT_X_TLS_NEVER)
directory = 'ldaps://MYSERVERURL'
base_dn =
'MYBASEDN'
scope =
ldap.SCOPE_SUBTREE
con = ldap.initialize
(directory)
auth_tokens = ldap.sasl.cram_md5(username, password)
try:
con.sasl_interactive_bind_s("", auth_tokens)
except ldap.LDAPError:
return
None
con.unbind()
try:
user = User.objects.get
(username=username)
print
user
return
user
except
User.DoesNotExist:
return
None

def get_user(self,
user_id):
try:
   user = User.objects.get
(id=user_id)
   return user
except User.DoesNotExist:
return None

Many thanks again to David and Peter.

Brenton.

On Aug 12, 12:31 pm, David De La Harpe Golden
 wrote:
> stupidgeek wrote:
> >     def get_user(self, username):
> >         try:
> >            user = User.objects.get(username=username)
> >            print user
> >            return user
> >         except User.DoesNotExist:
> >             return None
>
> Note part of the auth backend protocol AFAICS involves calling
> get_user() itself* (not just authenticate()), and it is expected to take
> a user_id arg, not username, i.e. you very likely need it to be:
>
> def get_user(self, user_id):
>     try:
>        return User.objects.get(pk=user_id)
>     except User.DoesNotExist:
>        return None
>
> * django/contrib/auth/__init__.py
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Need help with filter, limit and order_by query

2009-08-12 Thread Alex Gaynor

On Wed, Aug 12, 2009 at 11:49 AM, cerberos wrote:
>
> Say there are 10 records, I want records 3 & 4 in descending order.
>
> q1 = ModelName.objects.order_by('id').filter(id__gte=3)[:2] # gives
> the records I want but in ascending order
> q2 = ModelName.objects.order_by('-id').filter(id__gte=3)[:2] # gives
> the last 2 records (9 & 10) in correct order
> q3 = ModelName.objects.order_by('id').filter(id__gte=3)[:2].order_by('-
> id') # Assertion Error: cannot reorder query once a slice has been
> taken
> q4 = ModelName.objects.order_by('id').filter(id__gte=3)[:2].reverse()
> # Same as q2
>
> So can I get the correct records in the wrong order or incorrect
> records in the right order. I think I need to use extra() but don't
> know how exactly (I have read the docs and had a few attempts but the
> results were as above).
> >
>

Your best bet would be to take the items you want.  And do

items = list(items)
items.reverse()

to put them in the correct order in Python, this is going to be easier
than mucking around with custom SQL.

Alex

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

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



Need help with filter, limit and order_by query

2009-08-12 Thread cerberos

Say there are 10 records, I want records 3 & 4 in descending order.

q1 = ModelName.objects.order_by('id').filter(id__gte=3)[:2] # gives
the records I want but in ascending order
q2 = ModelName.objects.order_by('-id').filter(id__gte=3)[:2] # gives
the last 2 records (9 & 10) in correct order
q3 = ModelName.objects.order_by('id').filter(id__gte=3)[:2].order_by('-
id') # Assertion Error: cannot reorder query once a slice has been
taken
q4 = ModelName.objects.order_by('id').filter(id__gte=3)[:2].reverse()
# Same as q2

So can I get the correct records in the wrong order or incorrect
records in the right order. I think I need to use extra() but don't
know how exactly (I have read the docs and had a few attempts but the
results were as above).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Location of Change User admin template

2009-08-12 Thread bfrederi

I think you are right that a ModelAdmin definition must exist for it.
But I have been digging for it and can't seem to find it.

I am seeking to place a button on that page that will allow the user
to update the permissions the user can have. I have a function written
in my model that creates permissions based on something on another
server. The staff that are giving the users their permissions need a
way to update the permissions manually. Any suggestions? I have easily
made it to where the permissions update when a new user is created.
But I need a button for manual updates.

Thanks,
Brandon

On Aug 11, 11:13 pm, Karen Tracey  wrote:
> On Tue, Aug 11, 2009 at 11:57 PM, Russell Keith-Magee <
>
>
>
> freakboy3...@gmail.com> wrote:
>
> > On Wed, Aug 12, 2009 at 10:24 AM, Karen Tracey wrote:
> > > On Tue, Aug 11, 2009 at 4:14 PM, bfrederi 
> > wrote:
>
> > >> I was browsing contrib/admin templates for the "Change User" template
> > >> that allows you to change the user's permissions and such. I can't
> > >> seem to find it though. Can anyone point me in the right direction?
>
> > > Admin doesn't have special templates for certain models, so far as I
> > know.
>
> > Incorrect. See contrib/admin/templates/admin/auth/user. The general
> > capability to override templates on a per-model basis is generic. User
> > is the only model that exploits this capability by default.
>
> Yeah, I did find those and then failed to revise the sentence.  I don't see
> a template there for editing a user, though, just adding, changing password,
> and confirming delete.  So I think the template for "Change User" is not
> customized in any special way for User, it's the standard admin change
> template.  So how to get a similar effect (which is what I was guessing the
> real underlying question was) for a different model would be found by
> looking at the UserAdmin ModelAdmin definitions.
>
> 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-tinymce not appearing in admin

2009-08-12 Thread Karen Tracey
On Wed, Aug 12, 2009 at 12:05 PM, diogobaeder  wrote:

>
> Oops, sorry... it's version 1.1 final.
>
> I'll try to create the Media subclass with the media, then, although
> it's not specified in the django-tinymce use documentation.
>
> About dpaste, I'm confused, because in another post I pasted exception
> content and someone advised me to use dpaste to make the thread more
> readable. Are you really sure this is a recommendation for this list?
>

If it's going to be unreadable in email, definitely put it somewhere else
and point to it.  Expecting people to wade through pages of badly wrapped
Python code (not that you did that) is a bit much.  Personally I'd rather
see single exception tracebacks inline than linked; even though they tend to
wrap poorly it's easy enough to focus on the important bits.

It's a judgment call for what is better linked vs. inline.  Not every thread
is going to be useful for searching and finding solutions to similar
problems.  Moving the details out of line makes a thread less likely to be
useful for that, but there are enough re-occurrances of the common errors
that likely they get covered by inline mentions soon enough.

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: Strange problem with LDAP authentication backend

2009-08-12 Thread David De La Harpe Golden

stupidgeek wrote:


> def get_user(self, username):
> try:
>user = User.objects.get(username=username)
>print user
>return user
> except User.DoesNotExist:
> return None
> 

Note part of the auth backend protocol AFAICS involves calling
get_user() itself* (not just authenticate()), and it is expected to take
a user_id arg, not username, i.e. you very likely need it to be:

def get_user(self, user_id):
try:
   return User.objects.get(pk=user_id)
except User.DoesNotExist:
   return None



* django/contrib/auth/__init__.py







--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 Django a good choice for a LAN app?

2009-08-12 Thread snfctech

Thanks for all of the good feedback!

At the very least I am enthusiastic about the health of this list! ;-)

@Philippe: By mid-size I mean ~70 people in a retail business (~$500K/
sales/week).

Sounds like the community feels Django is a good choice for my type of
project.

Thanks!

On Aug 12, 5:18 am, Philippe Raoult  wrote:
> I don't know what you mean by mid-sized but I deployed exactly what
> you're describing in a 45-strong company. We have occasional browser
> incompatibilities with ajax but overall django was very much the right
> tool for the job. As a bonus the company's clients can now access a
> restricted part of the application to monitor their files and dealings
> over https. Employees can also log in from home over https without any
> software/hardware prerequisite. We're also planning on adding some
> smartphone friendly pages for specific tasks (billing when employees
> are working offsite).
>
> My app is around 25k lines of python+templates
>
> Hope this helps you make your mind.
>
> On Aug 11, 9:06 pm, snfctech  wrote:
>
> > I'm about to start a fairly large project for a mid-sized business
> > with a lot of integration with other systems (POS, accounting,
> > website, inventory, purchasing, etc.) The purpose of the system is to
> > try to reduce current data siloing and give employees role-based
> > access to the specific data entry and reports they need, as well as to
> > replace some manual and redundant business processes. The system needs
> > to be cross-platform (Windows/Linux), open source and is primarily for
> > LAN use.
>
> > My experience is mostly PHP/web/app development, but I have developed
> > a few LAN apps using Java/Servoy (like Filemaker). I am leaning
> > towards Python/Django - but wondering whether this may be
> > unnecessarily web-specific. I really felt Servoy development was very
> > rapid, and it was cross-paltform, but it was not open source (not to
> > mention that anything custom needed to be Java which I find too
> > verbose/ slow to develop in). Or maybe Open Office Base and some
> > scripting is sufficient to handle my needs.
>
> > So, my main question is: Does a web framework like Django sound like a
> > reasonable platform to build a LAN Dashboard for a mid-sized company?
> > Or am I thinking too much like a web developer?
>
> > Any tips or suggestions would be greatly appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Ticket #7539 (ON DELETE suppor) in Django 1.2?

2009-08-12 Thread Michael Glassford

Sorry, please ignore this post: it was supposed to go to the django 
developers group.

Mike



Michael Glassford wrote:
> http://code.djangoproject.com/ticket/7539 suggests a way to add On 
> Delete and On Update support to Django foreign key fields, and includes 
> a patch that implements the suggestions. At the time I submitted it, 
> getting Django 1.1 out the door prevented it from being seriously 
> considered, but now that 1.2 is in the planning stages, how about it?
> 
> The ticket actually suggests several changes:
> 
> 1) Adding an on_delete parameter to ForeignKey definitions and allowing 
> it to specify CASCADE, SET_NULL, or RESTRICT behavior.
> 
> 2) Modifying Django's built-in behavior, which currently always cascades 
> deletes, to handle the new SET_NULL and RESTRICT behaviors. Django still 
> defaults to CASCADE behavior for foreign keys that don't specify an 
> on_delete parameter.
> 
> 3) Allowing settings files to change the default on delete behavior from 
> CASCADE to one of the other options for foreign keys that don't specify 
> an on_delete parameter.
> 
> 4) Allowing settings files to specify that the on_delete behavior should 
> be handled by the database backend rather than by Django, and changing 
> the SQL generated by Django to contain appropriate ON DELETE clauses.
> 
> 5) Adding an on_update parameter to ForeignKey definitions. Unlike the 
> on_delete parameter, the patch doesn't implement built-in emulation of 
> on_update: on_update clauses are only handled by the database backend.
> 
> 
> I believe that items 1-3 are in a form that is usable with little 
> modification, and would like to suggest that at least this much be added 
> to 1.2.
> 
> Items 4 and 5 would need more work to support more back ends before it 
> makes sense to include them.
> 
> It might also be nice to have an implementation of item 5 that doesn't 
> depend on the db backend, although this might require a significant 
> amount of work.
> 
> 
> > 
> 


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



Re: Strange problem with LDAP authentication backend

2009-08-12 Thread stupidgeek

Hi Peter,

Thanks for your input, but I am afraid to say that you are indeed
wrong =( Ha.

The user that I am trying to login as (me) has superuser premissions;
by no errors, I mean that I get a plain login form - no red box
telling me something went wrong.

Thanks again for the input, and I'll grab a look at your app if I have
time, although I can't promise to be of much help, as I had help from
my department's LDAP guy to get the sasl bind working.

Meanwhile, the mystery continues - any other suggestions, folks?

On Aug 12, 11:48 am, Peter Herndon  wrote:
> On 08/12/2009 11:17 AM, stupidgeek wrote:
>
>
>
> > Hi all,
>
> > I'm having a strange problem. I wrote a basic LDAP backend, to
> > authenticate users against our open directory server:
>
> > [snip]
>
> > Note that the print user line works, so a valid user is being
> > returned, meaning the bind works just fine.
>
> > The problem I am getting is that the GET /admin/ is returning me to
> > the login form, without any errors, over and over. A login using a
> > user from the django db works without a problem.
>
> > Any suggestions?
>
> Hi Brenton,
>
> Your GET /admin/ is returning "without any errors".  By that, do you
> mean that it is sending you back to the login form and telling you to
> input a *correct* username and password?  If so, the thing I ran into
> with this is that the django.contrib.auth.models.User model has two
> attributes, is_staff and is_superuser.  If you are NOT setting at least
> is_staff = True, then your user is not allowed to access the admin,
> period, and you'll never get past the login screen.  If you go into
> /admin/ as an actual admin user, you'll likely see your user created in
> the Users section, but with no staff or superuser permissions.
>
> I actually very recently wrote an app to help with this sort of 
> thing,http://code.google.com/p/django-ldap-groups/, though I haven't targeted
> Open Directory or LDAP servers using SASL auth.  I'd be happy to work
> with you to add Open Directory to the list of supported servers.
>
> It is very new (about a week old or so), and has boogs, but I'd love to
> see if it helps your problem.
>
> (Of course, the fun part about LDAP is that my diagnosis may be entirely
> wrong, too...  ;)
>
> Regards,
>
> ---Peter Herndon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-tinymce not appearing in admin

2009-08-12 Thread diogobaeder

Oops, sorry... it's version 1.1 final.

I'll try to create the Media subclass with the media, then, although
it's not specified in the django-tinymce use documentation.

About dpaste, I'm confused, because in another post I pasted exception
content and someone advised me to use dpaste to make the thread more
readable. Are you really sure this is a recommendation for this list?

Thanks, Kenneth,

Diogo



On Aug 12, 2:45 am, Kenneth Gonsalves  wrote:
> On Wednesday 12 Aug 2009 11:08:55 am diogobaeder wrote:
>
> > I configured django-tinymce extension to work with a model field; It
> > loads all the JavaScript correctly, right after the field, in a script
> > tag, passing the right element ID, but the editor simply doesn't show,
> > only the original textarea is present. Here is a piece of my project
> > where TinyMCE configuration should be entered:
>
> >http://dpaste.com/hold/78621/
>
> > Anything wrong in here?
>
> you have not specified which django version you are using. If it is trunk, I 
> am
> under the impression that you need a Media subclass to your model.Admin class
> in admin.py to hold the tiny_mce settings. In older versions of django this
> was in the Admin subclass. btw, in a mailing list it is not advisable to paste
> in dpaste as that will vanish and b0rk the archives.
> --
> regards
> kghttp://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
-~--~~~~--~~--~--~---



Ticket #7539 (ON DELETE suppor) in Django 1.2?

2009-08-12 Thread Michael Glassford

http://code.djangoproject.com/ticket/7539 suggests a way to add On 
Delete and On Update support to Django foreign key fields, and includes 
a patch that implements the suggestions. At the time I submitted it, 
getting Django 1.1 out the door prevented it from being seriously 
considered, but now that 1.2 is in the planning stages, how about it?

The ticket actually suggests several changes:

1) Adding an on_delete parameter to ForeignKey definitions and allowing 
it to specify CASCADE, SET_NULL, or RESTRICT behavior.

2) Modifying Django's built-in behavior, which currently always cascades 
deletes, to handle the new SET_NULL and RESTRICT behaviors. Django still 
defaults to CASCADE behavior for foreign keys that don't specify an 
on_delete parameter.

3) Allowing settings files to change the default on delete behavior from 
CASCADE to one of the other options for foreign keys that don't specify 
an on_delete parameter.

4) Allowing settings files to specify that the on_delete behavior should 
be handled by the database backend rather than by Django, and changing 
the SQL generated by Django to contain appropriate ON DELETE clauses.

5) Adding an on_update parameter to ForeignKey definitions. Unlike the 
on_delete parameter, the patch doesn't implement built-in emulation of 
on_update: on_update clauses are only handled by the database backend.


I believe that items 1-3 are in a form that is usable with little 
modification, and would like to suggest that at least this much be added 
to 1.2.

Items 4 and 5 would need more work to support more back ends before it 
makes sense to include them.

It might also be nice to have an implementation of item 5 that doesn't 
depend on the db backend, although this might require a significant 
amount of work.


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



Use unicode character as variable in template.

2009-08-12 Thread timesong

In Django template, there is a very nice feature, we can use unicode
character variable in template, for example:

{% for article in 文章列表 %}
{{ article.title }} 
{% endfor %}

In this way, if you didn't define 文章列表 in context, it'll raise an
exception: Caught an exception while rendering: 'ascii' codec can't
encode characters in position 0-3: ordinal not in range(128). but if
we use an ascii based variable without pre-define, there isn't an
exception.

So I just add two lines to resolve this question, in django/template/
__init__.py", line 734-735, I used django 1.0

730except Exception, e:
731if getattr(e, 'silent_variable_failure',
False):
732current =
settings.TEMPLATE_STRING_IF_INVALID
733# Add by Timesong 2009/08/12
734   elif not isinstance(bit, str):
735current =
settings.TEMPLATE_STRING_IF_INVALID
736# End add
737else:
738raise

Hope this is useful.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



override _display_login_form

2009-08-12 Thread Davo

Hi I am trying to override the _display_login_form from

http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/views/decorators.py

So basicly I have the following code
--
from django.http import HttpResponseRedirect
from django.contrib.admin.views import decorators

def _redirect_login(request, *args, **kwargs):
return HttpResponseRedirect('http://www.google.com')

decorators._display_login_form = _redirect_login
--

I tried to add this inside models/middleware(precess_request)/urls
every time when I visit the admin login page I am not redirected at
all. am I missing something?

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Strange problem with LDAP authentication backend

2009-08-12 Thread stupidgeek

Hi all,

I'm having a strange problem. I wrote a basic LDAP backend, to
authenticate users against our open directory server:

from django.contrib.auth.models import User
import ldap
import ldap.sasl

class LDAPBackend:
def authenticate(self, username=None, password=None):
if username and password:
ldap.set_option(ldap.OPT_X_TLS_REQUIRE_CERT,
ldap.OPT_X_TLS_NEVER)
directory = 'ldaps://MYSERVERURL'
base_dn = 'MYBASEDN'
scope = ldap.SCOPE_SUBTREE
con = ldap.initialize(directory)
auth_tokens = ldap.sasl.cram_md5(username, password)
try:
con.sasl_interactive_bind_s("", auth_tokens)
except ldap.LDAPError:
return None
con.unbind()
return self.get_user(username)
return None

def get_user(self, username):
try:
   user = User.objects.get(username=username)
   print user
   return user
except User.DoesNotExist:
return None

Now, I know this works, because a) it works just lovely in the shell
and b) I get this output when I try a login:

Django version 1.0.2 final, using settings 'reviews.settings'
Development server is running at http://0.0.0.0:80/
Quit the server with CONTROL-C.
brenton
[11/Aug/2009 13:25:01] "POST /admin/ HTTP/1.1" 302 0
[11/Aug/2009 13:25:01] "GET /admin/ HTTP/1.1" 200 1511

Note that the print user line works, so a valid user is being
returned, meaning the bind works just fine.

The problem I am getting is that the GET /admin/ is returning me to
the login form, without any errors, over and over. A login using a
user from the django db works without a problem.

Any suggestions?

Thanks,
Brenton.

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



Re: Need for an internationalization/translation system not request-based

2009-08-12 Thread Andrea Zilio

I'm sorry, can you explain a little bit this problem? Or where I can
get info about it?

On Aug 12, 3:48 pm, Jarek Zgoda  wrote:
> Wiadomość napisana w dniu 2009-08-12, o godz. 13:00, przez Enrico  
> Sartorello:
>
> > i'm facing a problem developing with Django a Web Application: in
> > response to some events (for example, after an admin action) i need to
> >sendemailsto some users of my site.
>
> > The problem arises when i want theseemailsto be translated in any
> > user-specific language: the Request object i have just contains the
> > language infos of the user that trigger the event, so it's not what i
> > need.
> > Generally, LocaleMiddleware behaviour can't do that job, because is
> > based on sessions and cookies of a particular user.
> > Roughly speaking i need (at least) a way to manually decide which is
> > the language to apply for translations.
>
> OnceIneededtosendemailsinHungarianfromEnglishapplication and  
> this worked.
>
> Before translating any string you need to know which language to use.  
> If you have this information handy somewhere you can just switch the  
> translation catalog safely in separated process environments (FastCGI,  
> WSGI). As translation.activate() is process-wide, this approach is not  
> safe in multithreaded environment if using static translation (not  
> request-based).
>
> --
> Artificial intelligence stands no chance against natural stupidity
>
> Jarek Zgoda, R, Redefine
> jarek.zg...@redefine.pl

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



Re: syncdb with ForeignKey to_field outputs statements in wrong order

2009-08-12 Thread physicsnick

Hmm. It seems to be database-specific. PostgreSQL and Oracle require
that foreign key references be unique, while MySQL and SQLite do not
(although for SQLite that's mainly due to it not actually implementing
foreign key constraints). The MySQL documentation has this to say:

>> Additionally, MySQL and InnoDB require that the referenced columns be 
>> indexed for performance. However, the system does not enforce a requirement 
>> that the referenced columns be UNIQUE or be declared NOT NULL. The handling 
>> of foreign key references to nonunique keys or keys that contain NULL values 
>> is not well defined for operations such as UPDATE or DELETE CASCADE.

... which we never do, because it's a temporal database. It does
recommend that they be unique anyway though.

I'll file a bug with Django to make the validate command require that
foreign keys reference unique columns, and to update the documentation
to actually say that the to_field should be unique. In the meantime
I'll have to make a reference field that supports foreign key
semantics (e.g. book.author and Author.book_set) that doesn't actually
subclass ForeignKey. :/

Thanks,

Nick


On Aug 11, 10:00 pm, Malcolm Tredinnick 
wrote:
> On Tue, 2009-08-11 at 12:00 -0700, physicsnick wrote:
> > Actually they don't need to be unique (and I don't want them to be
> > unique). MySQL does not require that foreign keys be unique; only that
> > they be indexed.
>
> > I am actually using this for a temporal database. There are many
> > instances of an Author with the same code (an instance for each time
> > it was changed). In  relation to the above example I am having the
> > Author's default manager filter for live instances of the object, and
> > making it be used to resolve foreign keys via "use_for_related_fields
> > = True". This means the reverse relationship (book.author) gives one
> > object: the live version of the author with the referenced code. While
> > the foreign key itself is a many-to-many relation at the database
> > level,
>
> Django's ForeignKey field is many-to-one. The fact that it happens not
> to raise an error when you twist it slightly in the way you're doing
> doesn't mean it's expected to work.
>
> I'm not convinced there is a bug involved here, since you're not using
> the ForeignKey class correctly. As far as I can work out, when
> ForeignKey is used correctly, we always are going to be generating the
> correct SQL.
>
> I thought Django's "validate" management command raised an error when
> to_field was used to target a non-unique field, but apparently I'm
> hallucinating. That's probably an oversight in the implementation.
>
> 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: problem with the delete()

2009-08-12 Thread Karen Tracey
On Wed, Aug 12, 2009 at 10:44 AM, Lokesh  wrote:

>
> Hi Karen,
>
> Provided the details below.
> Here is the Traceback and Django version is 1.2


I assume you mean SVN trunk?  1.2 is in early "what might go in it" stage,
it's far from being a released version.


>
>
> Traceback (most recent call last):
> [snip] File "C:\Python25\Lib\site-packages\django\db\models\fields
> \__init__.py", line 361, in get_db_prep_value
>return int(value)
> ValueError: invalid literal for int() with base 10: 'lokesh'
> >>>
>

Thanks.  I believe this is:

http://code.djangoproject.com/ticket/11319

If you look at the history of the related ticket #10785 you'll see an
attempt was made to fix this for 1.1 but it caused more problems than it
fixed, so the larger issue was deferred to 1.2.

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: DateInput widget, format attr & ugettext

2009-08-12 Thread carsten

Thanks, Malcolm!

I filed the ugettext_lazy problem under #11701 and attached a patch
that fixes it by using force_unicode() on the format in DateWidget.

FWIW, users could also workaround this thing by using their forms
__init__, like so:

def __init__(self, *args, **kwargs):
super(SomeForm, self).__init__(*args, **kwargs)
self.fields['some_date'].widget.format = ugettext_lazy('%d.%m.
%Y')

Seems, the __proxy__ then already is a string/unicode when reaching
the widgets formatting method.


On Aug 7, 5:39 am, Malcolm Tredinnick 
wrote:
> On Fri, 2009-08-07 at 11:56 +1000, Malcolm Tredinnick wrote:
> > On Thu, 2009-08-06 at 08:06 -0700, cArkraus wrote:
> > > Hey all,
>
> > > I cant seem to get my (non-model-)forms datefield localized.
>
> > > Here's my first attempt:
> > > some_date = fields.DateField(widget=widgets.DateInput(format=ugettext
> > > ('%d.%m.%Y')))
>
> > This would do the translation when the file is imported, which won't
> > reflect the user's current locale. The working rule is that you don't
> > use ugettext() outside of a view function (or something called directly
> > by a view).
>
> > > That's working fine, until the user switches his sessions language.
> > > Then, the date is still shown in the format(ie. '%d.%m.%Y') and not
> > > the correctly localized one(ie. '%Y-%m-%d').
>
> > > Now, if I change to ugettext_lazy() like this:
>
> > > some_date = fields.DateField(widget=widgets.DateInput
> > > (format=ugettext_lazy('%d.%m.%Y')))
>
> > > I get a TemplateSyntaxError 'strftime() argument 1 must be string or
> > > read-only buffer, not __proxy__'
>
> > That's a bug in Django and Python (both sides share some blame: Python's
> > string handling is retarded in cases like this and Django doesn't work
> > around it correctly here). It's not particularly easy to work around it,
> > either.
>
> This came about ambiguously: without hunting down the offending place
> right at the moment, I'm still fairly certain it's easy to fix this in
> Django's core. I can't think of an easy way to work around it in Django
> apps, however (that might be because I'm not imaginative enough).
>
> 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: problem with the delete()

2009-08-12 Thread Lokesh

Hi Karen,

Provided the details below.
Here is the Traceback and Django version is 1.2

Traceback (most recent call last):
  File "", line 1, in 
  File "c:\Python25\lib\site-packages\django\db\models\query.py", line
395, in delete
object._collect_sub_objects(seen_objs)
  File "c:\Python25\lib\site-packages\django\db\models\base.py", line
542, in _collect_sub_objects
delete_qs = rel_descriptor.delete_manager(self).all()
  File "c:\Python25\lib\site-packages\django\db\models\fields
\related.py", line 344, in delete_manager
self.related.model._base_manager.__class__)
  File "c:\Python25\lib\site-packages\django\db\models\fields
\related.py", line 399, in create_manager
getattr(instance, attname)}
  File "c:\Python25\lib\site-packages\django\db\models\fields
\related.py", line 257, in __get__
rel_obj = QuerySet(self.field.rel.to).get(**params)
  File "c:\Python25\lib\site-packages\django\db\models\query.py", line
299, in get
clone = self.filter(*args, **kwargs)
  File "c:\Python25\lib\site-packages\django\db\models\query.py", line
498, in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File "c:\Python25\lib\site-packages\django\db\models\query.py", line
516, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File "c:\Python25\lib\site-packages\django\db\models\sql\query.py",
line 1675, in add_q
can_reuse=used_aliases)
  File "c:\Python25\lib\site-packages\django\db\models\sql\query.py",
line 1614, in add_filter
connector)
  File "C:\Python25\Lib\site-packages\django\db\models\sql\where.py",
line 56, in add
obj, params = obj.process(lookup_type, value)
  File "C:\Python25\Lib\site-packages\django\db\models\sql\where.py",
line 269, in process
params = self.field.get_db_prep_lookup(lookup_type, value)
  File "C:\Python25\Lib\site-packages\django\db\models\fields
\__init__.py", line 210, in get_db_prep_lookup
return [self.get_db_prep_value(value)]
  File "C:\Python25\Lib\site-packages\django\db\models\fields
\__init__.py", line 361, in get_db_prep_value
return int(value)
ValueError: invalid literal for int() with base 10: 'lokesh'
>>>

Lokesh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 aggregates and having

2009-08-12 Thread Alex Gaynor

On Wed, Aug 12, 2009 at 1:34 AM, lfrodrigues wrote:
>
> Sorry I didn't explain my self properly.
>
> I want this query:
> SELECT (date_format(date, '%%U')) AS `d`, SUM
> (`profile_scorehistory`.`points`) AS `l` FROM `profile_scorehistory`
> GROUP BY date_format(date, '%%U') HAVING  `d`= 2
>
> How can I make it with ORM?
>
> The other one was the only similar query I managed to make using the
> ORM.
>
>
> On Aug 12, 3:44 am, Russell Keith-Magee 
> wrote:
>> On Wed, Aug 12, 2009 at 5:50 AM, lfrodrigues wrote:
>>
>> > Hi,
>>
>> > I'm having some problems with "having":
>>
>> > I want to group by date and restrict to a given week, in my tests I
>> > can do this:
>> > select_data = {"d": """date_format(date, '%%U')"""}
>> > ScoreHistory.objects.extra(select=select_data).values('d').annotate
>> > (l=Sum("points")).filter(l=2).query.as_sql()
>>
>> > sql:
>> > SELECT (date_format(date, '%%U')) AS `d`, SUM
>> > (`profile_scorehistory`.`points`) AS `l` FROM `profile_scorehistory`
>> > GROUP BY date_format(date, '%%U') HAVING SUM
>> > (`profile_scorehistory`.`points`) = 2
>>
>> > Good but what I want to get is this:
>> > sql:
>> > SELECT (date_format(date, '%%U')) AS `d`, SUM
>> > (`profile_scorehistory`.`points`) AS `l` FROM `profile_scorehistory`
>> > GROUP BY date_format(date, '%%U') HAVING  `d`= 2
>>
>> I might be missing something here, but as far as I can make out,
>> you're getting exactly what you've asked for. Your query contains
>> filter(l=2) - that is, you're filtering on l, the SUM.
>>
>> > How can I force using having when I can't define the param in
>> > annotate?
>>
>> I'm afraid I don't see how this relates to your original question.
>>
>> Yours,
>> Russ Magee %-)
> >
>

You'd need to write a custom aggregate for the date_format function.
If you search this mailing list you can find a few examples of doing
that in past (or take a look at django/db/models/aggregates.py and
django/db/models/sql/aggregates.py for examples of how the ones in
Django itself look).

Alex

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

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



Re: problem with the delete()

2009-08-12 Thread Karen Tracey
On Wed, Aug 12, 2009 at 9:58 AM, Lokesh  wrote:

>
> Hi,
>
> Need help in understanding the relation between models and delete
> operations.
> Here is my model
>
> class UserBasicDetails(models.Model):
>user_id = models.OneToOneField(User, primary_key=True,
> to_field='username', parent_link=True)
>place = models.CharField(null=False, blank=False, max_length=30)
>
> Step1:
> user = User.objects.get(username='lokesh')
> bas = UserBasicDetails.objects.create(user_id = user, month='feb')
> Step2:
> After successful creation of the record i am trying to delete all the
> records from UserBasicDetails
> UserBasicDetails.objects.all().delete()
> Step3:
> Ended up with the error and pasted below
> ValueError: invalid literal for int() with base 10: 'lokesh'
>

Please supply the full traceback for this error, along with specifics of
what version of Django you are using.

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: IntegrityError!!!

2009-08-12 Thread Karen Tracey
On Wed, Aug 12, 2009 at 8:03 AM, rekha  wrote:

>
> Hi all,
> im a newbie, developing online address book application using django,
> mod_python, apache2, postgresql.
>
> i have two tables in my database viz login_table and contact_table..
> login_table stores username and password.. contact table stores first
> name, last name, phone number, email id.. username field in
> login_table is foreignkey to contact_table.. now my application want
> to access all the records from contact_table which corresponds to a
> particular username in the login_table.. but my code gives
> IntegrityError when try to do so.. how to fix this problem?
>

Again, if you want people to help you will likely need to put a little more
effort into providing good information about the problem.  Approx. 200 lines
of code and "IntegrityErorr" as the only clue is unlikely to result in
anyone attempting to dig in and point out where the errors may be.

An IntegrityError comes with a traceback, that pinpoints the line of code
(and the whole history of calls leading to it) that caused the error.
Including the traceback would help people help you.  You should also use it
to narrow the scope of the code you cut-and-paste into your questions.  The
call stack will show which of your routines are involved in triggering the
problem: including bunches of other views that aren't on the code path for
the problem is counterproductive.

It would also help if you got a lot more specific about what exactly you do
to cause the error.  Presumably you are accessing some url that is supposed
to result in a particular view being called.  Name that view, don't expect
people to dig through 200 lines of code to try to find where you are
"access[ing] all the records from contact_table which correspond to a
particular username in the login_table".

Without looking at the code I will say an IntegrityError is not something
you will get from trying to access records, it's an error you would get when
trying to save something to the database.  So I suspect your problem is
somewhere other than where you think it is and has nothing to do with that
particular lookup you mentioned.

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
-~--~~~~--~~--~--~---



problem with the delete()

2009-08-12 Thread Lokesh

Hi,

Need help in understanding the relation between models and delete
operations.
Here is my model

class UserBasicDetails(models.Model):
user_id = models.OneToOneField(User, primary_key=True,
to_field='username', parent_link=True)
place = models.CharField(null=False, blank=False, max_length=30)

Step1:
user = User.objects.get(username='lokesh')
bas = UserBasicDetails.objects.create(user_id = user, month='feb')
Step2:
After successful creation of the record i am trying to delete all the
records from UserBasicDetails
UserBasicDetails.objects.all().delete()
Step3:
Ended up with the error and pasted below
ValueError: invalid literal for int() with base 10: 'lokesh'

My Analysis:
I have tried with the 2 scenarios
1. Primary key - Integer, Delete successful
2. Primary key - Non-Integer - Delete fails

So, I felt the primary key field should be an integer.

Please correct me if i am in wrong direction.

Regards,
Lokesh


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: password encryption not working...

2009-08-12 Thread Karen Tracey
On Wed, Aug 12, 2009 at 7:50 AM, rekha  wrote:

>
> Hi all,
> im a newbie, developing a django online address book application.
> using mod_python, apache2, postgresql for database.
>
> i have two tables in my database viz login_table and contact_table..
> login_table stores username and password.. contact table stores first
> name, last name, phone number, email id.. i have created a login page
> that accepts username and password.. i need my application to store
> the password in encrypted form in the database.
> how to do password encryption? i have tried some codings ,but that
> doesnt work out. this is my models.py code.
>

"It doesn't work" followed by a bunch of code and then a request for how to
fix it is frequently asking too much of your potential helpers, unless there
happens to be someone in the audience who is very bored with a lot of time
on their hands and looking for a puzzle to solve.  Specifics of what
"doesn't work" looks like (exception? passwords never match? machine catches
fire?) would be the minimum you would want to provide to help people help
you.

In this case, though, my first question is why are you doing all of this
yourself instead of using Django's built in user authentication framework?
If the specifics of what is stored in the Django User model does not match
what you are looking for there are ways to extend User (via profiles).  If
you absolutely positively need to be re-implementing all of this stuff
yourself I'd suggest you look at the Django authentication code
(django/contrib/auth) for some guidance on how to do it.

Karen

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



Re: Need for an internationalization/translation system not request-based

2009-08-12 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-08-12, o godz. 13:00, przez Enrico  
Sartorello:

> i'm facing a problem developing with Django a Web Application: in
> response to some events (for example, after an admin action) i need to
> send emails to some users of my site.
>
> The problem arises when i want these emails to be translated in any
> user-specific language: the Request object i have just contains the
> language infos of the user that trigger the event, so it's not what i
> need.
> Generally, LocaleMiddleware behaviour can't do that job, because is
> based on sessions and cookies of a particular user.
> Roughly speaking i need (at least) a way to manually decide which is
> the language to apply for translations.

Once I needed to send emails in Hungarian from English application and  
this worked.

Before translating any string you need to know which language to use.  
If you have this information handy somewhere you can just switch the  
translation catalog safely in separated process environments (FastCGI,  
WSGI). As translation.activate() is process-wide, this approach is not  
safe in multithreaded environment if using static translation (not  
request-based).

-- 
Artificial intelligence stands no chance against natural stupidity

Jarek Zgoda, R, Redefine
jarek.zg...@redefine.pl


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



DjangoCon '09 Schedule

2009-08-12 Thread Robert Lofthouse

Hi All,

You can purchase tickets for the conference here - 
http://djangocon09.eventbrite.com

We have released the DjangoCon Schedule at: 
http://www.djangocon.org/2009/conference/schedule/
and will be releasing more information over the next day or two.

DjangoCon is on 8th - 12th September in Portland, Oregon at the
DoubleTree Green Hotel. We had a great time last year at Google HQ,
where 250 people turned up for the first ever DjangoCon.

Keynotes are: Avi Bryant, Ian Bicking and Ted Leung. We have a wide
variety of talks from all aspects of the community, including a
Technical Design Panel where you get to discuss design ideas/
confusions with the Core devs. DjangoCon is a great place to learn
more about the framework, talk to experienced developers/companies and
meet people in the community.

You can purchase tickets for the conference here - 
http://djangocon09.eventbrite.com

Robert Lofthouse
DjangoCon Chairman - http://www.djangocon.org/

Sponsors:

Silver:

Imaginary Landscape - http://www.imagescape.com/landing/python-django.html
Eldarion - http://eldarion.com/
SquareFactor - http://squarefactor.com/

Bronze:

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



Re: Model example for simple family tree

2009-08-12 Thread sniper

It works!! Thanks

On Aug 11, 7:44 pm, Mike Dewhirst  wrote:
> sniperwrote:
> > Hi,
> > I am new to django and wanted to try it out.
>
> > I would like to create a table for family tree
> > where Relation is a many to many table which contains Profile ids
>
> > profile_id, relative_id,type,priority.
>
> > RELATIVE_CHOICES = (
> >         (u'F', u'Father'),
> >         (u'M', u'Mother'),
> >         (u'B', u'Brother'),
> >         (u'S', u'Sister'),
> >         (u'N', u'Son'),
> >         (u'D', u'Daugter'),
> >         (u'H', u'Husband'),
> >         (u'W', u'Wife'),
> >     )
>
> > # Create your models here.
> > class Profile(models.Model):
> >    first_name = models.CharField(max_length=20)
> >    last_name = models.CharField(max_length=20,null=True)
> >    gender = models.CharField(max_length=2, choices=GENDER_CHOICES)
> >    birth_date = models.DateTimeField('birth day',null=True)
> >    notes = models.TextField(null=True)
>
> Sniper
>
> I did exactly the same thing at exactly the same stage of my own
> exposure to Django. It gets easier as the newness wears off a bit and
> you get to trust the error messages.
>
> Good luck
>
> > class Relation(models.Model):
>
>      person = models.ForeignKey(Profile, related_name='person_set')
>
> >    person = models.ForeignKey(Profile)
>
>      relative = models.ForeignKey(Profile, related_name='relation_set')
>
>
>
> >    relative = models.ForeignKey(Profile)
> >    type=models.CharField(max_length=2, choices=RELATIVE_CHOICES)
> >    priority = models.IntegerField(default=1)
>
> > how do i do that?
> > right now i am getting this error
>
> > Error: One or more models did not validate:
> > ftree.relation: Accessor for field 'person' clashes with related field
> > 'Profile.relation_set'. Add a
> >  related_name argument to the definition for 'person'.
> > ftree.relation: Accessor for field 'relative' clashes with related
> > field 'Profile.relation_set'. Add
> >  a related_name argument to the definition for 'relative'.
>
> > 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: Need for an internationalization/translation system not request-based

2009-08-12 Thread Torsten Bronger

Hallöchen!

Enrico Sartorello writes:

> [...]
>
> Roughly speaking i need (at least) a way to manually decide which
> is the language to apply for translations.

I had the same problem.  My solution (not in Django) can be seen at
.
You can use this module.  This only dependency of "common" can be
removed easily.

However, I'm very interested in a simpler approach.  :-)

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.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
-~--~~~~--~~--~--~---



Quick Newbie Question - reverse ManyToMany in admin site

2009-08-12 Thread ben

Hi all,
I've got a model with a plain many-to-many relationship (no
intermediate model) and want to edit the relationships in the admin
site. By default the multiple select box only appears on the admin
page for the model that defined it, however I'd like to be able to
modify the relationships the other way around too.

e.g. for items in groups, I'd like to have
item admin page allowing a multi-select on the groups related to it
group admin page allowing a multi-select of items within the group

The admin docs describe the problem but only show the solution for the
more complicated (intermediary model) case:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-many-to-many-intermediary-models

Is there an easy way to do what I want? The solutions I've found have
all been for some complicated syncdb and model definition solutions
that seem a bit overkill for just showing the relationship in the
admin site.

Cheers
Ben

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Concurrent Web Access and Edits

2009-08-12 Thread Ben Moran

On Tue, Aug 11, 2009 at 10:14 PM, Doug Blank wrote:

> New Django user here with a question about the client side: Is there
> built-in support for dealing with concurrent edits? ...
>   

Maybe you want the Django condition decorator, which lets you use HTTP 
headers to send an ETag or Modified date and reject the updates if 
they're not correct?

http://docs.djangoproject.com/en/dev/topics/conditional-view-processing/


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Need for an internationalization/translation system not request-based

2009-08-12 Thread Enrico Sartorello

Hi all,
i'm facing a problem developing with Django a Web Application: in
response to some events (for example, after an admin action) i need to
send emails to some users of my site.

The problem arises when i want these emails to be translated in any
user-specific language: the Request object i have just contains the
language infos of the user that trigger the event, so it's not what i
need.
Generally, LocaleMiddleware behaviour can't do that job, because is
based on sessions and cookies of a particular user.
Roughly speaking i need (at least) a way to manually decide which is
the language to apply for translations.

I've tried to search the web in order to look for a solution but i
wasn't able to find it.
For example, django-multilingual package doesn't affect the way the
translations are made.

Can somebody help me?

Thanks for the attention,

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: Inheritance at runtime (per model instance)

2009-08-12 Thread Thomas Guettler

Hi Malcolm and others,

Malcolm Tredinnick schrieb:
> On Wed, 2009-08-12 at 11:39 +0200, Thomas Guettler wrote:
>> Hi,
>>
>> I am writing a workflow engine. The base workflow is stored in the DB.
>> But some code needs to written for most workflows.
>>
>> This means I need code for a model instance (and not code per mode class).
>>
>> To make this most pythonic, how could this be done?
>>
>> My idea: since I want the workflow to be portable to several installations, 
>> I don't use
>> serial IDs for primary keys, but slug-fields. The slug-field could be a 
>> importable
>> classname like 'foo.workflow.MyClass'.
> 
> You already have the content type table for referring to other model
> objects. Why not use that so that you can maintain some referential
> integrity?

Content Types use serial keys. Take something like a ticket system:
Serial keys are good for the tickets. But if you have something like a
TicketTypeModel it is not a good solution. The customer uses the live
system and can create new TicketTypes. But during the same time,
I might create new TicketTypes in my development system. The serial IDs clash.

And the TicketTypes or (Workflow-Models) need to be installable for several 
customers.

>> Now I want that the Workflow model instance inherits from MyClass. This must
>> be done at runtime. I think this could be done with a custom manager.
> 
> This is where I become Old Conservative Malcolm and say that you might
> want to consider NOT abusing model inheritance! :) I have reasons,
> though, so let me explain...

... thank you for this hint. Up to now, I don't need model inheritance
at runtime. The model instance would inherit from a normal python class.
I even did not think about it. But you did and that's good.
I drop my first idea, because I understand, that doing model inheritance at
runtime does smell bad.

> 
> I try to always relate this back to Python and what you can do in Python
> with normal classes (Django's ORM just provides a way to store parts of
> classes on disk). You can do what you want in Python, using the type()
> command where you can create whatever base classes you like. 

Yes, I have your opinion, too.

  Thomas Güttler

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

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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 Django a good choice for a LAN app?

2009-08-12 Thread Philippe Raoult

I don't know what you mean by mid-sized but I deployed exactly what
you're describing in a 45-strong company. We have occasional browser
incompatibilities with ajax but overall django was very much the right
tool for the job. As a bonus the company's clients can now access a
restricted part of the application to monitor their files and dealings
over https. Employees can also log in from home over https without any
software/hardware prerequisite. We're also planning on adding some
smartphone friendly pages for specific tasks (billing when employees
are working offsite).

My app is around 25k lines of python+templates

Hope this helps you make your mind.

On Aug 11, 9:06 pm, snfctech  wrote:
> I'm about to start a fairly large project for a mid-sized business
> with a lot of integration with other systems (POS, accounting,
> website, inventory, purchasing, etc.) The purpose of the system is to
> try to reduce current data siloing and give employees role-based
> access to the specific data entry and reports they need, as well as to
> replace some manual and redundant business processes. The system needs
> to be cross-platform (Windows/Linux), open source and is primarily for
> LAN use.
>
> My experience is mostly PHP/web/app development, but I have developed
> a few LAN apps using Java/Servoy (like Filemaker). I am leaning
> towards Python/Django - but wondering whether this may be
> unnecessarily web-specific. I really felt Servoy development was very
> rapid, and it was cross-paltform, but it was not open source (not to
> mention that anything custom needed to be Java which I find too
> verbose/ slow to develop in). Or maybe Open Office Base and some
> scripting is sufficient to handle my needs.
>
> So, my main question is: Does a web framework like Django sound like a
> reasonable platform to build a LAN Dashboard for a mid-sized company?
> Or am I thinking too much like a web developer?
>
> Any tips or suggestions would be greatly appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



IntegrityError!!!

2009-08-12 Thread rekha

Hi all,
im a newbie, developing online address book application using django,
mod_python, apache2, postgresql.

i have two tables in my database viz login_table and contact_table..
login_table stores username and password.. contact table stores first
name, last name, phone number, email id.. username field in
login_table is foreignkey to contact_table.. now my application want
to access all the records from contact_table which corresponds to a
particular username in the login_table.. but my code gives
IntegrityError when try to do so.. how to fix this problem?

===forms.py
import re
from django.contrib.auth.models import User
from OnlineAddressBook.app.models import *
from django.core.exceptions import ObjectDoesNotExist
from django.forms.widgets import Widget
from django import forms

class LoginForm(forms.Form):
usr_name = forms.CharField(label="User Name:", max_length=50)
pswd = forms.CharField(label='Enter
password:',widget=forms.PasswordInput(render_value=False))

def clean_usr_name(self):
usr_name = self.cleaned_data['usr_name']
if not re.search(r'^[a-z]|[A-Z]$', usr_name):
raise forms.ValidationError('user Name can only contain
alphabets.')
return usr_name




class RegisterForm(forms.Form):
usr_name = forms.CharField(label='Enter your user
name:',max_length=50)
pswd = forms.CharField(label='Password:',widget=forms.PasswordInput
(render_value=False))



class AddForm(forms.Form):
fname = forms.CharField(label='Enter First Name:',max_length=50)
lname = forms.CharField(label='Enter Last Name:',max_length=50)
ph_num = forms.CharField(label='Enter Mobile Number:',max_length=10)
email = forms.EmailField(label='Enter Email ID:',max_length=75)

def clean_fname(self):
fname = self.cleaned_data['fname']
if not re.search(r'^[a-z]|[A-Z]$',fname):
raise forms.ValidationError('Username can only contain 
alphanumeric
characters and the underscore.')
return fname

def clean_lname(self):
lname = self.cleaned_data['lname']
if not re.search(r'^[a-z]|[A-Z]$',lname):
raise forms.ValidationError('Username can only contain 
alphanumeric
characters and the underscore.')
return lname

def clean_ph_num(self):
ph_num = self.cleaned_data['ph_num']
if not re.search(r'^\d+$',ph_num):
raise forms.ValidationError('Mobile number should 
contain 10 digits
only')
return ph_num



class EditForm(forms.Form):
fname = forms.CharField(label='First Name:',max_length=50)
lname = forms.CharField(label='Last Name:',max_length=50)
ph_num = forms.CharField(label='Number:',max_length=10)
email = forms.EmailField(label='Email ID:',max_length=75)

class RemoveForm(forms.Form):
fname = forms.CharField(label='Enter the First Name of the
person:',max_length=50)
ph_num = forms.CharField(label='Enter the Mobile Number of the
person:',max_length=10)

===views.py===
from django.http import HttpResponse
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect
from django.template import RequestContext
from django.shortcuts import get_object_or_404
from OnlineAddressBook.app.models import *
from OnlineAddressBook.app.forms import *
from django.contrib.auth import logout
from django.contrib import auth


def index(request):
return render_to_response('index.html')
def error(request):
return render_to_response('error.html')

def login(request):
if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
try:
obj = 
login_table.objects.get(usr_name=request.POST['usr_name'])
if obj.pswd == request.POST['pswd']:
#return 
HttpResponseRedirect('/user_page')
return 
render_to_response('user_page.html',{'form':form})
except login_table.DoesNotExist:
#return HttpResponse('password doesnt 
match')
return HttpResponseRedirect('/error')
else:
form = LoginForm()
variables = RequestContext(request, {'form':form})
return render_to_response('login.html',variables)

def register(request):
if request.method == 'POST':
form = RegisterForm(request.POST)
if form.is_valid():
reg = login_table( usr_name = 
form.cleaned_data['usr_name'], pswd =
form.cleaned_data['pswd'])
reg.save()
return 

AutoRefresh model field (filled in by a trigger)

2009-08-12 Thread Evgeny

Hi,
I have some fields in a model which are filled in by before_insert
trigger.
Is there any right way to autorefresh them after the object is
inserted, besides requesting a new instance of the object by
model.objects.get() method?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



password encryption not working...

2009-08-12 Thread rekha

Hi all,
im a newbie, developing a django online address book application.
using mod_python, apache2, postgresql for database.

i have two tables in my database viz login_table and contact_table..
login_table stores username and password.. contact table stores first
name, last name, phone number, email id.. i have created a login page
that accepts username and password.. i need my application to store
the password in encrypted form in the database.
how to do password encryption? i have tried some codings ,but that
doesnt work out. this is my models.py code.

===models.py
from django.conf import settings
import binascii
from os import urandom
from base64 import b64encode, b64decode
from django.db import models
from Crypto.Cipher import ARC4

def get_value(usr_name):
def f(self):
return login_table.decrypt(getattr(self, 'e_%s'%usr_name))
return f

def set_value(usr_name):
def f(self, value):
setattr(self, 'e_%s'%usr_name, login_table.encrypt(value))
return f


class login_table(models.Model):
SALT_SIZE = 8
usr_name = models.CharField(max_length=100,unique=True,blank=True)
pswd = models.CharField(max_length=50,blank=True)
def encrypt(plaintext):
salt = urandom(login_table.SALT_SIZE)
arc4 = ARC4.new(salt + settings.SECRET_KEY)
plaintext = "%3d%s%s" % 
(len(plaintext),plaintext,urandom(256-len
(plaintext)))
return "%s$%s" % (b64encode(salt), b64encode(arc4.encrypt
(plaintext)))
def decrypt(ciphertext):
salt, ciphertext = map(b64decode, ciphertext.split('$'))
arc4 = ARC4.new(salt + settings.SECRET_KEY)
plaintext = arc4.decrypt(ciphertext)
return plaintext[3:3+int(plaintext[:3].strip())]
def encrypted_property(username):
return property(get_value(username), set_value(username))
usr_name = encrypted_property('usr_name')
pswd = encrypted_property('pswd')

def __unicode__(self):
return self.usr_name
class contact_table(models.Model):
fname = models.CharField(max_length=50,unique=True)
lname = models.CharField(max_length=50)
ph_num = models.CharField(max_length=50)
email = models.EmailField(max_length=75)
usr_name = models.ForeignKey(login_table)
def __unicode__(self):
return '%s%s%s%s' % 
(self.fname,self.lname,self.ph_num,self.email)

How to fix this problem? and is there any pre-defined functions to do
password encryption?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Concurrent Web Access and Edits

2009-08-12 Thread Russell Keith-Magee

On Tue, Aug 11, 2009 at 10:14 PM, Doug Blank wrote:
>
> New Django user here with a question about the client side: Is there
> built-in support for dealing with concurrent edits? I'm not referring
> to the database issues (locking, etc) but is there Django support for
> handling a request to access or edit data for which another user is
> editing?
>
> I'm thinking about simple timestamps, detection of changed data, and
> showing the user options to abort, overwrite, or re-edit.
>
> Does one have to implement this for saving data? Anything I should
> read that covers this or related topic? I couldn't find anything on
> the Django site, nor in this forum.

The short answer is that Django doesn't provide any such protection
out of the box. There has been a little bit of discussion about this
feature (some of it over the last day or so), but a turnkey solution
is still a way off.

In the interim, you're might be able to hack together a solution using
a timestamp column on your model and a custom form field that renders
as a hidden field, and validates by comparing the existing instance
value with the value submitted in the form. However, you'll need to do
some experimentation here - I can't point you at any simple howto
documentation.

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: inspectdb and postgresql schema

2009-08-12 Thread Russell Keith-Magee

On Wed, Aug 12, 2009 at 6:09 PM, Marek
Pietrucha wrote:
>
> Thank you for the anwser :)
>
> It's not comforting but now I don't have to dig the whole google
> achieve ;)
>
> In this case, how do I construct django models?

I don't want to seem rude, but we provide an extensive documentation
for a reason.

http://docs.djangoproject.com/en/dev/

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: inspectdb and postgresql schema

2009-08-12 Thread Marek Pietrucha

Thank you for the anwser :)

It's not comforting but now I don't have to dig the whole google
achieve ;)

In this case, how do I construct django models?

best regards,
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: Inheritance at runtime (per model instance)

2009-08-12 Thread Malcolm Tredinnick

On Wed, 2009-08-12 at 11:39 +0200, Thomas Guettler wrote:
> Hi,
> 
> I am writing a workflow engine. The base workflow is stored in the DB.
> But some code needs to written for most workflows.
> 
> This means I need code for a model instance (an not code per mode class).
> 
> To make this most pythonic, how could this be done?
> 
> My idea: since I want the workflow to be portable to several installations, I 
> don't use
> serial IDs for primary keys, but slug-fields. The slug-field could be a 
> importable
> classname like 'foo.workflow.MyClass'.

You already have the content type table for referring to other model
objects. Why not use that so that you can maintain some referential
integrity.

I suspect, simply because you've been using Django forever and know
what's going on, that there is something subtle here I don't understand,
so feel free to tell me why I'm an idiot and this won't work.

> 
> Now I want that the Workflow model instance inherits from MyClass. This must
> be done at runtime. I think this could be done with a custom manager.

This is where I become Old Conservative Malcolm and say that you might
want to consider NOT abusing model inheritance! :) I have reasons,
though, so let me explain...

I try to always relate this back to Python and what you can do in Python
with normal classes (Django's ORM just provides a way to store parts of
classes on disk). You can do what you want in Python, using the type()
command where you can create whatever base classes you like. Sadly, it's
harder than that when we introduce the persistence part -- storing in
the DB. Since inheritance is implemented via relations that are
constraints at the DB level, allowing arbitrary tables is not going to
be possible. Although I've tried to implement model inheritance so that
it works as transparently as possible, there are limits and this is one
of them -- it's a genuine leaky abstraction, because the database
requirement influences the functionality regardless of what
implementation I use.

A Django relation that points to any type of model already exists,
however: GenericForeignKey. Since you can ignore model inheritance in
Django and use a OneToOneField to link the models, you can do the same
thing with GenericForeignKey in the place of OneToOneField. So you end
up storing the "type" of the remote model and the pk of the instance you
are pointing to. No referential integrity at the database level there
(although we do enforce that the type is an existing content type).

Based on your brief description, I would use GenericForeignKeys here, I
think. But please elaborate if there's a reason that won't work for you.

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: logic in templates

2009-08-12 Thread elminio

Thanks,
And what if I want to use another thiord or maybe even fourth item

customers
sellers
products

Im new in python so thanks for help

On Aug 12, 11:17 am, David Zhou  wrote:
> The easiest way is probably moving that list to the view.  For example
>
> customers = Customer.objects...
> sellers = Seller.objects...
>
> filtered_list = [pair for pair in zip(sellers, customers) if
> pair[0].customer_id == pair[1].id]
>
> Then pass filtered_list into the template context.  Inside the
> template, you could do:
>
> (Assuming Django >= 1.1)
>
> {% for seller, customer in filtered_list %}
>     {{ seller.name }} {{ customer.name }} 
> {% empty %}
>     No customers.
> {% endfor %}
>
> -- dz
>
> On Wed, Aug 12, 2009 at 5:06 AM, elminio wrote:
>
> > Hello,
>
> > Common task in template is doing for loop end inserting into html some
> > elements.
>
> > for example
>
> > 1: {% for  seller in sellers %}
> > 2:    {% for customer in customers %}
> > 3:        {% ifequal seller.customer_id customer.id %}
> > 4:            {{ seller.name }} {{ customer.name }} 
> > 5:        {% endifequal %}
> > 6:    {% endfor %}
> > 7: {% endfor %}
>
> > Thats clear.
>
> > Now I would like to know when the loop is over and system didnt't find
> > customer for seller (line 3). And in this case insert no customers > p>.
>
> > If it shouldnt be done in template how can I inject logic from python
> > file ?
>
> > thanks for help
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Inheritance at runtime (per model instance)

2009-08-12 Thread Thomas Guettler

Hi,

I am writing a workflow engine. The base workflow is stored in the DB.
But some code needs to written for most workflows.

This means I need code for a model instance (an not code per mode class).

To make this most pythonic, how could this be done?

My idea: since I want the workflow to be portable to several installations, I 
don't use
serial IDs for primary keys, but slug-fields. The slug-field could be a 
importable
classname like 'foo.workflow.MyClass'.

Now I want that the Workflow model instance inherits from MyClass. This must
be done at runtime. I think this could be done with a custom manager.

Does someone have a better approach, or feedback?

  Thomas


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

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Ajax in Django

2009-08-12 Thread Jorge Bastida
I' currently working in/with Dajax.
http://code.google.com/p/dajaxproject/

I hope it helps you.

-- 
neo2001[at]gmail.com
jorge[at]thecodefarm.com
neo[at]art-xtreme.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: Ajax in Django

2009-08-12 Thread Malcolm Tredinnick

On Wed, 2009-08-12 at 11:47 +0300, Jani Tiainen wrote:
> HB kirjoitti:
> > Hey,
> > Why Django doesn't provide integration with Ajax out of the box (like
> > Rails and Wicket)?
> 
> It all depends what you mean by "integration"?
> 
> You can use (model)forms with Ajax, or use any other means if you wish.
> 
> Only thing that django doesn't provide is Ajax form rendering - I mean 
> that you can't just say {{ form }} and magically get ajaxafied form.

I'll reply here, rather than against the original post, since you're hit
the nail on the head, but I want to expand somewhat...

We have always encouraged people to come up with a good set of template
tags to do this sort of stuff. Right now, there doesn't appear to be
anything that looks very Django-like. If you look at the Ajax helpers in
Rails, for example, it's like writing Ruby in the templates. Since
Django deliberately strives to have very simple templates, without
programming in the templates, the challenge is greater for "generic"
template tags.

This doesn't mean it's harder to use Ajax, it just means that people are
more likely to write custom template tags that insert the precise Ajax
bits they're after. Including Ajax or other Javascript bits in Django
templates isn't hard and writing custom tags is very easy, so it seems
that the middle ground we've arrived at is reasonably acceptable to our
core audience (experienced Python developers and web designers).

It also doesn't mean that people shouldn't continue to try and create
the perfect set of Ajax tags. When that happens, it will attract
attention, fame, fortune, etc, and after suitable shaking out, we would
look at whether it's worthwhile including in contrib. But in the 4+
years that Django has been open sourced, nobody has yet done that, which
shows where the balance between need and pragmatism lies.

> And there is good reason - what would be javascript framework to use 
> then? MooTools? jQuery? Prototype? ExtJS? Or my favourite Dojotoolkit (I 
> bet there is dozen of others that I don't remember or are aware of)

That is also definitely a consideration.

Along those lines, there are some library specific helpers that have
been created. Search for dojango, for example, a set of Dojo-based
Django template tags. I'm not sure if they're particularly good or not,
as I haven't used them much at all, but they exist, which is definitely
a good thing. There's also YUI-based incremental loading via Django
template tags out there, too, which was even featured on the YUI
developers blog (as an example of YUI-in-action) at one point.

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: logic in templates

2009-08-12 Thread David Zhou

The easiest way is probably moving that list to the view.  For example

customers = Customer.objects...
sellers = Seller.objects...

filtered_list = [pair for pair in zip(sellers, customers) if
pair[0].customer_id == pair[1].id]

Then pass filtered_list into the template context.  Inside the
template, you could do:

(Assuming Django >= 1.1)

{% for seller, customer in filtered_list %}
{{ seller.name }} {{ customer.name }} 
{% empty %}
No customers.
{% endfor %}


-- dz



On Wed, Aug 12, 2009 at 5:06 AM, elminio wrote:
>
> Hello,
>
> Common task in template is doing for loop end inserting into html some
> elements.
>
> for example
>
> 1: {% for  seller in sellers %}
> 2:    {% for customer in customers %}
> 3:        {% ifequal seller.customer_id customer.id %}
> 4:            {{ seller.name }} {{ customer.name }} 
> 5:        {% endifequal %}
> 6:    {% endfor %}
> 7: {% endfor %}
>
>
> Thats clear.
>
> Now I would like to know when the loop is over and system didnt't find
> customer for seller (line 3). And in this case insert no customers p>.
>
> If it shouldnt be done in template how can I inject logic from python
> file ?
>
> thanks for help
>
>
>
>
> >
>

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



Re: Deploying django on apache - cant access database

2009-08-12 Thread Graham Dumpleton



On Aug 12, 3:43 pm, consiglieri  wrote:
> Thanks Graham!
>
> The absolute path was the issue. Can't believe I couldnt find that
> anywhere.
>
> As for the Alias, well i was just testing to make sure that wasnt an
> issue.And its in the httpd.conf , for perl-cgi you need that so since
> i was having issues i decided to try and see if it was causing my
> issues. (Which it wasnt). As the apaches conf says
>
>     # ScriptAlias: This controls which directories contain server
> scripts.
>     # ScriptAliases are essentially the same as Aliases, except that
>     # documents in the target directory are treated as applications
> and
>     # run by the server when requested rather than as documents sent
> to the
>     # client.  The same rules about trailing "/" apply to ScriptAlias
>     # directives as to Alias.
>
> So i was thinking maybe i need to set an alias so that apache executes
> the python scripts.
>
> The only thing i have noted now is that that when i go to the admin
> url the css doesnt seem to follow but probably its just a sethandler
> issue.

For mod_python it is a bit of a fiddle for getting static files to be
served if logically under mount point of mod_python hosted
application. As you say, you need to disable mod_python for the URLs
using 'SetHandler None'. FWIW, mod_wsgi is a lot more saner in this
respect as it respect resource stuff and so an Alias is enough to have
static files mounted. For more details of using mod_wsgi instead of
mod_python see:

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

The mod_wsgi module also will make it easier for you if developing
code under Apache, as you can use daemon mode and just touch WSGI
script file to trigger a reload, or setup a code monitor so it behaves
just like Django development server. For more details on code
reloading in mod_wsgi see:

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

Graham

> Anyway Graham I really appreciate your input. At least now i know my
> setup is working and I ca get on with actually developing the app
> better as well as trying to master the django framework
>
> Thomas
>
> On 12 Aug, 00:02, Graham Dumpleton  wrote:
>
>
>
> > For SQLite database, the directory the database is in must also be
> > writable to user that Apache runs as. The location of the database in
> > settings file must also be an absolute path, can't use a relative
> > path.
>
> > BTW, what is:
>
> >   Alias test.django.com "/Users/someone/djangoproject/appname"
>
> > for in configuration? It will have no effect and normall your wouldn't
> > have anything like that in configuration for Django.
>
> > Graham
>
> > On Aug 12, 4:45 am, consiglieri  wrote:
>
> > > Thanks for the tip, however it does not make a difference. I moved the
> > > app to another catalogue and made sure that the database file was
> > > chmod to 755 and also that all directories have the same permissions.
> > > The error remains.
>
> > > There is something happening that i dont understand. I'm beginning to
> > > think there is someting wrong with the django or mod_python
> > > installation but i am at a loss understanding what it can be.
>
> > > Thomas
>
> > > On 11 Aug, 19:04, Mike Ramirez  wrote:
>
> > > > On Tuesday 11 August 2009 09:43:38 am consiglieri wrote:
>
> > > > > Hi
>
> > > > > I'm new with django and have made a small test app which works as it
> > > > > should with the development server.
>
> > > > > However when i try and deploy it with apache and mod_python I cant get
> > > > > it to work. I have tested that mod_python works. I can do the
> > > > > recommended mod_python test. When i try to run the django app via
> > > > > apache it works well as long as the page being displayed does not
> > > > > actually try and access the database. In other words if I enter a url
> > > > > that just pops up an empty page with no django tags in it the page is
> > > > > displayed as it should.
>
> > > > > These are my settings.
>
> > > > > Apache 2.2.11
> > > > > mod_python 3.3.2-dev
> > > > > I am on a Mac (Leopard 10.5.8)
> > > > > I have the latest stable version of django 1.1
>
> > > > > When I start apache the following can be found in the logs
>
> > > > > Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.7l DAV/2 mod_python/
> > > > > 3.3.2-dev-20080819 Python/2.5.1 configured -- resuming normal
> > > > > operations
>
> > > > > The necessary settings in httpd.conf with regards to django is as
> > > > > follows
>
> > > > > Alias test.django.com "/Users/someone/djangoproject/appname"
>
> > > > > SetHandler python-program
> > > > > PythonHandler django.core.handlers.modpython
> > > > > SetEnv DJANGO_SETTINGS_MODULE appname.settings
> > > > > PythonDebug On
> > > > > PythonPath "['/Users/someone/djangoproject/'] + sys.path"
>
> > > > > When i run a url that invokes a function which tries to access the
> > > > > database (sqlite3 in this case) i receive the 

logic in templates

2009-08-12 Thread elminio

Hello,

Common task in template is doing for loop end inserting into html some
elements.

for example

1: {% for  seller in sellers %}
2:{% for customer in customers %}
3:{% ifequal seller.customer_id customer.id %}
4:{{ seller.name }} {{ customer.name }} 
5:{% endifequal %}
6:{% endfor %}
7: {% endfor %}


Thats clear.

Now I would like to know when the loop is over and system didnt't find
customer for seller (line 3). And in this case insert no customers.

If it shouldnt be done in template how can I inject logic from python
file ?

thanks for help




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



Re: Ajax in Django

2009-08-12 Thread Jani Tiainen

HB kirjoitti:
> Hey,
> Why Django doesn't provide integration with Ajax out of the box (like
> Rails and Wicket)?

It all depends what you mean by "integration"?

You can use (model)forms with Ajax, or use any other means if you wish.

Only thing that django doesn't provide is Ajax form rendering - I mean 
that you can't just say {{ form }} and magically get ajaxafied form.

And there is good reason - what would be javascript framework to use 
then? MooTools? jQuery? Prototype? ExtJS? Or my favourite Dojotoolkit (I 
bet there is dozen of others that I don't remember or are aware of)

-- 
Jani Tiainen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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 0.96.4 does not has django.utils._os

2009-08-12 Thread Russell Keith-Magee

On Wed, Aug 12, 2009 at 12:48 PM, dongua wrote:
> after i download ]
> http://code.djangoproject.com/browser/django/branches/0.96-bugfixes/django/utils/_os.py
> and runserver:
>
> Development server is running at http://127.0.0.1:8000/
> Quit the server with CTRL-BREAK.
> Unhandled exception in thread started by 
> Traceback (most recent call last):
>   File "D:\Python25\Lib\site-packages\django\core\management.py", line 1195,
> in
> inner_run
>     handler = AdminMediaHandler(WSGIHandler(), admin_media_path)
> NameError: global name 'admin_media_path' is not defined

This is deeply embarrassing. You are completely correct - thank you
for the report.

The workaround fix is to edit line 1195 of django/core/management.py -
the reference to ``admin_media_path`` should read ``admin_media_dir``.
Alternatively, you can download a complete version of the corrected
file [1], and drop in the replacement as you did with _os.py.

[1] 
http://code.djangoproject.com/browser/django/branches/0.96-bugfixes/django/core/management.py

I have committed a fix for this in r11435. This fix will be included
in the updated release tarball.

Again - I apologize for the inconvenience.

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
-~--~~~~--~~--~--~---



Ajax in Django

2009-08-12 Thread HB

Hey,
Why Django doesn't provide integration with Ajax out of the box (like
Rails and Wicket)?
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: dates with a different format in the db

2009-08-12 Thread Vokial

Thanks a lot!
I'll try both the string filters and read carefully that part of the
documentation.. eventually i'll try to create a custom subclass.

Again you've been very helpful, thanks 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: dates with a different format in the db

2009-08-12 Thread Malcolm Tredinnick

On Wed, 2009-08-12 at 00:24 -0700, Vokial wrote:
> You've been very helpful, thanks.
> The problem here is that i have to use these fields as proper
> DateFields because i have to do some operations with these dates, like
> making monthly/daily reports, searching entries in a specific period
> of time and so on...
> I guess i have to convert these strings to datetime objects in each
> and every view but it's so annoying.. that's why i'm looking for a way
> to make django use these strings as dates..

You could write a custom field subclass then, which converts the string
it reads from the database to a DateTime value. Have a look at

http://docs.djangoproject.com/en/dev/howto/custom-model-fields/

That documentation addresses a fairly complicated example of mapping
database data to a Python class, not something like a datetime object,
but it's basically the same thing. So read the whole document before
leaping into code. At some point, I'll rewrite it to order things a bit
differently (from memory, I wrote the initial version of that at about
1:30 one morning and it's never really had a major rewrite, but all the
information is correct).

Also, searching for dates in a range is still possible with your current
data:

MyModel.objects.filter(date_string__gte="20090101,
  date_string__lte="20090131")

will return all the January, 2009 data, for example. You might be able
to go a long way with just string stuff if you want to do direct
database filtering.

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: translation issue

2009-08-12 Thread Torsten Bronger

Hallöchen!

alecs writes:

> Thanks :)) Sorry, a silly question :)

Not at all.  The sources of Gajim used to be full of such mistakes,
and it was difficult to get the problem across.  ;-)

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.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: unique_together with None

2009-08-12 Thread Malcolm Tredinnick

On Tue, 2009-08-11 at 23:36 -0700, gentlestone wrote:
> Thank you for the explanation. Seems to be the correct solution of the
> problem (NULL, v1) != (NULL, v1) is overwrite the save method and
> check for existence of (NULL, v1) before saving a new instance of
> (NULL, v1). What I don't understand, why are the well-known databases
> so stupid and why they can't do this job.

Um .. the well-known databases are doing exactly the right thing. The
behavior of NULL is well-defined to be not equal to itself (Oracle's
incorrect behavior here is for historical reasons and they won't change
it to avoid backwards-incompatibilities for their existing long-time
users). Using nullable columns in unique constraints carries this
risk-tradeoff with it, if you are going to be inserting NULL-able items.

If you want to add that check to your save() method, then you can
override it yourself, but the database behavior is a matter of least
obstruction for users, since two entries of (NULL, "xyz") *are*
different at that level. You don't want that behaviour, but that doesn't
mean it's incorrect for all situations.

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: translation issue

2009-08-12 Thread alecs

Thanks :)) Sorry, a silly question :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: translation issue

2009-08-12 Thread Torsten Bronger

Hallöchen!

alecs writes:

> from django.utils.translation import ugettext as _
> raise forms.ValidationError(_('%(email)s is not a valid e-mail
> address.' %  {'email': email}))

It must be 

raise forms.ValidationError(_('%(email)s is not a valid e-mail address.') %  
{'email': email})

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.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
-~--~~~~--~~--~--~---



translation issue

2009-08-12 Thread alecs

from django.utils.translation import ugettext as _
raise forms.ValidationError(_('%(email)s is not a valid e-mail
address.' %  {'email': email}))

#: helpers.py:30
#, python-format
msgid "%(email)s is not a valid e-mail address."
msgstr "%(email)s не верный формат e-mail адреса."

Everything works OK but this line is not ranslated. Why? Maybe newbie
question :)) 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: dates with a different format in the db

2009-08-12 Thread Vokial

You've been very helpful, thanks.
The problem here is that i have to use these fields as proper
DateFields because i have to do some operations with these dates, like
making monthly/daily reports, searching entries in a specific period
of time and so on...
I guess i have to convert these strings to datetime objects in each
and every view but it's so annoying.. that's why i'm looking for a way
to make django use these strings as dates..

Thanks a lot anyway.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: More Than Two Models With inlineformset_factory

2009-08-12 Thread Matthias Kestenholz

On Wed, Aug 12, 2009 at 12:51 AM, Geraldo wrote:
>
> Excellent, Matthias...  That should work nicely.  It does appear,
> however, that there is no way to have more than 2 forms in a single
> formset.  If inlineformset_factory had an append method things might
> be a bit cleaner.
>

I presume you mean more than two forms of the same type (Child1 or
Child2)? That's easily possible, and we use it all the time. Take a
look at the max_num and extra parameters to the factory function.


Matthias



-- 
FeinCMS Django CMS building toolkit: http://spinlock.ch/pub/feincms/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: unique_together with None

2009-08-12 Thread gentlestone

Thank you for the explanation. Seems to be the correct solution of the
problem (NULL, v1) != (NULL, v1) is overwrite the save method and
check for existence of (NULL, v1) before saving a new instance of
(NULL, v1). What I don't understand, why are the well-known databases
so stupid and why they can't do this job. What about make this pre-
save chceck as statndard behavior in Django?

On 11. Aug, 16:57 h., Karen Tracey  wrote:
> On Tue, Aug 11, 2009 at 10:40 AM, Alex Gaynor  wrote:
>
> > On Tue, Aug 11, 2009 at 8:25 AM, gentlestone
> > wrote:
>
> > > On 11. Aug, 15:01 h., Gustavo Henrique  wrote:
> > >> Try also: null=True, blank=True
>
> > >> --
> > >> Gustavo Henriquehttp://www.gustavohenrique.nethttp://
> > blog.gustavohenrique.net
>
> > > blank=True ... I have had, but this one doesn't solve the problem,
> > > maybe the problem is in postgresql, the associated SQL code for
> > > postgresql is
>
> > > CREATE TABLE ...
> > > ...
> > > UNIQUE ("some_fk_field_id", "some_plain_field"),
>
> > > and this apparently doesn't work
>
> > You are talking about in the forms/admin validation correct?  Thinking
> > to how this is implemented there likely is a bug where this doesn't
> > use the SQL concept of NULL != NULL and uses the Python None == None
> > instead, which of these behaviors is correct I'm not sure of (though I
> > lean towards the SQL interpretation).
>
> I don't believe there is a bug.  The original description of the problem
> confused me because I thought it was trying so specify unique_together for a
> field in one model and a field in another model related by a nullable
> foreign key, and I didn't think you could do that.  In fact you can't -- all
> the fields have to be in the same model/table and I see now that the
> original report wasn't saying that.  (The _field in the unique_together spec
> is what confused me as I read that as having a double underscore.)
>
> Anyway, form validation allows multiple allows multiple None/NULL values
> here since most of the database backends interpret NULL != NULL at the SQL
> level to mean that (NULL, v1) != (NULL, v1) when doing multiple field unique
> checks.  The one exception I know of is Oracle, it apparently will raise an
> IntegrityError for this case.  See the discussion here:
>
> http://code.djangoproject.com/ticket/9039#comment:10
>
> 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 aggregates and having

2009-08-12 Thread lfrodrigues

Sorry I didn't explain my self properly.

I want this query:
SELECT (date_format(date, '%%U')) AS `d`, SUM
(`profile_scorehistory`.`points`) AS `l` FROM `profile_scorehistory`
GROUP BY date_format(date, '%%U') HAVING  `d`= 2

How can I make it with ORM?

The other one was the only similar query I managed to make using the
ORM.


On Aug 12, 3:44 am, Russell Keith-Magee 
wrote:
> On Wed, Aug 12, 2009 at 5:50 AM, lfrodrigues wrote:
>
> > Hi,
>
> > I'm having some problems with "having":
>
> > I want to group by date and restrict to a given week, in my tests I
> > can do this:
> > select_data = {"d": """date_format(date, '%%U')"""}
> > ScoreHistory.objects.extra(select=select_data).values('d').annotate
> > (l=Sum("points")).filter(l=2).query.as_sql()
>
> > sql:
> > SELECT (date_format(date, '%%U')) AS `d`, SUM
> > (`profile_scorehistory`.`points`) AS `l` FROM `profile_scorehistory`
> > GROUP BY date_format(date, '%%U') HAVING SUM
> > (`profile_scorehistory`.`points`) = 2
>
> > Good but what I want to get is this:
> > sql:
> > SELECT (date_format(date, '%%U')) AS `d`, SUM
> > (`profile_scorehistory`.`points`) AS `l` FROM `profile_scorehistory`
> > GROUP BY date_format(date, '%%U') HAVING  `d`= 2
>
> I might be missing something here, but as far as I can make out,
> you're getting exactly what you've asked for. Your query contains
> filter(l=2) - that is, you're filtering on l, the SUM.
>
> > How can I force using having when I can't define the param in
> > annotate?
>
> I'm afraid I don't see how this relates to your original question.
>
> 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
-~--~~~~--~~--~--~---