login problem

2008-12-05 Thread vierda

Dear All,

today I try to make login page with follow example code in
djangoproject (user authentication chapter), code as following below :

def my_view(request):
   username = request.POST['username']
   password = request.POST['password']
   user =  authenticate(username=username, password=password)#create
Authentication object

   if user is not None:
  if user.is_active:
 login(request,user)
 return HttpResponse('login success')
  else:
 return HttpResponse('disable account')
   else:
  return HttpResponse('invalid login')

the above code always shows MultiValueDictKeyError with exception
value "Key 'username' not found in ".
please give me clue to resolve this problem. Thank you in advance

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



Re: Ruby on Rails vs Django

2008-12-05 Thread Kenneth Gonsalves

On Saturday 06 Dec 2008 1:01:37 am JonathanB wrote:
> admin interface, on the other hand, is permanent. It may not intended
> for public consumption, but it does make sanity-testing your models
> (wait! That DecimalField has the wrong max_digits! Doh!)

hey - this is a good point - should go in the docs/faq on what the admin 
interface is useful for.

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

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



Re: Can't edit reverse relation in a many2many field in admin site

2008-12-05 Thread anode

Hi,

I'm not an expert either, but I think you can get what you want using
a technique from here:
http://code.djangoproject.com/ticket/897

Basically you just tell your Track model it's part of a many to many
relationship like this:

class Track(models.Model):
name = models.CharField(max_length = 50)
records = models.ManyToManyField('Record', db_table =
'music_record_tracks')

The only issue with this is that running sync_db with this kind of set-
up might not work too well, as it would probably try to create the
intermediary many-to-many table twice. I think this will only happen
if the Track database table doesn't exist when syncdb is run, so it
should be fine in your case, but beware if you try to set up a
database from scratch. Just comment out the many-to-many field in the
Track model temporarily when you set up a new database and syncdb
should run ok.

On Dec 5, 6:21 pm, Nelson <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm fairly new to Django, so I've searched all over for an answer but
> could not really find it. Maybe this is simple stuff, but anyway I
> dont have enough information to judge, so I hope you guys can help
> me...
>
> I have the following many-to-many relation:
>
> class Record(models.Model):
>     name = models.CharField()
>     tracks = models.ManyToManyField('Track')
>
> class Track(models.Model):
>     name = models.CharField()
>
> This means that a Record has multiple Tracks, and a Track can belong
> to many albums (compilations).
>
> To make things easier for the content producers, the Record admin page
> shows the m2m relation in an 'include/exclude list box', since I used
> filter_horizontal = ('tracks',) in the ModelAdmin of the Record.
>
> However, the Track admin page DOES NOT show the 'reverse' of the many-
> to-many relation. I mean, I want to display the 'include/exclude list
> box' that shows all the Records, so the user can choose the ones that
> the Track may belong to.
>
> What do I need to do to show this 'reverse' relation in the Track form
> page?

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



Re: Django And os.path Behavior

2008-12-05 Thread Graham Dumpleton



On Dec 6, 10:07 am, dayvo <[EMAIL PROTECTED]> wrote:
> Good question.  That could affect the app if I were using relative
> path's or relying on the environment to locate files.  The path's I'm
> using in the app are stored are absolute paths.  They work correctly
> for path's that don't have unicode characters in them.  My Django app
> works correctly with %95+ of the data I'm using.  I'm just trying to
> resolve exceptions.  Those exceptions all have special characters in
> them.
>
> I'm starting to suspect apache and mod_python could have something to
> do with this.  Perhaps it's not a Django issue after all.

Should also be pointed out that even if you try and set locale in
Python application, when using mod_python it can be getting overridden
by another Apache module such as PHP scripts.

For this particular scenario, if you can't get rid of the PHP code,
you may have some success by running mod_wsgi and specifically using
its daemon mode to run your Django application in a separate daemon
process. Similarly, can also use FASTCGI/SCGI/AJP based solutions with
flup WSGI adapter.

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



Re: template tag

2008-12-05 Thread Eric Abrahamsen


On Dec 6, 2008, at 8:31 AM, Alfredo Alessandrini wrote:

>
> Hi,
>
> I've this variable in my template: {{ challenger.rating }}
>
> It'a a number...
>
> Can I calculate a sum like this:
>
> {{ challenger.rating }} + 200   ??
>
> I must write a custom tag?

There's already a filter for that:

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

Yours,
Eric


>
>
>
> Alfredo
>
> >


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



Re: transactions and locking in postgreSQL

2008-12-05 Thread Jeffrey Straszheim

msoulier wrote:
> Looking at the transaction middleware that wraps a transaction around
> every HTTP request, I've found that it only commits if the transaction
> is "dirty" (you change something).
>
> So, if you use this middleware unconditionally, then in view functions
> that only read, the transaction will never be committed.
>
> Even when you read, postgres implicitly locks tables for reading.
>
> I am finding that since commit is never called in these cases, the
> locks persist.
>
> Is anyone using the transaction middleware with postgres? I have to
> assume so. If so, then what am I doing wrong?
>
>   
I took a quick glance at transaction.py (where the TransactionMiddleware 
class is defined), and it appears you are correct.  However, it should 
be pretty easy to roll your own transaction class that skips the 
is_dirty check.

This should probably be a bug report in any case.

Jeffrey Straszheim

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



Re: Ruby on Rails vs Django

2008-12-05 Thread Jeffrey Straszheim

yejun wrote:
> This is unnecessary true. Python can be very dynamic with decorate,
> meta table and runtime code modification.
>   
Of course, one can write obscure code in any languages.  Personally, 
however, I find most online examples of meta-programming in Ruby pretty 
obtuse -- and I've written a fair amount of LISP macros, so I'm not 
_unprepared_ to understand.

I find most meta-programming examples in Python to be pretty obvious.

Jeffrey Straszheim

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



Re: UserChangeForm not working

2008-12-05 Thread Brandon Taylor

Hi Karen,

I did finally get this figured out, but decided not to implement the
functionality after all :)

Thanks,
Brandon

On Dec 5, 7:47 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Dec 5, 2008 at 3:18 AM, Brandon Taylor <[EMAIL PROTECTED]>wrote:
>
>
>
>
>
> > Hi everyone,
>
> > I want to allow users to change their username in a non-admin form. I
> > have a login form already working, and I can successfully show user
> > information. I have granted the change user permission to the user
> > that is logged in.
>
> > When I pull in the UserChangeForm from contrib.auth.forms and hand it
> > a user instance, the username field is populated correctly.
>
> > So, I have a simple view action (pseudo code):
>
> > if request.method == 'POST':
> >    form = UserChangeForm(data=request.POST)
> >    if form.is_valid():
> >        form.save()
>
> > but I can never get the form to validate. I can get it to fail
> > correctly, but even if I put in a value that I know isn't currently in
> > use, the form will still not validate. I tried making a custom form to
> > update the username property and do the same validation, just in my
> > own form instance, but that didn't work either. The new username
> > property wasn't saving to the database.
>
> > Does anyone have any experience with this form from auth? Any help
> > appreciated!
>
> No, but I'm not sure this has anything to do specifically with auth an its
> models/forms.  You aren't passing in the user instance when you populate the
> form with the POST data.  You need to, just as you did when creating the
> form for the GET request.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ruby on Rails vs Django

2008-12-05 Thread yejun



On Dec 5, 9:10 pm, Jeffrey Straszheim <[EMAIL PROTECTED]> wrote:
> I give a slight edge to Python/Django over Ruby/Rails, however, because
> in Python-land, things seem more transparent.  I seldom have to guess
> what the language/framework will do.  With Ruby/Rails I string together
> code then sit back and wait to be surprised.

This is unnecessary true. Python can be very dynamic with decorate,
meta table and runtime code modification.



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



Re: using locals() with render_to_response()

2008-12-05 Thread Malcolm Tredinnick


On Fri, 2008-12-05 at 13:12 -0800, Bluebit wrote:
> Hey,
> I was wondering if there was any disadvantages using locals() when
> calling render_to_response().

One aspect that is relevant as your codebases grow and you work in
larger teams, is that it's kind of a lazy, messy coding practice. It
becomes time consuming to work out what parameters are actually being
passed around. Particularly when some parameters might be optional (the
direct relevance to Django templates noted below). If somebody uses a
new variable in a function that passes locals() onto something else,
they have to think about whether that name might actually *mean*
something to the receiver.

With respect to templates, if you are using other people's templates, or
even as you write some more advanced ones of your own, you'll find that
it's often neat (in the "leads to clean layout" sense, not the "cool,
dude" sense) to not necessarily require all variables to be present. For
example, on my blog, I insert RSS feeds if they exist in a particular
context variable. If the variable isn't present, I just move on. Now
imagine if I used the locals() approach -- I would have to always
remember never to use that variable name as a local variable, since it
would lead to unexpected results. Now expand that restriction to every
variable you use in every template.

The locals() idiom works nicely for small amounts of code and maybe
throwaway fragments. Personally, if I had one of my team manager or code
reviewer hats one, I'd consider it a bug. But if it solves your problem
and you go into it with your eyes open, knowing what the downsides might
be, that's a reasonable decision to make.

Regards,
Malcolm



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



Re: django table locking

2008-12-05 Thread Malcolm Tredinnick


On Wed, 2008-12-03 at 11:16 -0800, msoulier wrote:
> On Nov 18, 7:46 pm, Malcolm Tredinnick <[EMAIL PROTECTED]>
> wrote:
> > Django doesn't do any explicit table locking, although there are
> > transactions involved. However, that shouldn't be affecting this.
> 
> So Django is not safe to use in a concurrent environment? 

Concurrent means many different things. At some level, every application
(including many Django usages) involve concurrent usage. I guess from
your subsequent comments you are talking about simultaneous updates to
the same piece of data. That is not a really common case in web-based
applications, since (a) they're much more read- than write-oriented and
(b) even in writes-heavy situations, the writes tend to be spread out
across the entire dataset. Simultaneous updates to the same piece of
data are rare.

> Well, it is
> if you don't mind two users stepping on one another's changes, which
> you would have to prevent with explicit, optimistic locking, I assume?

As you no doubt realise, things like "select for update" calls really
have to made explicitly no matter whether you're doing it in raw SQL or
via some library API. This is because trying to work out which data
should be reserved as unchangeable until a subsequent update happens is
effectively impossible to work out and getting it wrong either leads to
disappointment or woeful performance (essentially serialised access).

For Django 1.1 we're looking at adding an API for specifying "SELECT FOR
UPDATE" behaviour, which will allow the developer to specify when they
want that to be in place. It's not entirely trivial, since we'd like to
avoid normal code being able to cause locked up situations (particularly
here in the land of reusable applications), but it's work in progress.


> > You just say "read locks", but that isn't a defined postgreSQL lock
> 
> Sorry, my tables looked like this:
> 
>relname   | relation | database | transaction |  pid  |
> mode | granted
> -+--+--+-+---
> +-+-
>  pg_class| 1259 |17456 | | 12221 |
> AccessShareLock | t
>  adminevents |17818 |17456 | | 31151 |
> AccessShareLock | t
>  clients |17618 |17456 | | 10325 |
> AccessExclusiveLock | f
>  clusternode |17759 |17456 | | 31151 |
> AccessShareLock | t
>  pg_locks|16759 |17456 | | 12221 |
> AccessShareLock | t
>  clients |17618 |17456 | | 31151 |
> AccessShareLock | t
>  cluster |17746 |17456 | | 31151 |
> AccessShareLock | t
> 
> So one process was waiting to acquire an AccessExclusiveLock, and
> there was already an AccessShareLock on it (the clients table).

Okay, so you'll need to try and work out what is trying to get the
AccessExclusiveLock. That's normally only table changing operations and
vacuum analyze statements, from memory (the latter needs it to gather
accurate statistics). Normal Django operations won't trigger those
(well, some django-admin commands will -- see
django/core/management/commands/ -- but they aren't run in normal
operations). The AccessShare locks are likely coming from SELECT
statements and you'll no doubt have a bunch of those happening in any
normal operation.

