Re: Django for internationalized sites - are models.User internationalized?

2010-10-01 Thread Andy


On Oct 2, 1:45 am, Torsten Bronger 
wrote:
Thanks for responding.

> Hallöchen!
>
> > Are "first_name" & "last_name" limited to alphanumeric characters
> > or can they contain non-English characters like "ü" or
> > non-European characters like "黒"?
>
> Yes.

"Yes" is in "first_name" & "last_name" can contain non-English
characters like "ü" or non-European characters like "黒"?

>
> > What characters are allowed in the "email" field? Again can it
> > contain non-English or non-European characters?
>
> I don't know, but I hope not!

You mean you hope the field "email" is not allowed to contain non-
English or non-European characters?

But real email addresses do contain those characters:
http://en.wikipedia.org/wiki/Email_address#Internationalization

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Authentication backend

2010-10-01 Thread simonty
Hi Django folks,
I'm just getting into Django and I'm writing my own authentication
backend by implementing authenticate and get_user. Because my
authentication uses a  different hash algorithim (not sha1), I want to
implement my own UserManager.create_user, User.set_password,
User.check_password etc, so that the password gets set correctly.
I suppose I could subclass these functions within my own application
but what's the best way to do this so that it still works with the
django admin screens (ie I can create users and reset passwords from
within the admin screens)
Thanks.

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



Re: Django for internationalized sites - are models.User internationalized?

2010-10-01 Thread Torsten Bronger
Hallöchen!

Andy writes:

> According to documentation (http://docs.djangoproject.com/en/dev/
> topics/auth/), models.User contains:
>
> first_name
> Optional. 30 characters or fewer.
> last_name
> Optional. 30 characters or fewer.
> email
> Optional. E-mail address.
>
> Are "first_name" & "last_name" limited to alphanumeric characters
> or can they contain non-English characters like "ü" or
> non-European characters like "黒"?

Yes.

> What characters are allowed in the "email" field? Again can it
> contain non-English or non-European characters?

I don't know, but I hope not!

> Anyone who have built non-English or non-European websites using
> Django? What is your experience? Any pitfalls I need to be aware
> of?

The support for translating a Django project into various languages
is very good.  The issues I know of are very minor:

* You can't have comments on translation strings in templates

* The directory structure for the translations is static and may
  collide with other tools

* App names are untranslatable (yet)

Another thing is localisation, i.e. decimal point, formatting of
dates etc.  Django has support for it but I haven't used it so far.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

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



Django for internationalized sites - are models.User internationalized?

2010-10-01 Thread Andy
According to documentation (http://docs.djangoproject.com/en/dev/
topics/auth/), models.User contains:

first_name
Optional. 30 characters or fewer.
last_name
Optional. 30 characters or fewer.
email
Optional. E-mail address.

Are "first_name" & "last_name" limited to alphanumeric characters or
can they contain non-English characters like "ü" or non-European
characters like "黒"?

What characters are allowed in the "email" field? Again can it contain
non-English or non-European characters?

Anyone who have built non-English or non-European websites using
Django? What is your experience? Any pitfalls I need to be aware of?

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: [Announcement] Vim for Python and Django

2010-10-01 Thread David M. Besonen
On Sun, 26 Sep 2010 11:36:06 +0200
Antoni Aloy  wrote:

> http://code.google.com/p/trespams-vim/

i assume you've seen Alain's webpage:
 VIM as Python IDE
 http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/

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



Re: Full Text Search

2010-10-01 Thread m1chael
maybe i misunderstood your  question, but maybe it will help

On Fri, Oct 1, 2010 at 8:19 PM, m1chael  wrote:
> Hello!
>
> I use PostgreSQL, and this is how I accomplished a full text search:
>
> def search(request):
>  # how to set up postgresql for full text searching
>  #alter table quote_quote add column body_tsv tsvector;
>  #CREATE TRIGGER quote_quote_tsvectorupdate BEFORE INSERT OR UPDATE
> ON quote_quote FOR EACH ROW EXECUTE PROCEDURE
> tsvector_update_trigger(quote_tsv, 'pg_catalog.english', quote);
>  #CREATE INDEX quote_quote_tsv ON quote_quote USING gin(quote_tsv);
>  #UPDATE quote_quote SET quote_tsv=to_tsvector(quote);
>
>  q = request.GET['q']
>
>  quotes = Quote.objects.extra(
>    select={
>        'snippet': "ts_headline(quote, plainto_tsquery(%s))",
>        'rank': "ts_rank_cd(quote_tsv, plainto_tsquery(%s), 32)",
>    },
>    where=["quote_tsv @@ plainto_tsquery(%s)"],
>    params=[q],
>    select_params=[q, q],
>    order_by=('-rank',)
>  )
>
>  paginator = Paginator(quotes, 50)
>
>  try:
>    page = int(request.GET.get('page', '1'))
>  except ValueError:
>    page = 1
>
>  try:
>    quotes = paginator.page(page)
>  except (EmptyPage, InvalidPage):
>    quotes = paginator.page(paginator.num_pages)
>
>  my_data_dictionary = {
>        'quotes': quotes,
>        'q' : q,
>  }
>
>  return render_to_response('results.html',
>                               my_data_dictionary,
>                               context_instance=RequestContext(request))
>
> urlpatterns = patterns('',
>    url(r'^search/$', search),
> )
>
> On Fri, Oct 1, 2010 at 7:26 PM, Andrej  wrote:
>> Check this out:
>>
>> http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/
>>
>> On Oct 1, 6:52 am, Alessandro Ronchi 
>> wrote:
>>> On Fri, Oct 1, 2010 at 3:35 AM, Steve Holden  wrote:
>>> > On 9/30/2010 8:26 PM, Nick Arnett wrote:
>>> > > Brain is mush, though.
>>>
>  >> Thank you. I'm waiting with hope :)
>>>
>>> --
>>> Alessandro Ronchihttp://www.soasi.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-us...@googlegroups.com.
>> To unsubscribe from this group, send email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: Full Text Search

