Anyone have experience with this recursion template tag?

2009-03-23 Thread Brandon Taylor

Hi everyone,

I'm following this tutorial for recursion in templates:
http://www.undefinedfire.com/lab/recursion-django-templates/
Here is my model:

#models.py
class Category(models.Model):
parent = models.ForeignKey('self', blank=True, null=True)
name = models.CharField(max_length=50)
slug = models.SlugField()

class Meta:
verbose_name_plural = 'Categories'

def __unicode__(self):
parent = ''
if self.parent:
parent = str(self.parent) + ' - '
return '%s%s' % (parent, self.name)

class CategoryAdmin(admin.ModelAdmin):
prepopulated_fields = ({ 'slug' : ('name',) })

admin.site.register(Category, CategoryAdmin)


#categories.html
{% load recurse %}
{% recurse category.category_set.all with categories as category
%}

{% loop %}

{{ category.name }}
{% child %}

{% endloop %}

{% endrecurse %}


Let's say I have the following data:
Children
Children > Toys
Children > Clothing

The output I'm seeing is:

Children
Clothing

When I would expect it to be:
Children
Clothing
Toys


Here is my view:
def get_categories(request):
categories = Category.objects.filter(parent__isnull=True)
return render_to_response('categories.html', {'categories' :
categories})


If I get my first category root object, and call:
print categories[0].category_set.all()

I get:
[, ]


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



i18n template nightmare part two

2009-03-23 Thread John Handelaar


So,

I've got a i18n-enabled page which calls i18n/setlang with a JS call.
In this page, clicking on the link to "javascript:lang('es')"
correctly reloads the page and renders everything that is currently
translated in Spanish.

Yay.

Unfortunately, this:

  {% load i18n %}
  {% get_current_language as LANGUAGE_CODE %}
  {{ LANGUAGE_CODE }}

... prints "en" even when the page renders in Spanish.

Anybody got any ideas?

Thanks for your time.



John Handelaar
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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-registration - 504 error

2009-03-23 Thread Karen Tracey
On Mon, Mar 23, 2009 at 6:28 PM, neri...@gmail.com wrote:

>
> Hey,
>
> does anyone know why I'm getting a "Exception Type:
> SMTPRecipientsRefused" error using django-registration?
>
> Exception Type: SMTPRecipientsRefused
> Exception Value:
>
> {u'neri...@gmail.com ': (504, ':
> Sender address
> rejected: need fully-qualified address')}
>
> Exception Location: /home/USER/projects/django/trunk/django/core/
> mail.py in _send, line 186
>

webmas...@localhost is not a fully-qualified address and your mail server is
refusing to send mail claiming to be from that address.  I'd guess you need
to set DEFAULT_FROM_EMAIL (
http://docs.djangoproject.com/en/dev/ref/settings/#default-from-email) to a
valid fully-qualified email address, unless there is another
django-registration-specific setting that is controlling the sender address
on the mail involved here.

Karen

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



Re: Having trouble authenticating/validating

2009-03-23 Thread Karen Tracey
On Mon, Mar 23, 2009 at 4:45 PM, Adam Yee  wrote:

>
> I'm using Django's builtin AuthenticationForm
>
> Here's my login view: http://dpaste.com/18110/
>
> Form submittal (not empty or empty fields) takes me back to the login
> page with 'Did not login'.  My debugging print statement isn't showing
> up in the terminal, so is_valid is somehow returning false.
>
> If I submit with empty fields, I don't get the default 'This field is
> required' type of error messages that I would expect.  I'm not sure
> how clean() is working with the AuthenticationForm...  Am I validating
> correctly? Or is something happening in the authentication process?
> Thanks.
>
>
Your error() function is creating a brand-new blank AuthenticationForm that
is passed in the context to the template, so the specific error message
associated with whatever caused is_valid() to fail (which has been added to
the original form's error_list) is being thrown away.  If instead you pass
back the form you called is_valid() on, then the template would be able to
report the specific error that is causing the validation failure.

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: Split Database Model for Replication: RW/RO

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 12:05 -0700, seblb wrote:
> Hi - is it possible to configure Django so that the admin section
> pulls details for a read/write db account/server and the main sites
> access the db via read only details?

This particular situation is easy. You run two different versions of the
site (i.e. using two settings files). The people using the admin use one
particular URL entry point that uses a settings file which has
DATABASE_USER set to somebody with update and insert permissions and
with the admin app installed. The public-access version uses a different
settings file with a read-only DATABASE_USER and doesn't have the admin
app in the INSTALLED_APP list.

Regards,
Malcolm



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



Re: Django book mostly done?

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 15:08 -0700, Graham Dumpleton wrote:
[...]
> More of a concern is that mod_python is still regarded as the most
> robust production setup. I can't see that mod_wsgi is even mentioned
> at all.

Here's a wild thought from out of left field: have you thought of
contacting the author of said book and mentioning it to him? Adrian (the
author) doesn't read this group, so this approach isn't going to work.

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: mod_python and Dev server compatible coding

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 13:34 -0700, Ross wrote:
> I'm a bit confused by finding a process that works for both the dev
> server and mod_python.
> 
> Mod_python uses a 'trigger' word to know to pass serving of that stuff
> by Django.  So URL's with /mysite/ leading them get handled by
> Django.  But it seems that the urls.py then gets the URL without the
> leading /mysite/ element.

The leading prefix is called the "script name" (after the web server
variable SCRIPT_NAME) and is indeed stripped. The remaineder -- "path
info" is what Django processes.

> 
> The dev server however would pass along the full URL.   So if I have a
> URL that I am targetting which is /mysite/soStuff

The development server is a limited development environment and
(intentionally) doesn't have all the features of a fully blown
webserver. I'm not sure how I'd feel about adding this feature to it.
It's a bit of a "meh" issue, really.

> 
> my URL conf will service the request when using the dev server with:
>   (r'^mysite/doStuff/$', 'mysite.project.views.doSomething'),
> 
> whereas the same click handled by mod_python will need an URL conf:
>  (r'^doStuff/$', 'mysite.project.views.doSomething'),
> 
> To make me more confused, there is a cryptic line in the documentation
> that doesn't make sense to me:
> 
> Django's URLconfs won't trim the "/mysite/" -- they get passed the
> full URL

That's a bug in the documentation. It used to be that way in the code,
but we fixed it to handle SCRIPT_NAMEs properly.

> Anyway, I don't know how I can make my urls.py work for both dev-
> server and mod_python, short of having two url-confs for every URL,
> which I am awkwardly doing for now.   I must be missing something
> here, so your help would be appreciated..

If the dev server doesn't meet your needs and you need a full webserver,
then do exactly that: use a full-powered web server. Normally, though,
this shouldn't really matter. All the links within your site can be made
to work without caring about the SCRIPT_NAME (e.g. the "url" template
tag adds it when required), so it's good practice to build your site
being able to move it to a different SCRIPT_NAME prefix.

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: Savepoint error with fastcgi

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 12:11 -0700, Peter Sheats wrote:
[...]
> The error I was getting before was just a "connection already closed
> error" until I changed the following in wsgi.py line 235-248:

Well, that's really the more important issue, then. Why is the
connection already closed when Django expects it to already be opened.
You need to investigate that problem a bit more, I think. It's related
to the error you get when you change things (since the attempt to close
off the savepoint will be causing a new connection to be opened, which
will have a different transaction status, etc -- it's all a consequence
of the first problem).

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: DjangoBook forms

2009-03-23 Thread Alex Gaynor
On Mon, Mar 23, 2009 at 8:53 PM, AKK  wrote:

>
> Hi,
>
> I'm working through chapter 7 of the djangobook online. and i've got
> the following:
>
> def search(request):
>if 'criteria' in request.GET:
>message = 'You searched for: %r' % request.GET['criteria']
>else:
>message = 'You submitted an empty form.'
>return HttpResponse(message)
>
> however, if i leave it blank rather than it saying "You submitted an
> empty form" it says:
>
> You searched for: u''.
>
> Can someone tell me how to fix this or mention why it occurs?
>
> Thanks,
>
> Andrew
> >
>
It occurs because the URL you went to was /search/?criteria=

Which the webserver and Django understand to mean that criteria is a key
whos value is '', fix this change the first conditional to be:
if request.GET.get('conditional')

Which means "if conditional is in GET return it, else return None" both of
which will evaluate to False in a boolean context.

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

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



Re: clean data

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 12:31 -0700, Bobby Roberts wrote:
[...]
> I thought I read that there was a way to chk data for sql query
> injections / cross site scripting etc before insertion

The whole thing about SQL injections is that there is no way to 100%
reliably "check for them". So you don't ever insert user-supplied data
into an SQL statement without quoting it. That is what the Python
database wrappers all do. Any user-supplied data are passed as
parameters, meaning they will be inserted as string literals (or
integers or whatever) into the database, not interpreted as SQL. That's
got nothing to do with forms.

Similarly, cross site scripting isn't something you check for. It's
something you prevent by not allowing raw HTML to be inserted by users.
That's handled on the output side by, e.g., auto-escaping for HTML, the
esapejs filter for Javascript and so on. It's not an input issue, per
se.

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



DjangoBook forms

2009-03-23 Thread AKK

Hi,

I'm working through chapter 7 of the djangobook online. and i've got
the following:

def search(request):
if 'criteria' in request.GET:
message = 'You searched for: %r' % request.GET['criteria']
else:
message = 'You submitted an empty form.'
return HttpResponse(message)

however, if i leave it blank rather than it saying "You submitted an
empty form" it says:

You searched for: u''.

Can someone tell me how to fix this or mention why it occurs?

Thanks,

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



Re: OWNING code

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 19:34 +0900, Russell Keith-Magee wrote:
> On Mon, Mar 23, 2009 at 2:52 PM, mn  wrote:
> >
> > Hello,
> > new on here and not a tech guy, wanted to know if a company or
> > programmer who uses Django can claim they own the code?
> 
> Firstly, IANAL, etc.
> 
> There are at least three blocks of code under discussion here.
> 
> Firstly, there is the code that comprises Django itself. Django's code
> is licensed under the BSD license [1]. The copyright is held by the
> Django Software Foundation. 

*cough* No. The DSF has a license to release/use, etc the code from
people who've signed the Licensing Agreement (and normal rights through
BSD licensing otherwise) and they might have a copyright on the
aggregate work -- it's never been clear to me what the boundaries are
for that in the US law that apply to the DSF in the US. However, the
code copyright is held by the individual contributors -- you, me, a
couple of hundred other people. I know I haven't signed over any
copyright rights to the DSF for my Django contributions, for example.

I know where you're going with that post and I agree with it, but that
particular point is a hot-button issue for me. Licensing != copyright
assignment.

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: Templating language Include path dilemma

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 17:21 +, Colm Dougan wrote:
[...]
> The question is whether the definition of the document root should
> change when evaluating includes.
> 
> For example, if I have template1 which includes path1/template2 then
> should include statements within template2 be wrt. to the original
> docroot *or* should everything be only relative to the one docroot.

Probably best not to talk about document root here, since that's more of
a webserver concept, than something Django cares about. It will only
confuse people.

The "include" template tag uses the normal template loading process. So
it passes that string to the template loaders, in order. How they choose
to interpret it is up to them: the app-loader uses it as a relative path
under *any* of the /template/ directories, the file-loader
users it as a relative path under the TEMPLATE_DIRS directories. Other
template loaders might do other things.

There is, however, no concept of "context" passed through to the
template loader. Everything is loaded from the same base situation,
which is what I believe your question is asking. The relevant code is in
django/template/loader_tags.py.


[...]
> I tend to favor the latter because then the include path is
> unambiguous since all includes are relative to the document root.

Which brings up the other problem with thinking about this in web server
terms. There is no unique "document root". There are many roots for the
template loading hierarchy. Multiple app directories, multiple
directories in TEMPLATE_DIRS, etc.

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: html greater than less than encoding problem

2009-03-23 Thread gl330k

Thank you that was it :)

On Mar 23, 5:01 pm, Briel  wrote:
> Hi.
>
> It sounds like you have run into the auto escape filter. It basically
> converts html tags into something viewable but not html. This is
> a protective matter, to protect your site from cross site scripting
> attacks, that can take down your site and worse. If you want to
> display some html from your db that you know are "safe", you can
> use the |safe tag to tell django not to escape it. Read about it at
> the
> docs.
>
> http://docs.djangoproject.com/en/dev/topics/templates/#id2
>
> ~Jakob
>
> On 23 Mar., 21:16, gl330k  wrote:
>
> > Hi all,
>
> > I'm a django newbie. I have a mysql database backend and when I try to
> > output html from the database I'm getting all the html as
>
> > ampersand + l + t + ;
>
> > So then when I view the page I'm basically seeing all the html tags.
>
> > mysql server - 5.1.30
>
> > Thoughts?
>
> > What am I doing wrong?
>
> > thanks
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Creating bound form and sending it to the page without validation

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 17:46 +0100, Marek Wawrzyczek wrote:
> I'd like to make a page, where the user will be able to edit a data of
> his account and add photos. There will be 2 buttons: add photo, and
> submit form. Add photo button will cause adding a photo to the server,
> so the form will be submited, and then in the response generated by
> django (so that the fields user entered before adding a photo weren't
> cleaned) there will be error messages if the user filled the email
> field for example "addres@". So I'd like to do validating of "non
> image" fields only after submiting a form. 

Nothing requires you to display the error messages on the HTML page. You
can write your own form display method that only displays the errors if
some other context variable is set, for example.

However, you haven't mentioned what happens when you just try what you
want to do. Does it work? If not, what goes wrong?

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: Dynamic app_label

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 11:44 -0400, Dan Mallinger wrote:
> I put together a solution this morning, but I noticed something odd
> that I've run into before and I was wondering if someone could give me
> some insight.  I've noticed that some of the time, when a module is
> loaded, it's named 'app.foo' and sometimes it's named as
> 'project.app.foo'.   Why is it that the project is only sometimes
> included in the module name?  I've seen this issue generally in
> Python, and I think there's something major about the language I'm
> missing right now and would love to have it clarified.

Python identifies things by their import paths. So although
"project.app.foo" *might* be the same module as "app.foo", it might not
be (if both "project" and "app" directories are on the Python path), so
Python doesn't make any assumptions.

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: Per app middleware?

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 14:20 +0100, Gabriel Rossetti wrote:
> Hello everyone,
> 
> I have a project that has two apps that use the same models (I moved it 
> out of the apps, up to the project's root). I was wondering if it is 
> possible to have global middleware (that they both need) and per app 
> middleware (sspecific to each app). I don't want one app's middleware to 
> intercept and process the other app's stuff, does anyone know how to do 
> this?

Middleware doesn't make sense on a per-app basis. It is run *before* any
view dispatching is done (and views aren't even tied to applications).
So the answer to your question is "no".

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



inconsistency between remove() and clear()?

2009-03-23 Thread Margie

It seems to me there is an inconsistency between clear() and remove
().  After a remove() I find that the related object set no longer
contains the specified object (as expected), and the specified object
also no longer points to the related set (this also is what I'd
expect).  However, in the case of clear(), I find that the related
object set is now cleared out (as I'd expect), but the objects that
used to be in the set still point to the set (not what I'd expect).
Is this difference intentional?

I also find that after exiting the shell and then going back in, now
the objects that used to be in the set no longer point to the set.
IE, the inconsistent clear behavior goes away if I exit the django
shell and then re-enter.

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

class Book(models.Model):
title = models.CharField(max_length=100)
publisher = models.ForeignKey(Publisher, blank=True, null=True)

>>> pub = Publisher.objects.create(name="pub1")
>>> book1 = pub.book_set.create(title="title1")
>>> pub.book_set.all()
[]
>>> book2 = pub.book_set.create(title="title2")
>>> pub.book_set.all()
[, ]
>>> book1.publisher

>>> book2.publisher


# after using remove() to remove book1, book1.publisher is empty
>>> pub.book_set.remove(book1)
>>> book1.publisher
>>> pub.book_set.all()
[]

# Now book2 references pub.  After using clear(), book2.publisher
still references pub
# This seems inconsistent with the remove() behavior above.
>>> pub.book_set.clear()
>>> book2.publisher


Any comments from those in-the-know?

Margie

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



Re: Problem with Sum() function

2009-03-23 Thread Russell Keith-Magee

On Tue, Mar 24, 2009 at 12:17 AM, eli  wrote:
>
> How to pass to the Sum() function (ORM) more than one field?
>
> My problem:
>
> class Model1(models.Model):
>    name = models.CharField(u'Name', max_length=255)
>
> class Model2(models.Model):
>    fk1 = models.ForeignKey(Model1, related_name='fk_1')
>    fk2 = models.ForeignKey(Model1, related_name='fk_2')
>
> I want to sort data by sum of fk1 and fk2 field.
>
> Model1.objects.annotate(myfk1=Count('fk1', distinct=True), myfk2=Count
> ('fk2', distinct=True)).annotate(my_sum=Sum('myfk1+myfk2')).order_by('-
> my_sum')

The first two parts - the annotation of myfk1 and myfk2 is fine - but
at present, annotation is a purely aggregate activity - you can't
(currently) annotate an expression that is formed from two fields on
the same model instance. This is a feature I would like to add at some
point, but it won't be happening any time soon.

You could do this using an 'extra' clause; i.e., replace the final
annotate() with:

.extra(select={'my_sum':'myfk1+myfk2'})

The extra clause is used to insert raw SQL into a Django query, so you
are responsible for choosing column names, etc However, aggregate
column names are fairly predictable, so you shouldn't hit too many
problems. Regardless, I strongly advise reading the documentation on
the extra clause so that you are aware of the issues you may hit.

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: Split Database Model for Replication: RW/RO

2009-03-23 Thread Russell Keith-Magee

On Tue, Mar 24, 2009 at 4:05 AM, seblb  wrote:
>
> Hi - is it possible to configure Django so that the admin section
> pulls details for a read/write db account/server and the main sites
> access the db via read only details?
>
> This would enable a single point of edit (master database) and multi-
> point reads (slave databases) for a DB replication setup.

This sort of thing is possible, if you know what you are doing.
However, there isn't (currently) a clean public API for this.

The ORM does have hooks to make this sort of thing possible, so if you
dig around the internals, you may be able to patch this sort of
functionality together. If you search the Django-developer archives
for discussion about multi-db support (the recent Google Summer of
Code applications have yielded a couple of revivals of that
discussion), you may be able to find enough detail to help. However,
you're going to need to get your hands dirty - if you want a clean
solution, you will need to wait a while until multi-db support is
added to trunk.

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: More DJango Tagging Oracle Issues

2009-03-23 Thread Brandon Taylor

Hi Ian,

I'm not that familiar with Oracle, so I have no idea if the problems
I'm experiencing are related in some way to permissions, etc, but I
have been reassured by my Oracle person that my user has full
permissions on my schema.

That being said, the TagField() will show up in admin when specifying:

from tagging.fields import TagField

class MyModel(models.Model):
tags = TagField()


When I create a new record, any tags that I have entered will be saved
to the tagging tables and associated to the record. However, when I
update the record, and add tags that aren't already present, or remove
all of the tags, no changes to the record will occur. All of the tags
that were there when I created the record are still there, but no new
tags, and no tags removed.

If I take the *exact* same model code, and switch my database to
SQLite or MySQL, I have no issues. I can only deduce that it's
something either wrong with my Oracle permissions, or with cx_Oracle
itself. I have wiped out my tables, re-validated, re-sync'd. Quadruple-
checked my code. And still the same problem. But yes, at least I can
add tags.

Perplexed,
Brandon

On Mar 23, 4:31 pm, Ian Kelly  wrote:
> On Mar 23, 1:52 pm, Brandon Taylor  wrote:
>
> > Hi Everyone,
>
> > Is anyone having issues with Django Tagging (svn) not updating tags on
> > an existing model? I'm running cx_Oracle-4.4.1 - thanks to (Ian Kelly)
> > and Django Trunk.
>
> Hmm.  I tried running the same model you posted before with Python 2.6
> and cx_Oracle 5.0.1, and I can't see that it makes any difference; it
> still works for me.  Glad you got it (at least partially) working,
> though.
>
> > I can add tags when a model instance is created, but update/delete is
> > not working.
>
> Can you be more specific?  It seems to be working for me.
>
> Regards,
> Ian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i18n escape-able quote marks

2009-03-23 Thread John Handelaar

2009/3/23 Malcolm Tredinnick :
> To solve your particular problem here, though, it might be possible to
> write your own version of the url template tag. Writing custom template
> tags is easy enough (and documented). Writing a templtae tag that more
> or less wraps another template tag is probably even more
> straightforward.

I've just tried this:

{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% ifequal LANGUAGE_CODE "en" %}
{% include "web/langswitcher-english.html" 
%}
{% endifequal %}
{% ifequal LANGUAGE_CODE "es" %}
{% include "web/langswitcher-espanol.html" 
%}
{% endifequal %}

...but  LANGUAGE_CODE is set to "en" even when the page is correctly
displaying in Spanish.  Is this a bug or am I doing it wrong?


jh

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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-registration - 504 error

2009-03-23 Thread neri...@gmail.com

Hey,

does anyone know why I'm getting a "Exception Type:
SMTPRecipientsRefused" error using django-registration?

Exception Type: SMTPRecipientsRefused
Exception Value:

{u'neri...@gmail.com': (504, ': Sender address
rejected: need fully-qualified address')}

Exception Location: /home/USER/projects/django/trunk/django/core/
mail.py in _send, line 186

Thanks,

J
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 book mostly done?

2009-03-23 Thread Alex Gaynor
On Mon, Mar 23, 2009 at 6:08 PM, Graham Dumpleton <
graham.dumple...@gmail.com> wrote:

>
>
>
> On Mar 18, 6:20 pm, Gour  wrote:
> > > "Alex" == Alex Gaynor  writes:
> >
> > Alex> Adrian just put the last batch of chapters online, so I believe
> > Alex> all the content is now up.  Having skimmed most of it I can say it
> > Alex> looks really good and I'm sure it basically all works, that said
> > Alex> it isn't a final addition so there may be tiny errors, typos, or
> > Alex> other mistakes.
> >
> > It's nice to see all the chapters online...although I'm bit disappointed
> > to see that ch.12 still does not mention nginx server at all :-(
>
> More of a concern is that mod_python is still regarded as the most
> robust production setup. I can't see that mod_wsgi is even mentioned
> at all.
>
> Given all the problems that exist with mod_python am just surprised it
> is still pushed as the best option at this point.
>
> Graham
>
>
>
> >
>
Well that's an issue for the authors, I've filed a ticket in Django's trac
to have mod_wsgi docs added: http://code.djangoproject.com/ticket/9970 .
Feel free to give it a look over(consideirng you're the expert here).

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

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 book mostly done?

2009-03-23 Thread Graham Dumpleton



On Mar 18, 6:20 pm, Gour  wrote:
> > "Alex" == Alex Gaynor  writes:
>
> Alex> Adrian just put the last batch of chapters online, so I believe
> Alex> all the content is now up.  Having skimmed most of it I can say it
> Alex> looks really good and I'm sure it basically all works, that said
> Alex> it isn't a final addition so there may be tiny errors, typos, or
> Alex> other mistakes.  
>
> It's nice to see all the chapters online...although I'm bit disappointed
> to see that ch.12 still does not mention nginx server at all :-(

More of a concern is that mod_python is still regarded as the most
robust production setup. I can't see that mod_wsgi is even mentioned
at all.

Given all the problems that exist with mod_python am just surprised it
is still pushed as the best option at this point.

Graham



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



Re: Django book mostly done?

2009-03-23 Thread Alex Gaynor
On Mon, Mar 23, 2009 at 5:31 PM, Scot Hacker  wrote:

>
>
> On Mar 17, 2009, at 10:51 AM, Alex Gaynor wrote:
>
> > Adrian just put the last batch of chapters online, so I believe all
> > the content is now up.  Having skimmed most of it I can say it looks
> > really good and I'm sure it basically all works, that said it isn't
> > a final addition so there may be tiny errors, typos, or other
> > mistakes.  I wouldn't have a problem reading through that(I
> > originally learned from the original book before it was published).
> > If you haven't already I would take a look at the official django
> > docs/tutorial, they really are quite good :).
>
>
> Considering what an important learning resource the Django Book is,
> you'd think it would get some linkage from djangoproject.com  -- the
> string "book" doesn't appear on the homepage or any of the six top-
> level pages, or even in the Django FAQ index!
>
> ./s
>
>
>
> >
>
Though Adrian and Jacob are to BDFLs of Django, the DjangoBook is not an
official resource and is a private enterprise by them.  Thus using
djangoproject.com to advertise it might be seen as unethical.

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

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 book mostly done?

2009-03-23 Thread Scot Hacker


On Mar 17, 2009, at 10:51 AM, Alex Gaynor wrote:

> Adrian just put the last batch of chapters online, so I believe all  
> the content is now up.  Having skimmed most of it I can say it looks  
> really good and I'm sure it basically all works, that said it isn't  
> a final addition so there may be tiny errors, typos, or other  
> mistakes.  I wouldn't have a problem reading through that(I  
> originally learned from the original book before it was published).   
> If you haven't already I would take a look at the official django  
> docs/tutorial, they really are quite good :).


Considering what an important learning resource the Django Book is,  
you'd think it would get some linkage from djangoproject.com  -- the  
string "book" doesn't appear on the homepage or any of the six top- 
level pages, or even in the Django FAQ index!

./s



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



Re: More DJango Tagging Oracle Issues

2009-03-23 Thread Ian Kelly

On Mar 23, 1:52 pm, Brandon Taylor  wrote:
> Hi Everyone,
>
> Is anyone having issues with Django Tagging (svn) not updating tags on
> an existing model? I'm running cx_Oracle-4.4.1 - thanks to (Ian Kelly)
> and Django Trunk.

Hmm.  I tried running the same model you posted before with Python 2.6
and cx_Oracle 5.0.1, and I can't see that it makes any difference; it
still works for me.  Glad you got it (at least partially) working,
though.

> I can add tags when a model instance is created, but update/delete is
> not working.

Can you be more specific?  It seems to be working for me.

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



Re: RichTextField widget for django

2009-03-23 Thread Scot Hacker


On Mar 20, 2009, at 7:27 AM, Greg Fuller wrote:

> http://code.google.com/p/django-fckconnector/
> http://code.google.com/p/django-tinymce/

See also:

http://www.wymeditor.org/
https://trac.wymeditor.org/trac/wiki/Contrib/IntegrateInDjango

./s



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



Re: html greater than less than encoding problem

2009-03-23 Thread Briel

Hi.

It sounds like you have run into the auto escape filter. It basically
converts html tags into something viewable but not html. This is
a protective matter, to protect your site from cross site scripting
attacks, that can take down your site and worse. If you want to
display some html from your db that you know are "safe", you can
use the |safe tag to tell django not to escape it. Read about it at
the
docs.

http://docs.djangoproject.com/en/dev/topics/templates/#id2

~Jakob

On 23 Mar., 21:16, gl330k  wrote:
> Hi all,
>
> I'm a django newbie. I have a mysql database backend and when I try to
> output html from the database I'm getting all the html as
>
> ampersand + l + t + ;
>
> So then when I view the page I'm basically seeing all the html tags.
>
> mysql server - 5.1.30
>
> Thoughts?
>
> What am I doing wrong?
>
> thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



html greater than less than encoding problem

2009-03-23 Thread gl330k

Hi all,

I'm a django newbie. I have a mysql database backend and when I try to
output html from the database I'm getting all the html as

ampersand + l + t + ;

So then when I view the page I'm basically seeing all the html tags.

mysql server - 5.1.30

Thoughts?

What am I doing wrong?

thanks

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



seeking elegant solution to ordered list of installed applications

2009-03-23 Thread Michael Repucci

Hi All, I've got a Django project composed of several apps. The site's
main page creates links from the list of installed apps like so:

#taken from the project's urlconf
apps = [app.split('.')[1] for app in settings.INSTALLED_APPS if
app.startswith(#project name#)]
info_dict = {'template': 'index.html', 'extra_context': {'apps':
apps},}
urlpatterns = patterns('',(r'^$',
'django.views.generic.simple.direct_to_template', info_dict),)

Then in the template the links are created from the apps list. Now my
boss wants to be able to change the labels and order of those links by
going through the admin. I can't come up with any elegant solution to
this. Best I've come up with is creating a new model (with app_name,
label, and order fields) that somehow gets populated with instances
dynamically.

Can anyone think of a beautiful (simple) solution? Or should I just
tell my boss to go f%&^ himself? ;) Just kidding!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Having trouble authenticating/validating

2009-03-23 Thread Adam Yee

I'm using Django's builtin AuthenticationForm

Here's my login view: http://dpaste.com/18110/

Form submittal (not empty or empty fields) takes me back to the login
page with 'Did not login'.  My debugging print statement isn't showing
up in the terminal, so is_valid is somehow returning false.

If I submit with empty fields, I don't get the default 'This field is
required' type of error messages that I would expect.  I'm not sure
how clean() is working with the AuthenticationForm...  Am I validating
correctly? Or is something happening in the authentication process?
Thanks.


# django.contrib.auth.forms.py
# AuthenticationForm's clean()
...
def clean(self):
username = self.cleaned_data.get('username')
password = self.cleaned_data.get('password')

if username and password:
self.user_cache = authenticate(username=username,
password=password)
if self.user_cache is None:
raise forms.ValidationError(_("Please enter a correct
username and password. Note that both fields are case-sensitive."))
elif not self.user_cache.is_active:
raise forms.ValidationError(_("This account is
inactive."))

# TODO: determine whether this should move to its own method.
if self.request:
if not self.request.session.test_cookie_worked():
raise forms.ValidationError(_("Your Web browser
doesn't appear to have cookies enabled. Cookies are required for
logging in."))

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



Re: django-registration - outputting errors

2009-03-23 Thread jeffhg58


The way I have implemented this is to have to the validation occur at 
password2. 

Instead of having the check in clean, I would have the validation in 
clean_password2. 

Hope that helps. 
- Original Message - 
From: neri...@gmail.com 
To: "Django users"  
Sent: Monday, March 23, 2009 3:33:04 PM GMT -06:00 US/Canada Central 
Subject: django-registration - outputting errors 


Hello, 

I just started my first django project and I'm not sure how to print 
the errors from non_field_errors(). Here is the snippet from 
registration.forms.py: 

    def clean(self): 
        """ 
        Verifiy that the values entered into the two password fields 
        match. Note that an error here will end up in 
        ``non_field_errors()`` because it doesn't apply to a single 
        field. 

        """ 
        if 'password1' in self.cleaned_data and 'password2' in 
self.cleaned_data: 
            if self.cleaned_data['password1'] != self.cleaned_data 
['password2']: 
                raise forms.ValidationError(_(u'You must type the same 
password each time')) 
        return self.cleaned_data 

Here is my template snippet: 

{% if form.non_field_errors %} 
Print the errors. 
{% endif %} 

Thanks for any help, 

J 


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 a multiselect list box for a static list of options

2009-03-23 Thread Brian Neal

On Mar 23, 3:36 pm, Adam Fraser  wrote:
> I found the SelectMultiple widget here:
>
> http://docs.djangoproject.com/en/dev/ref/forms/widgets/
>
> But I still don't know how to hook that up to a model like
> CommaSeparatedIntegerField.
>
> help?
>

Did you try something like this? This is off the top of my head:

class MyForm(forms.ModelForm):
   my_choices = forms.CommaSeparatedIntegerField
(widget=forms.SelectMultiple(choices=STAIN_CHOICES))

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



aggregation with foreign key fields and the admin interface

2009-03-23 Thread Andrew D. Ball

I've got what appears to be a common (but not often answered)
question about the admin interface:

I want to use foreign key fields for aggregation (in the
object-oriented sense).  This is easily done with model
definitions like the following:

class USAddress(models.Model):
street_line_1 = models.CharField(max_length=120)
street_line_2 = models.CharField(max_length=120)
city = models.CharField(max_length=50)
state = models.CharField(max_length=2)
zip_code = models.CharField(max_length=10)

class Venue(models.Model):
shipping_address = models.ForeignKey(USAddress, null=True)
billing_address = models.ForeignKey(USAddress)
some_other_field = models.CharField(max_length=120)

I'd really like to be able to edit the fields in the
shipping address and billing address inline while creating
and editing venues in the admin interface.  However,
I haven't been able to find any simple way to do so.  I
don't want one-to-many relationships with these foreign
keys, I want aggregation.

What options do I have?

I've thought about making a special address form field
or even making an aggregation foreign key form field
that would generalize this idea.

Thanks for your help,
Andrew

-- 
===
Andrew D. Ball
ab...@americanri.com
Software Engineer
American Research Institute, Inc.
http://www.americanri.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: need a multiselect list box for a static list of options

2009-03-23 Thread Adam Fraser

I found the SelectMultiple widget here:

http://docs.djangoproject.com/en/dev/ref/forms/widgets/

But I still don't know how to hook that up to a model like
CommaSeparatedIntegerField.

help?

On Mar 23, 3:25 pm, Adam Fraser  wrote:
> I don't see anything called SelectMultiple on the page you linked.
> That was the page I've been scouring for a while now looking for a way
> to do this.  The ModelMultipleChoiceField looks promising, but
> apparently it's associated with a ManyToManyField model, and that
> doesn't really fit what I'm going for, but seems to complicate things,
> requiring me to make a whole separate model class and add the
> corresponding tables and columns to my database when all I want are a
> few static choices.
>
> Thanks for taking the time to respond!
>
> Any other ideas?
> -Adam
>
> On Mar 23, 3:09 pm, Briel  wrote:
>
> > Hi.
>
> > I haven't played much around with this kind of thing, but I
> > would suggest that you take a look at the form widgets.
> > One of them is called, SelectMultiple, which I bet is the one
> > you are after, but I'm not sure if it will work with choices.
> > You can find something about it 
> > athttp://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> > ~Jakob
>
> > On 23 Mar., 19:49, Adam Fraser  wrote:
>
> > > Hello,
>
> > > This should be a pretty simple question.  I have a list of options:
>
> > > STAIN_CHOICES = (
> > >     (1, 'DNA - DAPI'),
> > >     (2, 'DNA - Hoechst'),
> > >     (3, 'DNA - other'),
> > >     (4, 'Actin - Phalloidin'),
> > >     (5, 'Tubulin'),
> > > )
>
> > > I would like users to be able to select more than one of these things
> > > at a time.  It looks like models.CommaSeparatedIntegerField would be
> > > good for this, but how can I get a multi-selection list box as an
> > > input?
>
> > > -adam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



mod_python and Dev server compatible coding

2009-03-23 Thread Ross

I'm a bit confused by finding a process that works for both the dev
server and mod_python.

Mod_python uses a 'trigger' word to know to pass serving of that stuff
by Django.  So URL's with /mysite/ leading them get handled by
Django.  But it seems that the urls.py then gets the URL without the
leading /mysite/ element.

The dev server however would pass along the full URL.   So if I have a
URL that I am targetting which is /mysite/soStuff

my URL conf will service the request when using the dev server with:
  (r'^mysite/doStuff/$', 'mysite.project.views.doSomething'),

whereas the same click handled by mod_python will need an URL conf:
 (r'^doStuff/$', 'mysite.project.views.doSomething'),

To make me more confused, there is a cryptic line in the documentation
that doesn't make sense to me:

Django's URLconfs won't trim the "/mysite/" -- they get passed the
full URL

That seems to conflict with the actual behaviour described above, no?

Anyway, I don't know how I can make my urls.py work for both dev-
server and mod_python, short of having two url-confs for every URL,
which I am awkwardly doing for now.   I must be missing something
here, so your help would be appreciated..

-Ross


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 a multiselect list box for a static list of options

2009-03-23 Thread Brian Neal

On Mar 23, 1:49 pm, Adam Fraser  wrote:
> Hello,
>
> This should be a pretty simple question.  I have a list of options:
>
> STAIN_CHOICES = (
>     (1, 'DNA - DAPI'),
>     (2, 'DNA - Hoechst'),
>     (3, 'DNA - other'),
>     (4, 'Actin - Phalloidin'),
>     (5, 'Tubulin'),
> )
>
> I would like users to be able to select more than one of these things
> at a time.  It looks like models.CommaSeparatedIntegerField would be
> good for this, but how can I get a multi-selection list box as an
> input?
>

There is a form widget called SelectMultiple:

http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms.SelectMultiple

You could use a ChoiceField with a SelectMultipleWidget, it would
seem.

-BN
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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-registration - outputting errors

2009-03-23 Thread neri...@gmail.com

Hello,

I just started my first django project and I'm not sure how to print
the errors from non_field_errors(). Here is the snippet from
registration.forms.py:

def clean(self):
"""
Verifiy that the values entered into the two password fields
match. Note that an error here will end up in
``non_field_errors()`` because it doesn't apply to a single
field.

"""
if 'password1' in self.cleaned_data and 'password2' in
self.cleaned_data:
if self.cleaned_data['password1'] != self.cleaned_data
['password2']:
raise forms.ValidationError(_(u'You must type the same
password each time'))
return self.cleaned_data

Here is my template snippet:

{% if form.non_field_errors %}
Print the errors.
{% endif %}

Thanks for any help,

J
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 figuring out how to make request.GET.getlist to work plz --SOLVED

2009-03-23 Thread bsisco

figured it out on the IRC channeli basically just needed to modify
my view as follows to make it work
def results(request):
  select = request.GET.getlist('select')
  results = Warranty.objects.filter(id__in=select)

  return render_to_response('admin/report_list.html',
{'results':results, 'select':select})

On Mar 23, 2:37 pm, "Blake M. Sisco"  wrote:
> ok i am having an issue getting getlist() to work properly.  it displays the
> correct number of rows in the template but there is not any data in those
> rows.  firebug shows the following:
> *Request Headers*
> Host: wartrac.lormfg.com
> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7)
> Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)
> Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language: en-us,en;q=0.5
> Accept-Encoding: gzip,deflate
> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive: 300
> Connection: keep-alive
> Referer:http://wartrac.lormfg.com/tracker/reports/
> Cookie:
> __utma=244144280.546994815381888600.1236088196.1236959460.1237809098.5;
> __utmz=244144280.1236088196.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
> __utma=163233722.378754721565061.1236361989.1236361989.1236361989.1;
> __utmz=163233722.1236361989.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
> sessionid=96ae590c0ec429724113fdbb8d6da83d; __utmc=244144280
> Cache-Control: max-age=0
> *
> Response Headers*
> Date: Mon, 23 Mar 2009 18:29:16 GMT
> Server: Apache
> Content-Type: text/html; charset=utf-8
> Connection: close
> Transfer-Encoding: chunked
>
> *Params*
> *select* 42 (this is the correct item based on my selection from the form)
>
> if someone could show/tell me where i'm going wrong i would appreciate it.
> Below are my views .py, report.html and report_list.html
>
> views.py
> from django.shortcuts import render_to_response
>
> from models import
> Warranty
>
> from django.http import
> *
>
> def
> index(request):
>
>   open_warranty_list =
> Warranty.objects.all().order_by('date_ent')
>
>   return render_to_response('tracker/index.html', {'open_warranty_list':
> open_warranty_list})
>
> def
> report_view(request):
>
>   SelectForm =
> Warranty.objects.all().order_by('id')
>
>   return
> render_to_response('admin/report.html',{'SelectForm':SelectForm})
>
> def
> results(request):
>
>   if 'select' in request.GET and
> request.GET['select']:
>
>     results = request.GET.getlist("select")
>
>     return
> render_to_response('admin/report_list.html',{'results':results})
>
> else:
>
>     return render_to_response('admin/report.html', {'error':True})
>
> ~
>
> report.html
> 
>         
>           
>             
>               
>               QI
>               Part No.
>               Serial No.
>               Date Entered
>               Warranty
>               Desc.
>               {%ifequal result.desc "Other"%}
>                Other
>               {%endifequal%}
>               Comments
>             
>           
>           {%for warranty in SelectForm %}
>           
>               value="{{warranty.id}}" name="select" />
>              {{warranty.q_i_n}}
>              {{warranty.p_no}}
>              {{warranty.s_no}}
>              {{warranty.date_ent}}
>             {%ifequal warranty.warranty 0
> %}No{%else%}Yes{%endifequal%}
>              {{warranty.get_desc_display}}
>             {%ifequal warranty.desc "Other"%}
>              {{warranty.other}}
>             {%endifequal%}
>              {{warranty.comment}}
>           
>         {%endfor%}
>         
>         
>       
> report_list.html
> {% if select %}
>       
>         
>           
>             QI
>             Part No.
>             Serial No.
>             Date Entered
>             Warranty
>             Desc.
>             {%ifequal data.desc "Other"%}
>              Other
>             {%endifequal%}
>             Comments
>           
>         
>         {%for select in results %}
>         
>            {{select.q_i_n}}
>            {{select.p_no}}
>            {{select.s_no}}
>            {{select.date_ent}}
>           {%ifequal select.warranty 0 %}No{%else%}Yes{%endifequal%}
>            {{select.get_desc_display}}
>           {%ifequal select.desc "Other"%}
>            {{select.other}}
>           {%endifequal%}
>            {{select.comment}}
>         
>       {%endfor%}
>       
> Blake M. Sisco
> LOR Manufacturing Co., Inc
> Web Presence • Graphic Designwww.lormfg.com
> (866) 644-8622
> (888) 524-6292 FAX
>
> The information transmitted by Blake Sisco herewith is intended only for the
> person or entity to which it is addressed and may contain confidential
> and/or privileged material.  Any review, retransmission, dissemination or
> other use of, or taking of any action in reliance upon, this information by
> persons or entities other than the intended recipient is prohibited.  If you
> received this in error, please contact the sender and delete the material
> from any computer

Re: clean data

2009-03-23 Thread Briel

I'm not sure how django has built it sql injection protection, but I
would guess that when you fx do model.save() or form.save()
that the functions actually making the sql to the db makes sure
that there are no injections by making place holders for data ect.

XSS is something I do know how work, however, and is not
in effect when data is being saved, but rather when it is being
rendered. Django will auto escape all potentially harmful chars
like < > ", to prevent anything such attacks.

~Jakob

On 23 Mar., 20:31, Bobby Roberts  wrote:
> > Cleaning data is not in place as a security measure, but rather to
> > help you validate the data. That means that you can check the data
> > and find out if it fill your requirements. If you have a text field
> > and
> > want users to type in a serial number, you probably need some
> > custom validation like to see if the serial number has the correct
> > number of digits/chars ect. Or if they need to type in a phone number
> > you probably want to check that as well. Django does some validation
> > for you automatically, like checking email fields for @ and dots.
>
> I thought I read that there was a way to chk data for sql query
> injections / cross site scripting etc before insertion Is that a
> mis-understanding on my part?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 Sum() function

2009-03-23 Thread Alex Gaynor
On Mon, Mar 23, 2009 at 4:02 PM, eli  wrote:

>
> anybody?
>
> On 23 Mar, 16:17, eli  wrote:
> > How to pass to the Sum() function (ORM) more than one field?
> >
> > My problem:
> >
> > class Model1(models.Model):
> > name = models.CharField(u'Name', max_length=255)
> >
> > class Model2(models.Model):
> > fk1 = models.ForeignKey(Model1, related_name='fk_1')
> > fk2 = models.ForeignKey(Model1, related_name='fk_2')
> >
> > I want to sort data by sum of fk1 and fk2 field.
> >
> > Model1.objects.annotate(myfk1=Count('fk1', distinct=True), myfk2=Count
> > ('fk2', distinct=True)).annotate(my_sum=Sum('myfk1+myfk2')).order_by('-
> > my_sum')
> >
> > Thanks for help.
> >
> > regards.
> >
>
You've waited only 4 hours, and many people haven't had chance to see this
sinec they're either at work or on the other side of the world(asleep).
Please be patient.

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

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 Sum() function

2009-03-23 Thread eli

anybody?

On 23 Mar, 16:17, eli  wrote:
> How to pass to the Sum() function (ORM) more than one field?
>
> My problem:
>
> class Model1(models.Model):
>     name = models.CharField(u'Name', max_length=255)
>
> class Model2(models.Model):
>     fk1 = models.ForeignKey(Model1, related_name='fk_1')
>     fk2 = models.ForeignKey(Model1, related_name='fk_2')
>
> I want to sort data by sum of fk1 and fk2 field.
>
> Model1.objects.annotate(myfk1=Count('fk1', distinct=True), myfk2=Count
> ('fk2', distinct=True)).annotate(my_sum=Sum('myfk1+myfk2')).order_by('-
> my_sum')
>
> Thanks for help.
>
> regards.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



More DJango Tagging Oracle Issues

2009-03-23 Thread Brandon Taylor

Hi Everyone,

Is anyone having issues with Django Tagging (svn) not updating tags on
an existing model? I'm running cx_Oracle-4.4.1 - thanks to (Ian Kelly)
and Django Trunk.

I can add tags when a model instance is created, but update/delete is
not working.

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



Re: OWNING code

2009-03-23 Thread Mario

mn,

Django Web Framework is an open source; however, the customized code
developed for Django strictly belongs to the developer/organization.
Let's put this in perspective. For example, a Java Programmers relies
on Java to run their code. Although Java was developed by Sun
Microsystems, the programmers/developers who developed the proprietary
application such as Reservation Ticket Web Application relies on the
Java Run Time Engine to display and support the web application. The
"code" that the developer customized for a company is strictly the
property of the developer and under normal circumstances when a
contract agreement is signed. The same principle goes for Django.
There is usually a spelled-out before the inception of the project and
before the actual commencement of work.

For what it is worth, I would rather develop and write my own apps
rather spend precious time and monies to litigation.

Just my 2 cents.




On Mar 23, 1:52 am, mn  wrote:
> Hello,
> new on here and not a tech guy, wanted to know if a company or
> programmer who uses Django can claim they own the code?
>
> Also if I have my developer build my website using Django, do I own it
> or simply license the code?
>
> Please advise, thank you
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: clean data

2009-03-23 Thread Bobby Roberts

> Cleaning data is not in place as a security measure, but rather to
> help you validate the data. That means that you can check the data
> and find out if it fill your requirements. If you have a text field
> and
> want users to type in a serial number, you probably need some
> custom validation like to see if the serial number has the correct
> number of digits/chars ect. Or if they need to type in a phone number
> you probably want to check that as well. Django does some validation
> for you automatically, like checking email fields for @ and dots.


I thought I read that there was a way to chk data for sql query
injections / cross site scripting etc before insertion Is that a
mis-understanding on my part?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Can I limit the choices in a ContentType field in admin?

2009-03-23 Thread Adam Stein

Trying to create a generic FK using ContentType.  In admin, the menu
lists all the models.  Since I only ever need to select 1 of 2 different
models, anyway to limit the choice?

Setting the choices attribute as Django complains

must be a "ContentType" instance

ContentType.objects.get() returns an instance of a particular model, not
ContentType (as one would expect), so I'm not sure how to create an
instance with the particulars I need to point to something specific in
the choices list.  Here's what I have:

from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic

class GenericFKExample(models.Model):
CHOICES = (
(ContentType.objects.get(model="model1"), "Model 1"),
(ContentType.objects.get(model="model2"), "Model 2"),
)

content_type = models.ForeignKey(ContentType,
choices = CHOICES,
null = True,
)

object_id = models.PositiveIntegerField(
null = True,
)

content_object = generic.GenericForeignKey(
"content_type", "object_id"
)

Obviously, if I don't use choices, it works but then I have a very long
list of model choices.

-- 
Adam Stein @ Xerox Corporation   Email: a...@eng.mc.xerox.com

Disclaimer: Any/All views expressed
here have been proven to be my own.  [http://www.csh.rit.edu/~adam/]


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 a multiselect list box for a static list of options

2009-03-23 Thread Adam Fraser

I don't see anything called SelectMultiple on the page you linked.
That was the page I've been scouring for a while now looking for a way
to do this.  The ModelMultipleChoiceField looks promising, but
apparently it's associated with a ManyToManyField model, and that
doesn't really fit what I'm going for, but seems to complicate things,
requiring me to make a whole separate model class and add the
corresponding tables and columns to my database when all I want are a
few static choices.

Thanks for taking the time to respond!

Any other ideas?
-Adam

On Mar 23, 3:09 pm, Briel  wrote:
> Hi.
>
> I haven't played much around with this kind of thing, but I
> would suggest that you take a look at the form widgets.
> One of them is called, SelectMultiple, which I bet is the one
> you are after, but I'm not sure if it will work with choices.
> You can find something about it 
> athttp://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> ~Jakob
>
> On 23 Mar., 19:49, Adam Fraser  wrote:
>
> > Hello,
>
> > This should be a pretty simple question.  I have a list of options:
>
> > STAIN_CHOICES = (
> >     (1, 'DNA - DAPI'),
> >     (2, 'DNA - Hoechst'),
> >     (3, 'DNA - other'),
> >     (4, 'Actin - Phalloidin'),
> >     (5, 'Tubulin'),
> > )
>
> > I would like users to be able to select more than one of these things
> > at a time.  It looks like models.CommaSeparatedIntegerField would be
> > good for this, but how can I get a multi-selection list box as an
> > input?
>
> > -adam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Split Database Model for Replication: RW/RO

2009-03-23 Thread seblb

Hi - is it possible to configure Django so that the admin section
pulls details for a read/write db account/server and the main sites
access the db via read only details?

This would enable a single point of edit (master database) and multi-
point reads (slave databases) for a DB replication setup.

Thanks in advance!


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



Savepoint error with fastcgi

2009-03-23 Thread Peter Sheats

I am trying to setup my local box to run my site with fastcgi.  I want
to do this to mirror the way we have the site set up on our live
servers so I can work on implementing something like
http://soyrex.com/blog/django-nginx-and-memcached/.

I can run my site fine using django's test server, no errors or
anything.  However if I do the following I get a ProgrammingError:
SAVEPOINT can only be used in transaction blocks error.

1. ./manage.py runfcgi host=127.0.0.1 port=3000 pidfile=/usr/local/
nginx/logs/byp.pid
2. start nginx
3. hit the same url that works with runserver.

Here is the error that shows up in nginx error logs:

2009/03/23 15:05:34 [error] 11755#0: *5 FastCGI sent in stderr:
"Traceback (most recent call last):
  File "build/bdist.macosx-10.3-i386/egg/flup/server/fcgi_base.py",
line 558, in run
protocolStatus, appStatus = self.server.handler(self)
  File "build/bdist.macosx-10.3-i386/egg/flup/server/fcgi_base.py",
line 1116, in handler
result = self.application(environ, start_response)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/core/handlers/wsgi.py", line 245, in
__call__
response = middleware_method(request, response)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/contrib/sessions/middleware.py", line
36, in process_response
request.session.save()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/contrib/sessions/backends/db.py", line
56, in save
sid = transaction.savepoint()
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/db/transaction.py", line 190, in
savepoint
connection._savepoint(sid)
  File "/Library/Frameworks/Python.framework/Versions/2.5/lib/
python2.5/site-packages/django/db/backends/__init__.py", line 62, in
_savepoint
self.connection.cursor().execute(self.ops.savepoint_create_sql
(sid))
ProgrammingError: SAVEPOINT can only be used in transaction blocks"
while reading response header from upstream, client: 127.0.0.1,
server: byp, request: "GET /realestate/ HTTP/1.1", upstream:
"fastcgi://127.0.0.1:3000", host: "byp"

Here is what is happening in PostgreSQL:
LOG:  duration: 0.365 ms  statement: SELECT
"django_session"."session_key", "django_session"."session_data",
"django_session"."expire_date" FROM "django_session" WHERE
("django_session"."session_key" = '24259c268a8eddd4a32b5b0475ff6be9'
AND "django_session"."expire_date" > '2009-03-23 15:05:34.123882' )
ERROR:  SAVEPOINT can only be used in transaction blocks
STATEMENT:  SAVEPOINT s1610559488_x7

The error I was getting before was just a "connection already closed
error" until I changed the following in wsgi.py line 235-248:
# try:
try:
request = self.request_class(environ)
except UnicodeDecodeError:
response = http.HttpResponseBadRequest()
else:
response = self.get_response(request)

# Apply response middleware
for middleware_method in self._response_middleware:
response = middleware_method(request, response)
response = self.apply_response_fixes(request, response)
# finally:
# signals.request_finished.send(sender=self.__class__)

I am on trunk and using flup version flup-1.0.1 but the problem also
existed on django_1.0.2 and flup_0.5.

Thanks,

Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 a multiselect list box for a static list of options

2009-03-23 Thread Briel

Hi.

I haven't played much around with this kind of thing, but I
would suggest that you take a look at the form widgets.
One of them is called, SelectMultiple, which I bet is the one
you are after, but I'm not sure if it will work with choices.
You can find something about it at
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

~Jakob

On 23 Mar., 19:49, Adam Fraser  wrote:
> Hello,
>
> This should be a pretty simple question.  I have a list of options:
>
> STAIN_CHOICES = (
>     (1, 'DNA - DAPI'),
>     (2, 'DNA - Hoechst'),
>     (3, 'DNA - other'),
>     (4, 'Actin - Phalloidin'),
>     (5, 'Tubulin'),
> )
>
> I would like users to be able to select more than one of these things
> at a time.  It looks like models.CommaSeparatedIntegerField would be
> good for this, but how can I get a multi-selection list box as an
> input?
>
> -adam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Using Template Tags Within Markdown

2009-03-23 Thread Alex Gaynor
On Mon, Mar 23, 2009 at 12:56 PM, Daniel Watkins <
dan...@daniel-watkins.co.uk> wrote:

>
> Hello all,
>
> I'm currently trying to render some text in Markdown format, that
> contains templatetags.  For example:
>
>[This]({% cms_link 22 %}) is a link.
>
> If I render this:
>
>{{ that_text|markdown }}
>
> the '{% cms_link 22 %}' remains verbatim in the output.
>
> As I see it, there are two potential solutions:
>
>  * a solution using templatetags of which I am not yet aware, or
>  * some pre-processing within the view.
>
> Is this a correct assumption, or am I missing something?
>
> If I have to resort to the latter, what would it involve?  How do I pass
> a templatetag (rather than just a variable) into a template processor?
>
>
> Thanks in advance,
>
>
> Dan
>
>
> >
>
I would write a template filter that takes a block of text and renders it as
a template, and then render that as markdown so it would look like:

{{ that_text|templatize|markdown }}

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

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



Re: clean data

2009-03-23 Thread Briel

Hi
I'll try to help answer your 3 Qs

> 1.  what does cleaning actually do... prevent sql query injections?
> Anything else?

Cleaning data is not in place as a security measure, but rather to
help you validate the data. That means that you can check the data
and find out if it fill your requirements. If you have a text field
and
want users to type in a serial number, you probably need some
custom validation like to see if the serial number has the correct
number of digits/chars ect. Or if they need to type in a phone number
you probably want to check that as well. Django does some validation
for you automatically, like checking email fields for @ and dots.

> 2.  I'm assuming, if I had a function as follows:
>
>     def clean(self):
>         cleaned_data = self.cleaned_data
>         return cleaned_data
>
> That this would return a dictionary of  the form in it's cleaned
> state.  Is this a correct assumption?

The above method wouldn't actually do anything AFAIK as by
default django forms will have their cleaned data in a dictionary.
You actually don't need to write a clean method unless you need
to do custom/special validation. Like checking date inputs in a
textfield.

> 3.  How would I call this when saving data?  Lets say I have this in
> my view which saves the data to the database:
>
>                         mydata=Mydata(
>                                 
> description=request.POST.get('description',''),
>                                 sku = request.POST.get('sku',''),
>                         mydata.save()
>
> is it as simple as wrapping the request.POST.get... in clean()?

The cleaned_data is available to your form, so if you have a form
called MyForm, that you have imported in your view and are
rendering in your template. You could then do something like this:

form = MyForm(request.POST)
if form.is_valid():
sku = form.cleaned_date['sku']


If you are saving a model, you should look at ModelForms, where
you can save the form to create a new instance of the model.

~Jakob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 a multiselect list box for a static list of options

2009-03-23 Thread Adam Fraser

Hello,

This should be a pretty simple question.  I have a list of options:

STAIN_CHOICES = (
(1, 'DNA - DAPI'),
(2, 'DNA - Hoechst'),
(3, 'DNA - other'),
(4, 'Actin - Phalloidin'),
(5, 'Tubulin'),
)

I would like users to be able to select more than one of these things
at a time.  It looks like models.CommaSeparatedIntegerField would be
good for this, but how can I get a multi-selection list box as an
input?

-adam
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 figuring out how to make request.GET.getlist to work plz

2009-03-23 Thread Blake M. Sisco
ok i am having an issue getting getlist() to work properly.  it displays the
correct number of rows in the template but there is not any data in those
rows.  firebug shows the following:
*Request Headers*
Host: wartrac.lormfg.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7)
Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://wartrac.lormfg.com/tracker/reports/
Cookie:
__utma=244144280.546994815381888600.1236088196.1236959460.1237809098.5;
__utmz=244144280.1236088196.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
__utma=163233722.378754721565061.1236361989.1236361989.1236361989.1;
__utmz=163233722.1236361989.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none);
sessionid=96ae590c0ec429724113fdbb8d6da83d; __utmc=244144280
Cache-Control: max-age=0
*
Response Headers*
Date: Mon, 23 Mar 2009 18:29:16 GMT
Server: Apache
Content-Type: text/html; charset=utf-8
Connection: close
Transfer-Encoding: chunked

*Params*
*select* 42 (this is the correct item based on my selection from the form)

if someone could show/tell me where i'm going wrong i would appreciate it.
Below are my views .py, report.html and report_list.html

views.py
from django.shortcuts import render_to_response

from models import
Warranty

from django.http import
*

def
index(request):

  open_warranty_list =
Warranty.objects.all().order_by('date_ent')

  return render_to_response('tracker/index.html', {'open_warranty_list':
open_warranty_list})


def
report_view(request):

  SelectForm =
Warranty.objects.all().order_by('id')

  return
render_to_response('admin/report.html',{'SelectForm':SelectForm})

def
results(request):

  if 'select' in request.GET and
request.GET['select']:



results = request.GET.getlist("select")



return
render_to_response('admin/report_list.html',{'results':results})


else:

return render_to_response('admin/report.html', {'error':True})

~

report.html


  

  
  QI
  Part No.
  Serial No.
  Date Entered
  Warranty
  Desc.
  {%ifequal result.desc "Other"%}
   Other
  {%endifequal%}
  Comments

  
  {%for warranty in SelectForm %}
  
 
 {{warranty.q_i_n}}
 {{warranty.p_no}}
 {{warranty.s_no}}
 {{warranty.date_ent}}
{%ifequal warranty.warranty 0
%}No{%else%}Yes{%endifequal%}
 {{warranty.get_desc_display}}
{%ifequal warranty.desc "Other"%}
 {{warranty.other}}
{%endifequal%}
 {{warranty.comment}}
  
{%endfor%}


  
report_list.html
{% if select %}
  

  
QI
Part No.
Serial No.
Date Entered
Warranty
Desc.
{%ifequal data.desc "Other"%}
 Other
{%endifequal%}
Comments
  

{%for select in results %}

   {{select.q_i_n}}
   {{select.p_no}}
   {{select.s_no}}
   {{select.date_ent}}
  {%ifequal select.warranty 0 %}No{%else%}Yes{%endifequal%}
   {{select.get_desc_display}}
  {%ifequal select.desc "Other"%}
   {{select.other}}
  {%endifequal%}
   {{select.comment}}

  {%endfor%}
  
Blake M. Sisco
LOR Manufacturing Co., Inc
Web Presence • Graphic Design
www.lormfg.com
(866) 644-8622
(888) 524-6292 FAX

The information transmitted by Blake Sisco herewith is intended only for the
person or entity to which it is addressed and may contain confidential
and/or privileged material.  Any review, retransmission, dissemination or
other use of, or taking of any action in reliance upon, this information by
persons or entities other than the intended recipient is prohibited.  If you
received this in error, please contact the sender and delete the material
from any computer

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



Templating language Include path dilemma

2009-03-23 Thread Colm Dougan

Hi,

I'm part of an erlang project called erlydtl which is a port of the
Django templating language.

We currently have a small dilemma about the "right way" to do
something and we thought it best to mirror what Django does.

The question is whether the definition of the document root should
change when evaluating includes.

For example, if I have template1 which includes path1/template2 then
should include statements within template2 be wrt. to the original
docroot *or* should everything be only relative to the one docroot.

I find it easier to relate to examples, so consider the following
directory structure of templates :

  ./template1
  ./path1/template2
  ./path2/template3

If template1 looks like this :

./template1 = '{%include "path1/temtlate2"%}'

Then if template2 wants to include template3 should it do this :

./path1/template2 = '{%include "../path2/template3"%}'

*or* should it do this :

./path1/template2 = '{%include "path2/template3"%}'

I tend to favor the latter because then the include path is
unambiguous since all includes are relative to the document root.

Which of these does Django implement?  Or do you allow both?  Or something else?

Thanks,
Colm

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



Using Template Tags Within Markdown

2009-03-23 Thread Daniel Watkins

Hello all,

I'm currently trying to render some text in Markdown format, that
contains templatetags.  For example:

[This]({% cms_link 22 %}) is a link.

If I render this:

{{ that_text|markdown }}

the '{% cms_link 22 %}' remains verbatim in the output.

As I see it, there are two potential solutions:

  * a solution using templatetags of which I am not yet aware, or
  * some pre-processing within the view.

Is this a correct assumption, or am I missing something?

If I have to resort to the latter, what would it involve?  How do I pass
a templatetag (rather than just a variable) into a template processor?


Thanks in advance,


Dan


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



Django Admin site customization

2009-03-23 Thread Robocop

I have a couple of questions i would think have some pretty
straightforward answers, answers i've been unable to dig up in the
docs.  All i want to do in my admin interface is be able to specify
the name of a field via admin.py (i.e. have the name of a field on the
backend come from admin.py, not the model's field name), but i
couldn't find as much in the documentation on the admin site.  Would
it be something like:

class FlatPageAdmin(admin.ModelAdmin):
fieldsets = (
(None, {
'fields': ('url':'url of object', 'title':'title of
object', 'content':'object content', 'sites':'sites you dingus')

Also, i tried using the description key in field options, but it did
not work.  Could someone who has used it show me some toy syntax as
that seems to be the reason i can't get it working.  As always, any
help 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: OWNING code

2009-03-23 Thread creecode

Hello mn,

I'm not a lawyer and I don't play one on T.V.

Others have already answered about licenses and such.  I'm wondering
if your first question is about the custom code that the programmer
produces for you to make your website function?

Generally I think you'll find that you own the custom code.  It is
considered a work for hire, you can Google that.  I believe a work for
hire is the default situation if you and the programmer didn't specify
ahead of time the terms of code ownership.

Of course your situation may be different and a quick talk with a
lawyer that specializes in intellectual property and such is probably
a good idea.

If your programmer is being difficult you may need to take legal
action to get your code.

Toodle-l.
creecode

On Mar 22, 10:52 pm, mn  wrote:

> new on here and not a tech guy, wanted to know if a company or
> programmer who uses Django can claim they own the code?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Creating bound form and sending it to the page without validation

2009-03-23 Thread Marek Wawrzyczek
I'd like to make a page, where the user will be able to edit a data of his
account and add photos. There will be 2 buttons: add photo, and submit form.
Add photo button will cause adding a photo to the server, so the form will
be submited, and then in the response generated by django (so that the
fields user entered before adding a photo weren't cleaned) there will be
error messages if the user filled the email field for example "addres@". So
I'd like to do validating of "non image" fields only after submiting a form.


2009/3/23 Malcolm Tredinnick 

>
> On Mon, 2009-03-23 at 00:59 +0100, Marek Wawrzyczek wrote:
> > Hi
> >
> > Is there any possibility, to create an bound instance of a form (even if
> > it contains fields with incorrect data) and then resend the form to the
> > page without validating ?
> >
>
> Almost certainly yes, since there's nothing to stop you overriding any
> methods you like in your Form subclass and if a user submits invalid
> data it's already sent back to the web page (so Django already does
> something like that). However, what's the problem you're really trying
> to solve here? There might be a better approach that requires less
> hacking at the internals.
>
> Regards,
> Malcolm
>
>
> >
>


-- 
Pozdrawiam,

Marek Wawrzyczek

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



clean data

2009-03-23 Thread Bobby Roberts

Hi all.  I'm needing to learn how to tap into the clean data for
forms.  I'm looking at   
http://docs.djangoproject.com/en/dev/ref/forms/validation/
trying to figure things out.

By my understanding, raw data needs to be cleaned before insertion
into the database.  I have a few questions:

1.  what does cleaning actually do... prevent sql query injections?
Anything else?

2.  I'm assuming, if I had a function as follows:

def clean(self):
cleaned_data = self.cleaned_data
return cleaned_data

That this would return a dictionary of  the form in it's cleaned
state.  Is this a correct assumption?

3.  How would I call this when saving data?  Lets say I have this in
my view which saves the data to the database:

mydata=Mydata(
description=request.POST.get('description',''),
sku = request.POST.get('sku',''),
mydata.save()

is it as simple as wrapping the request.POST.get... in clean()?


TIA


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



Re: Dynamic app_label

2009-03-23 Thread Dan Mallinger
I put together a solution this morning, but I noticed something odd that
I've run into before and I was wondering if someone could give me some
insight.  I've noticed that some of the time, when a module is loaded, it's
named 'app.foo' and sometimes it's named as 'project.app.foo'.   Why is it
that the project is only sometimes included in the module name?  I've seen
this issue generally in Python, and I think there's something major about
the language I'm missing right now and would love to have it clarified.

Thanks,
Dan

On Fri, Mar 20, 2009 at 8:21 PM, Malcolm Tredinnick <
malc...@pointy-stick.com> wrote:

>
> On Fri, 2009-03-20 at 11:38 -0400, Dan Mallinger wrote:
> > Thanks Malcolm.  I'll try and look into this when I have a little
> > time.  It would be nice to be able to contribute
>
> By the way, I believe this problem really shouldn't be that hard to fix,
> so it isn't a bad way to start out diving into the code. I haven't
> personally done it as there are about 5000 other things to fix as well,
> all of similar priority. But if you have quick grep through the code for
> where app_label is used, you'll find it being computed automatically in
> only one (maybe two) places, from memory. Walking up a module hierarchy
> isn't exactly rocket surgery, either.
>
> So I guess I'm also not fixing this myself out of obstinance. If people
> want it, it shouldn't be that hard to write a proper patch with tests
> and everything and it's not something that can't be fixed by pretty much
> anybody with sufficient motivation (I'm happy to admit there are some
> enhancements and bugs that probably aren't "my very first bug fix"
> candidates; this isn't one of them).
>
> By all means, have at it. I think you'll find it rewarding. :-)
>
> 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
-~--~~~~--~~--~--~---



Problem with Sum() function

2009-03-23 Thread eli

How to pass to the Sum() function (ORM) more than one field?

My problem:

class Model1(models.Model):
name = models.CharField(u'Name', max_length=255)

class Model2(models.Model):
fk1 = models.ForeignKey(Model1, related_name='fk_1')
fk2 = models.ForeignKey(Model1, related_name='fk_2')

I want to sort data by sum of fk1 and fk2 field.

Model1.objects.annotate(myfk1=Count('fk1', distinct=True), myfk2=Count
('fk2', distinct=True)).annotate(my_sum=Sum('myfk1+myfk2')).order_by('-
my_sum')

Thanks for help.

regards.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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-Tagging not working with Oracle

2009-03-23 Thread Brandon Taylor

Downgrading to cx_Oracle-4.4.1 solved the problem. Now I can use the
tagging.fields TagField() as expected and everything shows up
correctly in the admin.

b

On Mar 20, 4:15 pm, Brandon Taylor  wrote:
> Hmm. I might downgrade my cs_Oracle and see if that makes a
> difference. I double-checked my import statements and they match what
> you have:
>
> fromtagging.models import Tag
> fromtagging.fields import TagField
>
> but still, no dice. I'll post my findings here. It may well be a bug
> in cx_Oracle-5.0.1. Lord knows I had enough issues getting it to
> install. Wouldn't surprise me at all if there's something messed up in
> it.
>
> Thanks for taking the time to help, I sincerely appreciate it. I'll
> post my findings later.
>
> Cheers,
> b
>
> On Mar 20, 3:33 pm, Ian Kelly  wrote:
>
> > On Mar 20, 1:52 pm, Brandon Taylor  wrote:
>
> > > Hmm. Well, I guess the only thing left to ask is what version of
> > >DjangoandTaggingyou're running?
>
> > > I'm usingOracle10g, cx_Oracle-5.0.1,DjangoandTaggingfrom svn.
> > > Other than that, I'm at a loss :)
>
> > The same, but cx_Oracle 4.4.1.
>
> > On Mar 20, 1:54 pm, Brandon Taylor  wrote:
>
> > > When you say "fixed the import" how so? I'm not seeing where I can
> > > import TagField from any other location intaggingother than
> > > forms.py.
>
> > Sorry, I guess I wasn't clear before.  I just meant that I changed
> > this line:
>
> > fromtagging.forms import TagField
>
> > to this:
>
> > fromtagging.fields import TagField
>
> > Both forms.py and fields.py define a TagField class, and they're not
> > the same thing.
>
> > HTH,
> > Ian
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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 Serialization of BooleanField inconsistent?

2009-03-23 Thread chefsmart

> So values that are
> ultimately coming from the database (as when you do a get) are returned from
> MySQL as 1/0 while values that originate from Python code are true bools and
> get reported as True/False.

Yes, you've explained it well.

My code in the ReST client expects 1/0 so True/False is giving me
trouble, but I'm inspecting the xml and replacing True with 1 and
False with 0.

I was just looking for an explanation for this behavior.

Thanks.

On Mar 23, 7:16 pm, Karen Tracey  wrote:
> On Mon, Mar 23, 2009 at 9:47 AM, chefsmart  wrote:
>
> > I have not changed my database. I've always been using MySQL.
>
> > In the meantime I did some more research and discovered that when I
> > use HTTP GET on a model (I'm talking django-rest-interface) the xml
> > returned has 1 or 0 for Boolean values, which is what I want.
>
> > However, when I do an HTTP PUT to update an instance of a model, the
> > xml response has True or False for Boolean values.
>
> > Though I'm using django-rest-interface, the de/serialization is
> > handled by Django itself.
>
> > I have tried walking through the code to find out what is going on,
> > but no luck yet.
>
> I'm not familiar with django-rest, but what you are describing doesn't
> surprise me.  I think it's a consequence of Django not coercing boolean
> field values coming from MySQL to an actual bool value.  So values that are
> ultimately coming from the database (as when you do a get) are returned from
> MySQL as 1/0 while values that originate from Python code are true bools and
> get reported as True/False.  Heading towards MySQL this is fine, as MySQL
> will accept True/False and internally transform them to the 1/0 it wants to
> use, but heading in the other direction the 1/0 returned by MySQL can
> sometimes lead to confusion in other code that is expecting true bool, not
> int, values.
>
> There was a ticket requesting that the 1/0 returned by MySQL be cast to a
> bool:
>
> http://code.djangoproject.com/ticket/7190
>
> but that got closed wontfix and some doc was added to note that MySQL
> behaves this way.   It isn't clear from what you've posted if the
> inconsistency is causing a problem for you or if you just noticed it and it
> concerned you?
>
> 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: Beginner URL question.

2009-03-23 Thread Bro

I use {% url myproject.core.views.member_create %}

But in the production server, it give :(
http://www.mysite.fr/var/www/mysite/mysite/user/create/
instead of : http://www.mysite.fr/user/create/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Beginner URL question.

2009-03-23 Thread Bro

Hi,

I use the same answer but I have another problem in the production
server
(in local, it works perfectly)

On 23 fév, 23:57, "Joe Goldthwaite"  wrote:
> >You could try using a  tag to explicitly state what the
> >base for relative URLs should be.
>
> Thanks Ned. That sounds like it will work.  I'll try it.
>
> >I would sugest that you look at named urls and the {%url%} template
> >tag. That way you can generate urls with the use of args for year,
> >month, date.
>
> Thanks Briel.  I don't know how named urls work but I'll look into that
> also.
>
> Thanks again to both of you for the help. I really appreciate 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: "Disabled" option with choiceField ?

2009-03-23 Thread Pierre

Hi Karen,

Thanks for your point (it explains why I couldn't see anything about
that in "current" django documentation.).
So I need to wait for 1.1 or to make something different...
Thanks for your reply Karen,

Regards,

Pierre

On Mar 23, 2:52 pm, Karen Tracey  wrote:
> On Mon, Mar 23, 2009 at 6:46 AM, Pierre  wrote:
>
> > Hi,
>
> > I turning crazy with something which seems relatively easy but isn't
> > (for me).
> > I want to create a dropdown (aka ) in
> > a form. To do this, I use a forms.ChoiceField
> > (label="Categories",required=True, choices=catz)
>
> > I'd like to have some choices in this drop down to be "disabled" to
> > create a kind of classification in this drop down.
> > -- Root -- Disabled
> > --child one -- not disabled
> > --Root 2 -- Disabled
> > --childtwo -- not disabled
>
> > etc.
>
> > Is there any way to do this easily ? I think choiceField doesn't allow
> > to pass extra attributes isn't it ?
>
> If what you want to do is organize the choices into nested groups, then that
> is supported in 1.1 alpha and trunk.  See the doc here:
>
> http://docs.djangoproject.com/en/dev/ref/models/fields/#choices
>
> and scroll down to where MEDIA_CHOICES are split into Audio, Video, and
> unknown.  The implementation of this is to group the choices together using
> html optgroup, not to disable the "root" choices, but it seems to be what
> you are looking for.
>
> 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: Absolute URL

2009-03-23 Thread Rajesh D



On Mar 23, 10:20 am, Bro  wrote:
> Hi,
>
> django.template.defaultags exist ?

Sorry about that. I should've typed:

django.template.defaulttags


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



Re: Absolute URL

2009-03-23 Thread Bro

Hi,

django.template.defaultags exist ?

On 20 mar, 16:36, Rajesh D  wrote:
> On Mar 20, 6:16 am, Alfonso  wrote:
>
>
>
> > Hi,
>
> > Insanely simple answer here I think but I'm trying to sort someurl
> > errors in a mapping app.  Virtual earth requires an absoluteurlto
> > the KML file django is generating for me and I can't seem to work out
> > how to define that in the urls.py.  of course I can just prepend the
> > site root to the VE javascript but who wants to do that for each
> > page!  Also the siteurlwill change so changing the urls in the JS is
> > a hassle I don't want to deal with.
>
> >url(r'^kml/popular_sites.kml','myproject.myapp.views.popular_sites',
> > name="popular_sites"),
>
> > When using the above with {%urlpopular_sites %} I get '/kml/
> > popular_sites.kml' which V Earth doesn't like.  Is there a simple
> > change in urls.py to get the full (I guess 
> > permalink)url-http://mysite.com/kml/popular_sites? Perhaps in the 
> > associated view?
>
> You could create a custom absolute_url tag whose structure is
> something like this:
>
> from django.template.defaultags import URLNode
>
> class AbsoluteURLNode(URLNode):
>     def render(self, context):
>        url= super(AbsoluteURLNode, self).render(context)
>         # prepend your protocol and hostname to
>         # the relativeurlhere
>         returnurl
>
> def absolute_url(parser, token):
>     # copy the entire django.template.defaultags.urlmethod
>     # here and change the last line to
>     return AbsoluteURLNode(viewname, args, kwargs, asvar)
> absolute_url = register.tag(absolute_url)
>
> -Rajesh D
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django Serialization of BooleanField inconsistent?

2009-03-23 Thread Karen Tracey
On Mon, Mar 23, 2009 at 9:47 AM, chefsmart  wrote:

>
> I have not changed my database. I've always been using MySQL.
>
> In the meantime I did some more research and discovered that when I
> use HTTP GET on a model (I'm talking django-rest-interface) the xml
> returned has 1 or 0 for Boolean values, which is what I want.
>
> However, when I do an HTTP PUT to update an instance of a model, the
> xml response has True or False for Boolean values.
>
> Though I'm using django-rest-interface, the de/serialization is
> handled by Django itself.
>
> I have tried walking through the code to find out what is going on,
> but no luck yet.
>

I'm not familiar with django-rest, but what you are describing doesn't
surprise me.  I think it's a consequence of Django not coercing boolean
field values coming from MySQL to an actual bool value.  So values that are
ultimately coming from the database (as when you do a get) are returned from
MySQL as 1/0 while values that originate from Python code are true bools and
get reported as True/False.  Heading towards MySQL this is fine, as MySQL
will accept True/False and internally transform them to the 1/0 it wants to
use, but heading in the other direction the 1/0 returned by MySQL can
sometimes lead to confusion in other code that is expecting true bool, not
int, values.

There was a ticket requesting that the 1/0 returned by MySQL be cast to a
bool:

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

but that got closed wontfix and some doc was added to note that MySQL
behaves this way.   It isn't clear from what you've posted if the
inconsistency is causing a problem for you or if you just noticed it and it
concerned you?

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: Design patterns for create/update view

2009-03-23 Thread Eric Abrahamsen


On Mar 23, 2009, at 6:48 PM, Liubomir.Petrov wrote:

>
> Yep, i'm already using generic views, but its a big pain (a lot of
> code) for a single view that embeds create & update in one place.
> I wanned to ask here, because maybe my approach (the single create/
> update view) is not right ?

I'm not quite sure what you mean here, are you saying it's a lot of  
code in your url config to have CRUD lines for each model in each app?  
You could take a look at the admin app to see how it does model  
autodiscovery, and get some ideas about how you might automatically  
create url config lines for each model. The code lives in contrib/ 
admin/sites.py

Is that what you meant?


>
> On Mar 23, 12:13 pm, Eric Abrahamsen  wrote:
>> On Mar 23, 2009, at 6:06 PM, Lyubomir Petrov wrote:
>>
>>
>>
>>> Just wondering are there any docs/examples of design pattern with
>>> django for creating a "create/update" view.
>>
>> These views are written for you! See the CRUD section of the Generic
>> Views page:
>>
>> http://docs.djangoproject.com/en/dev/ref/generic-views/#create- 
>> update...
>>
>> All you have to do is design the URLs, and you can take hints from  
>> the
>> admin contrib app for that.
>>
>> Yours,
>> Eric
>>
>>
> >


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



Re: "Disabled" option with choiceField ?

2009-03-23 Thread Karen Tracey
On Mon, Mar 23, 2009 at 6:46 AM, Pierre  wrote:

>
> Hi,
>
> I turning crazy with something which seems relatively easy but isn't
> (for me).
> I want to create a dropdown (aka ) in
> a form. To do this, I use a forms.ChoiceField
> (label="Categories",required=True, choices=catz)
>
> I'd like to have some choices in this drop down to be "disabled" to
> create a kind of classification in this drop down.
> -- Root -- Disabled
> --child one -- not disabled
> --Root 2 -- Disabled
> --childtwo -- not disabled
>
> etc.
>
> Is there any way to do this easily ? I think choiceField doesn't allow
> to pass extra attributes isn't it ?
>

If what you want to do is organize the choices into nested groups, then that
is supported in 1.1 alpha and trunk.  See the doc here:

http://docs.djangoproject.com/en/dev/ref/models/fields/#choices

and scroll down to where MEDIA_CHOICES are split into Audio, Video, and
unknown.  The implementation of this is to group the choices together using
html optgroup, not to disable the "root" choices, but it seems to be what
you are looking for.

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 Serialization of BooleanField inconsistent?

2009-03-23 Thread chefsmart

I have not changed my database. I've always been using MySQL.

In the meantime I did some more research and discovered that when I
use HTTP GET on a model (I'm talking django-rest-interface) the xml
returned has 1 or 0 for Boolean values, which is what I want.

However, when I do an HTTP PUT to update an instance of a model, the
xml response has True or False for Boolean values.

Though I'm using django-rest-interface, the de/serialization is
handled by Django itself.

I have tried walking through the code to find out what is going on,
but no luck yet.

Regards.

On Mar 23, 6:33 pm, Karen Tracey  wrote:
> On Mon, Mar 23, 2009 at 2:58 AM, chefsmart  wrote:
> > I am working on an application that interacts with a Django app
> > through Django's xml serialization (using django-rest-interface).
>
> > All was going ok, when today I got stuck because while Django used to
> > serialize BooleanFields as  > name="is_active">1 or  > name="is_active">0 today I received  > name="is_active">True
>
> > Why did this happen? I am using the same Django (svn trunk) that I was
> > using yesterday.
>
> Did you change databases?  1/0 for BooleanField looks like MySQL, True/False
> something else.  There's a ticket reporting this:
>
> http://code.djangoproject.com/ticket/6276
>
> 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: How to get the root path ?

2009-03-23 Thread Bro

I use {% url myproject.core.views.member_create %}

But in the production server, it give :(
http://www.mysite.fr/var/www/mysite/mysite/user/create/
instead of : http://www.mysite.fr/user/create/

On 18 mar, 14:24, Briel  wrote:
> Hi.
> Instead of generating all of your urls as a base url + something, you
> can insteadl use the url template tag, that way you can get your url
> in the template more or less like this (if you use named urls):
> {% url user_change %}
> using reverse matching, django can figure out what the url needs to
> be, and if you deside to change your url mapping, all you need to do
> is change your urls.py files to get the change. That way you wont have
> to go through templates ect to make a lot of changes all over the
> place.
> You can read about the url template tag at the 
> docs.http://docs.djangoproject.com/en/dev/ref/templates/builtins/#url
>
> ~Jakob
>
> On 18 Mar., 13:35, Bro  wrote:
>
> > Hi,
>
> > My project root path is :http://127.0.0.1:8000/
>
> > The user path is :http://127.0.0.1:8000/user/
> > The change form path is :http://127.0.0.1:8000/user/change/
> > In the template.html file I use : {{ root_path }}change/
>
> > My question : how to get the variable of the root path (http://
> > 127.0.0.1:8000/)
> > I want to have this url :http://127.0.0.1:8000/change/
>
> > 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: OWNING code

2009-03-23 Thread Tim Chase

> new on here and not a tech guy, wanted to know if a company or
>  programmer who uses Django can claim they own the code?

Just out of curiosity, what are your reasons for wanting to OWN 
the code?  Do you want to change it?  Do you want to distribute 
it on your own terms?  Do you want to assert that you control 
your local rate of change, rather than be dictated by licensing 
terms?


You can claim ownership if

1) you authored the entire thing

2) or you purchased all rights to the thing

3) or the thing was in the public domain

Clearly none of these three are the case for Django (you didn't 
write it, you didn't puchase all rights, and it's not in the PD). 
  However, none of those are true regarding just about any other 
framework you'd find either.  Do you OWN the .NET libraries?  Do 
you OWN Python? Do you OWN Rails?  no, no, and no.

So unless you write your own operating system, your own 
programming language and libraries, your own web framework, and 
then code in that, you don't OWN it.

See the absurdity & futility of anybody wanting to OWN the entire 
thing?

Plenty of folks are doing great development USING the framework 
they don't OWN.

> Also if I have my developer build my website using Django, do 
> I own it or simply license the code?

Both Python & Django are licensed under *very* liberal terms. 
Just read the LICENSE file included in the distribution and 
compare it to the licensing terms on any other framework you're 
considering.  You may find a few others under the BSD license, 
but I've never found any framework worth considering in the 
public-domain.

You don't own them, but you have far more rights with far fewer 
responsibilities than just about anything on the market.

> Please advise, thank you

For goodness sake, I abhor the phrase "please advise".  People 
who use it should be smacked in the head as a penalty.

-tim








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



Re: Django Serialization of BooleanField inconsistent?

2009-03-23 Thread Karen Tracey
On Mon, Mar 23, 2009 at 2:58 AM, chefsmart  wrote:

> I am working on an application that interacts with a Django app
> through Django's xml serialization (using django-rest-interface).
>
> All was going ok, when today I got stuck because while Django used to
> serialize BooleanFields as  name="is_active">1 or  name="is_active">0 today I received  name="is_active">True
>
> Why did this happen? I am using the same Django (svn trunk) that I was
> using yesterday.
>

Did you change databases?  1/0 for BooleanField looks like MySQL, True/False
something else.  There's a ticket reporting this:

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

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



Per app middleware?

2009-03-23 Thread Gabriel Rossetti

Hello everyone,

I have a project that has two apps that use the same models (I moved it 
out of the apps, up to the project's root). I was wondering if it is 
possible to have global middleware (that they both need) and per app 
middleware (sspecific to each app). I don't want one app's middleware to 
intercept and process the other app's stuff, does anyone know how to do 
this?

Thank you,
Gabriel

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send 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. postgre and errors (integrity errors not raised as expected in unit tests)

2009-03-23 Thread LD

OK. solved.

The problem was that I did something like this:

class MyModel(models.Model):
   field = #this field is marked as unique

and then in tests:

sid = transaction.savepoint()

ml1 = MyModel(field = 'a')
ml1.save()

m2 = MyModel(field = 'b')
self.assertRaises(IntegrityError, m2.save)

tranasction.avepoint_rollback(sid)

and that was case where I had problem.

When I moved savepoint after m1 was create - then it is ok.

Best Regards,
Luke

On 23 Mar, 13:16, LD  wrote:
> Thanks for response,
>
> savepoint api looks nice and in fact it did the thing for some tests.
> But for some other I still got the same error - looks strange since
> tests are trying to do simmilar logic.
>
> I thought that problem was in some logic in test setUp, but again in
> both test cases there is setUp and they look simmilar as well.
>
> I also found that running single test is OK (manage.py test app
> TestCase.test_name), but running whole test case (manage.py test app
> TestCase) leads to error.
>
> Do you have any ideas? And once again thanks for response
> Luke
>
> On 21 Mar, 02:00, Malcolm Tredinnick  wrote:
>
> > On Fri, 2009-03-20 at 16:26 -0700, LD wrote:
> > > Hi,
>
> > > Today I enforced strange situation, hope it is strange only for me nad
> > > you will quickly tell me what stupidness I am doing.
>
> > > Well, today I have switched from sqlite to postgre. Everything was
> > > perfect since I've tried to run set of unit tests for my project.
>
> > > Every time my tests deals with situation where IntegrityError is
> > > expected test execution is stopped with error:
> > > Error: Database test_my_project couldn't be flushed. Possible reasons:
> > >      * The database isn't running or isn't configured correctly.
> > >      * At least one of the expected database tables doesn't exist.
> > >      * The SQL was invalid.
> > >    Hint: Look at the output of 'django-admin.py sqlflush'. That's the
> > > SQL this command wasn't able to ru
> > >    The full error: current transaction is aborted, commands ignored
> > > until end of transaction block
>
> > > When I look into postgre logs I can see that db tried to do operation
> > > that I was expected. I don't know why with sqlite IntegrityErrors
> > > where raised normally and with postgre thet are not.
>
> > The issue is that PostgreSQL wants you to explicitly clean up the
> > transaction that is open after an error like this occurs. SQLite doens't
> > have transactions for normal operations (it does have transaction-like
> > behaviour for writes, but it's not quite the same thing), which is why
> > you didn't see it there.
>
> > Secondly, Django runs the whole test suite inside a bunch of large
> > transactions. We clean up at the end of each test by rolling back the
> > transaction.
>
> > If you're intentionally causing IntegrityErrors in your tests -- which
> > isn't a bad things at all -- you just have to do a little preparation.
> > The simplest solution is to use savepoints. Your tests will still run
> > across all database backends, since Django provides "do nothing"
> > implementations for backends that don't care about this (those where
> > transactions aren't supported or aren't visible to every cursor --
> > technical details you don't have to worry about). The only slight
> > problem is PostgreSQL prior to 8.0 (the 7.x didn't support savepoints).
>
> > Right now, savepoint handling isn't documented, mostly because I was
> > waiting to check that the API didn't suck. Also, I'm not really sure
> > what to do about the PostgreSQL 7.x situation, since we still nominally
> > support that (there are existing non-end-of-lifed production-worthy
> > distributions that use it).
>
> > However, to see how to use them in tests, have a look at, for example,
> > django/tests/modeltests/force_insert_update/models.py. There are a few
> > tests in there where we are trying to force an IntegrityError.
>
> > If you're using unittests, rather than doctests, the same logic still
> > applies. You set up a savepoint before starting and clean it up
> > afterwards.
>
> > 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
-~--~~~~--~~--~--~---



"Disabled" option with choiceField ?

2009-03-23 Thread Pierre

Hi,

Does anybody have succeeded in having choicField option "disabled"
from a modelForm ?

Regards,
Pierre

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 site: display forms from different models on one page

2009-03-23 Thread PaulePanter

Dear Django group,


in part 2 of the tutorial some ways are shown how to format the admin
site. This is really nice, how fast this can be set up. Does the admin
site bring also a way to display it the following way, without having
to write it by myself? I could not find it neither in its
documentation [2] nor using the search field in the documentation.

I have the following models defined in models.py. (I “normalized” the
models because for example siblings can have the same address.)

class Adresse(models.Model):
strasse = models.CharField(max_length=200)
nummer = models.CharField(max_length=5)

def __unicode__(self):
return u'%s %s' % (self.strasse, self.hausnummer)

class Person(models.Model):
name = models.CharField(max_length=200)
vorname = models.CharField(max_length=200)
adresse = models.ForeignKey(Adresse, blank=True, null=True)

def __unicode__(self):
return u'%s %s' % (self.vorname, self.name)

As decribed I am registering these two models in admin.py.

admin.site.register(Adresse)
admin.site.register(Person)

As you know it is displayed as follows when I want to add a Person.

Name: ___
Vorname: ___
Adresse:  Selection Box + (+ for adding now record)

What I would like how it is displayed when adding a person is as
follows.

Name: ___
Vorname: ___
Strasse:   Nummer __ +

(When typing the already available records are shown to be selectable,
but if it is not there I can type in the street name and number and
hit plus and it is added to Adresse.)

With the provided inline-classes of the admin site I just could figure
out that I can get add an adress and right away several persons who
live there. But this is not very intuitive.

Is there an easy way to accomplish my goal as we have gotten used to
using Django?


Thanks a lot,

Paul


[1] http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02
[2] http://docs.djangoproject.com/en/dev/ref/contrib/admin/#ref-contrib-admin

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



"Disabled" option with choiceField ?

2009-03-23 Thread Pierre

Hi,

I turning crazy with something which seems relatively easy but isn't
(for me).
I want to create a dropdown (aka ) in
a form. To do this, I use a forms.ChoiceField
(label="Categories",required=True, choices=catz)

I'd like to have some choices in this drop down to be "disabled" to
create a kind of classification in this drop down.
-- Root -- Disabled
--child one -- not disabled
--Root 2 -- Disabled
--childtwo -- not disabled

etc.

Is there any way to do this easily ? I think choiceField doesn't allow
to pass extra attributes isn't it ?

Best regards,
Pierre

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



Portable Python 1.1 released

2009-03-23 Thread Perica Zivkovic
Dear people,

Portable Python 1.1 is released and includes Django 1.0.2 and two free
Python IDE's - PyScripter and SPE.

Included in this release:
-
This release contains three different packages for three different Python
versions – Python 2.5.4, Python 2.6.1 and Python 3.0.1. Packages are totally
independent and can run side-by-side each other or any other Python
installation. Software included (in alphabetical order per package):

Portable Python 1.1 based on Python 2.5.4
- Django-1.0.2-final
- IPython-0.9.1
- Matplotlib-0.98.5.2
- Numpy-1.2.1
- PIL-1.1.6
- Py2exe-0.6.9
- PyGame-1.8.1
- PyReadline-1.5
- PyScripter v1.9.9.6
- PyWin32-212
- Rpyc-2.60
- Scipy-0.7.0b1
- SPE-0.8.4.c
- VPython-3.2.11
- wxPython-unicode-2.8.9.1

Portable Python 1.1 based on Python 2.6.1
- Django-1.0.2-final
- IPython-0.9.1
- PIL-1.1.6
- Py2exe-0.6.9
- PyGame-1.8.1
- PyReadline-1.5
- PyScripter v1.9.9.6
- PyWin32-212
- Rpyc-2.60
- SPE-0.8.4.c
- wxPython-unicode-2.8.9.1

Portable Python 1.1 based on Python 3.0.1
- PyScripter v1.9.9.6
- Rpyc-2.60

Installation and use:
-
After downloading entire distribution or specific Python version package,
run the installer, select the target folder and you are done! In the main
folder you will find shortcuts for selected applications in that package.
Some of the most popular free Python IDE’s come preinstalled and
preconfigured with Portable Python. How to use and configure them further
please consult their documentation or project sites.

All issues, suggestions or success stories you can post on the Portable
Python Google group: http://groups.google.com/group/portablepython

kind regards,

Perica Zivkovic
http://www.PortablePython.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: django. postgre and errors (integrity errors not raised as expected in unit tests)

2009-03-23 Thread LD

Thanks for response,

savepoint api looks nice and in fact it did the thing for some tests.
But for some other I still got the same error - looks strange since
tests are trying to do simmilar logic.

I thought that problem was in some logic in test setUp, but again in
both test cases there is setUp and they look simmilar as well.

I also found that running single test is OK (manage.py test app
TestCase.test_name), but running whole test case (manage.py test app
TestCase) leads to error.

Do you have any ideas? And once again thanks for response
Luke

On 21 Mar, 02:00, Malcolm Tredinnick  wrote:
> On Fri, 2009-03-20 at 16:26 -0700, LD wrote:
> > Hi,
>
> > Today I enforced strange situation, hope it is strange only for me nad
> > you will quickly tell me what stupidness I am doing.
>
> > Well, today I have switched from sqlite to postgre. Everything was
> > perfect since I've tried to run set of unit tests for my project.
>
> > Every time my tests deals with situation where IntegrityError is
> > expected test execution is stopped with error:
> > Error: Database test_my_project couldn't be flushed. Possible reasons:
> >      * The database isn't running or isn't configured correctly.
> >      * At least one of the expected database tables doesn't exist.
> >      * The SQL was invalid.
> >    Hint: Look at the output of 'django-admin.py sqlflush'. That's the
> > SQL this command wasn't able to ru
> >    The full error: current transaction is aborted, commands ignored
> > until end of transaction block
>
> > When I look into postgre logs I can see that db tried to do operation
> > that I was expected. I don't know why with sqlite IntegrityErrors
> > where raised normally and with postgre thet are not.
>
> The issue is that PostgreSQL wants you to explicitly clean up the
> transaction that is open after an error like this occurs. SQLite doens't
> have transactions for normal operations (it does have transaction-like
> behaviour for writes, but it's not quite the same thing), which is why
> you didn't see it there.
>
> Secondly, Django runs the whole test suite inside a bunch of large
> transactions. We clean up at the end of each test by rolling back the
> transaction.
>
> If you're intentionally causing IntegrityErrors in your tests -- which
> isn't a bad things at all -- you just have to do a little preparation.
> The simplest solution is to use savepoints. Your tests will still run
> across all database backends, since Django provides "do nothing"
> implementations for backends that don't care about this (those where
> transactions aren't supported or aren't visible to every cursor --
> technical details you don't have to worry about). The only slight
> problem is PostgreSQL prior to 8.0 (the 7.x didn't support savepoints).
>
> Right now, savepoint handling isn't documented, mostly because I was
> waiting to check that the API didn't suck. Also, I'm not really sure
> what to do about the PostgreSQL 7.x situation, since we still nominally
> support that (there are existing non-end-of-lifed production-worthy
> distributions that use it).
>
> However, to see how to use them in tests, have a look at, for example,
> django/tests/modeltests/force_insert_update/models.py. There are a few
> tests in there where we are trying to force an IntegrityError.
>
> If you're using unittests, rather than doctests, the same logic still
> applies. You set up a savepoint before starting and clean it up
> afterwards.
>
> 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: cannot import name ugettext

2009-03-23 Thread James Bennett

On Mon, Mar 23, 2009 at 4:43 AM, dbbarua  wrote:
> It works with Django-1.0 and gives me the site ...but some fields are
> not enabled in the website...is that related to django or the rapidsms
> code?

I'd very strongly suggest that you contact the developers of the
application you're using, since they are far more likely to have
useful information for you than a bunch of people who've never used
this application before.


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

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



Re: Hooking up Django signal to urls.py

2009-03-23 Thread Addy Yeow
Apache would have solved the problem for simple request but there are other
data that I wanted to store when the request is made, e.g. attribute data,
etc.

On Mon, Mar 23, 2009 at 6:44 PM, Russell Keith-Magee  wrote:

>
> On Mon, Mar 23, 2009 at 7:17 PM, Addy Yeow  wrote:
> > Hi guys,
> >
> > I like to track my visitors URL request in my application.
> ...
> > Any idea? Or I should not use signal for this purpose?
>
> You could probably get something like this to work, but I have to ask
> - Is there any reason that you're not just using the HTTP server's
> logs for this purpose? Apache (for example) provides extensive logging
> capabilities, and there are numerous tools available that can read,
> analyse and report on that logging format. Rather than trying to
> implement a whole logging framework basedon signals, why not use the
> tools that are already available and understood?
>
> 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: ModelForm - field sort order

2009-03-23 Thread PNM

Thanks - that's it. Sanity confirmed. Those "new in Django xx"
comments are invaluable (when they're there!) for tired eyes looking
at two superficially identical documents.



On Mar 23, 11:40 am, Russell Keith-Magee 
wrote:
> On Mon, Mar 23, 2009 at 6:55 PM, PNM  wrote:
>
> > I have a sorting problem with a completely basic ModelForm instance
> > (the class has only Meta with model and fields) -- the object's
> > __iter__ seems to be following object.fields (as defined in the
> > model), rather than Meta.fields (as the documentation leads me to
> > expect). Is it me, or is there something wrong here?
>
> What version of Django are you using? The ordering behaviour you
> describe was only added recently to trunk; it isn't (and won't ever
> be) available in v1.0.X.
>
> This should be explicitly marked in the documentation, although it
> appears that it isn't. However, if you compare the relevant section of
> the docs between v1.0 and development:
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a...http://docs.djangoproject.com/en/1.0/topics/forms/modelforms/#using-a...
>
> You will see that the operation of Meta.fields has changed.
> 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: Design patterns for create/update view

2009-03-23 Thread Liubomir.Petrov

Yep, i'm already using generic views, but its a big pain (a lot of
code) for a single view that embeds create & update in one place.
I wanned to ask here, because maybe my approach (the single create/
update view) is not right ?

On Mar 23, 12:13 pm, Eric Abrahamsen  wrote:
> On Mar 23, 2009, at 6:06 PM, Lyubomir Petrov wrote:
>
>
>
> > Just wondering are there any docs/examples of design pattern with
> > django for creating a "create/update" view.
>
> These views are written for you! See the CRUD section of the Generic  
> Views page:
>
> http://docs.djangoproject.com/en/dev/ref/generic-views/#create-update...
>
> All you have to do is design the URLs, and you can take hints from the  
> admin contrib app for that.
>
> Yours,
> Eric
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Hooking up Django signal to urls.py

2009-03-23 Thread Russell Keith-Magee

On Mon, Mar 23, 2009 at 7:17 PM, Addy Yeow  wrote:
> Hi guys,
>
> I like to track my visitors URL request in my application.
...
> Any idea? Or I should not use signal for this purpose?

You could probably get something like this to work, but I have to ask
- Is there any reason that you're not just using the HTTP server's
logs for this purpose? Apache (for example) provides extensive logging
capabilities, and there are numerous tools available that can read,
analyse and report on that logging format. Rather than trying to
implement a whole logging framework basedon signals, why not use the
tools that are already available and understood?

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: ModelForm - field sort order

2009-03-23 Thread Russell Keith-Magee

On Mon, Mar 23, 2009 at 6:55 PM, PNM  wrote:
>
> I have a sorting problem with a completely basic ModelForm instance
> (the class has only Meta with model and fields) -- the object's
> __iter__ seems to be following object.fields (as defined in the
> model), rather than Meta.fields (as the documentation leads me to
> expect). Is it me, or is there something wrong here?

What version of Django are you using? The ordering behaviour you
describe was only added recently to trunk; it isn't (and won't ever
be) available in v1.0.X.

This should be explicitly marked in the documentation, although it
appears that it isn't. However, if you compare the relevant section of
the docs between v1.0 and development:

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form
http://docs.djangoproject.com/en/1.0/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form

You will see that the operation of Meta.fields has changed.
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: OWNING code

2009-03-23 Thread Russell Keith-Magee

On Mon, Mar 23, 2009 at 2:52 PM, mn  wrote:
>
> Hello,
> new on here and not a tech guy, wanted to know if a company or
> programmer who uses Django can claim they own the code?

Firstly, IANAL, etc.

There are at least three blocks of code under discussion here.

Firstly, there is the code that comprises Django itself. Django's code
is licensed under the BSD license [1]. The copyright is held by the
Django Software Foundation. "Owned" is a bit of a loose phrase here,
but for most practical purposes, Django's code is "owned" by the
Django Foundation.

[1] http://code.djangoproject.com/browser/django/trunk/LICENSE

Secondly, there are any other libraries used by your website. This
will probably include the Python libraries and any number of other
utility libraries that your website developer has used. You will need
to investigate the licenses for each of those libraries, but they will
usually offer terms that are similar to Django's license (although the
details can be very significant). Consult the libraries in question
for more details on their licensing terms.

Lastly, there is the code that comprises your website - the code that
utilizes the Django, Python, and other libraries to implement whatever
functionality your website has. The license for this code is entirely
between you and your developer.

> Also if I have my developer build my website using Django, do I own it
> or simply license the code?

As far as the Django code is concerned, you have been granted a
license, subject to the terms and conditions of the BSD license. If
you build your website using Django, you don't suddenly "own" Django's
code, but you do have a fairly liberal license to use, modify and
redistribute Django's code. See the license [1] for details.

As far as your website is concerned - that's entirely up to your
contract with your developer. It is possible to negotiate contracts
where you own the code, or they own the code, or various splits and
variations in between. This is something to take up with your
developer and your lawyer.

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



Hooking up Django signal to urls.py

2009-03-23 Thread Addy Yeow
Hi guys,

I like to track my visitors URL request in my application.
To achieve this, I am trying to trigger my signal's receiver function called
log_start when a browser request matches a URL pattern in my_app/urls.py.

=== my_proj/my_app/models.py ===

from django.core.signals import *
from my_proj.my_app import signals as custom_signals

request_started.connect(custom_signals.log_start)

=== my_proj/my_app/signals.py ===

def log_start(sender, **kwargs):
  print "log_start called"

I am thinking this could be achieved by providing the proper sender argument
which generally takes in Model argument.
request_started.connect(custom_signals.log_start, sender=??)

Any idea? Or I should not use signal for this purpose?

- Addy

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



Re: Design patterns for create/update view

2009-03-23 Thread Eric Abrahamsen


On Mar 23, 2009, at 6:06 PM, Lyubomir Petrov wrote:

>
> Just wondering are there any docs/examples of design pattern with
> django for creating a "create/update" view.

These views are written for you! See the CRUD section of the Generic  
Views page:

http://docs.djangoproject.com/en/dev/ref/generic-views/#create-update-delete-generic-views

All you have to do is design the URLs, and you can take hints from the  
admin contrib app for that.

Yours,
Eric


> >


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



Design patterns for create/update view

2009-03-23 Thread Lyubomir Petrov

Just wondering are there any docs/examples of design pattern with
django for creating a "create/update" view.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, 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 - field sort order

2009-03-23 Thread PNM

I have a sorting problem with a completely basic ModelForm instance
(the class has only Meta with model and fields) -- the object's
__iter__ seems to be following object.fields (as defined in the
model), rather than Meta.fields (as the documentation leads me to
expect). Is it me, or is there something wrong here?

The project is at a very early stage -- pretty much as per the
tutorials at the moment, so I can't see that anything should be
interfering with this.

Example (see comment field):

for x in  TESTADDRESS.htmform  :
print x.label_tag()
print '**'
for x in  TESTADDRESS.htmform.Meta.__dict__.get('fields')  :
print x

Result:


Comment
Address name
Address name2
Address postaddress
Address postcode
Address contact
Address telephone
Address telefax
Address mobile
Address email
Address url
Address nickname
Address organisationnumber
**
address_nickname
address_name
address_name2
address_postaddress
address_postcode
address_contact
address_telephone
address_telefax
address_mobile
address_email
address_url
address_organisationnumber
comment

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



RE: OWNING code

2009-03-23 Thread mn

Hello,
new on here and not a tech guy, wanted to know if a company or
programmer who uses Django can claim they own the code?

Also if I have my developer build my website using Django, do I own it
or simply license the code?

Please advise, thank you

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



Re: cannot import name ugettext

2009-03-23 Thread dbbarua

Hi Karen,
  I got some code from the rapidsms sf.net site...
it's called rapidsms-1.0-final-svn-unknow
It works with Django-1.0 and gives me the site ...but some fields are
not enabled in the website...is that related to django or the rapidsms
code?

Regards
Deepak

On Mar 23, 1:08 am, Karen Tracey  wrote:
> On Sun, Mar 22, 2009 at 2:53 PM, dbbarua  wrote:
>
> > Hi Karen,
> >              I am sorry if my messages seem confusing to you , it is
> > to me too...
> > I changes Django to 1.0 and i get the following errors related to core
> > like you said should not happen
>
> > r...@portable:/usr/local/rapidsmsdev/rapidsms/rapidsms# python
> > manage.py runserver 127.0.0.1:8000
> > Validating models...
> > [snip]
>
> File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
>
> > line 9, in 
> >    class Recipient(models.Model):
> >  File "/usr/lib/python2.5/site-packages/rapidsms/balert/models.py",
> > line 11, in Recipient
> >    phone_number = models.CharField('phone number', maxlength=15,
> > core=True)
> > TypeError: __init__() got an unexpected keyword argument 'core'
>
> > Does this mean that the svn version of the app is not compatible with
> > Django-1.0 ? and maybe i should try older versions of the app?
>
> It means you are not running the svn version of rapidsms, at least, not the
> one I found online at sourceforge.  You can see that models.py here:
>
> http://svn.mepemepe.com/rapidsms/trunk/balert/models.py
>
> and the phone_number field in the Recipient model does not have core=True
> specified.  Further, the one I'm pointing to uses max_length (compatible
> with Django 1.0) while the version you are running uses maxlength
> (compatible with an older Django).
>
> You need to update your rapidsms code, I believe.
>
> 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: exclude=field only for non superuser staff

2009-03-23 Thread Malcolm Tredinnick

On Mon, 2009-03-23 at 09:44 +0100, Alessandro Ronchi wrote:
> I need to set a field as escluded in admin.py only for non-superuser
> staff people.
> is it possible?
> how can I do that?

You can override the ModelAdmin.get_form() method and return a different
form in those cases, I guess. It's passed the "request" object, so you
can work out the user from there.

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



exclude=field only for non superuser staff

2009-03-23 Thread Alessandro Ronchi

I need to set a field as escluded in admin.py only for non-superuser
staff people.
is it possible?
how can I do that?

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

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

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

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



  1   2   >