It's really just that table-level exclusive lock that is the problem, so
try to work out what might be causing that. It has a clearly different
PID there, too (it's the only one with that PID), suggesting it really
is some distinct operation.

Regards,
Malcolm



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



Re: Bay Area Django consultant wanted

2008-12-05 Thread Malcolm Tredinnick


On Fri, 2008-12-05 at 12:47 -0800, Margie wrote:
> Hi,
> 
> I am looking for a django developer/consultant that I can consult with
> in getting myself bootstrapped on django.  I have an application in
> mind and would like to develop it myself, but I would like someone to
> advise me on the model creation and basically help guide me in getting
> started.  This would be relatively informal, possibly some time
> together where I can explain my project, followed by various questions/
> email.  I can pay a reasonable, but not exorbitant rate.  I work for a
> large company and would be developing this product for that company,
> but would be paying this out of my own pocket.
> 
> Looking for someone that is available pretty much immediately.  My
> time is flexible in terms of day/time for meeting.
> 
> Hope this is an ok place to post this, sorry if I am offending anyone,
> I will post it only this once.

You may want to post something on Django Gigs (djangogigs.com). If
you're looking for something more social -- for want of a better word,
something like "random meet up for coffee sometimes and ask questions"
-- you may want to join the Django SF group
(http://groups.google.com/group/django-sf ). Don't ask me how I know
that exists, since I live more than a few thousand miles from San
Francisco. I'm just a fount of useless knowledge.

Regards,
Malcolm



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



Re: Django And os.path Behavior

2008-12-05 Thread dayvo

Solved.

I had to surround my folderpath field with smart_str according to
http://docs.djangobrasil.org/ref/unicode.html#ref-unicode

The only change needed in the example was on the last line:

[EMAIL PROTECTED]:/home/published/www/django/catalog/music# cat demo.py

import os
import music.models as model
import django.utils.encoding encode

def checkpath():
album = model.Album.objects.get(slug='como-al-agua')

return os.path.exists(encode.smart_str(album.folderpath))

I appreciate your time in helping me resolve this.  Maybe this post
will help someone else who runs into this problem.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Invalid block tag: render_comment_form (repost)

2008-12-05 Thread Malcolm Tredinnick


On Fri, 2008-12-05 at 03:17 -0600, James Bennett wrote:
> On Fri, Dec 5, 2008 at 2:07 AM, Florian Lindner <[EMAIL PROTECTED]> wrote:
> > Last time I used Django (pre 1.0) it was recommended to always use
> > trunk since the last released version was too outdated. Has this
> > changed?
> 
> Yes.
> 
> 0.96 -> 1.0 involved a large number of backwards-incompatible changes,
> so many people simply followed trunk so that they could make changes
> as they went rather than having a single huge upgrade process.
> 
> From 1.0 on, this is not a problem because compatibility is preserved
> between releases. Thus, your best bet (unless you're a developer
> actively working on Django itself, and interested in helping to
> develop new features or fix new bugs) is simply to use the latest
> release (Django 1.0.2).

That being said, we (the maintainers) have also agreed that we aren't
going to destabilise trunk in any cavalier fashion. Following trunk
should be no more risky than it was pre-1.0, but it might not be as
necessary. It will probably be less work than before 1.0, since there
won't be all the backwards incompatible changes (at least in the areas
marked in our API stability document) to worry about.

Regards,
Malcolm


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



Re: Django And os.path Behavior

2008-12-05 Thread Karen Tracey
On Fri, Dec 5, 2008 at 6:07 PM, dayvo <[EMAIL PROTECTED]> wrote:

>
> Good question.  That could affect the app if I were using relative
> path's or relying on the environment to locate files.  The path's I'm
> using in the app are stored are absolute paths.  They work correctly
> for path's that don't have unicode characters in them.  My Django app
> works correctly with %95+ of the data I'm using.  I'm just trying to
> resolve exceptions.  Those exceptions all have special characters in
> them.
>
> I'm starting to suspect apache and mod_python could have something to
> do with this.  Perhaps it's not a Django issue after all.
>

Part of the locale is the preferred encoding, and I believe that will impact
how unicode objects are encoded to bytestrings for system calls regardless
of whether you are dealing with absolute or relative paths.  Import locale
in your test and check the value returned for
locale.getpreferredencoding().  It appears when running under the shell your
preferred encoding is utf-8 while when running under your server (Apache?)
it is ascii. See http://code.djangoproject.com/ticket/8965 for an example of
this sort of thing happening when running under Apache.

Karen

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



Re: confused with session chapters in djangoproject

2008-12-05 Thread vierda

Dear Karen,

thanks for your clarification. it clear now. Ok  I will try to make
the Comment model and see how it code works.

regards,
-vierda-


On Dec 6, 8:47 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Dec 5, 2008 at 4:10 PM, vierda <[EMAIL PROTECTED]> wrote:
>
> > Dear Karen,
>
> > thanks for your reply. Actually in my learning I try to follow the
> > code which is provide in the book to understand how it works. It
> > sounds silly but from above code, I really didn't get what below line
> > trying to do :
>
> > c = comments.Comment(comment=new_comment)
>
> > somebody kindly help to clarify me, thank you.
>
> It's creating a Comment.  This particular (fictitious) Comment model
> apparently has one required argument, comment, which is being set to the
> value new_comment that has been passed into the post_comment routine.  The
> next line saves the created comment to the DB.  The real point of the
> example, though, is how the session is used to track whether a comment has
> been posted using this session yet, and to prevent more than one comment per
> session.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ruby on Rails vs Django

2008-12-05 Thread Jeffrey Straszheim

Masklinn wrote:
> I'd say that Rails and Django differ much more than Python and Ruby.  
> There are "small" differences between Python and Ruby, but the core  
> philosophies and structures of Rails and Django on the other hand are  
> completely unrelated and pretty much incompatible.
>   
Considering I do raw Java servlet/JDBC programming as my day job 
(seriously), I find Rails and Django more alike than different.  I think 
I give a slight edge to Python/Django over Ruby/Rails, however, because 
in Python-land, things seem more transparent.  I seldom have to guess 
what the language/framework will do.  With Ruby/Rails I string together 
code then sit back and wait to be surprised.

Both are VERY good, in any case.  Take it from one man slogging through 
Java hell.

Jeffrey Straszheim



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



Re: Django And os.path Behavior

2008-12-05 Thread dayvo

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

import datetime

class TagItem(models.Model):
foreignID = models.IntegerField()
description = models.TextField(blank=True)
itemType = models.ForeignKey(ContentType)
titleWords = models.IntegerField()

tag = models.ForeignKey('Tag',related_name='tagItem_tag')
content = generic.GenericForeignKey('itemType', 'foreignID')

def __str__(self):
return ("%s; %s; %s") % 
(self.tag,self.itemType,self.content.name)

class Meta:
verbose_name_plural = "Tag Items"

class Admin:
pass

class Tag(models.Model):
name = models.CharField(max_length=100)
slug = models.SlugField(unique=True,max_length=150)
displayCount = models.IntegerField()
description = models.TextField(blank=True)

def __str__(self):
return self.name

class Admin:
pass

class Genre(models.Model):
name = models.CharField(max_length=150)
slug = models.SlugField(unique=True,max_length=150)

tags = generic.GenericRelation(TagItem)

def __str__(self):
return self.name

class Admin:
pass

class Artist(models.Model):
name = models.CharField(max_length=150)
slug = models.SlugField(unique=True,max_length=150)

tags = generic.GenericRelation(TagItem)

def __str__(self):
return self.name

class Admin:
pass

class Album(models.Model):
name = models.CharField(max_length=150)
slug = models.SlugField(unique=True,max_length=150)
folderpath = models.TextField()
publisher = models.CharField(max_length=100)
releasedate = models.CharField(max_length=50)
description = models.TextField()
rating = models.CharField(max_length=3)
keywords = models.CharField(max_length=16)
lookupon = models.DateField(null=True,editable=False)
modifiedon = models.DateField(editable=False)

genre = models.ForeignKey(Genre,related_name='album_genre')
tags = generic.GenericRelation(TagItem)

def save(self):
self.modifiedon = datetime.datetime.today()
super(Album, self).save()

def __str__(self):
return self.name

class Admin:
pass

class AlbumReview(models.Model):
Summary = models.CharField(max_length=100)
Content = models.TextField()
ReviewDate = models.CharField(max_length=50)
Rating = models.CharField(max_length=3)

album = models.ForeignKey(Album,related_name='review_album')

def __str__(self):
return self.id

class Admin:
pass

class Song(models.Model):
name = models.CharField(max_length=150)
slug = models.SlugField(unique=True,max_length=150)
bitrate = models.IntegerField()
duration = models.IntegerField()
size = models.IntegerField()
track = models.IntegerField()
filepath = models.TextField()

artist = models.ForeignKey(Artist,related_name='song_artist')
album = models.ForeignKey(Album,related_name='song_album')
tags = generic.GenericRelation(TagItem)

def __str__(self):
return self.name

class Admin:
pass

class Link(models.Model):
name = models.CharField(max_length=50)
url = models.CharField(max_length=500)
requirelogin = models.BooleanField(default=False)
requireadmin = models.BooleanField(default=False)

def __str__(self):
return self.name

class Admin:
pass

class News(models.Model):
title = models.CharField(max_length=500)
link = models.CharField(max_length=500)
published = models.DateTimeField()
summary = models.TextField()
photo = models.CharField(max_length=250,null=True)
caption = models.TextField(null=True)

def __str__(self):
return self.title

class Admin:
pass

class Download(models.Model):
foreignID = models.IntegerField()
itemType = models.ForeignKey(ContentType)
content = generic.GenericForeignKey('itemType', 'foreignID')
user = models.ForeignKey(User)
modifiedon = models.DateTimeField()

def __str__(self):
return 'None'

class Admin:
pass

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL 

Re: Ruby on Rails vs Django

2008-12-05 Thread Colin Bean

On Fri, Dec 5, 2008 at 4:06 AM, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I'm new to the django world and I was just wondering how Django
> compears with  Ruby on Rails ?
>
> did anybody try Ruby on Rails so can give us a feedback ?
>
> thanks
>
> >
>


Another big difference between Django and Rails is the template
system:  Django tries very hard to separate presentation from business
logic, Rails lets you do anything you want in a template (including
database queries and other egregious abuse :).
Also, Rails comes with numerous helper functions to generate common
html elements, and a bundled javascript framework.  Django leaves the
javascript framework and HTML generation largely up to you (you can
create your own shortcuts with templatetags, of course).
Although I've used and enjoyed Rails, I prefer the Django approach in
both of these areas.

Colin

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



Re: confused with session chapters in djangoproject

2008-12-05 Thread Karen Tracey
On Fri, Dec 5, 2008 at 4:10 PM, vierda <[EMAIL PROTECTED]> wrote:

>
> Dear Karen,
>
> thanks for your reply. Actually in my learning I try to follow the
> code which is provide in the book to understand how it works. It
> sounds silly but from above code, I really didn't get what below line
> trying to do :
>
> c = comments.Comment(comment=new_comment)
>
> somebody kindly help to clarify me, thank you.
>

It's creating a Comment.  This particular (fictitious) Comment model
apparently has one required argument, comment, which is being set to the
value new_comment that has been passed into the post_comment routine.  The
next line saves the created comment to the DB.  The real point of the
example, though, is how the session is used to track whether a comment has
been posted using this session yet, and to prevent more than one comment per
session.

Karen

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



Re: Ruby on Rails vs Django

2008-12-05 Thread yejun

I think he means python is a more traditional procedure like language
than ruby is.

On Dec 5, 2:43 pm, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 5 déc, 16:16, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Metaphorically that Python/Djangois for a conservative engineer
> > mindset,
>
> ??? care to elaborate on this ???

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



Re: Django And os.path Behavior

2008-12-05 Thread Carlos A. Carnero Delgado
Hello,

> The path in this demo contains "El Camarón de la Isla", where the
> accent character is the trouble maker.

Can you post your music.models?

Best regards,
Carlos.

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



Re: Paginator - JSON - Serializing related issue

2008-12-05 Thread chachra

Why don't you create a new list

l = []

put the pagenumber etc. only a map and append to list

Then iterate over your objects and append them too. Then use
simplejson.dumps() and job done ? Works for me!

Cheers!
Sumit


On Oct 20, 5:48 am, "H. de Vries" <[EMAIL PROTECTED]> wrote:
> Hey Rajesh,
>
> Thank you so much for your comment. Somehow Google didn't sent me a
> message that I had a reply on my post, so that's why I'm late with my
> reply.
>
> I think your solution looks neat, but this way I would still need 2
> ajax requests wouldn't I?
>
> Doesn't self.options.pop('fields', None) delete the fields key from
> the json data?
>
> I'm not that familiar with Python yet, so I'm probably wrong. Please
> enlighten me :-)
>
> The dirty hack I came up with:
>
> data = json_serializer.serialize(users.object_list,
> ensure_ascii=False, fields=('username', 'first_name', 'last_name',
> 'email'))
>     return HttpResponse('[{"numpages": "' +
> str(users.paginator.num_pages) + '", "start_index": "'+
> str(users.start_index()) +'", "end_index": "'+ str(users.end_index())
> +'", "count": "'+ str(p.count) +'", "has_next": "'+
> str(int(users.has_next())) +'", "has_previous": "'+
> str(int(users.has_previous())) +'", ' + data[2:],
> mimetype='application/javascript')
>
> It's isn't pretty, but it works. I'm going to try your solution, I
> will reply if it works.
>
> Greets,
>
> Henk.
>
> On 2 okt, 21:41, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > > I have the following:
> > > [snip]
> > > def people_json(request):
> > >         userobjects = 
> > > User.objects.filter(is_superuser=False).extra(order_by
> > > = ['auth_user.username+0'])
> > >         p =Paginator(userobjects, 10)
> > >         pagenumber = request.POST.get('pagenumber', 1)
> > >         try:
> > >                 users = p.page(pagenumber)
> > >         except:
> > >                 users = p.page(1)
> > >         json_serializer = serializers.get_serializer("json")()
> > >         data = json_serializer.serialize(users.object_list,
> > > ensure_ascii=False, fields=('username', 'first_name', 'last_name',
> > > 'email'))
> > >         return HttpResponse(data, mimetype='application/javascript')
> > > [/snip]
>
> > > This will return aJSONstring to the browser that I use to make a
> > > people overview that uses AJAX.
> > > Anyway, because I have to draw 'previous' and 'next' buttons, I want
> > > to attach some extra data to thejsonresponse.
>
> > > For example I would like to concatenate the following list to the
> > > response:
> > > pageinfo = [p.start_index(), p.end_index(), p.paginator.count,
> > > p.has_next(), p.has_previous()]
>
> > > I tried to convert users.object_list to a list and concatenate it with
> > > pageinfo, but that doesn't work ( tells me str doesn't have the
> > > attribute _meta ).
> > > I don't want to use html as a response because that would throw more
> > > bytes over the pipe. ( it's also slower ).
> > > I also don't want to use 2 separate requests because that would be
> > > more overhead ( 2 separate requests take more time and it would also
> > > result in to 2 queries because thePaginatorhas to be initiated once
> > > again ).
>
> > > Does anyone have a good solution for this problem? Using Django has
> > > been a great experience but things like this take a lot of time.
>
> > You could register your own[1] serializer class that extends the built-
> > inJSONserializer.
>
> > You serializer would be something like this:
>
> > from django.utils import simplejson
> > from django.core.serializers importjson
>
> > class Serializer(json.Serializer):
> >     def __init__(self, dict):
> >         self.dict = dict or {}
> >     def end_serialization(self):
> >         self.options.pop('stream', None)
> >         self.options.pop('fields', None)
> >         self.dict['objects'] = self.objects
> >         simplejson.dump(self.dict, self.stream,
> > cls=json.DjangoJSONEncoder, **self.options)
>
> > See this setting to register your own serializer:
> > [1]http://docs.djangoproject.com/en/dev/ref/settings/#serialization-modules
>
> > Let's say you registered this custom serializer as "my_json". You'd
> > use it like this:
>
> > dict = {'pageinfo':pageinfo} # where pageinfo is your previously
> > mentioned list
> > json_serializer = serializers.get_serializer("json")(dict)
> > data = json_serializer.serialize(users.object_list,
> > ensure_ascii=False, fields=('username', 'first_name', 'last_name',
> > 'email'))
>
> > The "dict" can contain any keys and values that
> > django.utils.simplejson can encode.
>
> > -RD

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

Re: Ruby on Rails vs Django

2008-12-05 Thread Bluebit

My experience with rails was fantastic.
I thought there wouldn't be anything that could replace it.
but eventually, as you get to know the inner workings and the
limitations and the issues it has, you stop and think for a moment and
look for solutions/alternatives.
That was what happened to me.
I switched to django first mainly because of the admin interface. I
didn't know python then and I thought ruby was a better language for
me (i still think it is). BUT... rails tried so hard to drive me away.
With every new release you have issues with backwards-compatibility
and changes in the api. Deploying a rails app wasn't fun either. There
was no timeline/planned releases with features clearly known like
django had.
I really miss the named routes though, I know django has this too, but
with rails it's so simple that you have to love it.
and about the "django is for engineers, rails for hackers" comments, I
kind of agree.

On Dec 5, 4:06 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'm new to the django world and I was just wondering how Django
> compears with  Ruby on Rails ?
>
> did anybody try Ruby on Rails so can give us a feedback ?
>
> thanks

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



using locals() with render_to_response()

2008-12-05 Thread Bluebit

Hey,
I was wondering if there was any disadvantages using locals() when
calling render_to_response().
I know it might return more variables than what I need to use in the
template, but in terms of performance/security, is there a reasonable
concern?
thanks,

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



'extra' modifier and generic relations

2008-12-05 Thread Julien Phalip

Hi,

I have an Event model which can have comments. Comments can be added
to any kind of objects so the Comment model uses a generic relation
via content types.

When displaying a list of events I would like to display the number of
comments for each event. To improve performance and limit the number
of queries I'd like to use the 'extra' queryset modifier, but is that
even possible? The fact that it uses a generic relation means that I
need to know the content type id. If I hardcode that id in the 'extra'
statement then the site cannot reliably be ported to another database.

Can the extra modifier be reliably used with generic relations, or is
there a workaround?

Thanks a lot for your advice.

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



template tag

2008-12-05 Thread Alfredo Alessandrini

Hi,

I've this variable in my template: {{ challenger.rating }}

It'a a number...

Can I calculate a sum like this:

 {{ challenger.rating }} + 200   ??

I must write a custom tag?


Alfredo

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



Re: How to use Fixtures and/or Initial SQL for project auth_user data?

2008-12-05 Thread Russell Keith-Magee

On Sat, Dec 6, 2008 at 1:54 AM, Jeff Kowalczyk <[EMAIL PROTECTED]> wrote:
>
> During early prototyping, I'm relying on specific auth_user content in
> the project admin, as my app model use User as a ForeignKeyField.
>
> Project layout is:myproject/myapp
>
> Initial SQL myproject/myapp/mymodel/sql/mymodel.sql works fine, and
> I'm interested in initial_data.[xml/yaml/json for the same purpose.
>
> Is there an equivalent location under the project (or app) level for
> loading auth_{user,user_user_permissions} data, including the one
> superuser I always want configured?

This is one of the use cases that fixture loading was designed for.
Put your user and permissions into a fixture called initial_data, and
it will be automatically loaded whenever you run syncdb. If you don't
want it to be automatically loaded (which is a good idea if you're
dealing with passwords), choose another fixture name, and manually
load the data using ./manage.py loaddata.

http://docs.djangoproject.com/en/dev/howto/initial-data/
http://docs.djangoproject.com/en/dev/topics/serialization/
http://docs.djangoproject.com/en/dev/ref/django-admin/#loaddata-fixture-fixture

You can write your fixtures by hand if you want; alternatively, you
can use the dumpdata command to dump the current database contents (or
part of the database):

http://docs.djangoproject.com/en/dev/ref/django-admin/#dumpdata

Yours,
Russ Magee %-)

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