2010-10-01 Thread m1chael
Hello!

I use PostgreSQL, and this is how I accomplished a full text search:

def search(request):
  # how to set up postgresql for full text searching
  #alter table quote_quote add column body_tsv tsvector;
  #CREATE TRIGGER quote_quote_tsvectorupdate BEFORE INSERT OR UPDATE
ON quote_quote FOR EACH ROW EXECUTE PROCEDURE
tsvector_update_trigger(quote_tsv, 'pg_catalog.english', quote);
  #CREATE INDEX quote_quote_tsv ON quote_quote USING gin(quote_tsv);
  #UPDATE quote_quote SET quote_tsv=to_tsvector(quote);

  q = request.GET['q']

  quotes = Quote.objects.extra(
select={
'snippet': "ts_headline(quote, plainto_tsquery(%s))",
'rank': "ts_rank_cd(quote_tsv, plainto_tsquery(%s), 32)",
},
where=["quote_tsv @@ plainto_tsquery(%s)"],
params=[q],
select_params=[q, q],
order_by=('-rank',)
  )

  paginator = Paginator(quotes, 50)

  try:
page = int(request.GET.get('page', '1'))
  except ValueError:
page = 1

  try:
quotes = paginator.page(page)
  except (EmptyPage, InvalidPage):
quotes = paginator.page(paginator.num_pages)

  my_data_dictionary = {
'quotes': quotes,
'q' : q,
  }

  return render_to_response('results.html',
   my_data_dictionary,
   context_instance=RequestContext(request))

urlpatterns = patterns('',
url(r'^search/$', search),
)

On Fri, Oct 1, 2010 at 7:26 PM, Andrej  wrote:
> Check this out:
>
> http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/
>
> On Oct 1, 6:52 am, Alessandro Ronchi 
> wrote:
>> On Fri, Oct 1, 2010 at 3:35 AM, Steve Holden  wrote:
>> > On 9/30/2010 8:26 PM, Nick Arnett wrote:
>> > > Brain is mush, though.
>>
 >> Thank you. I'm waiting with hope :)
>>
>> --
>> Alessandro Ronchihttp://www.soasi.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-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Full Text Search

2010-10-01 Thread Andrej
Check this out:

http://www.julienphalip.com/blog/2008/08/16/adding-search-django-site-snap/

On Oct 1, 6:52 am, Alessandro Ronchi 
wrote:
> On Fri, Oct 1, 2010 at 3:35 AM, Steve Holden  wrote:
> > On 9/30/2010 8:26 PM, Nick Arnett wrote:
> > > Brain is mush, though.
>
> Thank you. I'm waiting with hope :)
>
> --
> Alessandro Ronchihttp://www.soasi.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Vim for Python and Django

2010-10-01 Thread Antoni Aloy
2010/9/27 flebber :
> OKay thanks for the tortoisehg link.I get an error when trying to use
> the hg command
>
>
> C:\>hg clone https://trespams-vim.googlecode.com/hg/ trespams-vim
> requesting all changes
> adding changesets
> adding manifests
> adding file changes
> added 13 changesets with 223 changes to 197 files
> updating to branch default
> abort: case-folding collision between .vim/syntax/cvsannotate.vim
> and .vim/syntax/CVSAnnotate.vim
>
I'll check it seems a duplicated file to me, but in Linux there is no
such a problem as it's case sensitve. Sorry but I can't test it in
Windows, just guess.

-- 
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Error

2010-10-01 Thread Steve Holden
On 10/1/2010 1:12 PM, Tsolmon Narantsogt wrote:
> Hi there
> 
> i got this error
> 
> *Exception RuntimeError: 'maximum recursion depth exceeded while calling
> a Python object' in  
> help me
> 
Was this *really* the only output you got? [I suppose it's possible,
given the nature of the error]. Or did you just copy a partial output
thinking that it would be enough? The full "traceback", as it's called,
would allow a more detailed analysis.

regards
 Steve
-- 
DjangoCon US 2010 September 7-9 http://djangocon.us/

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



Re: Error

2010-10-01 Thread Jonathan Endersby
Hi

You have a function or method that is calling itself.

Something like this:

def foo():
 print "fun"
 bar = foo()
 print "never going to happen"

J.
On 01 Oct 2010 9:49 PM, "Tsolmon Narantsogt"  wrote:
> So how fix it ?
>
> On Sat, Oct 2, 2010 at 1:37 AM, Brandon Taylor wrote:
>
>> Sounds like you have an infinite loop.
>>
>> On Oct 1, 12:12 pm, Tsolmon Narantsogt  wrote:
>> > Hi there
>> >
>> > i got this error
>> >
>> > *Exception RuntimeError: 'maximum recursion depth exceeded while
calling
>> a
>> > Python object' in > >
>> > help me
>> >
>> > Thank you
>> > Tsolmon
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com

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

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



View to edit many-to-many relationship with extra fields

2010-10-01 Thread ses1984
http://docs.djangoproject.com/en/1.2/topics/db/models/#extra-fields-on-many-to-many-relationships

I have two models with a many-to-many relationship through another
table with extra fields. In this case, I have one extra field which
represents the weight of the relationship.

I'm working on a view to edit the relationships between the two
models. If we call the two models left-hand-side and right-hand-side,
then the view is specific to one instance of the LHS, and the purpose
of the view is to add relationships from that LHS-row to an arbitrary
number of pre-existing RHS-rows.

Writing a view that, given an instance of the LHS, adds a single
weighted relationship to an element on the RHS is pretty trivial.
Writing  view that adds an arbitrary number of relationships to the
RHS is not that trivial, and that's what I would like to deliver to my
users.