Re: Using managers for related object access

2008-12-05 Thread Luke Graybill
Thanks for the help, bruno. I'm glad to hear that I wasn't misreading the
documentation in some fashion. I'll apply your suggestions.

Luke

On Thu, Dec 4, 2008 at 2:21 PM, bruno desthuilliers <
[EMAIL PROTECTED]> wrote:

>
>
>
> On 4 déc, 21:39, "Luke Graybill" <[EMAIL PROTECTED]> wrote:
> > I am attempting to use a custom manager for related object access, as
> > documented here<
> http://docs.djangoproject.com/en/dev/topics/db/managers/#using-manage...>,
> > but it does not appear to be working properly. Upon accessing the reverse
> > relationship, I am getting an unfiltered queryset result. Using this
> trimmed
> > down code ,
>
> invert lines 17 and 18, ie make 'referenced' the first declared object
> manager and 'objects' the second.
>
> And yes, the result you get is not what one would expect reading the
> mentioned doc.
>
> The fact is that is that use_for_related_fields only impacts the other
> side of the relationship, ie Shift.worked_by (but since you didn't
> define a  Custom manager for Employee...). In this side of a OneToMany
> relationship, it's the default manager that is used, and the default
> manager is the first declared one.
>
> HTH
>
> PS : As a side note: the pattern I personnally use is :
>
> class ShiftManager(models.Manager):
>use_for_related_fields = True
>def referenced(self):
>return self.filter(is_dereferenced=False)
>
> e = Employee.objects.get(id=1)
> e.shifts.referenced()
>
> This avoid having to write too many managers
>
>
> >
>

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



Re: Django And os.path Behavior

2008-12-05 Thread dayvo

Good question.  That could affect the app if I were using relative
path's or relying on the environment to locate files.  The path's I'm
using in the app are stored are absolute paths.  They work correctly
for path's that don't have unicode characters in them.  My Django app
works correctly with %95+ of the data I'm using.  I'm just trying to
resolve exceptions.  Those exceptions all have special characters in
them.

I'm starting to suspect apache and mod_python could have something to
do with this.  Perhaps it's not a Django issue after all.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



transactions and locking in postgreSQL

2008-12-05 Thread msoulier

Looking at the transaction middleware that wraps a transaction around
every HTTP request, I've found that it only commits if the transaction
is "dirty" (you change something).

So, if you use this middleware unconditionally, then in view functions
that only read, the transaction will never be committed.

Even when you read, postgres implicitly locks tables for reading.

I am finding that since commit is never called in these cases, the
locks persist.

Is anyone using the transaction middleware with postgres? I have to
assume so. If so, then what am I doing wrong?

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



Re: Django And os.path Behavior

2008-12-05 Thread Graham Dumpleton

What locale settings do you have set in the environment of your user
account? These will not be getting used in context of Apache.

Graham

On Dec 6, 9:21 am, dayvo <[EMAIL PROTECTED]> wrote:
> Thanks for the response Andy.
>
> The code does work fine in the interpreter.  It's when the code is
> called from a web page where it throws an error.  I know it has
> something to do with unicode but I can't understand why os.stat is
> behaving differently.  To test from a view:
>
> --- 
> --
> Relevant URL in urls.py
> --- 
> --
> [EMAIL PROTECTED]:/home/published/www/django/catalog/music# grep demo
> urls.py
>     (r'^demo/$', 'music.views.demo'),
>
> --- 
> --
> Call to checkpath from views.py
> --- 
> --
>
> [EMAIL PROTECTED]:/home/published/www/django/catalog/music# head -16
> views.py
> import django.shortcuts as shortcuts
> from django.template import RequestContext
> from django.http import HttpResponseRedirect
> from django.contrib.contenttypes.models import ContentType
> import models
> import music.demo
>
> def demo(request):
>         music.demo.checkpath()
>         return HttpResponseRedirect('http://google.com')
>
> --- 
> --
> And the error (viahttp://domain.tld/demo)
> --- 
> --
>
> Exception Type:         UnicodeEncodeError
> Exception Value:
>
> 'ascii' codec can't encode character u'\xf3' in position 35: ordinal
> not in range(128)
>
> Exception Location:     /usr/lib/python2.5/posixpath.py in exists, line
> 171
> Python Executable:      /usr/bin/python
> Python Version:         2.5.2
>
> Traceback:
> File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
> in get_response
>   86.                 response = callback(request, *callback_args,
> **callback_kwargs)
> File "/home/published/www/django/catalog/music/views.py" in demo
>   14.   music.demo.checkpath()
> File "/usr/lib/python2.5/posixpath.py" in exists
>   171.         st = os.stat(path)
>
> Exception Type: UnicodeEncodeError at /demo/
> Exception Value: 'ascii' codec can't encode character u'\xf3' in
> position 35: ordinal not in range(128)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: djangobook.com sourcecode

2008-12-05 Thread Manu


> If you go and read about the comments system on the site, it tells you
> (see:http://djangobook.com/about/comments/) exactly where it came
> from:
>
> "Many, many thanks to Jack Slocum; the inspiration and much of the
> code for the comment system comes from Jack's blog, and this site
> couldn't have been built without his wonderful YAHOO.ext library.
> Thanks also to Yahoo for YUI itself."
>
> There are even links in that paragraph to help you go find the stuff.

I already did that and more before asking the question.
1. The link to Jack Slocum blog in that page is broken. His new blog/
site no longer has that type of commenting system.
2. Extjs does not provide old versions of their code for download.
Their new version is licensed in a very messy fashion making it
impossible to use in almost any project without buying their
commercial license.
Some info on that can be found at http://pablotron.org/?cid=1556. They
also claimed that extjs licensed under LGPL was not actually LGPL and
should not be distributed. I think the version used on djangobook.com
was based on the BSD/public domain licensed initial extjs which is
free of all this mess.
3. I was interested in the django source code as well to see how the
extjs comments was integrated.


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



Re: Django And os.path Behavior

2008-12-05 Thread dayvo

Thanks for the response Andy.

The code does work fine in the interpreter.  It's when the code is
called from a web page where it throws an error.  I know it has
something to do with unicode but I can't understand why os.stat is
behaving differently.  To test from a view:

-
Relevant URL in urls.py
-
[EMAIL PROTECTED]:/home/published/www/django/catalog/music# grep demo
urls.py
(r'^demo/$', 'music.views.demo'),

-
Call to checkpath from views.py
-

[EMAIL PROTECTED]:/home/published/www/django/catalog/music# head -16
views.py
import django.shortcuts as shortcuts
from django.template import RequestContext
from django.http import HttpResponseRedirect
from django.contrib.contenttypes.models import ContentType
import models
import music.demo

def demo(request):
music.demo.checkpath()
return HttpResponseRedirect('http://google.com')

-
And the error (via http://domain.tld/demo)
-

Exception Type: UnicodeEncodeError
Exception Value:

'ascii' codec can't encode character u'\xf3' in position 35: ordinal
not in range(128)

Exception Location: /usr/lib/python2.5/posixpath.py in exists, line
171
Python Executable:  /usr/bin/python
Python Version: 2.5.2

Traceback:
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py"
in get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/published/www/django/catalog/music/views.py" in demo
  14.   music.demo.checkpath()
File "/usr/lib/python2.5/posixpath.py" in exists
  171. st = os.stat(path)

Exception Type: UnicodeEncodeError at /demo/
Exception Value: 'ascii' codec can't encode character u'\xf3' in
position 35: ordinal not in range(128)


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



Re: djangobook.com sourcecode

2008-12-05 Thread James Bennett

On Fri, Dec 5, 2008 at 3:45 PM, Manu <[EMAIL PROTECTED]> wrote:
> Has the source code for djangobook.com ever released ? Is there a plan
> to release it if it is not released ? And lastly does anyone know of
> any projects which can provide the comments functionality of
> djangobook.com ?

If you go and read about the comments system on the site, it tells you
(see: http://djangobook.com/about/comments/) exactly where it came
from:

"Many, many thanks to Jack Slocum; the inspiration and much of the
code for the comment system comes from Jack's blog, and this site
couldn't have been built without his wonderful YAHOO.ext library.
Thanks also to Yahoo for YUI itself."

There are even links in that paragraph to help you go find the stuff.


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



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

2008-12-05 Thread garagefan

nevermind. I've borked the server messing around again :)

On Dec 5, 4:19 pm, garagefan <[EMAIL PROTECTED]> wrote:
> http://www.kennethdavid.net/djangoblog/admin/
> getting this error on my admin page. just started working w/
> webmonkey.com's 
> tutorialhttp://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First...
>
> this is occurring after installing the tagging module... which
> including me needing to install python-devel as well as using Eric's
> fix (third to 
> bottom):http://code.google.com/p/django-tagging/issues/detail?id=110
> to get around the issue i'm seeing on my site now.
>
> my /etc/httpd/conf.d/python.conf file looks like this:
>
> LoadModule python_module modules/mod_python.so
> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE djangoblog.settings
>     PythonOption django.root /djangoblog
>     PythonDebug On
> 
>
> on the godaddy virtual server my site directory, per site:
>
> /home/kdwadmin
>
> w/ djangoblog being a directory within there. I'm wondering if the
> tagging module is causing this issue?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django And os.path Behavior

2008-12-05 Thread Andy McKay

> os.path.exists behaves differently if called from a django app.  Why?


I don't think it does, for example:

~/sandboxes/arecibo $ ls -al ~/Desktop/
[...snip..]
drwxr-xr-x   2 andy  andy 68  5 Dec 21:57 El Camarón de la Isla

~/sandboxes/arecibo $ cat test.py
# -*- coding: utf-8 -*-
import os
print os.path.exists("/Users/andy/Desktop/El Camarón de la Isla")

~/sandboxes/arecibo $ python test.py
True

~/sandboxes/arecibo $ python manage.py shell
imPython 2.4.4 (#1, Feb 18 2007, 22:11:27)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
 >>> import django
 >>> import test
True

Seems to work just fine, there's nothing I've seen that fiddles with  
os.path. What is more likely: in one situation you've got a string  
encoded one way, in another its another. Check those strings encodings  
are what you expect prior to calling them.
--
   Andy McKay
   www.clearwind.ca | www.agmweb.ca/blog/andy







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



Django And os.path Behavior

2008-12-05 Thread dayvo

os.path.exists behaves differently if called from a django app.  Why?
Can I work around this?  I need to check if pathnames exist where the
path may have special/unicode characters.  I also need to open files
from that path.

The path in this demo contains "El Camarón de la Isla", where the
accent character is the trouble maker.

Any help is really appreciated.

-
Contents of demo.py
-

[EMAIL PROTECTED]:/home/published/www/django/catalog/music# cat demo.py

import os
import music.models as model

def checkpath():
album = model.Album.objects.get(slug='como-al-agua')

return os.path.exists(album.folderpath)

-
Calling checkpath() function in demo.py from the command interpreter
-

[EMAIL PROTECTED]:/home/published/www/django/catalog# python

Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> import music.demo
>>> music.demo.checkpath()
True
>>>

-
Finally, what happens when called from a Django application.
You can see that I call checkpath in demo.py
Code fails in posixpath.py when doing os.stat(path)
-

'ascii' codec can't encode character u'\xf3' in position 35: ordinal
not in range(128)

Request Method: GET
Request URL:http://music.sensiblestaffing.com/music/cover/como-al-agua/
Exception Type: UnicodeEncodeError
Exception Value:

'ascii' codec can't encode character u'\xf3' in position 35: ordinal
not in range(128)

Exception Location: /usr/lib/python2.5/posixpath.py in exists, line
171
Python Executable:  /usr/bin/python
Python Version: 2.5.2

#  /home/published/www/django/catalog/music/extended.py in Cover


  54. result = music.demo.checkpath() ...


# /usr/lib/python2.5/posixpath.py in exists


 171. st = os.stat(path) ...



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



Re:

2008-12-05 Thread PFL

Rajesh -- THANK YOU  very much!  you are correct.

My issue was not on the  side -- it was on the target side -- i had
a typo that was messing up the text of the id="".
Once that was fixed, it worked exactly as you said it should; this was
a PIBKAC issue.

I did however learn something: I was not aware of the distinction
between browser/server functionality in resolving local links...of
course it seem obvious to me now.


On Dec 5, 11:58 am, Rajesh Dhawan <[EMAIL PROTECTED]> wrote:
> On Dec 5, 2:41 pm, PFL <[EMAIL PROTECTED]> wrote:
>
> > Thanks for your replies --I am still stuck here.
>
> > >Have a look in the output from the development server - I very much doubt 
> > >that the click results in any request being sent.
>
> > A request is definitely sent for each of these cases: "/doc/", "/
> > doc#", "/doc#1/".  I can see each of these generating a hit on the
> > local dev server standard out.
>
> But you omitted the one that your template is actually resulting in:
>
> /doc/#1
>
> Incidentally, they will all generate a hit if you punch them into your
> browser's URL bar. The # anchor implementation is a browser feature
> not a web server feature. So, the way to test whether a new link is
> being generated is to use your browser like this:
>
> First point your browser to /doc/ to get Django to serve your request.
> Now, click on the anchor link in your browser. You should not see a
> new web server request resulting from that click. Your browser should
> simply pan you down to where you have the element with id=1.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



djangobook.com sourcecode

2008-12-05 Thread Manu

Has the source code for djangobook.com ever released ? Is there a plan
to release it if it is not released ? And lastly does anyone know of
any projects which can provide the comments functionality of
djangobook.com ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



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

2008-12-05 Thread garagefan

http://www.kennethdavid.net/djangoblog/admin/
getting this error on my admin page. just started working w/
webmonkey.com's tutorial 
http://www.webmonkey.com/tutorial/Install_Django_and_Build_Your_First_App

this is occurring after installing the tagging module... which
including me needing to install python-devel as well as using Eric's
fix (third to bottom): 
http://code.google.com/p/django-tagging/issues/detail?id=110
to get around the issue i'm seeing on my site now.

my /etc/httpd/conf.d/python.conf file looks like this:

LoadModule python_module modules/mod_python.so

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE djangoblog.settings
PythonOption django.root /djangoblog
PythonDebug On


on the godaddy virtual server my site directory, per site:

/home/kdwadmin

w/ djangoblog being a directory within there. I'm wondering if the
tagging module is causing this issue?


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



Re: confused with session chapters in djangoproject

2008-12-05 Thread vierda

Dear Karen,

thanks for your reply. Actually in my learning I try to follow the
code which is provide in the book to understand how it works. It
sounds silly but from above code, I really didn't get what below line
trying to do :

c = comments.Comment(comment=new_comment)

somebody kindly help to clarify me, thank you.

On Dec 5, 10:27 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, Dec 5, 2008 at 9:53 AM, vierda <[EMAIL PROTECTED]> wrote:
>
> > Dear all,
>
> > I'm newbie in Django and have started study since two weeks. I tried
> > code that shows in djangoproject.com, in session chapters I got
> > problem with below code. It shows error that says module comments
> > doesn't have attribute Comment. am I missing something here?
> > Kindly help and thank you in advance
>
> > from django.contrib import comments
> > def post_comment(request, new_comment):
> >    if request.session.get('has_commented', False):
> >        return HttpResponse("You've already commented.")
> >    c = comments.Comment(comment=new_comment) # got error in this line
> >    c.save()
> >    request.session['has_commented'] = True
> >    return HttpResponse('Thanks for your comment!')
>
> That example code (which doesn't actually include "from django.contrib
> import comments" in the doc, which is a clue the example is not actually
> referring to the Django contrib.comments add-on) is trying to illustrate how
> to set and use session variables.  As the example is focused on sessions,
> the referenced models aren't necessarily provided by Django.  The next
> example uses a ficticious "Member" model which you won't find in Django
> either.  These particular examples are not meant to be cut-and-pasted into
> your own code, they are simply trying to illustrate how you might use
> sessions with your own models.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django table locking

2008-12-05 Thread msoulier

On Dec 3, 2:16 pm, msoulier <[EMAIL PROTECTED]> wrote:
> So one process was waiting to acquire an AccessExclusiveLock, and
> there was already an AccessShareLock on it (the clients table).

I've tried Django's transaction middleware, but I'm not sure that a
commit is taking place in postgres, as the locks don't seem to be
releasing.

I've had to remove the transaction middleware to prevent the locks
from being held forever.

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



Re: Error when querying with unicode data

2008-12-05 Thread dayvo

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



Bay Area Django consultant wanted

2008-12-05 Thread Margie

Hi,

I am looking for a django developer/consultant that I can consult with
in getting myself bootstrapped on django.  I have an application in
mind and would like to develop it myself, but I would like someone to
advise me on the model creation and basically help guide me in getting
started.  This would be relatively informal, possibly some time
together where I can explain my project, followed by various questions/
email.  I can pay a reasonable, but not exorbitant rate.  I work for a
large company and would be developing this product for that company,
but would be paying this out of my own pocket.

Looking for someone that is available pretty much immediately.  My
time is flexible in terms of day/time for meeting.

Hope this is an ok place to post this, sorry if I am offending anyone,
I will post it only this once.

Thanks,

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



Error when querying with unicode data

2008-12-05 Thread dayvo

I have the following code:

otherAlbums = models.Album.objects.filter
(song_album__artist__name=artist).distinct().order_by('releasedate')

when artist contains a unicode value, such as 'El Camarón de la Isla',
then I receive the following:

Exception Type: UnicodeEncodeError
Exception Value:'ascii' codec can't encode character u'\xf3' in
position 8: ordinal not in range(128)
Exception Location: /usr/lib/python2.5/site-packages/django/utils/
encoding.py in force_unicode, line 53

I've never run across this before.  The project has been in production
for about 2 years.  I've tried 0.96-pre and the 1.02-final versions.
It seems Django doesn't like filtering on a unicode string.


I would appreciate any suggestions you might have on working around
this problem.

Thanks!


The framework location that pukes is here:

/usr/lib/python2.5/site-packages/django/utils/encoding.py in
force_unicode

  46. if strings_only and isinstance(s, (types.NoneType, int, long,
datetime.datetime, datetime.date, datetime.time, float)):
  47. return s
  48. try:
  49. if not isinstance(s, basestring,):
  50. if hasattr(s, '__unicode__'):
  51. s = unicode(s)
  52. else:

  53. s = unicode(str(s), encoding, errors)

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



Re:

2008-12-05 Thread Rajesh Dhawan



On Dec 5, 2:41 pm, PFL <[EMAIL PROTECTED]> wrote:
> Thanks for your replies --I am still stuck here.
>
> >Have a look in the output from the development server - I very much doubt 
> >that the click results in any request being sent.
>
> A request is definitely sent for each of these cases: "/doc/", "/
> doc#", "/doc#1/".  I can see each of these generating a hit on the
> local dev server standard out.

But you omitted the one that your template is actually resulting in:

/doc/#1

Incidentally, they will all generate a hit if you punch them into your
browser's URL bar. The # anchor implementation is a browser feature
not a web server feature. So, the way to test whether a new link is
being generated is to use your browser like this:

First point your browser to /doc/ to get Django to serve your request.
Now, click on the anchor link in your browser. You should not see a
new web server request resulting from that click. Your browser should
simply pan you down to where you have the element with id=1.

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



Re:

2008-12-05 Thread David Zhou

On Fri, Dec 5, 2008 at 2:41 PM, PFL <[EMAIL PROTECTED]> wrote:

> A request is definitely sent for each of these cases: "/doc/", "/
> doc#", "/doc#1/".  I can see each of these generating a hit on the
> local dev server standard out.

Are you opening them in a new tab or anything of that nature?

-- 
---
David Zhou
[EMAIL PROTECTED]

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



Re: Ruby on Rails vs Django

2008-12-05 Thread bruno desthuilliers

On 5 déc, 16:16, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Metaphorically that Python/Djangois for a conservative engineer
> mindset,

??? care to elaborate on this ???


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



Re: Ruby on Rails vs Django

2008-12-05 Thread bruno desthuilliers



On 5 déc, 15:31, Masklinn <[EMAIL PROTECTED]> wrote:
> On 5 Dec 2008, at 14:30 , bruno desthuilliers wrote:> On 5 déc, 13:06, 
> "[EMAIL PROTECTED]"
> > <[EMAIL PROTECTED]> wrote:
> >> Hi All,
>
> >> I'm new to the django world and I was just wondering how Django
> >> compears with  Ruby on Rails ?
>
> > Mostly just like Python compares with (with ??? to ???) Ruby IMHO.
> > Quite close overall, and yet very different philosophies.
>
> I'd say that Rails and Django differ much more than Python and Ruby.
> There are "small" differences between Python and Ruby,

for which definition of "small" ? Granted, Python and Ruby are both hi-
level object-oriented highly dynamic languages, and there are a couple
superficial similarties in their respective syntaxes. But the object
model and the general philosophy are _totally_ different.

> but the core
> philosophies and structures of Rails and Django on the other hand are
> completely unrelated and pretty much incompatible.

As far as I'm concerned, this is just as true (or false) of Python vs
Ruby. And this mostly reflects the "architectural" and philosophical
differences between both languages.


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



Re:

2008-12-05 Thread PFL


Thanks for your replies --I am still stuck here.

>Have a look in the output from the development server - I very much doubt that 
>the click results in any request being sent.

A request is definitely sent for each of these cases: "/doc/", "/
doc#", "/doc#1/".  I can see each of these generating a hit on the
local dev server standard out.

I think this is a URL mapping mapping .

My url.py is:

(r'^doc/', 'doc.views.get_sections'),

Using the above, all of the following URLS map to the same
'doc.views.get_sections' view:
  http://localhost:8000/doc/
  http://localhost:8000/doc#1
  http://localhost:8000/doc#1/

I am not sure what I need to do to either my url mappings or in my
view to handle the  "#" ?
What is the way to get local links working?


On Dec 5, 11:02 am, Daniel Roseman <[EMAIL PROTECTED]>
wrote:
> On Dec 5, 6:04 pm, PFL <[EMAIL PROTECTED]> wrote:
>
> > The source generated by the templates is indeed correct; it looks
> > like:
>
> > Section1
>
> > However,  when I click on the link, Django(?) tries to resolve it as:
>
> >http://localhost:8000/doc/#1 -- not ---http://localhost:8000/doc#1
>
> > So -- how do I get local links working with Django?
>
> Django isn't doing anything. Have a look in the output from the
> development server - I very much doubt that the click results in any
> request being sent.
>
> The address of the page is indeed /doc/, not /doc, so it's correct
> that the local anchor would be /doc/#1.
> -
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ruby on Rails vs Django

2008-12-05 Thread JonathanB

On Dec 5, 7:06 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:

> did anybody try Ruby on Rails so can give us a feedback ?

As someone who tried both, I have personally found that Django better
fits my conceptual models than RoR. YMMV, because conceptions are a
very personal thing. My friend finds the exact same thing true of RoR.
But, the RoRs projects I worked on never got far past the concept
phase because I always got hung up implementing them. My current
Django project is far more complex than any of my RoRs projects, and
I'm making blazing fast progress. It took me about 3 weeks to nail
down exactly what I wanted my models and stuff to look like, but since
then it takes about 2 days for a portion of my project to go from
django-admin.py startapp to "all done except for what depends on parts
I haven't written yet".

Things I have found easier/better in Django than RoR include:
1) The admin interface. This is what I wish scaffolding was. Scaffolds
are nice, but they are implicitly temporary, intended to be built out
into something more useful. Because of this, they leave out a lot of
very useful things that Django's admin interfaces puts in. The Django
admin interface, on the other hand, is permanent. It may not intended
for public consumption, but it does make sanity-testing your models
(wait! That DecimalField has the wrong max_digits! Doh!) and initial
(or ongoing) data entry a lot easier than scaffolding does.

2) Relationships. I suspect that this is the biggest thing that isn't
"I like Python better." I just get relationships in Django, I didn't
in RoR. Everytime I hit a join or a relationship in my concept, my
implementation broke down because I couldn't untangle it in my mind.
This is probably mostly because I do not come from a database
background. In fact, my random web-dev projects are my only real
exposure to databases.

3) I like Python better than Ruby. I wanted to like Ruby, I tried
really hard. There aren't a lot of Python programmers where I live
(shoot, there aren't a lot of programmers where I live), and my friend
was into Ruby, which meant I'd have a sounding board who could
actually help with the details rather than just gaping conceptual
holes. So I tried. Oh, so hard. Finally, after a year away from
Python, I decided to come back and give it a try with a simple CLI
ToDo app I was building. Even after a year away from Python, even with
having to look up syntax for basic things, even with having to code
with the PyDocs open in another window, I was coding as fast as I
could type. For the first time in a year, my fingers were the
bottleneck, not my brain. It was probably the most effortless, most
freeing, and most exciting programming I had ever experienced.

I can still read and write Ruby, but I haven't written anything more
than corrections or suggestions for code my friend has shown me since
August. Python has won me over completely, which is why I like Django,
hands-down, better than RoR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



template tags for simple comparison

2008-12-05 Thread Aaron Lee
I found this wiki and seems pretty useful in general, is there any reason
why it's not included in Django by default?

http://code.djangoproject.com/wiki/BasicComparisonFilters

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



Re:

2008-12-05 Thread Daniel Roseman

On Dec 5, 6:04 pm, PFL <[EMAIL PROTECTED]> wrote:
> The source generated by the templates is indeed correct; it looks
> like:
>
> Section1
>
> However,  when I click on the link, Django(?) tries to resolve it as:
>
> http://localhost:8000/doc/#1 -- not ---http://localhost:8000/doc#1
>
> So -- how do I get local links working with Django?

Django isn't doing anything. Have a look in the output from the
development server - I very much doubt that the click results in any
request being sent.

The address of the page is indeed /doc/, not /doc, so it's correct
that the local anchor would be /doc/#1.
-
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin widget for large number of related records

2008-12-05 Thread Daniel Roseman

On Dec 5, 6:23 pm, "Jim D." <[EMAIL PROTECTED]> wrote:
> I apologize if this question has been asked/answered here before, but
> I searched around and couldn't find anything.
>
> We're working on a django app in which we're porting some existing
> user data overwe have about 100,000 user records that are being
> imported. We have many other models that are linked back to User in a
> one-to-many association.
>
> The problem we're experiencing is with the admin. When we're
> displaying the admin edit form for a model that's related to User, it
> ends up with a drop down allowing you to change which user is
> associated with the object. The problem is that 100,000 user records
> end up appearing in this drop down!
>
> Is there a different widget that can be used in the case where an
> object is related to another with a really large number of records?
>
> Or are we doing something wrong that I'm overlooking? I feel like this
> must have come up for many people and I must be missing something
> that's super obvious to everyone else.
>
> Any advice or guidance you guys can provide is very much appreciated.
> Many thanks!

Add it to the raw_id_fields list on your admin class.
See http://docs.djangoproject.com/en/dev/ref/contrib/admin/#raw-id-fields

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



Admin widget for large number of related records

2008-12-05 Thread Jim D.

I apologize if this question has been asked/answered here before, but
I searched around and couldn't find anything.

We're working on a django app in which we're porting some existing
user data overwe have about 100,000 user records that are being
imported. We have many other models that are linked back to User in a
one-to-many association.

The problem we're experiencing is with the admin. When we're
displaying the admin edit form for a model that's related to User, it
ends up with a drop down allowing you to change which user is
associated with the object. The problem is that 100,000 user records
end up appearing in this drop down!

Is there a different widget that can be used in the case where an
object is related to another with a really large number of records?

Or are we doing something wrong that I'm overlooking? I feel like this
must have come up for many people and I must be missing something
that's super obvious to everyone else.

Any advice or guidance you guys can provide is very much appreciated.
Many thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re:

2008-12-05 Thread PFL

The source generated by the templates is indeed correct; it looks
like:

Section1

However,  when I click on the link, Django(?) tries to resolve it as:

http://localhost:8000/doc/#1  -- not --- http://localhost:8000/doc#1

So -- how do I get local links working with Django?



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



Re: Session based messages without touching DB

2008-12-05 Thread Andre P LeBlanc

Sorry, I didn't notice that you said you didn't like the DB hits
associated with the session based approach, you can use memcached
sessions, or file-backed if avoid the database hits. :P

On Dec 5, 12:33 pm, Andre P LeBlanc <[EMAIL PROTECTED]> wrote:
> What about the patches on the ticket?  The cookie-based approach is
> not the right way to do it, as the comments on that page indicate,
> these things should be stored server side, especially since it is
> being unpickled serverside, it leave a larges security hole.  (and the
> encryption he later added makes it just silly, just keep it
> serverside).
>
> I really like this idea, the current message system seems pretty
> broken to me.  I don't see any reason why it should be limited to
> authenticated users, when it's the type of thing that can and should
> be used for anonymous users as well... I'm thinking "Your comment has
> been recieved but must be moderated.." etc.
>
> The approach used in the patches supplied with the ticket seems sane,
> so whether or not its accepted into django it's definitely a good
> starting point if you really want that functionality, and I'll
> probably use it in my next project.
>
> Cheers,
> Andre
>
> On Dec 5, 7:51 am, Thomas Guettler <[EMAIL PROTECTED]> wrote:
>
> > Hi,
>
> > I use code based on "session based messages" 
> > from:http://code.djangoproject.com/ticket/4604
>
> > What I don't like: There are two database hits, which are not necessary:
> > Store message in session-pickle
> > and pop message from session-pickle.
>
> > I found this:
> >    http://www.djangosnippets.org/snippets/1064/
> > The (flash) message is stored in a cookie.
>
> > But I think the snippet is not thread safe. Has anyone a working example?
>
> >   Thomas
>
> > --
> > Thomas Guettler,http://www.thomas-guettler.de/
> > E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Session based messages without touching DB

2008-12-05 Thread Andre P LeBlanc

What about the patches on the ticket?  The cookie-based approach is
not the right way to do it, as the comments on that page indicate,
these things should be stored server side, especially since it is
being unpickled serverside, it leave a larges security hole.  (and the
encryption he later added makes it just silly, just keep it
serverside).

I really like this idea, the current message system seems pretty
broken to me.  I don't see any reason why it should be limited to
authenticated users, when it's the type of thing that can and should
be used for anonymous users as well... I'm thinking "Your comment has
been recieved but must be moderated.." etc.

The approach used in the patches supplied with the ticket seems sane,
so whether or not its accepted into django it's definitely a good
starting point if you really want that functionality, and I'll
probably use it in my next project.

Cheers,
Andre


On Dec 5, 7:51 am, Thomas Guettler <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I use code based on "session based messages" 
> from:http://code.djangoproject.com/ticket/4604
>
> What I don't like: There are two database hits, which are not necessary:
> Store message in session-pickle
> and pop message from session-pickle.
>
> I found this:
>    http://www.djangosnippets.org/snippets/1064/
> The (flash) message is stored in a cookie.
>
> But I think the snippet is not thread safe. Has anyone a working example?
>
>   Thomas
>
> --
> Thomas Guettler,http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ruby on Rails vs Django

2008-12-05 Thread Marinho Brandao

I see... but what I mean is that you will find "better" informations
about this on Google than asking on a list of Django-fans :P

good luck :)

2008/12/5 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> yes... I saw that thread... but it is 14 months old !!! and in IT 14
> months is a LOT
>
> On 5 dic, 10:17, "Marinho Brandao" <[EMAIL PROTECTED]> wrote:
>> http://www.google.com.br/search?q=Ruby+on+Rails+vs+Django
>>
>> 2008/12/5 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>>
>>
>>
>> > Hi All,
>>
>> > I'm new to the django world and I was just wondering how Django
>> > compears with  Ruby on Rails ?
>>
>> > did anybody try Ruby on Rails so can give us a feedback ?
>>
>> > thanks
>>
>> --
>> Marinho Brandão (José Mário)http://marinhobrandao.com/
> >
>



-- 
Marinho Brandão (José Mário)
http://marinhobrandao.com/

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



Re: Custom Widget for admin application

2008-12-05 Thread Ricardo Bánffy

But what if I have a ForeignKey or a ManyToManyField in my model?

On Fri, Dec 5, 2008 at 12:58 PM, Michel Thadeu Sabchuk
<[EMAIL PROTECTED]> wrote:
> Pass a grouped list to choices:
>
> ['group1', [(1, 'item 1'), (2, 'item 2'), ...], ...]

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



How to use Fixtures and/or Initial SQL for project auth_user data?

2008-12-05 Thread Jeff Kowalczyk

During early prototyping, I'm relying on specific auth_user content in
the project admin, as my app model use User as a ForeignKeyField.

Project layout is:myproject/myapp

Initial SQL myproject/myapp/mymodel/sql/mymodel.sql works fine, and
I'm interested in initial_data.[xml/yaml/json for the same purpose.

Is there an equivalent location under the project (or app) level for
loading auth_{user,user_user_permissions} data, including the one
superuser I always want configured?

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



Re: Ruby on Rails vs Django

2008-12-05 Thread David Zhou
On Fri, Dec 5, 2008 at 9:31 AM, Masklinn <[EMAIL PROTECTED]> wrote:
>
> On 5 Dec 2008, at 14:30 , bruno desthuilliers wrote:
>> On 5 déc, 13:06, "[EMAIL PROTECTED]"
>> <[EMAIL PROTECTED]> wrote:
>>> Hi All,
>>>
>>> I'm new to the django world and I was just wondering how Django
>>> compears with  Ruby on Rails ?
>>
>> Mostly just like Python compares with (with ??? to ???) Ruby IMHO.
>> Quite close overall, and yet very different philosophies.
> I'd say that Rails and Django differ much more than Python and Ruby.
> There are "small" differences between Python and Ruby, but the core
> philosophies and structures of Rails and Django on the other hand are
> completely unrelated and pretty much incompatible.

What do you think are the core philosophies of Rails and Django?

-- 
---
David Zhou
[EMAIL PROTECTED]

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



Re: Custom Middleware TypeError exception

2008-12-05 Thread Rajesh Dhawan



On Dec 5, 11:20 am, Chris Smith <[EMAIL PROTECTED]>
wrote:
> Found an oddity - possibly in my code.  Can't seem to work around it.
>
> Code in question (current multi-tenant middleware implementation):
>
> middleware.py ..
>
> from projectname.models import Tenant, HostEntry
> from django.http import HttpResponseNotFound
> from django.core.exceptions import ObjectDoesNotExist
>
> class MultiTenantMiddleware(object):
> """Multi tenant middleware"""
> def process_request(self, request):
> http_host = request.META['HTTP_HOST']
> try:
> host_entry = HostEntry.objects.get(host=http_host)
> except ObjectDoesNotExist:
> return HttpResponseNotFound("Host not found")
> request.tenant = host_entry.tenant
> return None
>
> -
>
> Exception details 
>
> Environment:
>
> Request Method: GET
> Request URL:http://localhost:8000/
> Django Version: 1.0.2 final
> Python Version: 2.6.0
> Installed Applications:
> ['django.contrib.sessions', 'productname']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'vhdesk.middleware.MultiTenantMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
> Traceback:
> File "C:\Python26\Lib\site-packages\django\core\handlers\base.py" in
> get_response
>   86. response = callback(request, *callback_args,
> **callback_kwargs)
>
> Exception Type: TypeError at /
> Exception Value: test() takes exactly 1 argument (2 given)
>
> -
>
> Only occurs after i "return None".  If the host entry is not found it
> works correctly.

In that case, it's not this Middleware that's your culprit. Look in
the view function for your base URL (/). Perhaps your view function is
called "test" but is not defined properly? For example, you might have
a non-optional second parameter defined for the test function.

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



Re: Custom Middleware TypeError exception

2008-12-05 Thread Chris Smith

On Dec 5, 4:20 pm, Chris Smith <[EMAIL PROTECTED]>
wrote:

> Any ideas?  Is it something silly I've done?

Actually, please ignore this.  The exception was firing in user code
due to me forgetting to handle a capture group in a URL regex.

Back to the coffee machine...

Cheers,

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



Re:

2008-12-05 Thread Rajesh Dhawan

> How can I get Django templates to generate links to anchors that are
> *local* to the document?
> In a static HTML page, I have a table of contents with links to
> internal sections within the same page:
>
> Section1
> Section2
>
> These link to sections that  that look like this:
>
>  111 
>  222 
>
> Converting the above into a template I have:
>   {% for row in content.rows %}
>{{ row.label }}
>
> butwhen the template loads it creates output that looks like:
>
> http://localhost:8000/doc/#1;>

How are you checking that it's generating that absolute URL? It is
almost certainly your web browser that's showing you the links in an
absolute form. Try to look at the source code for your page or use
curl/wget to fetch the source and you will see that your template code
is just fine.

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



Custom Middleware TypeError exception

2008-12-05 Thread Chris Smith

Found an oddity - possibly in my code.  Can't seem to work around it.

Code in question (current multi-tenant middleware implementation):

middleware.py ..

from projectname.models import Tenant, HostEntry
from django.http import HttpResponseNotFound
from django.core.exceptions import ObjectDoesNotExist

class MultiTenantMiddleware(object):
"""Multi tenant middleware"""
def process_request(self, request):
http_host = request.META['HTTP_HOST']
try:
host_entry = HostEntry.objects.get(host=http_host)
except ObjectDoesNotExist:
return HttpResponseNotFound("Host not found")
request.tenant = host_entry.tenant
return None

-

Exception details 

Environment:

Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.0.2 final
Python Version: 2.6.0
Installed Applications:
['django.contrib.sessions', 'productname']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'vhdesk.middleware.MultiTenantMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')


Traceback:
File "C:\Python26\Lib\site-packages\django\core\handlers\base.py" in
get_response
  86. response = callback(request, *callback_args,
**callback_kwargs)

Exception Type: TypeError at /
Exception Value: test() takes exactly 1 argument (2 given)

-

Only occurs after i "return None".  If the host entry is not found it
works correctly.

Any ideas?  Is it something silly I've done?

Cheers,

Chris.

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



Re: help with file uploads

2008-12-05 Thread Karen Tracey
On Thu, Dec 4, 2008 at 6:12 PM, Alan <[EMAIL PROTECTED]> wrote:

> Hi there!
> Although I have some experience in Python and Plone and have done Django
> tutorial, I am still not getting how to do a simple task I proposed myself:
> build a submitting page for a zip file.
>
> So I am looking at
> http://docs.djangoproject.com/en/dev/topics/http/file-uploads/
>
> It seems to have all I need, but I still don't know well how to connect the
> dots. So, it would be really great if I could put my hands in a example or,
> better, tutorial, of how to build such a page for submitting a file.
>
> The difficult I find is that when I was building webpages I used to think
> first the html code and then the rest, but with Django, I feel I have to
> think first models, but then I still lack how to link with view.
>

I think it makes sense to think first in terms of what you want to present
to the user for your task, which in Django would be a combination of a form
and template.  From there start thinking about what your view code needs to
do to manipulate the submitted form data to be saved in one or more model
instances.  What models you want to create rather depends on more than the
one simple task of submitting a zip file -- what sorts of things do you want
to do with the submitted zip files after they've been been submitted?

If the form for your task maps nicely to a single model then perhaps it
makes sense to use a ModelForm, but maybe not.  In some cases what should
logically be presented to the user doesn't map so nicely to what it makes
logical sense to keep in your database, and then it's best to give up on the
very easy ModelForm approach and write some custom forms and code that deals
with mapping from what is best for the user to deal with to what is best to
store in the DB.

To give a concrete example, I have a crossword puzzle database to which I
upload new published puzzles daily.  Models in the DB include Publishers,
Authors, Puzzles, Entries, and Clues.  There is no PuzzleFile model --
uploading a new puzzle file will involve creating a new Puzzle instance, may
involve creating a new Author instance, many new Entries instances, many new
Clues, etc.  Uploading and adding a puzzle is a two step process, the basic
upload form is very simple and doesn't involve any models. The file is
stashed in a staging area where it can be found and processed during the add
step, which is where actual DB models are created/updated.  In case it's of
any illustrative use, here's the basics of the upload code:
http://dpaste.com/96432/ -- form, view, and template.

Karen

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



django-users@googlegroups.com

2008-12-05 Thread PFL

How can I get Django templates to generate links to anchors that are
*local* to the document?
In a static HTML page, I have a table of contents with links to
internal sections within the same page:

Section1
Section2

These link to sections that  that look like this:

 111 
 222 


Converting the above into a template I have:
  {% for row in content.rows %}
   {{ row.label }}


butwhen the template loads it creates output that looks like:

http://localhost:8000/doc/#1;>

That URL above now gets processed by URL conf...

I have tried various things but I cannot get the Django temlplate to
generate simply:
 so that it will navigate to a  section down the page

thanks in advance for any advice.

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



Re: Add fields to another app model

2008-12-05 Thread Bojan Mihelac

Hey RM,
thanks for your answer. I am looking into 2nd option and try to get
more links on this subject.
best,
Bojan



On Dec 4, 6:32 pm, redmonkey <[EMAIL PROTECTED]> wrote:
> Hey Bojan
>
> There is a few ways you could do this (certainly more that what I'm
> about to tell you). It depends on the effect you want to create.
>
> Perhaps the simplest way is to inherit from the existing class. But
> inheriting classes should only strictly be used as an `is a`
> relationship. So perhaps you could justify it by thinking of your
> Contact model as just a different, specialised version of the satchmo
> Contact model. It's worth baring in mind the DB joins this type of
> thing could add though, and the consequences these joins bring with
> them. In a recent project I was working on, I imported the model I
> needed, changed `abstract = True` and then inherited from it in one of
> my models to do a similar sort of thing to what you're trying to
> create:
>
> from voting.models import Vote as VoteBase
> VoteBase._meta.abstract = True
>
> class SpecialVote(VoteBase):
>     pass
>
> There's a good TWiD article on inheriting models so you could take a
> look at that to find out more about 
> ithttp://thisweekindjango.com/articles/2008/jun/17/abstract-base-classe...
>
> The other option is to use a registering paradigm like that used in
> Django-MPTT. You basically call a function with a bunch of models and
> this function adds some properties to them. You can see it here in the
> DJango-MPTT __init__.py 
> file:http://code.google.com/p/django-mptt/source/browse/trunk/mptt/__init_...
>
> If you read the docs for Django-MPTT you see that you have to add a
> call to ``mptt.register`` with every model you want to have this
> functionality. This function just adds a tonne of fields and
> properties to your models using _meta. You can read more about that by
> James Bennett:
>
> http://www.b-list.org/weblog/2007/nov/04/working-models/
>
> Have a poke around in loads of the project on Google Code though, see
> what other people are doing, and how they're tackling problems like
> you'll soon start having your own ideas about how to do stuff.
>
> Hope all that helps.
>
> RM
>
> On Dec 4, 8:45 am, Bojan Mihelac <[EMAIL PROTECTED]> wrote:
>
> > Hi all!
>
> > I am looking for right way to add fields to model that is in another
> > app. At first I created mysite application and in models.py put
>
> > from satchmo.contact.models import Contact
> > Contact.add_to_class("company_name", models.CharField(max_length =
> > 200))
>
> > that raises exception ProgrammingError sometimes:
> > ProgrammingError: (1110, "Column 'company_name' specified twice")
>
> > So now I check before if field is already in model:
>
> > if 'company_name' not in Contact._meta.get_all_field_names():
> >     Contact.add_to_class("company_name", models.CharField(max_length =
> > 200))
>
> > I have feeling that this is not right way to do. I'd appreciate any
> > help, hint or thought on this.
> > I also wonder how models are loaded in django.
>
> > Bojan
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Advanced list_filter in admin

2008-12-05 Thread Karen Tracey
On Fri, Dec 5, 2008 at 10:04 AM, Michel Thadeu Sabchuk
<[EMAIL PROTECTED]>wrote:

>
> Hi guys,
>
> Is there a way to use advanced list_filter in admin? I can filter by
> pub_date but is there a way to filter by pub_date__isnull or by some
> python function?
>
> I want to filter all entries with pub_date set to None but I don´t
> want to change the modeladmin queryset, how can I do this?
>
>
The null filtering sounds like this ticket:

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

More advanced (having your own Python function) sounds like this one:

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

which is on the maybe list for Django 1.1.

(I have not looked at either of these in any detail, am simply pointing to
things that might have patches you may find useful or want to help with
moving along in the process.)

Karen

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



Re: Ruby on Rails vs Django

2008-12-05 Thread Masklinn

On 5 Dec 2008, at 14:30 , bruno desthuilliers wrote:
> On 5 déc, 13:06, "[EMAIL PROTECTED]"
> <[EMAIL PROTECTED]> wrote:
>> Hi All,
>>
>> I'm new to the django world and I was just wondering how Django
>> compears with  Ruby on Rails ?
>
> Mostly just like Python compares with (with ??? to ???) Ruby IMHO.
> Quite close overall, and yet very different philosophies.
I'd say that Rails and Django differ much more than Python and Ruby.  
There are "small" differences between Python and Ruby, but the core  
philosophies and structures of Rails and Django on the other hand are  
completely unrelated and pretty much incompatible.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ruby on Rails vs Django

2008-12-05 Thread [EMAIL PROTECTED]

I worked with Rails for about 2 years.
I see a lot of innovative ideas in Rails; however, I was constantly
running into issues with them changing the API.
Add to that, the documentation is poor relative to that of Python
Django.

Metaphorically that Python/Djangois for a conservative engineer
mindset, Rails is for a hacker and let's create something innovative
crowd.
Rails does a lot of stuff implicitly, which is fine if you understand
what's going or if no issues rrise.
Python is explicit by design.

Both are Great, but I always felt I was forced to learn something new.
I like learning new things, but sometime you just want to build
something from tools you already understand.

YMMV,
Bryan
p.s. I have not worked with Python3k. That will be a change, but it's
a big number change.

On Dec 5, 8:30 am, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 5 déc, 13:06, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Hi All,
>
> > I'm new to the django world and I was just wondering how Django
> > compears with  Ruby on Rails ?
>
> Mostly just like Python compares with (with ??? to ???) Ruby IMHO.
> Quite close overall, and yet very different philosophies.

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



Re: confused with session chapters in djangoproject

2008-12-05 Thread Karen Tracey
On Fri, Dec 5, 2008 at 9:53 AM, vierda <[EMAIL PROTECTED]> wrote:

>
> Dear all,
>
> I'm newbie in Django and have started study since two weeks. I tried
> code that shows in djangoproject.com, in session chapters I got
> problem with below code. It shows error that says module comments
> doesn't have attribute Comment. am I missing something here?
> Kindly help and thank you in advance
>
> from django.contrib import comments
> def post_comment(request, new_comment):
>if request.session.get('has_commented', False):
>return HttpResponse("You've already commented.")
>c = comments.Comment(comment=new_comment) # got error in this line
>c.save()
>request.session['has_commented'] = True
>return HttpResponse('Thanks for your comment!')
>

That example code (which doesn't actually include "from django.contrib
import comments" in the doc, which is a clue the example is not actually
referring to the Django contrib.comments add-on) is trying to illustrate how
to set and use session variables.  As the example is focused on sessions,
the referenced models aren't necessarily provided by Django.  The next
example uses a ficticious "Member" model which you won't find in Django
either.  These particular examples are not meant to be cut-and-pasted into
your own code, they are simply trying to illustrate how you might use
sessions with your own models.

Karen

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



Advanced list_filter in admin

2008-12-05 Thread Michel Thadeu Sabchuk

Hi guys,

Is there a way to use advanced list_filter in admin? I can filter by
pub_date but is there a way to filter by pub_date__isnull or by some
python function?

I want to filter all entries with pub_date set to None but I don´t
want to change the modeladmin queryset, how can I do this?

Best regards,

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



AuditTrail with Django-1.0 Admin: how to define type() as dj.c.admin.autodiscovered module attribute?

2008-12-05 Thread Jeff Kowalczyk

For AuditTrail [1] to appear in Django-1.0.x Admin, I need to define a
ModelAdmin subclass as a module attribute. The current version of
AuditTrail still uses the Admin class attribute.

How can I set the result of type('FooAdmin',admin.ModelAdmin) as a
module
attribute that will be located by django.contrib.admin.autodiscover?

from django.contrib import admin

  def create_audit_model(cls, **kwargs):
  """Create an audit model for the specific class"""
  name = cls.__name__ + 'Audit'

  ...

  if 'show_in_admin' in kwargs and kwargs['show_in_admin']:
  # Enable admin integration
  # class Admin:
  # pass
  # attrs['Admin'] = Admin
  cls_admin_name = cls.__name__ + 'Admin'
  clsAdmin = type(cls_admin_name, (admin.ModelAdmin,),{})
  ? = clsAdmin
  admin.site.register(?, ?)

Thanks.

[1] http://code.djangoproject.com/wiki/AuditTrail

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



confused with session chapters in djangoproject

2008-12-05 Thread vierda

Dear all,

I'm newbie in Django and have started study since two weeks. I tried
code that shows in djangoproject.com, in session chapters I got
problem with below code. It shows error that says module comments
doesn't have attribute Comment. am I missing something here?
Kindly help and thank you in advance

from django.contrib import comments
def post_comment(request, new_comment):
if request.session.get('has_commented', False):
return HttpResponse("You've already commented.")
c = comments.Comment(comment=new_comment) # got error in this line
c.save()
request.session['has_commented'] = True
return HttpResponse('Thanks for your comment!')

-vierda-

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



Re: Django & referential integrity

2008-12-05 Thread Karen Tracey
On Fri, Dec 5, 2008 at 8:50 AM, Thierry <[EMAIL PROTECTED]>wrote:

>
> I noticed that Django handles all the referential integrity issues for
> delete statements at the Python/ORM level.
> - Is this documented anywhere?
>

http://docs.djangoproject.com/en/dev/topics/db/queries/#deleting-objects


>
> Furthermore I can't seem to find a switch to turn the whole ORM/python
> level referential stuff off. Is there a setting for this somewhere? (I
> prefer the database to handle it)
>

No.  Search this list for CASCADE and you'll find other threads that mention
why.


>
> Also, there is no support for different actions upon a delete.
> Basically like this ticket sais:
> http://code.djangoproject.com/ticket/2288


That ticket was closed wontfix with a mention that signals should be capable
of handling whatever is required here.  I see there's a follow-on signals
ticket with patch that is still open.  It isn't clear to me whether you
don't feel that the signals approach will work for you or if you feel you
need whatever is provided by the still-open follow-on ticket?


> I have a logging table with relations to my production tables. They
> are relations but no action would be more appropriate. The only way to
> do this seems to be a IntegerField, instead of a ForeignKey. Is there
> any alternative.
>

I'm assuming you are saying when you delete something from the referenced
tables you do not want entries in the logging table to be deleted?  Using
the signals approach you could, before the delete, find the would-be
affected logging entries and fix them up so they no longer reference the
to-be-deleted object.  Simply nulling the affected field would lose
information, so at the same time you might want to store info in another
field in the logging entry to record something about the referenced deleted
object and when it was deleted.  Or you could take the sometimes-used
approach of never deleting records but rather using a field to indicate it
has been deleted.  Or you could use your IntegerField instead of ForeignKey
approach.  So there are alternativeswhich one is best for you rather
depends on your own needs.

Karen

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



Re: Custom Widget for admin application

2008-12-05 Thread Michel Thadeu Sabchuk

Hi Ricardo,

> 1) Is there a sane way to make a custom widget that extends Select and
> that has its options grouped by in  tags according to some
> criteria?