So far the view for a particular LHS-instance renders a page with a
form to define a single additional relationship to the RHS. I have
included a basic ajax function that GETs another form to the page.
This is where the problem comes up: IDs of the form elements are going
to overlap, and I won't be able to handle this when the form is
POSTed.

I have thought of two options I could try to tackle this so far, both
with javascript. The first would be to increment an index and send
that through the ajax function to the view that returns a new form.
The second would be to hook into the POST submission and munge the
data before it's passed back to django to save model instances.

It seems to me that something like this, while not common, has to have
been done before in web apps. I was wondering if there were some
established patterns to do this sort of thing, and if I am on the
right track. I have searched a few places including django snippets
and packages to see if something like this has been done before, but I
couldn't find anything. I'm not sure if I'm using the best search
terms.

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



Re: Error

2010-10-01 Thread Tsolmon Narantsogt
So how fix it ?

On Sat, Oct 2, 2010 at 1:37 AM, Brandon Taylor wrote:

> Sounds like you have an infinite loop.
>
> On Oct 1, 12:12 pm, Tsolmon Narantsogt  wrote:
> > Hi there
> >
> > i got this error
> >
> > *Exception RuntimeError: 'maximum recursion depth exceeded while calling
> a
> > Python object' in  >
> > help me
> >
> > Thank you
> > Tsolmon
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Change auth User display name in admin interface

2010-10-01 Thread Nathan
You, sir, are awesome. It worked perfectly.

In case anyone else is wondering what I did:

In models.py:
# import the auth User
from django.contrib.auth.models import User

# Create the proxy model, inherits from User:
class myUser(User):
class Meta:
proxy = True

def __unicode__(self):
if not self.last_name or not self.first_name:
return u'%s' % (self.username)
else:
return u'%s, %s' % (self.last_name, self.first_name)

Also in models.py, all instances that had a ForeignKey or
ManyToManyField pointing to User, I changed to myUser.

In admin.py:
# import the auth User and UserAdmin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin

class MyModelAdmin(UserAdmin):
def formfield_for_manytomany(self, db_field, request, **kwargs):
if db_field.name == "users":
kwargs["queryset"] = myUser.objects.get(id=request.id)
return super(MyModelAdmin,
self).formfield_for_manytomany(db_field, request, **kwargs)

# Had to unregister the User so it could be registered with
MyModelAdmin
admin.site.unregister(User)
admin.site.register(User, MyModelAdmin)

Though to be completely honest, I have no idea what:

if db_field.name == "users":

is doing. I can change "users" to anything and it still works, but if
I take that line out, I cannot add a new User.  So any help with that
would be appreciated. And if what I did can be done simpler or better,
please let me know.

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



Re: [Announcement] Vim for Python and Django

2010-10-01 Thread Piotr Zalewa
 Answering to ,yself...

Just installed vim 7.3 colorcolumn=80 is perfect for that

zalun
On 10/01/10 17:40, Piotr Zalewa wrote:
>  It is great and I'm using it - I was using minibuf before, but somehow
> your config convinced me to use NerdTree.
> One question thought - I'd like to have the 80+ characters highlighted
> somehow.
> I found this:
> http://stackoverflow.com/questions/235439/vim-80-column-layout-concerns
> but I guess it's not working in multicolumn or is overwritten  by
> highlighting.
> Do you have any solution to that?
>
> Thanks
> zalun
> On 09/26/10 10:36, Antoni Aloy wrote:
>> Hello all!
>>
>> In this list we have a recurrent thread: "What'ts the best IDE for
>> Django and Python development?" trespams-vim is my try to answer this
>> question for people who likes to have a very powerful editor and needs
>> to have an editor which is able to run in the desktop as well as in a
>> remote session. I have updated the previous version with delimMate and
>> easytags, so actually you'll find:
>>
>> * Syntax highlight
>> * Python autocompletion
>> * Smart tabbing
>> * Templates for Python, Django, js, html, ... (just try to edit a
>> python file and press sbu + tab as an example)
>> * Add/remove comments on multiple lines
>> * Tabs
>> * Surround
>> * marks
>>
>> etc. etc. :
>>
>> This is a list of my favorite shortcuts
>>
>> http://code.google.com/p/trespams-vim/wiki/readme
>>
>> So, you'll find a collection of plugins and .vimrc settings that I
>> have found very useful in my day-by-day work in Python and Django.
>>
>> http://code.google.com/p/trespams-vim/
>>
>> Happy coding!
>>
>


-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



Need suggestions for autocomplete profile

2010-10-01 Thread Detectedstealth
Hi,

I am using autocomplete on my site for country, state/province and
city.

Problem:
Some people type USA instead of United States. NY instead of New York
etc...

Question:
How can I make an auto complete field not accept anything except the
data that is pulled from the database?

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



Re: Error

2010-10-01 Thread Brandon Taylor
Sounds like you have an infinite loop.

On Oct 1, 12:12 pm, Tsolmon Narantsogt  wrote:
> Hi there
>
> i got this error
>
> *Exception RuntimeError: 'maximum recursion depth exceeded while calling a
> Python object' in 
> help me
>
> Thank you
> Tsolmon

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



PyDev create new project wizard creates two folders in Aptana Studio 3?

2010-10-01 Thread Brandon Taylor
Hi everyone,

I'm used to organizing my Django projects in one folder for the
project and then sub folders for app modules...

/my_project
-__init__.py
-settings.py
/some_app

and so on. However, when I create a new Django project using the PyDev
wizard, I get:

/my_project
/my_project
-__init__.py
-settings.py

Why is that?

TIA,
Brandon

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



Error

2010-10-01 Thread Tsolmon Narantsogt
Hi there

i got this error

*Exception RuntimeError: 'maximum recursion depth exceeded while calling a
Python object' in http://groups.google.com/group/django-users?hl=en.



Re: How do I troubleshoot mod_wsgi 404 admin issues