Pass a grouped list to choices:

['group1', [(1, 'item 1'), (2, 'item 2'), ...], ...]

> 2) How one does make the built-in admin app to use it?

Extend the ModelAdmin and, in the __init__, change the choices of the
proper field.

> 3) Once decided I will do my own widgets, where is the "right" place
> to put them? In a widgets.py file within the applciation?

This way you didn´t need to use custom fields, but I use to put my
custom widgets in the module project.utils.forms.

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



Re: Change message unicode issue

2008-12-05 Thread Karen Tracey
2008/12/5 Will McGugan <[EMAIL PROTECTED]>

> Hi,
>
> I'm getting an 500 error in my admin site when modifying an object
> containing unicode. It seems to be an issue when constructing the change
> message. Here's the details (running on Django 1.0). Any help would be
> appreciated.
>
>
> 'ascii' codec can't decode byte 0xe2 in position 37: ordinal not in
> range(128)
>
>
> ·/www/django-sites/itpp/itpp/django/contrib/admin/options.py in
> change_view
>
> 594. change_message =
> self.construct_change_message(request, form, formsets) ...
>
> ▶ Local vars
>
> ·/www/django-sites/itpp/itpp/django/contrib/admin/options.py in
> construct_change_message
>
> 347. change_message.append(_('Changed
> %(list)s for %(name)s "%(object)s".') ...
>

If you are running Python 2.3 then this may be fixed by upgrading to 1.0.2,
which includes this fix:

http://code.djangoproject.com/changeset/9384

Karen

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



Custom Widget for admin application

2008-12-05 Thread Ricardo Bánffy

Hi folks.

I am looking into Django and the admin framework and I have a couple
newbie-ish questions:

1) Is there a sane way to make a custom widget that extends Select and
that has its options grouped by in  tags according to some
criteria?

2) How one does make the built-in admin app to use it?

3) Once decided I will do my own widgets, where is the "right" place
to put them? In a widgets.py file within the applciation?

-- 
Ricardo Bánffy
http://www.dieblinkenlights.com

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



Re: modeling questions

2008-12-05 Thread Karen Tracey
On Fri, Dec 5, 2008 at 3:38 AM, Margie <[EMAIL PROTECTED]> wrote:

>
> Am trying to get the hang of specifying my models, so bear with me ...
>
> Suppose that I want to reprsent states and the cities that are in
> them.  I think I would have a model that looks like this:
>
> class State(models.Model):
>name = models.CharField('name', max_length=20)
>
> class City(models.Model):
>name = models.CharField('name', max_length=20)
>state = models.ForeignKey(State)
>
> Now, suppose that cities can have the same name, as long as they are
> in different states, and I want a way to check that when the user adds
> a city, that he/she doesn't add it twice for the same state.  IE, the
> user has data for certain states and cities and wants to add only
> those for which there is data.  The user will manually click on "add
> state", which will take them to a page where they input some state
> data and then can click a 'submit' button to save it.  And also from
> that window they can click on an 'add city' button that will take them
> to a window where they can input data for a city and then submit
> that.  If I want to make sure that the same city isn't added twice for
> the same state, do I simply do that check when the city data is
> "posted"?  IE, if they try to add the same city twice, I just give an
> error saying it's already there?
>