2010-10-01 Thread Bill Freeman
And thank you for the pointer to the modwsgi debugging page.

On Fri, Oct 1, 2010 at 12:39 PM, dclaar  wrote:
> Just as a follow-up, 
> http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Python_Interactive_Debugger
> was pretty helpful. In the end, it turned out to be one of those
> incredibly frustrating Regular Expression things, where the fix was to
> add a "^" anchor to a single RE.
>
> Without an “^” anchor, /admin/manager/testbed/add matched  /manager/
> (r'testbed/(?P\w+)/$', and that RE came first, so it won.
> With the built-in browser, however, the url was /perf/admin/manager/
> testbed/add, and it didn't match, but I'm not sure why. I'm not
> motivated enough to beat my head against that one for a couple more
> days, since I've fixed the problem, and...I'm on to the next one!
>
> Thanks for you help!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: [Announcement] Vim for Python and Django

2010-10-01 Thread Piotr Zalewa
 It is great and I'm using it - I was using minibuf before, but somehow
your config convinced me to use NerdTree.
One question thought - I'd like to have the 80+ characters highlighted
somehow.
I found this:
http://stackoverflow.com/questions/235439/vim-80-column-layout-concerns
but I guess it's not working in multicolumn or is overwritten  by
highlighting.
Do you have any solution to that?

Thanks
zalun
On 09/26/10 10:36, Antoni Aloy wrote:
> Hello all!
>
> In this list we have a recurrent thread: "What'ts the best IDE for
> Django and Python development?" trespams-vim is my try to answer this
> question for people who likes to have a very powerful editor and needs
> to have an editor which is able to run in the desktop as well as in a
> remote session. I have updated the previous version with delimMate and
> easytags, so actually you'll find:
>
> * Syntax highlight
> * Python autocompletion
> * Smart tabbing
> * Templates for Python, Django, js, html, ... (just try to edit a
> python file and press sbu + tab as an example)
> * Add/remove comments on multiple lines
> * Tabs
> * Surround
> * marks
>
> etc. etc. :
>
> This is a list of my favorite shortcuts
>
> http://code.google.com/p/trespams-vim/wiki/readme
>
> So, you'll find a collection of plugins and .vimrc settings that I
> have found very useful in my day-by-day work in Python and Django.
>
> http://code.google.com/p/trespams-vim/
>
> Happy coding!
>


-- 
blog  http://piotr.zalewa.info
jobs  http://webdev.zalewa.info
twit  http://twitter.com/zalun
face  http://facebook.com/zaloon

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



Re: How do I troubleshoot mod_wsgi 404 admin issues

2010-10-01 Thread dclaar
Just as a follow-up, 
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Python_Interactive_Debugger
was pretty helpful. In the end, it turned out to be one of those
incredibly frustrating Regular Expression things, where the fix was to
add a "^" anchor to a single RE.

Without an “^” anchor, /admin/manager/testbed/add matched  /manager/
(r'testbed/(?P\w+)/$', and that RE came first, so it won.
With the built-in browser, however, the url was /perf/admin/manager/
testbed/add, and it didn't match, but I'm not sure why. I'm not
motivated enough to beat my head against that one for a couple more
days, since I've fixed the problem, and...I'm on to the next one!

Thanks for you help!

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



Re: Full Text Search

2010-10-01 Thread Nick Arnett
On Fri, Oct 1, 2010 at 3:52 AM, Alessandro Ronchi <
alessandro.ron...@soasi.com> wrote:

>
>
> On Fri, Oct 1, 2010 at 3:35 AM, Steve Holden  wrote:
>
>> On 9/30/2010 8:26 PM, Nick Arnett wrote:
>> > Brain is mush, though.
>>
>>
> Thank you. I'm waiting with hope :)
>

Brain less mushy now...  Sometimes just knowing something is possible helps,
which was why I posted last night.

I used this idea:

http://www.mercurytide.co.uk/news/article/django-full-text-search/

and added a parameter to turn boolean on and off.

However, I'll add that I didn't much care for the results when not using
boolean.

Nick

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



Re: Configuring URLs for different views

2010-10-01 Thread bruno desthuilliers
On 1 oct, 16:07, simon_saffer  wrote:
(snip)
>
 My attempt at doing
> this was to put the following in
> urls.py in urlpatterns
>
> (r'^(?P[a-zA-Z0-9]*?\.html?)$', 'mysite.views.showPage')

hint : named urls are cool

> and then have a views.py in the mysite 'root' with the function

is 'mysite' an app in your project, or is it the project itself ?


> def showPage(request, page):

hint: Python coding conventions : use all_lower names for functions

>     t = loader.get_template(page)
>     c = Context({})
>
>     return HttpResponse(t.render(c))

hint : use the render_to_response()
hint : use RequestContext if you want your context processors to be of
any use

> How can I achieve something like this?


Hmmm... What happened with your above attempt exactly ? I guess it
didn't yield the expected results, but you don't tell what happened
exactly (and when I mean "exactly", it means that if you got a
traceback you should post the _whole_ traceback too).


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



Re: Configuring URLs for different views

2010-10-01 Thread Carlton Gibson

On 1 Oct 2010, at 15:07, simon_saffer wrote:

> In the web site I'm creating many of the pages will not be database
> driven.
> I am trying to set up my urls.py so that all pages that all extend the
> base.html template
> can be rendered in the same way. I'm sure that I shouldn't need a
> unique pair in urlpatterns
> in urls.py for each *.html that I want to show. 


It sounds as if you may need to direct_to_template generic view...

http://docs.djangoproject.com/en/dev/ref/generic-views/

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



Configuring URLs for different views

2010-10-01 Thread simon_saffer
Hi,

I'm completely new to Django so forgive me if this is a dumb question.


In the web site I'm creating many of the pages will not be database
driven.
I am trying to set up my urls.py so that all pages that all extend the
base.html template
can be rendered in the same way. I'm sure that I shouldn't need a
unique pair in urlpatterns
in urls.py for each *.html that I want to show. My attempt at doing
this was to put the following in
urls.py in urlpatterns

(r'^(?P[a-zA-Z0-9]*?\.html?)$', 'mysite.views.showPage')

and then have a views.py in the mysite 'root' with the function

def showPage(request, page):
t = loader.get_template(page)
c = Context({})

return HttpResponse(t.render(c))


How can I achieve something like this?

I'll be grateful for any help I can get.

/Simon

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



Re: UnicodeEncodeError

2010-10-01 Thread Benedict Verheyen
On 30/09/2010 18:47, jean polo wrote:
> ok, thanks to everybody for the help but unfortunately nothing works
> for my issue.
> (except Karen one that solves it on one of my local machines but not
> the other which has the same linux system... weird..).
> 
> I guess I'll ask my client to rename their files without any special
> char
> not the best solution but a good habit anyway =)
> 
> cheers,
> _y
> 
> 
> On Sep 30, 2:20 pm, Karen Tracey  wrote:
>> On Wed, Sep 29, 2010 at 12:59 PM, jean polo 
>> wrote:
>>
>>
>>
>>> Hi.
>>> I get an 'UnicodeEncodeError' if I upload a file (ImageField) with non-
>>> ascii chars in my application (django-1.2.1).
>>
>>> I added:
>>
>>> export LANG='en_US.UTF-8'
>>> export LC_ALL='en_US.UTF-8'
>>
>>> in my /etc/apache2/envvars as stated here:
>>
>>> http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#if-y...
>>
>>> but I still have the same error (after restarting apache).
>>> Any hint much appreciated.
>>
>> Some servers do not have the necessary language files to allow successfully
>> setting the locale to one that supports utf-8 encoding. See the very last
>> sentence here:http://code.djangoproject.com/wiki/ExpectedTestFailures
>>
>> You should be able to experiment with setting these variables in a shell
>> session and passing unicode strings containing non-ASCII characters to file
>> system routines like stat. If it works in a shell, then likely you've got
>> the necessary language support installed, and the problem then is that the
>> Apache configuration for some reason is not taking effect. If you cannot get
>> it to work in a shell either, then likely you are missing a language pack
>> that would allow successfully setting locale in this way.
>>
>> Karen
>> --http://tracey.org/kmt/
> 

I had a similar problem in a python script. Not necessary to rename files :)
The problem is that when you print a debug statement or write to a file, you
need to specify the correct encoding.
I'll add a snippet of the logger class that i'm using so you'll have an idea.
Also, play with the shell and see if you can reproduce and solve the problem 
there.

try:
# If the message is unicode, convert to bytecode
screen_message = message
file_message = message

if ( isunicode(message) ):
screen_message = message.encode("cp850")
file_message = (message + '\n').encode("utf-8")

# Print to screen
if ( to_screen == 1 ): print screen_message

# Write to file
f = open(logfile, 'a')
f.write(file_message)
f.close()
except Exception, e:
print "Logmessage: exception %s" % str(e)

I seem to remember that on my windows, the code page in the command screen 
(cp850)
is different from the code page used in a file (latin1).

Anyway, as you can see, before i print a message to the cmd screen, i encode it.
Same happens when i save the message in the logfile. I encode it to a different
code page however.
You'll have to do the same with other strings that get printed.

This works for me

Regards,
Benedict

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



Re: UnicodeEncodeError

2010-10-01 Thread Klaas van Schelven
Hi all,

I just ran into the same problem. Locally it doesn't occur, but it
does on the server.

I share Karen's analysis that the variable path of type unicode cannot
be encoded into ascii.
However, sys.getfilesystemencoding is also "UTF-8", so I don't see why
os.stat would try to encode using ascii anyway.

Klaas

>  File "/usr/languages/python/2.6/lib/python2.6/genericpath.py", line 18, in
> exists
>    st = os.stat(path)
>
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xe7' in position
> 53: ordinal not in range(128)
>
> "path" here includes the file name, no file data is involved. Django is
> passing a unicode string "path" to the os.stat() function. On many operating
> systems, Python must actually pass a bytestring, not unicode, to the
> underlying OS routine that implements "stat".  Therefore Python must convert
> the unicode string to a bytestring using some encoding. The encoding it uses
> is whatever is returned by 
> os.getfilesystemencoding:http://docs.python.org/library/sys.html#sys.getfilesystemencoding.
>  As noted
> in that documentation, on Unix the encoding will be:
>
> ... the user’s preference according to the result of nl_langinfo(CODESET),
> or None if the nl_langinfo(CODESET) failed.
>
> That's a pretty obscure description but it boils down to the encoding
> associated with the currently set locale. (And on some systems successfully
> setting a locale with an encoding like utf-8 requires installing some
> "extra" language packs.) So the key to fixing this problem is to ensure the
> locale of the running server is successfully set to one with an encoding
> such as utf-8, which supports (can encode) the full range of unicode values.
> Unfortunately details on setting locales differs from machine to machine so
> it is hard to give specific instructions here.
>
> Karen
> --http://tracey.org/kmt/

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



Re: With apache2 and mod_python I can't get static files loading in admin

2010-10-01 Thread Karim Gorjux
On Fri, Oct 1, 2010 at 15:17, Daniel Roseman  wrote:
> Either use
> a DocumentRoot directive

Thanks! I solved the problem using the directive. Thanks really a lot! :-)

-- 
K.
Blog Personale: http://www.karimblog.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: A better way of checking if a record exists

2010-10-01 Thread bruno desthuilliers


On 1 oct, 12:34, ALJ  wrote:
> ... what is the infamous obj.__dict__.update() hack?

http://docs.python.org/library/stdtypes.html#mapping-types-dict
http://docs.python.org/reference/datamodel.html
http://www.google.fr/search?q=obj.__dict__.update()


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