Specify unique_together for name and state in your City model.  See:

http://docs.djangoproject.com/en/dev/ref/models/options/#unique-together


> What if I want the user to be able to enter a whole bunch of cities at
> once, for example by entering them all in a table on a single page.
> What would be the appropriate way to represent that table?
>

Formsets or model formsets could be the way to go here:

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

Karen

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



Django & referential integrity

2008-12-05 Thread Thierry

I noticed that Django handles all the referential integrity issues for
delete statements at the Python/ORM level.
- Is this documented anywhere?

Furthermore I can't seem to find a switch to turn the whole ORM/python
level referential stuff off. Is there a setting for this somewhere? (I
prefer the database to handle it)

Also, there is no support for different actions upon a delete.
Basically like this ticket sais:
http://code.djangoproject.com/ticket/2288

I have a logging table with relations to my production tables. They
are relations but no action would be more appropriate. The only way to
do this seems to be a IntegerField, instead of a ForeignKey. Is there
any alternative.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: UserChangeForm not working

2008-12-05 Thread Karen Tracey
On Fri, Dec 5, 2008 at 3:18 AM, Brandon Taylor <[EMAIL PROTECTED]>wrote:

>
> Hi everyone,
>
> I want to allow users to change their username in a non-admin form. I
> have a login form already working, and I can successfully show user
> information. I have granted the change user permission to the user
> that is logged in.
>
> When I pull in the UserChangeForm from contrib.auth.forms and hand it
> a user instance, the username field is populated correctly.
>
> So, I have a simple view action (pseudo code):
>
> if request.method == 'POST':
>form = UserChangeForm(data=request.POST)
>if form.is_valid():
>form.save()
>
> but I can never get the form to validate. I can get it to fail
> correctly, but even if I put in a value that I know isn't currently in
> use, the form will still not validate. I tried making a custom form to
> update the username property and do the same validation, just in my
> own form instance, but that didn't work either. The new username
> property wasn't saving to the database.
>
> Does anyone have any experience with this form from auth? Any help
> appreciated!
>

No, but I'm not sure this has anything to do specifically with auth an its
models/forms.  You aren't passing in the user instance when you populate the
form with the POST data.  You need to, just as you did when creating the
form for the GET request.

Karen

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



Re: Change message unicode issue

2008-12-05 Thread Jarek Zgoda

Wiadomość napisana w dniu 2008-12-05, o godz. 12:43, przez Will  
McGugan:

> I'm getting an 500 error in my admin site when modifying an object  
> containing unicode. It seems to be an issue when constructing the  
> change message. Here's the details (running on Django 1.0). Any help  
> would be appreciated.
>
>
> 'ascii' codec can't decode byte 0xe2 in position 37: ordinal not in  
> range(128)
>
>
> ·/www/django-sites/itpp/itpp/django/contrib/admin/options.py  
> in change_view
>
> 594. change_message =  
> self.construct_change_message(request, form, formsets) ...
>
> ▶ Local vars
>
> ·/www/django-sites/itpp/itpp/django/contrib/admin/options.py  
> in construct_change_message
>
> 347.  
> change_message.append(_('Changed %(list)s for %(name)s "% 
> (object)s".') ...


Check if __unicode__ method of this object really returns unicode  
object.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R, Redefine
[EMAIL PROTECTED]


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



Re: Ruby on Rails vs Django

2008-12-05 Thread bruno desthuilliers

On 5 déc, 13:06, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I'm new to the django world and I was just wondering how Django
> compears with  Ruby on Rails ?

Mostly just like Python compares with (with ??? to ???) Ruby IMHO.
Quite close overall, and yet very different philosophies.


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



Session based messages without touching DB

2008-12-05 Thread Thomas Guettler

Hi,

I use code based on "session based messages" from:
http://code.djangoproject.com/ticket/4604

What I don't like: There are two database hits, which are not necessary:
Store message in session-pickle
and pop message from session-pickle.

I found this:
   http://www.djangosnippets.org/snippets/1064/
The (flash) message is stored in a cookie.

But I think the snippet is not thread safe. Has anyone a working example?

  Thomas


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


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



Re: Ruby on Rails vs Django

2008-12-05 Thread leonel

[EMAIL PROTECTED] wrote:
> Hi All,
>
> I'm new to the django world and I was just wondering how Django
> compears with  Ruby on Rails ?
>
> did anybody try Ruby on Rails so can give us a feedback ?
>
> thanks
>
> >
>
>
>   

I was as you long time ago .

I was going to test both and choose .
Tested Django  first  and  had no need to test  rails  

Leonel


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



Re: Ruby on Rails vs Django

2008-12-05 Thread [EMAIL PROTECTED]

yes... I saw that thread... but it is 14 months old !!! and in IT 14
months is a LOT

On 5 dic, 10:17, "Marinho Brandao" <[EMAIL PROTECTED]> wrote:
> http://www.google.com.br/search?q=Ruby+on+Rails+vs+Django
>
> 2008/12/5 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
>
> > Hi All,
>
> > I'm new to the django world and I was just wondering how Django
> > compears with  Ruby on Rails ?
>
> > did anybody try Ruby on Rails so can give us a feedback ?
>
> > thanks
>
> --
> Marinho Brandão (José Mário)http://marinhobrandao.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Ruby on Rails vs Django

2008-12-05 Thread Marinho Brandao

http://www.google.com.br/search?q=Ruby+on+Rails+vs+Django

2008/12/5 [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
> Hi All,
>
> I'm new to the django world and I was just wondering how Django
> compears with  Ruby on Rails ?
>
> did anybody try Ruby on Rails so can give us a feedback ?
>
> thanks
>
> >
>



-- 
Marinho Brandão (José Mário)
http://marinhobrandao.com/

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



Ruby on Rails vs Django

2008-12-05 Thread [EMAIL PROTECTED]

Hi All,

I'm new to the django world and I was just wondering how Django
compears with  Ruby on Rails ?

did anybody try Ruby on Rails so can give us a feedback ?

thanks

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



Change message unicode issue

2008-12-05 Thread Will McGugan
Hi,

I'm getting an 500 error in my admin site when modifying an object
containing unicode. It seems to be an issue when constructing the change
message. Here's the details (running on Django 1.0). Any help would be
appreciated.


'ascii' codec can't decode byte 0xe2 in position 37: ordinal not in
range(128)


·/www/django-sites/itpp/itpp/django/contrib/admin/options.py in
change_view

594. change_message =
self.construct_change_message(request, form, formsets) ...

▶ Local vars

·/www/django-sites/itpp/itpp/django/contrib/admin/options.py in
construct_change_message

347. change_message.append(_('Changed
%(list)s for %(name)s "%(object)s".') ...



-- 
Will McGugan
http://www.willmcgugan.com

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



Re: Invalid block tag: render_comment_form (repost)

2008-12-05 Thread James Bennett

On Fri, Dec 5, 2008 at 2:07 AM, Florian Lindner <[EMAIL PROTECTED]> wrote:
> Last time I used Django (pre 1.0) it was recommended to always use
> trunk since the last released version was too outdated. Has this
> changed?

Yes.

0.96 -> 1.0 involved a large number of backwards-incompatible changes,
so many people simply followed trunk so that they could make changes
as they went rather than having a single huge upgrade process.

>From 1.0 on, this is not a problem because compatibility is preserved
between releases. Thus, your best bet (unless you're a developer
actively working on Django itself, and interested in helping to
develop new features or fix new bugs) is simply to use the latest
release (Django 1.0.2).


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



modeling questions

2008-12-05 Thread Margie

Am trying to get the hang of specifying my models, so bear with me ...

Suppose that I want to reprsent states and the cities that are in
them.  I think I would have a model that looks like this:

class State(models.Model):
name = models.CharField('name', max_length=20)

class City(models.Model):
name = models.CharField('name', max_length=20)
state = models.ForeignKey(State)

Now, suppose that cities can have the same name, as long as they are
in different states, and I want a way to check that when the user adds
a city, that he/she doesn't add it twice for the same state.  IE, the
user has data for certain states and cities and wants to add only
those for which there is data.  The user will manually click on "add
state", which will take them to a page where they input some state
data and then can click a 'submit' button to save it.  And also from
that window they can click on an 'add city' button that will take them
to a window where they can input data for a city and then submit
that.  If I want to make sure that the same city isn't added twice for
the same state, do I simply do that check when the city data is
"posted"?  IE, if they try to add the same city twice, I just give an
error saying it's already there?

What if I want the user to be able to enter a whole bunch of cities at
once, for example by entering them all in a table on a single page.
What would be the appropriate way to represent that table?

Sorry, I know these are probably very basic questions, just want to
make sure I am on the right track.

May I ask - is there anyone in the SF Bay area that would be
interested in providing some irelatively nexpensive consulting to me
to get me bootstrapped?  I'm thinking a few hours to get me off and
running, with perhaps continued time as needed.  I live in Menlo Park
and work in Santa Clara.  Have tons of software and python experience,
but no practical experience with django, sql, and web clients.  The
project I am working on is a project management tool to manage the
process of chip design (the state/city thing above is just an
analogy).

Thanks!

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



Re: Django is changing my html!

2008-12-05 Thread Masklinn

On 5 déc. 08, at 04:19, DragonSlayre <[EMAIL PROTECTED]> wrote:
> yes, this fixed the problem. I should change my original title to
> "Firefox is changing my html!"
>
> Thanks for the speedy responses... I was trying to do things *right*
> using xhtml standards, but I guess that it's more trouble than it's
> worth.
>
>>
>>
>>
Only if you absolutely don't know what you're doing. a is an inline  
element while li is a block element, putting blocks within inlines is  
completely verboten in HTML, which leads to the browser trying to make  
sense of your markup as well as it can.

Simply swap them around (put the link inside the list element) and  
things should work much better.

I'd also suggest using HTML validators (such as the very good Tidy  
firefox extension), to point out such well-formedness errors.


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



UserChangeForm not working

2008-12-05 Thread Brandon Taylor

Hi everyone,

I want to allow users to change their username in a non-admin form. I
have a login form already working, and I can successfully show user
information. I have granted the change user permission to the user
that is logged in.

When I pull in the UserChangeForm from contrib.auth.forms and hand it
a user instance, the username field is populated correctly.

So, I have a simple view action (pseudo code):

if request.method == 'POST':
form = UserChangeForm(data=request.POST)
if form.is_valid():
form.save()

but I can never get the form to validate. I can get it to fail
correctly, but even if I put in a value that I know isn't currently in
use, the form will still not validate. I tried making a custom form to
update the username property and do the same validation, just in my
own form instance, but that didn't work either. The new username
property wasn't saving to the database.

Does anyone have any experience with this form from auth? Any help
appreciated!
Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Populating form from instance not working

2008-12-05 Thread Brandon Taylor

Hi David,

Stupid error on my part. Problem has been resolved.

On Dec 5, 1:34 am, "David Zhou" <[EMAIL PROTECTED]> wrote:
> On Fri, Dec 5, 2008 at 1:44 AM, Brandon Taylor <[EMAIL PROTECTED]> wrote:
>
> > But, the form fields aren't being populated. What am I doing wrong?
> > form_for_instance is deprecated in 1.0, and everything I'm doing looks
> > correct from the docs 
> > at:http://docs.djangoproject.com/en/dev/topics/forms/modelforms/
>
> What does your form class look like?
>
> --
> ---
> David Zhou
> [EMAIL PROTECTED]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Invalid block tag: render_comment_form (repost)

2008-12-05 Thread Florian Lindner


Am 04.12.2008 um 21:58 schrieb [EMAIL PROTECTED]:

>
> On 04.12-20:22, Florian Lindner wrote:
> [ ... ]
>> I use the comments framework from the newest Django SVN checkout.
>
> sorry to not be of more help (i've never used the comments framework)
> but i can only suggest that you select a release version and not the
> 'newest' (i'm assuming that means trunk).

Last time I used Django (pre 1.0) it was recommended to always use  
trunk since the last released version was too outdated. Has this  
changed?

Regards,

Florian


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



Re: best practices for SOAP client in Django

2008-12-05 Thread Antoni Aloy

2008/12/4 wynfred <[EMAIL PROTECTED]>:
>
> Hi, all. I am new to Django/Python. For one project, I need to be
> posting data to a .NET SOAP web service. I've read about the various
> Python SOAP libraries, mainly SOAPpy (http://diveintopython.org/
> soap_web_services/). What is not clear yet is how best to use a tool
> like SOAPpy within the Django framework.
>
> Our application should have the following routine:
> 1) Our django app would pull data from our database
> 2) We'd take that data and format the SOAP XML message
> 3) We'd post the SOAP XML message to the .NET SOAP web service
> 4) When the response verifies a successful post to the SOAP web
> service, we'd record that transaction as successful in our database
>
> Anyway, I'm learning how to do all these steps as isolated pieces of
> code, but what's not clear is how best to achieve this task flow
> within our Django application.
>
d to the Google Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com
> To unsubscribe from this group, send email to [EMAIL PROTECTED]
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en
> -~--~~~~--~~--~--~---
>
>
We use ZSI to consume web services from our Django application. What
we have made is make a pythonic lawer for the web service, adding
caches when appropiated, connection pooling etc

For the Django point of view is just another library, in the form of a
service we instatiate in the application __init__.py.

I don't know if this is the best way to do it, but it works quite well for us.

Best regards,

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Populating form from instance not working

2008-12-05 Thread David Zhou

On Fri, Dec 5, 2008 at 1:44 AM, Brandon Taylor <[EMAIL PROTECTED]> wrote:
>
> But, the form fields aren't being populated. What am I doing wrong?
> form_for_instance is deprecated in 1.0, and everything I'm doing looks
> correct from the docs at: 
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/

What does your form class look like?


-- 
---
David Zhou
[EMAIL PROTECTED]

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



  1   2   >