Re: A better way of checking if a record exists

2010-10-01 Thread Thomas Guettler
Hi,

I really would love the see this dictionary like access:

obj=MyModel.objects.get(primary_key)
if obj is None:
... does not exist.

But the ticket was closed:

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

  Thomas

ALJ wrote:
> I'm running through a spreadsheet to update customer info. It takes
> quite a while and I was just trying to optimize things a bit. I want
> to check if the record is already there and if so update it with the
> newer data. If not append it to the table.
> 
> Two code snippets below ...
> 
> 
> try:
> customer = models.Retailer.objects.get(shared_id='1')
> except models.Retailer.DoesNotExist:
> customer = models.Retailer()
> 
> 
> This just seems 'dirty' to me. I mean, using the exceptions this way.
> Exceptions to me feel as if they are the last resort when things go
> wrong. But on the other hand it is probably quicker than ...
> 
> 
> if models.Retailer.objects.filter(shared_id='1'):
> customer = models.Retailer.objects.get(shared_id='1')
> else:
> customer = models.Retailer()
> 
> 
> This seems cleaner but doubles the calls to the database.
> 
> Is the first really the 'accepted' way of doing this?
> 
> ALJ
> 

-- 
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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Full Text Search

2010-10-01 Thread Alessandro Ronchi
On Fri, Oct 1, 2010 at 3:35 AM, Steve Holden  wrote:

> On 9/30/2010 8:26 PM, Nick Arnett wrote:
> > Brain is mush, though.
>
>
Thank you. I'm waiting with hope :)



-- 
Alessandro Ronchi
http://www.soasi.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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: A better way of checking if a record exists

2010-10-01 Thread ALJ
... what is the infamous obj.__dict__.update() hack?

On Oct 1, 11:57 am, bruno desthuilliers
 wrote:
> On 1 oct, 10:29, Shawn Milochik  wrote:
>
>
>
> > For what it's worth, I use the get_or_create with the 'default' keyword to 
> > do this:
>
> > for record in reader:
>
> >     new_values = {
> >         'product_code': slugify(record['Product Code']),
> >         'msrp': record['Suggested Retail'],
> >         #etc...
> >     }
>
> >     product, was_created = Product.objects.get_or_create(source_id = 
> > record['Source ID'], defaults = new_values)
>
> >     if not was_created:
> >         product.product_code = slugify(record['Product Code'])
> >         product.msrp = record['Suggested Retail']
> >         #etc...
>
> Err... What about:
>
>     if not was_created:
>         for attrname, value in new_values.items():
>             setattr(product, attrname, value)
>         product.save()
>
> > I don't like the DRY violation, but a model instance doesn't have an 
> > update() method like a queryset for me to dump the kwargs into -- unless 
> > I'm missing something.
>
> For "direct" model fields you could use the infamous
> obj.__dict.__.update() hack but it's dirty and brittle - and it still
> won't work with foreign keys, m2ms etc.
>
> Now nothing prevents you from providing this model.update method...

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



Re: Separating application media from project media

2010-10-01 Thread Thomas Weholt
>> I'm developing on Windows so i don't have the luxury of a nicely working
>> symlink system :)
>
> ??? Windows is STILL not able to properly handle symlinks ???
>
> OMG :(

mklink might work. Didn`t know of this myself before I googled
"symlinks in windows":

http://lifehacker.com/5496652/how-to-use-symlinks-in-windows

And it works on my vista box here at work :-)


-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

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



Re: A better way of checking if a record exists

2010-10-01 Thread bruno desthuilliers


On 1 oct, 10:29, Shawn Milochik  wrote:
> For what it's worth, I use the get_or_create with the 'default' keyword to do 
> this:
>
> for record in reader:
>
>     new_values = {
>         'product_code': slugify(record['Product Code']),
>         'msrp': record['Suggested Retail'],
>         #etc...
>     }
>
>     product, was_created = Product.objects.get_or_create(source_id = 
> record['Source ID'], defaults = new_values)
>
>     if not was_created:
>         product.product_code = slugify(record['Product Code'])
>         product.msrp = record['Suggested Retail']
>         #etc...

Err... What about:

if not was_created:
for attrname, value in new_values.items():
setattr(product, attrname, value)
product.save()


> I don't like the DRY violation, but a model instance doesn't have an update() 
> method like a queryset for me to dump the kwargs into -- unless I'm missing 
> something.

For "direct" model fields you could use the infamous
obj.__dict.__.update() hack but it's dirty and brittle - and it still
won't work with foreign keys, m2ms etc.

Now nothing prevents you from providing this model.update method...

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



Re: Separating application media from project media

2010-10-01 Thread bruno desthuilliers
On 1 oct, 10:55, Benedict Verheyen 
wrote:

> I found a solution that works for me.
> In the application dir, i've made a media\calltracking directory where
> the static files go.
> I need the extra dirname in the path (the trailing calltracking), otherwise
> i end up with media not being found.

FWIW, this mirrors the usual pattern for app templates / project
templates.

> This is because of the order media is searched in, as specified in the urls.py
> (I'm still developing so the projects hasn't been released yet)
>
> urls.py
> ===
> ...
> urlpatterns = patterns('',
>     (r'^%s/(?P.*)$' % settings.CALLTRACKING_MEDIA_URL, 
> 'django.views.static.serve', {'document_root':
> settings.CALLTRACKING_MEDIA_ROOT, 'show_indexes': True } ),
>     (r'^%s/(?P.*)$' % settings.MEDIA_URL, 'django.views.static.serve', 
> {'document_root': settings.MEDIA_ROOT, 'show_indexes': True } ),
>

This is fine when using the dev server, but what when you will serve
your static files directly from the frontend web server ?

> settings.py
> ===
> ...
> MEDIA_URL = '/media'
> MEDIA_ROOT = os.path.join(project_path, MEDIA_URL)
> MEDIA_ROOT_FILES = "files/"
> ...
> # At the end of the file, import the app specific stuff
> from  settings_calltracking import *
>
> settings_calltracking.py
> 
> ...
> CALLTRACKING_MEDIA_URL = '/media/calltracking'
> CALLTRACKING_MEDIA_ROOT = os.path.join(application_calltracking_path, 
> CALLTRACKING_MEDIA_URL)
> CALLTRACKING_MEDIA_FILES = "files/"
> ...

Same question here - how will this save you the pain from having to
either symlink (or alias in your apache conf) each and any app's media
folder when deploying to the production server ?


> You still need to expose the new media url to your app.
> Since i don't want other applications to be able to access other apps 
> settings,
> i chose to work with a custom template tag instead of working with the 
> request context.
>
> templatetags\media.py in the app dir
> ...
> def do_expose_app_media(parser, token):
>     return template.TextNode(settings.CALLTRACKING_MEDIA_URL)
> register.tag('media_url', do_expose_app_media)
>
> I could use simpletag too.
>
> In my calltracking templates i can now access the app media via {% media_url 
> %}
> {% load media %}


Hmmm... And how will it work when you'll add a second, then a third
app with to your project ? I didn't checked for some times now but
AFAICT we still don't have namespaced template tags / filters.


Since you went the templatetag route, you could extract your
templatetag into a distinct app and rewrite it to accept the appname
as param so it would work with as many apps as you want.


> > FWIW, even for a more canonical "integrated" website / webapp composed
> > of distinct django apps, "assets" (app specific css, js, images and
> > whatnot) management can sometimes be a pain. My own solution so far is
> > to keep all app-specific static stuff in a /medias/ subir of
> > the app and manually symlink this to the project's /static dir, but
> > I'd really enjoy a better solution.
>
> I'm developing on Windows so i don't have the luxury of a nicely working
> symlink system :)

??? Windows is STILL not able to properly handle symlinks ???

OMG :(

> I like your solution too as you only have a symlink in the media directory
> and the static data actually is placed in the application directory.

I think it's more or less a canonical solution but it's far from
ideal. Now I never spent any time thinking of a better one :-/

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



Re: Separating application media from project media

2010-10-01 Thread Benedict Verheyen
On 1/10/2010 10:06, bruno desthuilliers wrote:
> I don't think that's the case, and FWIW the OP's layout makes perfect
> sense to me. His point is that even while all apps are in a same
> project and share a common auth, they are otherwise totally (or
> mostly ?) independent so it doesn't really makes sense to put all the
> media together in the project's /static/ dir.

Indeed, that's exactly what i mean.
It just doesn't make sense to put it in the projects static dir.
I found a solution that works for me.
In the application dir, i've made a media\calltracking directory where
the static files go.
I need the extra dirname in the path (the trailing calltracking), otherwise
i end up with media not being found.
This is because of the order media is searched in, as specified in the urls.py
(I'm still developing so the projects hasn't been released yet)

I could work around this by using another media name like calltracking_media
but i don't like that. So the one catch is that i need to place the
application media url's above the project's media url:

urls.py
===
...
urlpatterns = patterns('',
(r'^%s/(?P.*)$' % settings.CALLTRACKING_MEDIA_URL, 
'django.views.static.serve', {'document_root':
settings.CALLTRACKING_MEDIA_ROOT, 'show_indexes': True } ),
(r'^%s/(?P.*)$' % settings.MEDIA_URL, 'django.views.static.serve', 
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True } ),

settings.py
===
...
MEDIA_URL = '/media'
MEDIA_ROOT = os.path.join(project_path, MEDIA_URL)
MEDIA_ROOT_FILES = "files/"
...
# At the end of the file, import the app specific stuff
from  settings_calltracking import *

settings_calltracking.py

...
CALLTRACKING_MEDIA_URL = '/media/calltracking'
CALLTRACKING_MEDIA_ROOT = os.path.join(application_calltracking_path, 
CALLTRACKING_MEDIA_URL)
CALLTRACKING_MEDIA_FILES = "files/"
...

You still need to expose the new media url to your app.
Since i don't want other applications to be able to access other apps settings,
i chose to work with a custom template tag instead of working with the request 
context.

templatetags\media.py in the app dir
...
def do_expose_app_media(parser, token):
return template.TextNode(settings.CALLTRACKING_MEDIA_URL)
register.tag('media_url', do_expose_app_media)

I could use simpletag too.

In my calltracking templates i can now access the app media via {% media_url %}
{% load media %}


It seems like a fairly clean solution except for the order i have to put the 
media
url's in, but i don't mind.

> FWIW, even for a more canonical "integrated" website / webapp composed
> of distinct django apps, "assets" (app specific css, js, images and
> whatnot) management can sometimes be a pain. My own solution so far is
> to keep all app-specific static stuff in a /medias/ subir of
> the app and manually symlink this to the project's /static dir, but
> I'd really enjoy a better solution.

I'm developing on Windows so i don't have the luxury of a nicely working
symlink system :)
I like your solution too as you only have a symlink in the media directory
and the static data actually is placed in the application directory.

Regards,
Benedict

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



Re: Separating application media from project media

2010-10-01 Thread Ian Lewis
> FWIW, even for a more canonical "integrated" website / webapp composed
> of distinct django apps, "assets" (app specific css, js, images and
> whatnot) management can sometimes be a pain. My own solution so far is
> to keep all app-specific static stuff in a /medias/ subir of
> the app and manually symlink this to the project's /static dir, but
> I'd really enjoy a better solution.

In the past I have used django-staticfiles to manage static media for
various apps. django-staticfiles searches your installed apps for
media directories and copies them to a site_media directory so that
you can serve them from a web server. It also allows you to manage
uploaded media separately from static files.

http://pypi.python.org/pypi/django-staticfiles/

-- 
Ian

http://www.ianlewis.org/

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



Re: Separating application media from project media

2010-10-01 Thread Thomas Weholt
On Fri, Oct 1, 2010 at 10:06 AM, bruno desthuilliers
 wrote:
> On 30 sep, 22:45, Carles Barrobés  wrote:
>> If the ideal solution for you is different sites, one authentication,
>
> I don't think that's the case, and FWIW the OP's layout makes perfect
> sense to me. His point is that even while all apps are in a same
> project and share a common auth, they are otherwise totally (or
> mostly ?) independent so it doesn't really makes sense to put all the
> media together in the project's /static/ dir.
>
> FWIW, even for a more canonical "integrated" website / webapp composed
> of distinct django apps, "assets" (app specific css, js, images and
> whatnot) management can sometimes be a pain. My own solution so far is
> to keep all app-specific static stuff in a /medias/ subir of
> the app and manually symlink this to the project's /static dir, but
> I'd really enjoy a better solution.

I`m using the same solution using symlinks, but that`s much harder to
achieve on windows because you have to install third party software to
make symlinks so it doesn`t make the app easy to port to that
platform. Doesn`t matter much to me, but we should work to make our
apps portable.


-- 
Mvh/Best regards,
Thomas Weholt
http://www.weholt.org

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



Re: A better way of checking if a record exists

2010-10-01 Thread Shawn Milochik
For what it's worth, I use the get_or_create with the 'default' keyword to do 
this:

for record in reader:

new_values = {
'product_code': slugify(record['Product Code']),
'msrp': record['Suggested Retail'],
#etc...
}

product, was_created = Product.objects.get_or_create(source_id = 
record['Source ID'], defaults = new_values)

if not was_created:
product.product_code = slugify(record['Product Code'])
product.msrp = record['Suggested Retail']
#etc...
product.save()

I don't like the DRY violation, but a model instance doesn't have an update() 
method like a queryset for me to dump the kwargs into -- unless I'm missing 
something.

Shawn


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



A better way of checking if a record exists

2010-10-01 Thread ALJ
I'm running through a spreadsheet to update customer info. It takes
quite a while and I was just trying to optimize things a bit. I want
to check if the record is already there and if so update it with the
newer data. If not append it to the table.

Two code snippets below ...


try:
customer = models.Retailer.objects.get(shared_id='1')
except models.Retailer.DoesNotExist:
customer = models.Retailer()


This just seems 'dirty' to me. I mean, using the exceptions this way.
Exceptions to me feel as if they are the last resort when things go
wrong. But on the other hand it is probably quicker than ...


if models.Retailer.objects.filter(shared_id='1'):
customer = models.Retailer.objects.get(shared_id='1')
else:
customer = models.Retailer()


This seems cleaner but doubles the calls to the database.

Is the first really the 'accepted' way of doing this?

ALJ

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



Re: Unable to login to admin site in localhost

2010-10-01 Thread bruno desthuilliers
On 30 sep, 19:05, mamcx  wrote:
> As reported on :http://stackoverflow.com/questions/3817808/unable-to-
> login-to-admin-site-in-localhost
>
> I can't login to the admin site on localhost.
>
> I try with firefox, IE.
>
> I try using the 127.0.0.1:8000 address. Also, I set the
> SESSION_COOKIE_DOMAIN to localhost, localhost:8000
>


Make sure you have localhost pointing to 127.0.0.1 in your /etc/hosts,
set your SESSION_COOKIE_DOMAIN to 'localhost' (nb: port numbers are
NOT part of the hostname) and start the dev server with the
appropriate domain and port, ie:

./manage.py runserver localhost:8000

FWIW, I never had to mess with SESSION_COOKIE_DOMAIN in any Django
version since the 0.96 days.

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



Re: Separating application media from project media

2010-10-01 Thread bruno desthuilliers
On 30 sep, 22:45, Carles Barrobés  wrote:
> If the ideal solution for you is different sites, one authentication,

I don't think that's the case, and FWIW the OP's layout makes perfect
sense to me. His point is that even while all apps are in a same
project and share a common auth, they are otherwise totally (or
mostly ?) independent so it doesn't really makes sense to put all the
media together in the project's /static/ dir.

FWIW, even for a more canonical "integrated" website / webapp composed
of distinct django apps, "assets" (app specific css, js, images and
whatnot) management can sometimes be a pain. My own solution so far is
to keep all app-specific static stuff in a /medias/ subir of
the app and manually symlink this to the project's /static dir, but
I'd really enjoy a better solution.

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



Re: url not going to view

2010-10-01 Thread Carlton Gibson

On 30 Sep 2010, at 16:38, Bradley Hintze wrote:

> OH, they're regular expressions, right? Ok, I need to try to
> understand RE but they still escape any meaning for me somehow.

Yeah, I think that's a meme. 

I can't really offer any advice beyond:
- Just learn enough to get the URLs you need working
- Don't try to read regexps fast - they're hard - live with it. 
- Buy O'Reilly's "Regular Expression Cookbook" and use it as a pillow for the 
winter.

I hope sone of that helps. Good luck.

Regards,
Carlton

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



Quirky tabular display for customized inline models?

2010-10-01 Thread Derek
I have a field which I need to reference in an override of the save()
function (as part of the class MyModelInlineForm(forms.ModelForm)).

However, I don't want that same field to appear in the inline tabular
display.  In the __init__ for form class, I have this:

def __init__(self, *args, **kwargs):
...
self.fields['eggs'].required = False
self.fields['eggs'].widget.attrs['disabled'] = 'disabled'

The 'eggs' field subsequently does not appear in the listing.  However,
while the field title does not appear in the header row (nor there is there
a  for it), there is an extra blank column in the data rows (i.e a
extra blank ).  This looks a little odd as the rows/headers do not
match up.

How can I alter the template so it does not show up... and, is this behavior
expected, or is it a quirk in the design?

Thanks
Derek

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