Re: how to make readonly in change but editable in add?

2010-08-04 Thread Paulo Almeida
Actually, what he wanted was just to override a field, and not the whole
form, but he can do it with slight modifications of your code. He would
override the form class he wants to modify, instead of creating a generic
one, and instead of iterating all the fields he would just set the relevant
one(s) read only.

- Paulo

On Wed, Aug 4, 2010 at 4:03 AM, shmengie <1st...@gmail.com> wrote:

> I cobbled these two classes together which work very nicely for me,
> wish they could make into django.
> Drop these two classes into a util.py and import them instead of Form
> or ModelForm.  When you want your form readonly instantiate it with
> "form=MyForm(record, readonly=True)"
>
> class roForm(forms.Form):
>def __init__(self, *args, **kwargs):
>self.readonly = False
>if kwargs.has_key('readonly'):
>if kwargs['readonly']:
>self.readonly = True
>kwargs.pop('readonly')
>super(roForm, self).__init__(*args, **kwargs)
>if self.readonly:
>for key in self.fields.iterkeys():
>self.fields[key].widget.attrs['disabled'] = True
>
>
> class roModelForm(forms.ModelForm):
>def __init__(self, *args, **kwargs):
>self.readonly = False
>if kwargs.has_key('readonly'):
>if kwargs['readonly']:
>self.readonly = True
>kwargs.pop('readonly')
>super(roModelForm, self).__init__(*args, **kwargs)
>if self.readonly:
>for key in self.fields.iterkeys():
>self.fields[key].widget.attrs['disabled'] = True
>
>
> On Aug 3, 2:36 pm, snipinben  wrote:
> > I was wondering how to make a field readonly when you click on it or want
> to
> > change the record. and i have done that with the readonly_feilds method.
> but
> > that makes it to where you cant add information to that feild when you
> add a
> > new record. is there something i can use where you are not able to edit a
> > feild in the change view, but when you add new, you are able to edit the
> > field until you press save? thanks alot
> > --
> > View this message in context:
> http://old.nabble.com/how-to-make-readonly-in-change-but-editable-in-...
> > Sent from the django-users mailing list archive at Nabble.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.



problem : create form

2010-08-04 Thread Jagdeep Singh Malhi
i follow these documentation for create form

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

i use command for create application
#python manage.py startapp form

after this a use this code in model.py file

from django import forms

class ContactForm(forms.Form):
subject = forms.CharField(max_length=100)
message = forms.CharField()
sender = forms.EmailField()
cc_myself = forms.BooleanField(required=False)

but nothing can be show in when a run this command
#python manage.py sql form.

where is problem ?
 please 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: problem : create form

2010-08-04 Thread Daniel Roseman
On Aug 4, 9:19 am, Jagdeep Singh Malhi 
wrote:
> i follow these documentation for create form
>
> http://docs.djangoproject.com/en/dev/topics/forms/
>
> i use command for create application
> #python manage.py startapp form
>
> after this a use this code in model.py file
>
> from django import forms
>
> class ContactForm(forms.Form):
>     subject = forms.CharField(max_length=100)
>     message = forms.CharField()
>     sender = forms.EmailField()
>     cc_myself = forms.BooleanField(required=False)
>
> but nothing can be show in when a run this command
> #python manage.py sql form.
>
> where is problem ?
>  please help.

Why do you think you would get any SQL with that? You're creating a
form, not a model.
--
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-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: problem : create form

2010-08-04 Thread Paulo Almeida
Hi,

SQL is created for models, not for forms. Maybe you should try following the
tutorial first (it's near the top of the Django documentation page), and
then move to other documentation for the specifics.

- Paulo

On Wed, Aug 4, 2010 at 9:19 AM, Jagdeep Singh Malhi  wrote:

> i follow these documentation for create form
>
> http://docs.djangoproject.com/en/dev/topics/forms/
>
> i use command for create application
> #python manage.py startapp form
>
> after this a use this code in model.py file
>
> from django import forms
>
> class ContactForm(forms.Form):
>subject = forms.CharField(max_length=100)
>message = forms.CharField()
>sender = forms.EmailField()
>cc_myself = forms.BooleanField(required=False)
>
> but nothing can be show in when a run this command
> #python manage.py sql form.
>
> where is problem ?
>  please 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.



Auhtentification

2010-08-04 Thread galbourn
Hello,

I have an application that runs on Django 1.2.1 and uses
django_auth_ldap.backend.LDAPBackend in terms of authentication.
In version 1.2.1, is it possible to create local users without
superuser?
In fact, I added django.contrib.auth.backends.ModelBackend and I have
created a user local non-superuser and I get an error when I try to
access my site:
I have no problem with a local account superuser.

AttributeError at / admin /

'NoneType' object has no attribute 'replace'

Request Method: GET
Request URL:
Django Version: 1.2.1
Exception Type: AttributeError
Exception Value:

'NoneType' object has no attribute 'replace'

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



Select widget options

2010-08-04 Thread Ryan Osborn
Hi,

Is there a way to change the text shown in the select widget for each
option?  I have the following form where player2 is a foreign key to
user.

class MatchForm(forms.ModelForm):
class Meta:
model = Match
fields = ['player2','result','date']
widgets = {'result': forms.RadioSelect(), 'date':
AdminDateWidget()}

The select widget shows the returned value from the User models
__unicode__ method, which is their username.  I want to change this to
display get_full_name.  Is there an easy way to do this?

Thanks,

Ryan

-- 
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: convert mysql database tables into classes of model.py file

2010-08-04 Thread Jagdeep Singh Malhi
Problem solve
@Steve Holden

Thanks sir

-- 
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: problem : create form

2010-08-04 Thread Jagdeep Singh Malhi




>
> Why do you think you would get any SQL with that? You're creating a
> form, not a model.
ok
I also want to store the value in database using form.

Now what i can do?
any tutorial of that?

-- 
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: problem : create form

2010-08-04 Thread Paulo Almeida
If possible, the easiest way would be to create a form based on a model
(subclass ModelForm). When you save the form the values will be stores in
the appropriate database fields.

To answer your final question, the 4 part tutorial I mentioned covers that.

- Paulo

On Wed, Aug 4, 2010 at 10:09 AM, Jagdeep Singh Malhi <
singh.malh...@gmail.com> wrote:

>
>
>
>
> >
> > Why do you think you would get any SQL with that? You're creating a
> > form, not a model.
> ok
> I also want to store the value in database using form.
>
> Now what i can do?
> any tutorial of that?
>
> --
> 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.



djangoproject access fields of object dynamically

2010-08-04 Thread ars_sim


Hello, Can anyone help me?

I have list of fields called 'allowed_fields' and I have object called
'individual'.
allowed_fields is sub set of individual. Now I want to run loop like
this

for field in allowed_fields:
obj.field = individual.field

obj have same fields like individual. Do you have solution of my
problem? I will thankful to you.

Regards,

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

2010-08-04 Thread Erisa
Oops! I copied the old class with the "self" mistake left in.  The
correct class is:

class SettingsAdmin(admin.ModelAdmin):
def changelist_view(self, request, extra_context=None):
object_id = str(Settings.objects.all()[0].id)
return super(SettingsAdmin, self).change_view(self, request,
object_id, extra_context=None)


On Aug 3, 10:46 pm, Erisa  wrote:
> I found the problem.  The object_id needs to be a string!  So the
> following works like a charm:
>
> from wolkdata.database.models import *
> from django.contrib import admin
>
> class SettingsAdmin(admin.ModelAdmin):
>     def changelist_view(self, request, extra_context=None):
>         object_id = str(Settings.objects.all()[0].id)
>         return super(SettingsAdmin, self).change_view(self, request,
> object_id, extra_context=None)
>
> admin.site.register(Settings, SettingsAdmin)
>
> When I click on the Settings option on the admin page I go right to
> the change_view 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-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: UnicodeDecodeError: 'utf8' codec can't decode

2010-08-04 Thread Yateen
Hi Bill, thanks for the valuable inputs. I could hit a better solution
and I believe that is simplest one. Better, the solution is on the
application side and not on the DJango side.
What I did was this -
When my parser starts reading data from files (for which I don't know
the encoding), it first converts the URL information from the file in
to appropriate encoded values using iri_to_uri. Also, the encoding in
postgres database is set to utf-8 instead of default sql_ascii. This
setting in postgres creates another problem for psycopg2 connection,
so, whenever I create a connection object for psycopg2, i need to set
the encoding on the object. e.g. conn is my connection object, the
moment it is created, i do conn.set_client_encoding('utf-8'). The
things work fine thereafter.
The only change as compared previous implementation is, for those
special non-ascii characters, I see corresponding encoding in my
display (as %NN), in earlier implementation, I used to see the
characters as they were in the GUI.

One would question which one is a preferred method?
I would go with second one (changes on application side). In former
case, the story does not end there. If there is another component in
your application that needs to fetch data and process it (may be for
exporting to excel etc), you
have to handle that interface too, and keep on doing the same for
every new interface that you introduce. On the other hand, the changes
mentioned in this method ensure that we set proper encoding for the
data in the database so that all the components are comfortable in
processing the same.

I believe I should close this thread having found the appropriate
solution, still, comments/suggestions are welcome.

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.



multi_db support for doctests? How to enable?

2010-08-04 Thread Reinout van Rees

Hi,

http://docs.djangoproject.com/en/dev/topics/testing/#multi-database-support 
tells me to add "multi_db = True" to my unittest TestCase class to get 
multi db support.


I'm using a doctest, however, and I can't figure out how to set that for 
my doctest.  Anyone know how to get that working?  My tests.py looks 
like this:


===
import doctest
import unittest


def suite():
"""Return test suite

This method is automatically called by django's test mechanism.

"""
suite = unittest.TestSuite()
doctests = doctest.DocFileSuite(
'USAGE.txt',
'models.txt',
module_relative=True,
optionflags=(doctest.NORMALIZE_WHITESPACE |
 doctest.ELLIPSIS |
 doctest.REPORT_NDIFF))
# Multi db hack, I cannot set the multi_db to true otherwise.
for test in doctests._tests:
test.multi_db = True
# End of hack, which doesn't work anyway...
suite.addTest(doctests)
return suite

=


Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
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: PIL failed in virtualenv?

2010-08-04 Thread joconnell
Hi,

A quick search on google turned up the following:

http://trac-hacks.org/ticket/6321

It looks like it might be a similar issue. Was due to missing
dependencies - python-dev (among others)

Maybe if you use pip to install, it might take care of these
dependencies for you?

John


On Aug 4, 7:43 am, kostia  wrote:
> Good day,
>
> I created via ssh my virtualenv ENV and installed over there Django,
> its modules like captcha, modeltranslation and thumbs. But I have a
> trouble with Imaging-1.1.7! See below. My Django project is called
> "projector".
>
> When running the server I do:
>
> (ENV)kos...@au-kbc:~/ENV/projector$ python manage.py runserver
> 127.0.0.1:9980
> Validating models...
> modeltranslation: Registered 0 models for translation ().
> Unhandled exception in thread started by  0x8b92f7c>
> Traceback (most recent call last):
>   File "/home/kostia/ENV/lib/python2.6/site-packages/django/core/
> management/commands/runserver.py", line 48, in inner_run
>     self.validate(display_num_errors=True)
>   File "/home/kostia/ENV/lib/python2.6/site-packages/django/core/
> management/base.py", line 249, in validate
>     raise CommandError("One or more models did not validate:\n%s" %
> error_text)
> django.core.management.base.CommandError: One or more models did not
> validate:
> main.project: "image": To use ImageFields, you need to install the
> Python Imaging Library. Get it athttp://www.pythonware.com/products/pil/
> .
>
> And it shows that PIL was not installed. Ok, I go to /home/kostia/ENV/
> django modules/Imaging-1.1.7 and manually run
> python setup.py install
>
> Then it shows an error within the long log:
>
> (ENV)kos...@au-kbc:~/ENV/django modules/Imaging-1.1.7$ python setup.py
> install
>
> running install
> running build
> running build_py
> running build_ext
> building '_imaging' extension
> gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -
> Wstrict-prototypes -fPIC -DHAVE_LIBJPEG -DHAVE_LIBZ -I/usr/include/
> freetype2 -IlibImaging -I/home/kostia/ENV/include -I/usr/local/include
> -I/usr/include -I/usr/include/python2.6 -c _imaging.c -o build/
> temp.linux-i686-2.6/_imaging.o
> _imaging.c:75:20: error: Python.h: No such file or directory
> In file included from libImaging/Imaging.h:14,
>                  from _imaging.c:77:
> libImaging/ImPlatform.h:14:2: error: #error Sorry, this library
> requires support for ANSI prototypes.
> libImaging/ImPlatform.h:17:2: error: #error Sorry, this library
> requires ANSI header files.
> libImaging/ImPlatform.h:55:2: error: #error Cannot find required 32-
> bit integer type
> In file included from _imaging.c:77:
> libImaging/Imaging.h:90: error: expected specifier-qualifier-list
> before ‘INT32’
> libImaging/Imaging.h:264: error: expected specifier-qualifier-list
> before ‘INT32’
> libImaging/Imaging.h:395: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘ImagingCRC32’
> _imaging.c:124: error: expected specifier-qualifier-list before
> ‘PyObject_HEAD’
> _imaging.c:129: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘PyTypeObject’
> _imaging.c:143: error: expected specifier-qualifier-list before
> ‘PyObject_HEAD’
> _imaging.c:151: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘PyTypeObject’
> _imaging.c:154: error: expected specifier-qualifier-list before
> ‘PyObject_HEAD’
> _imaging.c:160: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘PyTypeObject’
> _imaging.c:165: error: expected specifier-qualifier-list before
> ‘PyObject_HEAD’
> _imaging.c:170: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘PyTypeObject’
> _imaging.c:172: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or
> ‘__attribute__’ before ‘*’ token
> _imaging.c: In function ‘_dealloc’:
> _imaging.c:204: error: ‘ImagingObject’ has no member named ‘access’
> _imaging.c:206: error: ‘ImagingObject’ has no member named ‘image’
> _imaging.c:207: warning: implicit declaration of function ‘PyMem_DEL’
> _imaging.c: At top level:
> _imaging.c:212: error: expected ‘)’ before ‘*’ token
> _imaging.c: In function ‘ImagingSectionEnter’:
> _imaging.c:230: error: ‘PyThreadState’ undeclared (first use in this
> function)
> _imaging.c:230: error: (Each undeclared identifier is reported only
> once
> _imaging.c:230: error: for each function it appears in.)
> _imaging.c:230: error: expected expression before ‘)’ token
> _imaging.c: In function ‘ImagingSectionLeave’:
> _imaging.c:237: warning: implicit declaration of function
> ‘PyEval_RestoreThread’
> _imaging.c:237: error: ‘PyThreadState’ undeclared (first use in this
> function)
> _imaging.c:237: error: expected expression before ‘)’ token
> _imaging.c: At top level:
> _imaging.c:248: error: expected ‘)’ before ‘*’ token
> _imaging.c:257: error: expected ‘)’ before ‘*’ token
> _imaging.c: In function ‘ImagingError_IOError’:
> _imaging.c:301: warning: implicit declaration of function
> ‘PyErr_SetString’
> _imaging.c:301: error: ‘PyExc_IOError’ undeclared (firs

Re: problem : create form

2010-08-04 Thread Kenneth Gonsalves
On Wed, 2010-08-04 at 01:19 -0700, Jagdeep Singh Malhi wrote:
> i use command for create application
> #python manage.py startapp form
> 
> after this a use this code in model.py file
> 
> from django import forms
> 
> class ContactForm(forms.Form):
> subject = forms.CharField(max_length=100)
> message = forms.CharField()
> sender = forms.EmailField()
> cc_myself = forms.BooleanField(required=False)
> 
> but nothing can be show in when a run this command
> #python manage.py sql form.
> 
> where is problem ?
>  please help. 

you are going about it wrong. models.py have models and sql is created
to create the database tables. Forms have nothing to do with the
database - so you will not get sql from them. Please go through the
relevant part of the tutorial first.

-- 
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: problem : create form

2010-08-04 Thread Kenneth Gonsalves
On Wed, 2010-08-04 at 02:09 -0700, Jagdeep Singh Malhi wrote:
> > Why do you think you would get any SQL with that? You're creating a
> > form, not a model.
> ok
> I also want to store the value in database using form.

make a model - use ModelForm - or just plain form
> 
> Now what i can do?
> any tutorial of that? 

it would be a good idea to sit down and do the tutorial on the website
(polls tutorial) from beginning to end.

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



no such table: django_session when doing the tutorial

2010-08-04 Thread merabi
Hi.
im using python 2.6, django 1.1, eclipse3.4, and pydev 1.6, macbook
pro mac os 10.6.4.
trying to do the tutorial: 
http://docs.djangoproject.com/en/dev/intro/tutorial02/

first of all, i DID syncdb. -> no problem.
i check using dbshell, .dump. -> says django_session DOES EXISTS.

Changed urls.py:

from django.conf.urls.defaults import *

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),

# Uncomment the admin/doc line below and add
'django.contrib.admindocs'
# to INSTALLED_APPS to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)

Added "django.contrib.admin" to INSTALLED_APPS on setting.py.
btw,
django.contrib.auth,
django.contrib.session,
django.contrib.site
are also listed.

When I tried to access http://localhost:8000/admin/
it says:

DatabaseError: no such table: django_session

Why is that

after the error i did syncdb, and it says No fixtures found...

-- 
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: PIL failed in virtualenv?

2010-08-04 Thread Kenneth Gonsalves
On Wed, 2010-08-04 at 03:43 -0700, joconnell wrote:
> It looks like it might be a similar issue. Was due to missing
> dependencies - python-dev (among others) 

actually it was due to missing python-dev

-- 
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: no such table: django_session when doing the tutorial

2010-08-04 Thread Alexandre González
Have you run the script manage.py with syncdb option?

python manage.py syncdb

On Wed, Aug 4, 2010 at 12:44, merabi  wrote:

> Hi.
> im using python 2.6, django 1.1, eclipse3.4, and pydev 1.6, macbook
> pro mac os 10.6.4.
> trying to do the tutorial:
> http://docs.djangoproject.com/en/dev/intro/tutorial02/
>
> first of all, i DID syncdb. -> no problem.
> i check using dbshell, .dump. -> says django_session DOES EXISTS.
>
> Changed urls.py:
>
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
># Example:
># (r'^mysite/', include('mysite.foo.urls')),
>
># Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
># to INSTALLED_APPS to enable admin documentation:
># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
># Uncomment the next line to enable the admin:
>(r'^admin/', include(admin.site.urls)),
> )
>
> Added "django.contrib.admin" to INSTALLED_APPS on setting.py.
> btw,
> django.contrib.auth,
> django.contrib.session,
> django.contrib.site
> are also listed.
>
> When I tried to access http://localhost:8000/admin/
> it says:
>
> DatabaseError: no such table: django_session
>
> Why is that
>
> after the error i did syncdb, and it says No fixtures found...
>
> --
> 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.
>
>


-- 
Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
and/or .pptx
http://mirblu.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: no such table: django_session when doing the tutorial

2010-08-04 Thread Yoji H
i did as i wrote above.

2010/8/4 Alexandre González 

> Have you run the script manage.py with syncdb option?
>
> python manage.py syncdb
>
> On Wed, Aug 4, 2010 at 12:44, merabi  wrote:
>
>> Hi.
>> im using python 2.6, django 1.1, eclipse3.4, and pydev 1.6, macbook
>> pro mac os 10.6.4.
>> trying to do the tutorial:
>> http://docs.djangoproject.com/en/dev/intro/tutorial02/
>>
>> first of all, i DID syncdb. -> no problem.
>> i check using dbshell, .dump. -> says django_session DOES EXISTS.
>>
>> Changed urls.py:
>>
>> from django.conf.urls.defaults import *
>>
>> # Uncomment the next two lines to enable the admin:
>> from django.contrib import admin
>> admin.autodiscover()
>>
>> urlpatterns = patterns('',
>># Example:
>># (r'^mysite/', include('mysite.foo.urls')),
>>
>># Uncomment the admin/doc line below and add
>> 'django.contrib.admindocs'
>># to INSTALLED_APPS to enable admin documentation:
>># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>
>># Uncomment the next line to enable the admin:
>>(r'^admin/', include(admin.site.urls)),
>> )
>>
>> Added "django.contrib.admin" to INSTALLED_APPS on setting.py.
>> btw,
>> django.contrib.auth,
>> django.contrib.session,
>> django.contrib.site
>> are also listed.
>>
>> When I tried to access http://localhost:8000/admin/
>> it says:
>>
>> DatabaseError: no such table: django_session
>>
>> Why is that
>>
>> after the error i did syncdb, and it says No fixtures found...
>>
>> --
>>
>> 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.
>>
>>
>
>
> --
> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx, .ppt
> and/or .pptx
> http://mirblu.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: no such table: django_session when doing the tutorial

2010-08-04 Thread Yoji H
this is just a guess but i think the path is not set right.
but i don know how to set it correctly.

On Wed, Aug 4, 2010 at 8:39 PM, Yoji H  wrote:

> i did as i wrote above.
>
> 2010/8/4 Alexandre González 
>
> Have you run the script manage.py with syncdb option?
>>
>> python manage.py syncdb
>>
>> On Wed, Aug 4, 2010 at 12:44, merabi  wrote:
>>
>>> Hi.
>>> im using python 2.6, django 1.1, eclipse3.4, and pydev 1.6, macbook
>>> pro mac os 10.6.4.
>>> trying to do the tutorial:
>>> http://docs.djangoproject.com/en/dev/intro/tutorial02/
>>>
>>> first of all, i DID syncdb. -> no problem.
>>> i check using dbshell, .dump. -> says django_session DOES EXISTS.
>>>
>>> Changed urls.py:
>>>
>>> from django.conf.urls.defaults import *
>>>
>>> # Uncomment the next two lines to enable the admin:
>>> from django.contrib import admin
>>> admin.autodiscover()
>>>
>>> urlpatterns = patterns('',
>>># Example:
>>># (r'^mysite/', include('mysite.foo.urls')),
>>>
>>># Uncomment the admin/doc line below and add
>>> 'django.contrib.admindocs'
>>># to INSTALLED_APPS to enable admin documentation:
>>># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>>>
>>># Uncomment the next line to enable the admin:
>>>(r'^admin/', include(admin.site.urls)),
>>> )
>>>
>>> Added "django.contrib.admin" to INSTALLED_APPS on setting.py.
>>> btw,
>>> django.contrib.auth,
>>> django.contrib.session,
>>> django.contrib.site
>>> are also listed.
>>>
>>> When I tried to access http://localhost:8000/admin/
>>> it says:
>>>
>>> DatabaseError: no such table: django_session
>>>
>>> Why is that
>>>
>>> after the error i did syncdb, and it says No fixtures found...
>>>
>>> --
>>>
>>> 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.
>>>
>>>
>>
>>
>> --
>> Please, don't send me files with extensions: .doc, .docx, .xls, .xlsx,
>> .ppt and/or .pptx
>> http://mirblu.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: multi_db support for doctests? How to enable?

2010-08-04 Thread Russell Keith-Magee
On Wed, Aug 4, 2010 at 6:40 PM, Reinout van Rees  wrote:
> Hi,
>
> http://docs.djangoproject.com/en/dev/topics/testing/#multi-database-support
> tells me to add "multi_db = True" to my unittest TestCase class to get multi
> db support.
>
> I'm using a doctest, however, and I can't figure out how to set that for my
> doctest.  Anyone know how to get that working?

There's no multi_db flag for doctests -- because you don't need one.

The multi_db=True flag on TestCase doesn't actually change anything in
the way the test operates; it's just telling the flushing
infrastructure which databases need to be flushed at the start of a
test.

Since flushing/rollback at the start of a test is an expensive
operation, it's time consuming to continuously flush all the databases
in your configuration. Therefore, Django will only flush the 'default'
database unless you specifically mark your test as a 'multi-db' test.
This way, you only flush the full database set if every database is
required in order to run the test.

Doctests don't do any database flushing, so there is no analog for the
multi-db flag. Just make your calls on the database as you normally
would.

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



first app

2010-08-04 Thread yalda.nasirian
Hi dear friends
finally , i finish my first app tutorials of djangoproject.com . i
want to share this whith u ,
i wish it'll be helpfull .
note to change dir template in setting,py .

http://www.4shared.com/file/23TzJzLt/mysite.html

-- 
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 to make readonly in change but editable in add?

2010-08-04 Thread Steve Holden
On 8/3/2010 11:03 PM, shmengie wrote:
> I cobbled these two classes together which work very nicely for me,
> wish they could make into django.
> Drop these two classes into a util.py and import them instead of Form
> or ModelForm.  When you want your form readonly instantiate it with
> "form=MyForm(record, readonly=True)"
> 
> class roForm(forms.Form):
> def __init__(self, *args, **kwargs):
> self.readonly = False
> if kwargs.has_key('readonly'):
> if kwargs['readonly']:
> self.readonly = True
> kwargs.pop('readonly')
> super(roForm, self).__init__(*args, **kwargs)
> if self.readonly:
> for key in self.fields.iterkeys():
> self.fields[key].widget.attrs['disabled'] = True
> 
Just a stylistic point. It's easy to second-guess someone else's code
when you have the liberty of scrutinizing it at what I sometimes
laughingly call "leisure", so I don't want this to be interpreted as
being critical, but the code might (?) be easier to read (barring typos) as:

class roForm(forms.Form):
def __init__(self, *args, **kwargs):
self.readonly = 'readonly' in kwargs
if self.readonly:
kwargs.pop('readonly')
super(roForm, self).__init__(*args, **kwargs)
if self.readonly:
for key in self.fields.iterkeys():
self.fields[key].widget.attrs['disabled'] = True

regards
 Steve

-- 
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: first app

2010-08-04 Thread Sameer Rahmani
hi , congratulation.

why don't you use a VCS like git or mercurial  ?

-- 
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: djangoproject access fields of object dynamically

2010-08-04 Thread Steve Holden
On 8/4/2010 5:26 AM, ars_sim wrote:
> 
> 
> Hello, Can anyone help me?
> 
> I have list of fields called 'allowed_fields' and I have object called
> 'individual'.
> allowed_fields is sub set of individual. Now I want to run loop like
> this
> 
> for field in allowed_fields:
> obj.field = individual.field
> 
> obj have same fields like individual. Do you have solution of my
> problem? I will thankful to you.
> 
> Regards,
> 
See the Python setattr() and getattr() functions. They allow you to
access attributes programmatically by name. I suspect you want

for field in allowed_fields:
setattr(obj, field, getattr(individual, field))

regards
 Steve
-- 
I'm no expert.
"ex" == "has-been"; "spurt" == "drip under pressure"
"expert" == "has-been drip under pressure".

-- 
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: Strange error overriding changelist_view in ModelAdmin

2010-08-04 Thread Steve Holden
On 8/4/2010 5:43 AM, Erisa wrote:
> Oops! I copied the old class with the "self" mistake left in.  The
> correct class is:
> 
> class SettingsAdmin(admin.ModelAdmin):
> def changelist_view(self, request, extra_context=None):
> object_id = str(Settings.objects.all()[0].id)
> return super(SettingsAdmin, self).change_view(self, request,
> object_id, extra_context=None)
> 
Congratulations nevertheless on moving so quickly from "that's a strange
error" to "wow, I can fix this!".

regards
 Steve
-- 
I'm no expert.
"ex" == "has-been"; "spurt" == "drip under pressure"
"expert" == "has-been drip under pressure".

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



Multiple Databases and ModelFormSets

2010-08-04 Thread Parker
I am somewhat new to Django and am trying to use the ModelFormSets
alongside multiple-databases.

I'm trying to create an empty ModelFormSet that will allow me to
create objects for a specific database and pull in the appropriate
drop-downs from that database.  What I'm seeing is that the Form Set
has populated all of the drop-downs based on the Foreign Key values
for the 'default' database and not the database of my choosing.

Consider the following example where there are a different set of
users on each databases ('default' and 'NotDefault').  The following
code will always render a select list that contains the users from the
'default' database even though the QuerySet that I've passed into the
ModelFormSet is using a different database.

class ScheduledReport(models.Model):
reportID= models.AutoField(db_column="reportID", 
primary_key=True)
Owner   = models.ForeignKey(user.User)

class Meta:
db_table = "scheduledReports"

ReportFormSet = modelformset_factory(ScheduledReport)

report_form =
ReportFormSet(queryset=sr.ScheduledReport.objects.get_empty_query_set().using('NotDefault'))
report_form.as_table() # Trigger the render

After looking thorough the source code, I've realized that the
ModelChoiceFields get populated using each form's instance's database:
# django.forms.models
qs = qs.using(form.instance._state.db)
form.fields[self._pk_field.name] = ModelChoiceField(qs,
initial=pk_value, required=False, widget=HiddenInput

With that information I tried directly modifying the instances state
without any success.  (This worked in the case where I was using just
a ModelForm and not a ModelFormSet)

report_form =
ReportFormSet(queryset=sr.ScheduledReport.objects.get_empty_query_set().using('NotDefault'))
for f in report_form.forms:
f.instance._state.db = 'NotDefault'
report_form.as_table() # Trigger the rendering


I'm all out of ideas and am lost in how I am supposed to use
ModelFormSets in conjunction with Multiple Databases.  Has anyone else
run into this issue?

Thanks
Parker


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

2010-08-04 Thread Ковалевич
gedit + plugins + snippets is easier to learn than vim(gvim) and looks more
beautiful :) , but on windows there is bad support of python plugins (if you
really need to develop on win)
vim may be more flexible
Wing IDE not free. I meant version with django support
(http://wingware.com/wingide/features)

On 4 August 2010 07:15, Alexander Jeliuc  wrote:

> gvim, emacs, eclipse, eric
>
>
> On Wed, Aug 4, 2010 at 6:50 AM, Nick Arnett  wrote:
>
>>
>>
>> On Sun, Jul 18, 2010 at 10:19 AM, Biju Varghese wrote:
>>
>>> Eclipse is the best IDE for python and django.
>>>
>>>
>> I don't know if it is actually the best, but I'm happy with it.
>>
>> 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.
>>
>
>  --
> 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.



Django No Messages Error

2010-08-04 Thread kostia
After I do:

kos...@baikal$ python manage.py runserver
Error: No module named messages
kos...@baikal$

Django 1.2.1 with python 2.6.5+ devel installed.

-- 
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 No Messages Error

2010-08-04 Thread kostia
SOLVED!

On Aug 4, 3:48 pm, kostia  wrote:
> After I do:
>
> kos...@baikal$ python manage.py runserver
> Error: No module named messages
> kos...@baikal$
>
> Django 1.2.1 with python 2.6.5+ devel installed.

-- 
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: PIL failed in virtualenv?

2010-08-04 Thread Kai Diefenbach

Hi,

On 2010-08-04 08:43:34 +0200, kostia said:


But I have a trouble with Imaging-1.1.7!


Take a look at Pillow: http://pypi.python.org/pypi/Pillow/1.2

Kai


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

2010-08-04 Thread Dan Gentry
I'm trying to move some code from a view to a decorator to use with
many views.  This is the view:

views.py:
def list_type(request):

inst_id=request.session.get('inst_id',None)

## move to decorator
if not inst_id:
path = urlquote(request.get_full_path())
tup = reverse('select_inst'), REDIRECT_FIELD_NAME, path
return HttpResponseRedirect('%s?%s=%s' % tup)
##

queryset = RecordType.objects.filter(institution=inst_id)
return object_list(request, queryset, paginate_by = 12)

I've moved the middle bit of code to a decorator I wrote (basically
copying user_passes_test), but when I use it I get the strange error
that my urls.py file contains no patterns.

decorators.py:
def institution_required(fn, redirect_field_name=REDIRECT_FIELD_NAME):

inst_url = reverse('select_inst')  ##  URL to select institution

def _wrapped_view(request, *args, **kwargs):
if not request.session.get('inst_id',None):
path = urlquote(request.get_full_path())
tup = inst_url, redirect_field_name, path
return HttpResponseRedirect('%s?%s=%s' % tup)
return fn(request, *args, **kwargs)
return _wrapped_view



Would anyone like to school me on the correct way to write a view
decorator?  Thanks in advance.

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

2010-08-04 Thread Franklin Einspruch
A decorator is a specific construction in Python (and one that doesn't
appear in your code):

http://www.python.org/dev/peps/pep-0318/#current-implementation-history

http://www.artima.com/weblogs/viewpost.jsp?thread=240808

Good luck!

Franklin

On Wed, Aug 4, 2010 at 9:15 AM, Dan Gentry  wrote:
> I'm trying to move some code from a view to a decorator to use with
> many views.  This is the view:
>
> views.py:
> def list_type(request):
>
>    inst_id=request.session.get('inst_id',None)
>
>    ## move to decorator
>    if not inst_id:
>        path = urlquote(request.get_full_path())
>        tup = reverse('select_inst'), REDIRECT_FIELD_NAME, path
>        return HttpResponseRedirect('%s?%s=%s' % tup)
>    ##
>
>    queryset = RecordType.objects.filter(institution=inst_id)
>    return object_list(request, queryset, paginate_by = 12)
>
> I've moved the middle bit of code to a decorator I wrote (basically
> copying user_passes_test), but when I use it I get the strange error
> that my urls.py file contains no patterns.
>
> decorators.py:
> def institution_required(fn, redirect_field_name=REDIRECT_FIELD_NAME):
>
>    inst_url = reverse('select_inst')  ##  URL to select institution
>
>    def _wrapped_view(request, *args, **kwargs):
>        if not request.session.get('inst_id',None):
>            path = urlquote(request.get_full_path())
>            tup = inst_url, redirect_field_name, path
>            return HttpResponseRedirect('%s?%s=%s' % tup)
>        return fn(request, *args, **kwargs)
>    return _wrapped_view
>
>
>
> Would anyone like to school me on the correct way to write a view
> decorator?  Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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.
>
>



-- 
Art, writing, journal: http://einspruch.com
Comics: http://themoonfellonme.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: Announces django-guardian: per object permissions for Django 1.2

2010-08-04 Thread derek
On Aug 4, 1:20 am, lukaszb  wrote:
> Hi all,
>
> I'd like to announce django-guardian - very basic yet usable per
> object permissions
> implementation for Django 1.2, using new authorization backend
> facilities.
>
> It was created during 2 days sprint, code have been released and may
> be found athttp://github.com/lukaszb/django-guardian/.
> Documentation is available athttp://packages.python.org/django-guardian/.
>
> Currently I think there should be better integration with admin app
> and some shortcuts (permission assignment/removal)
> should support table-level permissions as well.
>
> If you spot a bug or have an idea how to improve this little app,
> please spare a minute at issue tracker, which is located 
> athttp://github.com/lukaszb/django-guardian/issues.
>
> Hope someone would find this useful.

No doubt this will be extremely useful!  For me, integration with the
Django admin is a must, though, as permissions will need to be
assigned by users themselves via the standard interface.

One (maybe stupid) question:  Can rights only be assigned to the pre-
specified "Group", or can any model that handles user grouping (I have
some custom ones in my app) be used?

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.



Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread André A . Santos
Hello friends,
this is André AS from São Paulo-Brazil, total beginner to Python
technologies, I am working on a project that uses those we are
converting all those to Java, so I would like to know where I must put the
logic rules I am a little confusing if I must put on Python or Django
code... Which
difference?

André AS

-- 
André Asantos
Skype - andredecotia
MSN - andre_deco...@hotmail.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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread Daniel Roseman
On Aug 4, 2:38 pm, André A. Santos  wrote:
> Hello friends,
> this is André AS from São Paulo-Brazil, total beginner to Python
> technologies, I am working on a project that uses those we are
> converting all those to Java, so I would like to know where I must put the
> logic rules I am a little confusing if I must put on Python or Django
> code... Which
> difference?
>
> André AS

Your question doesn't really make sense. Django code *is* Python code.
--
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-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: View Decorator

2010-08-04 Thread Daniel Roseman
On Aug 4, 2:15 pm, Dan Gentry  wrote:
> I'm trying to move some code from a view to a decorator to use with
> many views.  This is the view:
>
> views.py:
> def list_type(request):
>
>     inst_id=request.session.get('inst_id',None)
>
>     ## move to decorator
>     if not inst_id:
>         path = urlquote(request.get_full_path())
>         tup = reverse('select_inst'), REDIRECT_FIELD_NAME, path
>         return HttpResponseRedirect('%s?%s=%s' % tup)
>     ##
>
>     queryset = RecordType.objects.filter(institution=inst_id)
>     return object_list(request, queryset, paginate_by = 12)
>
> I've moved the middle bit of code to a decorator I wrote (basically
> copying user_passes_test), but when I use it I get the strange error
> that my urls.py file contains no patterns.
>
> decorators.py:
> def institution_required(fn, redirect_field_name=REDIRECT_FIELD_NAME):
>
>     inst_url = reverse('select_inst')  ##  URL to select institution
>
>     def _wrapped_view(request, *args, **kwargs):
>         if not request.session.get('inst_id',None):
>             path = urlquote(request.get_full_path())
>             tup = inst_url, redirect_field_name, path
>             return HttpResponseRedirect('%s?%s=%s' % tup)
>         return fn(request, *args, **kwargs)
>     return _wrapped_view
>
> Would anyone like to school me on the correct way to write a view
> decorator?  Thanks in advance.

Can you show how you're using that decorator in your views - and also
your urls.py, since there seems to be a problem there?
--
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-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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread André A . Santos
hmmm...
Dr thanks for answering... my doubt is if is better put the business rules
code on Python or Django... got it?

On Wed, Aug 4, 2010 at 10:50 AM, Daniel Roseman wrote:

> On Aug 4, 2:38 pm, André A. Santos  wrote:
> > Hello friends,
> > this is André AS from São Paulo-Brazil, total beginner to Python
> > technologies, I am working on a project that uses those we are
> > converting all those to Java, so I would like to know where I must put
> the
> > logic rules I am a little confusing if I must put on Python or Django
> > code... Which
> > difference?
> >
> > André AS
>
> Your question doesn't really make sense. Django code *is* Python code.
> --
> 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-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.
>
>


-- 
André Asantos
Skype - andredecotia
MSN - andre_deco...@hotmail.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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread Masklinn
On 2010-08-04, at 16:04 , André A. Santos wrote:
> hmmm...
> Dr thanks for answering... my doubt is if is better put the business rules
> code on Python or Django... got it?
> 
As Daniel indicated, your question doesn't make sense. Django is Python, that's 
like asking whether you should write with a pen or with ink. Your pen contains 
ink, so you're writing with ink in both cases.

Django is simply a Python library, so apart from when you're writing Django 
templates you're writing Python code.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Admin Inline inside another admin inline

2010-08-04 Thread Alessandro Ronchi
2010/7/3 Sean Brant 

>
> Im not even sure if this is best way to display things, I would like
> one main product edit screen that lets you attach "product types"
> which have "sizes" to a "product", it seems jumping between a bunch of
> screens is not good ux. Wondering if I need to create a custom view
> for this? Thanks for any help.
>

It's not possible to make nested inline.
I'm trying to do the same thing, with this solution:
http://packages.python.org/django-easymode/tree/index.html?highlight=inline#admin-support-for-model-trees-with-more-than-2-levels-of-related-items

But it doesn't work.
-- 
Alessandro Ronchi
http://www.soasi.com

Hobby & Giochi
http://hobbygiochi.com
http://www.facebook.com/hobbygiochi

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



How to get the model name of an object in template?

2010-08-04 Thread David.D
 I did it by adding this to my models:
def get_model_name(self):
return self.__class__.__name__

And it works

But I don't want to define the 'get_model_name' method in my model.

Is there a built-in way?

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, Rails but a cost to pay ?

2010-08-04 Thread didier rano
Why Google has updated Youtube framework for Java, .NET and PHP, but not
for Python ?

It was a real question. I need it for my Python project. And, I don't
understand why Google choose to update Java, .NET and PHP apis and not
Python. It is my "cost to pay", because Python is not yet a mainstream
language.

I know these constraints, but my project will remain in Python. Actually,
fun is more important for me.

Some tools like pip, virtualenv, fabric, celery, twisted, tornado... make me
confident about my choice.

Finally, for me, Python or/and Django are not always a perfect choice. But,
it is just an opinion.

2010/8/4 Eugene Wee 

> Hi,
>
> On Wed, Aug 4, 2010 at 3:21 AM, didier rano  wrote:
> > But, not all good developers
> > are able to use efficiently dynamic languages.
>
> I suspect that there will always be a programming language for which
> there exists a good developer who is currently unable to use it
> efficiently. Programming languages are tools, and not everyone is
> engaged in the same tasks, hence some will be more proficient with
> some tools than others. So, find a good developer who is currently
> able to use the programming language (and platform, framework, etc)
> efficiently, or wait for for your good developer to catch up (which
> will happen eventually, if he/she is any good).
>
> > And, sometimes, to choose an open source framework could be more
> problematic
> > than proprietary frameworks.
>
> And, sometimes, to choose a proprietary framework could be more
> problematic than open source frameworks. You should show by reasoned
> argument that choosing an open source framework tends to lead to more
> problems than choosing a proprietary framework, otherwise you are just
> making a vague assertion that does not really mean anything.
>
> > Why Google has updated Youtube framework for Java, .NET and PHP, but not
> for
> > Python ?
>
> Why did Google support Python for App Engine before Java? Why does it
> still not support .NET and PHP? It really is quite ironic to see that
> you wrote that '"Religions" wars are useless' :)
>
> Regards,
> Eugene
>
> --
> 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.
>
>


-- 
Didier Rano
didier.r...@gmail.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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread Xavier Ordoquy
Hi,

You're asking if you'd rather put all the business logic in pure python classes 
or django models ?
I'm not sure there's a straight answer to this, esp with no information about 
what you're trying to do.

Regards,
Xavier.

Le 4 août 2010 à 16:04, André A. Santos a écrit :

> hmmm... 
> Dr thanks for answering... my doubt is if is better put the business rules 
> code on Python or Django... got it?
> 
> On Wed, Aug 4, 2010 at 10:50 AM, Daniel Roseman  wrote:
> On Aug 4, 2:38 pm, André A. Santos  wrote:
> > Hello friends,
> > this is André AS from São Paulo-Brazil, total beginner to Python
> > technologies, I am working on a project that uses those we are
> > converting all those to Java, so I would like to know where I must put the
> > logic rules I am a little confusing if I must put on Python or Django
> > code... Which
> > difference?
> >
> > André AS
> 
> Your question doesn't really make sense. Django code *is* Python code.
> --
> 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-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.
> 
> 
> 
> 
> -- 
> André Asantos
> Skype - andredecotia
> MSN - andre_deco...@hotmail.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: How to get the model name of an object in template?

2010-08-04 Thread Scott Gould
How about writing a simple template tag that takes an object and
returns object.__class__.__name__?

On Aug 4, 10:20 am, "David.D"  wrote:
>  I did it by adding this to my models:
>         def get_model_name(self):
>                 return self.__class__.__name__
>
> And it works
>
> But I don't want to define the 'get_model_name' method in my model.
>
> Is there a built-in way?
>
> 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: View Decorator

2010-08-04 Thread Dan Gentry
When I attempt to use the decorator logic, the view becomes this:

views.py
@institution_required
def list_type(request):

inst_id=request.session.get('inst_id',None)

queryset = RecordType.objects.filter(institution=inst_id)
return object_list(request, queryset, paginate_by = 12)

I don't make any changes to urls.py, but the error is
"TemplateSyntaxError at /index
Caught ImproperlyConfigured while rendering: The included urlconf
person.urls doesn't have any patterns in it"
However, when I take out the decorator, all of the urls work as
expected.

urls.py does import * from views.py

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

2010-08-04 Thread Dan Gentry
Forgot to paste in the urls.

urls.py
from django.conf.urls.defaults import *
from django.views.generic.simple import redirect_to
from views import *


urlpatterns = patterns('person',

url(r'^create_type/$',create_type,name='type_create'),
url(r'^view_type/(?P\d+)/$',view_type,name='type_view'),
url(r'^update_type/(?P\d+)/$',update_type,name='type_update'),
url(r'^list_type/$',list_type,name='type_list'),
url(r'^delete_type/(?P\d+)/$',delete_type,name='type_delete'),

url(r'^index',index,name='person_index'),
url(r'^$', redirect_to, {'url': 'index'}),

)

-- 
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: Saving formsets with multiple databases

2010-08-04 Thread Paulo Almeida
Sorry if this is obvious and you're looking for a more direct way, but If
it's only the formset save that fails, I would suggest:

instances = formset.save(commit=False)
for instance in instances:
instance.save(using=database)

I have never used multiple databases though, so I don't know if that works
or if there is a better method.

- Paulo

On Tue, Aug 3, 2010 at 11:05 PM, Melanie  wrote:

> I am developing a formset for an application which uses multiple
> databases.  On load of the formset, I am able to utilize:
>
> model.objects.using(database).get(id)
>
> to get an instance of the object from the active database.  However,
> when the formset is submitted, I generate a new formset from the data
> in request.POST:
>
> formset = SampleFormSet(request.POST)
>
> When attempting to save the formset to the database, I attempted to
> pass the "using" parameter in the save method:
>
> formset.save(using=database)
>
> and got the error:
>
> save() got an unexpected keyword argument 'using'
>
> which suggests to me that the save method on the formset does not
> support multiple databases.  Is there any known way to save a formset
> when using multiple databases?
>
> --
> 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: TypeError: decoding Unicode is not supported

2010-08-04 Thread sohesado
Well your example clarifies the problem. I removed the unicode calls.

The initial problem was an  UnicodeEncodeError exception. I tried to
solve it by encoding the strings to utf-8. It seems that's not the
case.
So i'm at square one.

Note that..
-with python manage.py runserver the app runs flawlessly.
-With apache+mod-python i get an UnicodeEncodeError.

So , it is an apache localization issue?

My /etc/apache2/envvars contains


export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data
export APACHE_PID_FILE=/var/run/apache2.pid

## The locale used by some modules like mod_dav
export LANG='el_GR.UTF8'<- also tried el_GR.UTF-8 variation
export LC_ALL='el_GR.UTF8'
## Uncomment the following line to use the system default locale
instead:
#. /etc/default/locale

export LANG
-

Have you got any clues what may cause the problem?

Thank you for your help.

On Aug 3, 11:31 pm, Alec Shaner  wrote:
> unicode gives me nightmares.
>
> Taking django out of the picture for a moment:>>> unicode('foo', 'utf-8')
> u'foo'
> >>> unicode(u'foo', 'utf-8')
>
> Traceback (most recent call last):
>   File "", line 1, in 
> TypeError: decoding Unicode is not supported
>
> So I would assume when you run it inside django you're already using a
> unicode string. Do you need to pass the encoding argument ('utf-8') to
> unicode?
>
> On Tue, Aug 3, 2010 at 3:30 PM, sohesado  wrote:
> > Hi
>
> > I'm currently developing a django project and i've encountered a
> > problem regarding Unicode string manipulation.
>
> > There is a backend python module in my project that perform's mainly
> > shutil (shell utilities) tasks.
>
> > I get an TypeError: "decoding Unicode is not supported" exception
> > while running the following method
>
> > -
> > def create_base(name, reg):
> >    path = unicode(ROOT + name, 'utf-8')  error at this line
> >    shutil.copytree(ROOT + 'matrix', path)
> >    shutil.copystat(ROOT + 'matrix', path)
>
> >    f = codecs.open(path + '/conf/local.php', "w", "UTF-8")
> >    tmp = unicode(" >    f.write(tmp)
> >    if not reg:
> >        f.write("$conf['disableactions'] = 'register';\n")
>
> > ---
>
> > The weird thing that puzzles me is that when i test the module in a
> > python shell , the method runs flawlessly which yields me to the
> > assumption that it's a django thing.
> > By the way i use apache+mod-python as a web-server
>
> > I can't get adequate information regarding this type of exception. I'm
> > stuck , please 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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread André A . Santos
now i got it... thx




On Wed, Aug 4, 2010 at 11:09 AM, Masklinn  wrote:

> On 2010-08-04, at 16:04 , André A. Santos wrote:
> > hmmm...
> > Dr thanks for answering... my doubt is if is better put the business
> rules
> > code on Python or Django... got it?
> >
> As Daniel indicated, your question doesn't make sense. Django is Python,
> that's like asking whether you should write with a pen or with ink. Your pen
> contains ink, so you're writing with ink in both cases.
>
> Django is simply a Python library, so apart from when you're writing Django
> templates you're writing Python code.
>
> --
>  You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-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.
>
>


-- 
André Asantos
Skype - andredecotia
MSN - andre_deco...@hotmail.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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread André A . Santos
for exemple using MVC parttern how it works ->

M - model (Python)
V - view (JSP)
C - controller (Django or also Django on Model tier?)

On Wed, Aug 4, 2010 at 12:00 PM, André A. Santos
wrote:

> now i got it... thx
>
>
>
>
> On Wed, Aug 4, 2010 at 11:09 AM, Masklinn  wrote:
>
>> On 2010-08-04, at 16:04 , André A. Santos wrote:
>> > hmmm...
>> > Dr thanks for answering... my doubt is if is better put the business
>> rules
>> > code on Python or Django... got it?
>> >
>> As Daniel indicated, your question doesn't make sense. Django is Python,
>> that's like asking whether you should write with a pen or with ink. Your pen
>> contains ink, so you're writing with ink in both cases.
>>
>> Django is simply a Python library, so apart from when you're writing
>> Django templates you're writing Python code.
>>
>> --
>>  You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To post to this group, send email to django-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.
>>
>>
>
>
>  --
> André Asantos
> Skype - andredecotia
> MSN - andre_deco...@hotmail.com
>
>
>
>
>


-- 
André Asantos
Skype - andredecotia
MSN - andre_deco...@hotmail.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.



WAP communicating with server-side Python

2010-08-04 Thread shi shaozhong
Is there an equivalent mailling list for WAP?
I am in need of a very simple demo website/webpage accessible by
mobile handset and simply get a few critical data, e.g.
its id, or/and x, y, z position.
http://www.google.co.uk/search?hl=en&q=how+to+mobile+website&aq=8&aqi=g10&aql=&oq=how+to+mobile&gs_rfai=


I want to try out moving my Python internet service on to mobile
phones.  Therefore, the front-end will have to be in WAP.

All I need is an excellent demo WAP page to show me how to get the
mobile handset's ID, and x, y, z position.

Regards.

David

-- 
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 to get the model name of an object in template?

2010-08-04 Thread David.D
There's no django's built-in way?

On Aug 4, 10:37 pm, Scott Gould  wrote:
> How about writing a simple template tag that takes an object and
> returns object.__class__.__name__?
>
> On Aug 4, 10:20 am, "David.D"  wrote:
>
>
>
> >  I did it by adding this to my models:
> >         def get_model_name(self):
> >                 return self.__class__.__name__
>
> > And it works
>
> > But I don't want to define the 'get_model_name' method in my model.
>
> > Is there a built-in way?
>
> > 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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread Xavier Ordoquy
This relates to:
http://docs.djangoproject.com/en/dev/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names

Le 4 août 2010 à 17:02, André A. Santos a écrit :

> for exemple using MVC parttern how it works ->
>  
> M - model (Python)
> V - view (JSP)
> C - controller (Django or also Django on Model tier?)
> 
> On Wed, Aug 4, 2010 at 12:00 PM, André A. Santos  
> wrote:
> now i got it... thx
>  
> 
> 
>  
> On Wed, Aug 4, 2010 at 11:09 AM, Masklinn  wrote:
> On 2010-08-04, at 16:04 , André A. Santos wrote:
> > hmmm...
> > Dr thanks for answering... my doubt is if is better put the business rules
> > code on Python or Django... got it?
> >
> As Daniel indicated, your question doesn't make sense. Django is Python, 
> that's like asking whether you should write with a pen or with ink. Your pen 
> contains ink, so you're writing with ink in both cases.
> 
> Django is simply a Python library, so apart from when you're writing Django 
> templates you're writing Python code.
> 
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-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.
> 
> 
> 
> 
> -- 
> André Asantos
> Skype - andredecotia
> MSN - andre_deco...@hotmail.com
> 
> 
> 
> 
> 
> 
> 
> -- 
> André Asantos
> Skype - andredecotia
> MSN - andre_deco...@hotmail.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: View Decorator

2010-08-04 Thread Steve Holden
On 8/4/2010 10:52 AM, Dan Gentry wrote:
> When I attempt to use the decorator logic, the view becomes this:
> 
> views.py
> @institution_required
> def list_type(request):
> 
> inst_id=request.session.get('inst_id',None)
> 
> queryset = RecordType.objects.filter(institution=inst_id)
> return object_list(request, queryset, paginate_by = 12)
> 
> I don't make any changes to urls.py, but the error is
> "TemplateSyntaxError at /index
> Caught ImproperlyConfigured while rendering: The included urlconf
> person.urls doesn't have any patterns in it"
> However, when I take out the decorator, all of the urls work as
> expected.
> 
> urls.py does import * from views.py
> 

Your decorator takes two arguments - its signature is

  institution_required(fn, redirect_field_name=REDIRECT_FIELD_NAME)

But the decorator mechanism only allows you to specify one argument (the
decorated function). There is no way to specify anything OTHER than the
default value for the redirect_field_name argument ...

Therefore if you want to use decorators for this application you will
have to write something more complex still: a function that takes a
single redirect_field_name argument and /returns a decorator/ that can
be applied to views. Then you would call it as

@institution_required("Some_field_name")
def list_type(request):
  ...

Your call to institution_required should return a decorator. That takes
the decorated function as its single argument and returns the decorated
function. This is getting a little complex for a beginner.

regards
 Steve
-- 
I'm no expert.
"ex" == "has-been"; "spurt" == "drip under pressure"
"expert" == "has-been drip under pressure".

-- 
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, Rails but a cost to pay ?

2010-08-04 Thread Sithembewena Lloyd Dube
Surprising that anybody would be offended by the OP's post. Why do people so
readily see red? As for the "think special" part, one would have to be
pretty intent on getting upset to miss the sarcasm.

The English is not perfect, but this isn't a language course.



On Wed, Aug 4, 2010 at 4:24 PM, didier rano  wrote:

> Why Google has updated Youtube framework for Java, .NET and PHP, but not
> for Python ?
>
> It was a real question. I need it for my Python project. And, I don't
> understand why Google choose to update Java, .NET and PHP apis and not
> Python. It is my "cost to pay", because Python is not yet a mainstream
> language.
>
> I know these constraints, but my project will remain in Python. Actually,
> fun is more important for me.
>
> Some tools like pip, virtualenv, fabric, celery, twisted, tornado... make
> me confident about my choice.
>
> Finally, for me, Python or/and Django are not always a perfect choice. But,
> it is just an opinion.
>
> 2010/8/4 Eugene Wee 
>
> Hi,
>>
>> On Wed, Aug 4, 2010 at 3:21 AM, didier rano 
>> wrote:
>> > But, not all good developers
>> > are able to use efficiently dynamic languages.
>>
>> I suspect that there will always be a programming language for which
>> there exists a good developer who is currently unable to use it
>> efficiently. Programming languages are tools, and not everyone is
>> engaged in the same tasks, hence some will be more proficient with
>> some tools than others. So, find a good developer who is currently
>> able to use the programming language (and platform, framework, etc)
>> efficiently, or wait for for your good developer to catch up (which
>> will happen eventually, if he/she is any good).
>>
>> > And, sometimes, to choose an open source framework could be more
>> problematic
>> > than proprietary frameworks.
>>
>> And, sometimes, to choose a proprietary framework could be more
>> problematic than open source frameworks. You should show by reasoned
>> argument that choosing an open source framework tends to lead to more
>> problems than choosing a proprietary framework, otherwise you are just
>> making a vague assertion that does not really mean anything.
>>
>> > Why Google has updated Youtube framework for Java, .NET and PHP, but not
>> for
>> > Python ?
>>
>> Why did Google support Python for App Engine before Java? Why does it
>> still not support .NET and PHP? It really is quite ironic to see that
>> you wrote that '"Religions" wars are useless' :)
>>
>> Regards,
>> Eugene
>>
>> --
>> 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.
>>
>>
>
>
> --
> Didier Rano
> didier.r...@gmail.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.
>



-- 
Regards,
Sithembewena Lloyd Dube
http://www.lloyddube.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.



How to record users ip address every-time user logs in

2010-08-04 Thread vishy
Hi,

I want to record an entry in admin log,everytime a user logs in.How
can I do this.I am using django's default authentication modules.

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, Rails but a cost to pay ?

2010-08-04 Thread Masklinn
On 2010-08-04, at 17:35 , Sithembewena Lloyd Dube wrote:
> Surprising that anybody would be offended by the OP's post. Why do people so
> readily see red? As for the "think special" part, one would have to be
> pretty intent on getting upset to miss the sarcasm.

Surprising that anybody would read any comment in this thread as being offended 
by the OP's post. Why do people so readily jump to conclusions?

-- 
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: TypeError: decoding Unicode is not supported

2010-08-04 Thread Alec Shaner
I'm no expert on encodings so I can only suggest some alternatives that
might get around the issue:

First, maybe you can find something here:
http://docs.python.org/howto/unicode

You could try the literal method of generating a unicode string:

path = u'%s%s' % (ROOT, name)

Where exactly do you get the UnicodeEncodeError exception when you remove
the unicode calls?

On Wed, Aug 4, 2010 at 11:00 AM, sohesado  wrote:

> Well your example clarifies the problem. I removed the unicode calls.
>
> The initial problem was an  UnicodeEncodeError exception. I tried to
> solve it by encoding the strings to utf-8. It seems that's not the
> case.
> So i'm at square one.
>
> Note that..
> -with python manage.py runserver the app runs flawlessly.
> -With apache+mod-python i get an UnicodeEncodeError.
>
> So , it is an apache localization issue?
>
> My /etc/apache2/envvars contains
>
>
> 
> export APACHE_RUN_USER=www-data
> export APACHE_RUN_GROUP=www-data
> export APACHE_PID_FILE=/var/run/apache2.pid
>
> ## The locale used by some modules like mod_dav
> export LANG='el_GR.UTF8'<- also tried el_GR.UTF-8 variation
> export LC_ALL='el_GR.UTF8'
> ## Uncomment the following line to use the system default locale
> instead:
> #. /etc/default/locale
>
> export LANG
>
> -
>
> Have you got any clues what may cause the problem?
>
> Thank you for your help.
>
> On Aug 3, 11:31 pm, Alec Shaner  wrote:
> > unicode gives me nightmares.
> >
> > Taking django out of the picture for a moment:>>> unicode('foo', 'utf-8')
> > u'foo'
> > >>> unicode(u'foo', 'utf-8')
> >
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > TypeError: decoding Unicode is not supported
> >
> > So I would assume when you run it inside django you're already using a
> > unicode string. Do you need to pass the encoding argument ('utf-8') to
> > unicode?
> >
> > On Tue, Aug 3, 2010 at 3:30 PM, sohesado  wrote:
> > > Hi
> >
> > > I'm currently developing a django project and i've encountered a
> > > problem regarding Unicode string manipulation.
> >
> > > There is a backend python module in my project that perform's mainly
> > > shutil (shell utilities) tasks.
> >
> > > I get an TypeError: "decoding Unicode is not supported" exception
> > > while running the following method
> >
> > >
> -
> > > def create_base(name, reg):
> > >path = unicode(ROOT + name, 'utf-8')  error at this line
> > >shutil.copytree(ROOT + 'matrix', path)
> > >shutil.copystat(ROOT + 'matrix', path)
> >
> > >f = codecs.open(path + '/conf/local.php', "w", "UTF-8")
> > >tmp = unicode(" > >f.write(tmp)
> > >if not reg:
> > >f.write("$conf['disableactions'] = 'register';\n")
> >
> > >
> ---
> >
> > > The weird thing that puzzles me is that when i test the module in a
> > > python shell , the method runs flawlessly which yields me to the
> > > assumption that it's a django thing.
> > > By the way i use apache+mod-python as a web-server
> >
> > > I can't get adequate information regarding this type of exception. I'm
> > > stuck , please 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.
>
>

-- 
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, Rails but a cost to pay ?

2010-08-04 Thread Masklinn
On 2010-08-04, at 16:24 , didier rano wrote:
> Why Google has updated Youtube framework for Java, .NET and PHP, but not
> for Python ?
> 
> It was a real question.
It isn't, however, one which has any reason to be asked on this mailing list 
does it?

> because Python is not yet a mainstream language.
Uh… define "mainstream language"?

-- 
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 to get the model name of an object in template?

2010-08-04 Thread Scott Gould
Not that I'm aware of, in which case I'd say a tag (or even a filter)
*is* the "built-in way". No great hardship:

@register.filter
def class_name(value):
return value.__class__.__name__


On Aug 4, 11:13 am, "David.D"  wrote:
> There's no django's built-in way?
>
> On Aug 4, 10:37 pm, Scott Gould  wrote:
>
>
>
> > How about writing a simple template tag that takes an object and
> > returns object.__class__.__name__?
>
> > On Aug 4, 10:20 am, "David.D"  wrote:
>
> > >  I did it by adding this to my models:
> > >         def get_model_name(self):
> > >                 return self.__class__.__name__
>
> > > And it works
>
> > > But I don't want to define the 'get_model_name' method in my model.
>
> > > Is there a built-in way?
>
> > > 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: multi_db support for doctests? How to enable?

2010-08-04 Thread Reinout van Rees

On 08/04/2010 01:49 PM, Russell Keith-Magee wrote:


Doctests don't do any database flushing, so there is no analog for the
multi-db flag. Just make your calls on the database as you normally
would.


Ah, ok.

Then I'm doing something else wrong (I've only got doctests right now): 
my second database isn't created by the test mechanism.  I added a 
regular unittest with the multi_db=True, but that also didn't result in 
a second database.


The code *does* use the regular database (sqlite, if available), but it 
doesn't create a test database like it does for the default database.


The relevant part from my testsettings.py:

DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.spatialite',
'NAME': 'test.db',
},
'fews-unblobbed': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'testunblobbed.db',
}
}

No special options, I'd say.  The test database *used* to get created 
when I last ran the tests a few weeks ago, now that I think about it. 
I'll have to do some more debugging.



Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
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, Rails but a cost to pay ?

2010-08-04 Thread Steve Holden
I don't believe anybody *was* offended - the OP asked "What do you think
about this post ?", and he got sincere responses that would, if taken to
heart, help to improve that post.

regards
 Steve

On 8/4/2010 11:35 AM, Sithembewena Lloyd Dube wrote:
> Surprising that anybody would be offended by the OP's post. Why do
> people so readily see red? As for the "think special" part, one would
> have to be pretty intent on getting upset to miss the sarcasm.
> 
> The English is not perfect, but this isn't a language course.
> 
> 
> 
> On Wed, Aug 4, 2010 at 4:24 PM, didier rano  > wrote:
> 
> Why Google has updated Youtube framework for Java, .NET and PHP, but
> not for Python ?
> 
> It was a real question. I need it for my Python project. And, I
> don't understand why Google choose to update Java, .NET and PHP apis
> and not Python. It is my "cost to pay", because Python is not yet a
> mainstream language.
> 
> I know these constraints, but my project will remain in Python.
> Actually, fun is more important for me.
> 
> Some tools like pip, virtualenv, fabric, celery, twisted, tornado...
> make me confident about my choice.
> 
> Finally, for me, Python or/and Django are not always a perfect
> choice. But, it is just an opinion.
> 
> 2010/8/4 Eugene Wee  >
> 
> Hi,
> 
> On Wed, Aug 4, 2010 at 3:21 AM, didier rano
> mailto:didier.r...@gmail.com>> wrote:
> > But, not all good developers
> > are able to use efficiently dynamic languages.
> 
> I suspect that there will always be a programming language for which
> there exists a good developer who is currently unable to use it
> efficiently. Programming languages are tools, and not everyone is
> engaged in the same tasks, hence some will be more proficient with
> some tools than others. So, find a good developer who is currently
> able to use the programming language (and platform, framework, etc)
> efficiently, or wait for for your good developer to catch up (which
> will happen eventually, if he/she is any good).
> 
> > And, sometimes, to choose an open source framework could be
> more problematic
> > than proprietary frameworks.
> 
> And, sometimes, to choose a proprietary framework could be more
> problematic than open source frameworks. You should show by reasoned
> argument that choosing an open source framework tends to lead to
> more
> problems than choosing a proprietary framework, otherwise you
> are just
> making a vague assertion that does not really mean anything.
> 
> > Why Google has updated Youtube framework for Java, .NET and
> PHP, but not for
> > Python ?
> 
> Why did Google support Python for App Engine before Java? Why
> does it
> still not support .NET and PHP? It really is quite ironic to see
> that
> you wrote that '"Religions" wars are useless' :)
> 
> Regards,
> Eugene
> 
> --
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To post to this group, send email to
> django-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> 
> -- 
> Didier Rano
> didier.r...@gmail.com 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
> 
> 
> 
> 
> -- 
> Regards,
> Sithembewena Lloyd Dube
> http://www.lloyddube.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.


-- 
I'm no expert.
"ex" == "has-been"; "spurt" == "drip under pressure"
"expert" == "has-been drip under pressure".

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to thi

Re: Django, Rails but a cost to pay ?

2010-08-04 Thread didier rano
About "mainstream language"...

If you ask to Java, C# developers about Python, then some of them should be
know Python and have a good definition about it.
If you ask to Java developers about C#, then all of them should be know it
and have a good definition about it.
If you ask to C# developers about Java, then all of them should be know it
and have a good definition about it.
If you ask to Python developers about C# or Java, then all of them should be
know them and have a good definition about them.

2010/8/4 Masklinn 

> On 2010-08-04, at 16:24 , didier rano wrote:
> > Why Google has updated Youtube framework for Java, .NET and PHP, but not
> > for Python ?
> >
> > It was a real question.
> It isn't, however, one which has any reason to be asked on this mailing
> list does it?
>
> > because Python is not yet a mainstream language.
> Uh… define "mainstream language"?
>
> --
> 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.
>
>


-- 
Didier Rano
didier.r...@gmail.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: Django, Rails but a cost to pay ?

2010-08-04 Thread didier rano
Effectively, my next post should be better. Maybe focus on more technical
subjects. And, I would like to work with someone to correct my bad english !

2010/8/4 Steve Holden 

> I don't believe anybody *was* offended - the OP asked "What do you think
> about this post ?", and he got sincere responses that would, if taken to
> heart, help to improve that post.
>
> regards
>  Steve
>
> On 8/4/2010 11:35 AM, Sithembewena Lloyd Dube wrote:
> > Surprising that anybody would be offended by the OP's post. Why do
> > people so readily see red? As for the "think special" part, one would
> > have to be pretty intent on getting upset to miss the sarcasm.
> >
> > The English is not perfect, but this isn't a language course.
> >
> >
> >
> > On Wed, Aug 4, 2010 at 4:24 PM, didier rano  > > wrote:
> >
> > Why Google has updated Youtube framework for Java, .NET and PHP, but
> > not for Python ?
> >
> > It was a real question. I need it for my Python project. And, I
> > don't understand why Google choose to update Java, .NET and PHP apis
> > and not Python. It is my "cost to pay", because Python is not yet a
> > mainstream language.
> >
> > I know these constraints, but my project will remain in Python.
> > Actually, fun is more important for me.
> >
> > Some tools like pip, virtualenv, fabric, celery, twisted, tornado...
> > make me confident about my choice.
> >
> > Finally, for me, Python or/and Django are not always a perfect
> > choice. But, it is just an opinion.
> >
> > 2010/8/4 Eugene Wee  > >
> >
> > Hi,
> >
> > On Wed, Aug 4, 2010 at 3:21 AM, didier rano
> > mailto:didier.r...@gmail.com>> wrote:
> > > But, not all good developers
> > > are able to use efficiently dynamic languages.
> >
> > I suspect that there will always be a programming language for
> which
> > there exists a good developer who is currently unable to use it
> > efficiently. Programming languages are tools, and not everyone is
> > engaged in the same tasks, hence some will be more proficient
> with
> > some tools than others. So, find a good developer who is
> currently
> > able to use the programming language (and platform, framework,
> etc)
> > efficiently, or wait for for your good developer to catch up
> (which
> > will happen eventually, if he/she is any good).
> >
> > > And, sometimes, to choose an open source framework could be
> > more problematic
> > > than proprietary frameworks.
> >
> > And, sometimes, to choose a proprietary framework could be more
> > problematic than open source frameworks. You should show by
> reasoned
> > argument that choosing an open source framework tends to lead to
> > more
> > problems than choosing a proprietary framework, otherwise you
> > are just
> > making a vague assertion that does not really mean anything.
> >
> > > Why Google has updated Youtube framework for Java, .NET and
> > PHP, but not for
> > > Python ?
> >
> > Why did Google support Python for App Engine before Java? Why
> > does it
> > still not support .NET and PHP? It really is quite ironic to see
> > that
> > you wrote that '"Religions" wars are useless' :)
> >
> > Regards,
> > Eugene
> >
> > --
> > You received this message because you are subscribed to the
> > Google Groups "Django users" group.
> > To post to this group, send email to
> > django-users@googlegroups.com
> > .
> > To unsubscribe from this group, send email to
> > 
> > django-users+unsubscr...@googlegroups.com
> > 
> >  >.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
> >
> >
> > --
> > Didier Rano
> > didier.r...@gmail.com 
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com
> > .
> > To unsubscribe from this group, send email to
> > 
> > django-users+unsubscr...@googlegroups.com
> > 
> >  >.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> >
> >
> >
> > --
> > Regards,
> > Sithembewena Lloyd Dube
> > http://www.lloyddube.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.co

Re: multi_db support for doctests? How to enable?

2010-08-04 Thread Xavier Ordoquy
Hi,

The second database should be created. Maybe you want to double check you setup 
a database router.
You also want to take care to fixture file name which expects you to add the 
database name in the file name.

So far, the only issue I found with testing on multi database is that django 
1.2 expects all the tables are created on the second database which may not 
always be the case (bug reported, I just uploaded a patch for that).

Regards,
Xavier.

Le 4 août 2010 à 17:55, Reinout van Rees a écrit :

> On 08/04/2010 01:49 PM, Russell Keith-Magee wrote:
>> 
>> Doctests don't do any database flushing, so there is no analog for the
>> multi-db flag. Just make your calls on the database as you normally
>> would.
> 
> Ah, ok.
> 
> Then I'm doing something else wrong (I've only got doctests right now): my 
> second database isn't created by the test mechanism.  I added a regular 
> unittest with the multi_db=True, but that also didn't result in a second 
> database.
> 
> The code *does* use the regular database (sqlite, if available), but it 
> doesn't create a test database like it does for the default database.
> 
> The relevant part from my testsettings.py:
> 
> DATABASES = {
>'default': {
>'ENGINE': 'django.contrib.gis.db.backends.spatialite',
>'NAME': 'test.db',
>},
>'fews-unblobbed': {
>'ENGINE': 'django.db.backends.sqlite3',
>'NAME': 'testunblobbed.db',
>}
>}
> 
> No special options, I'd say.  The test database *used* to get created when I 
> last ran the tests a few weeks ago, now that I think about it. I'll have to 
> do some more debugging.
> 
> 
> Reinout
> 
> 
> -- 
> Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
> Programmer at http://www.nelen-schuurmans.nl
> "Military engineers build missiles. Civil engineers build targets"
> 
> -- 
> 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: Django, Rails but a cost to pay ?

2010-08-04 Thread Xavier Ordoquy


> If you ask to Java, C# developers about Python, then some of them should be 
> know Python and have a good definition about it. 
> If you ask to Java developers about C#, then all of them should be know it 
> and have a good definition about it. 
> If you ask to C# developers about Java, then all of them should be know it 
> and have a good definition about it. 
> If you ask to Python developers about C# or Java, then all of them should be 
> know them and have a good definition about them. 

Which means marketing services did a good job on C# and Java.
I can't speak for C# but I whished Java devs were as good as programming Java 
as they are advocating it.

Regards,
Xavier.

-- 
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, Rails but a cost to pay ?

2010-08-04 Thread didier rano
One more thing... I have an iphone and a macbook air !!!

It could be dangerous to imagine be "different". Sometimes it is my case
too.

2010/8/4 didier rano 

> Effectively, my next post should be better. Maybe focus on more technical
> subjects. And, I would like to work with someone to correct my bad english !
>
> 2010/8/4 Steve Holden 
>
> I don't believe anybody *was* offended - the OP asked "What do you think
>> about this post ?", and he got sincere responses that would, if taken to
>> heart, help to improve that post.
>>
>> regards
>>  Steve
>>
>> On 8/4/2010 11:35 AM, Sithembewena Lloyd Dube wrote:
>> > Surprising that anybody would be offended by the OP's post. Why do
>> > people so readily see red? As for the "think special" part, one would
>> > have to be pretty intent on getting upset to miss the sarcasm.
>> >
>> > The English is not perfect, but this isn't a language course.
>> >
>> >
>> >
>> > On Wed, Aug 4, 2010 at 4:24 PM, didier rano > > > wrote:
>> >
>> > Why Google has updated Youtube framework for Java, .NET and PHP, but
>> > not for Python ?
>> >
>> > It was a real question. I need it for my Python project. And, I
>> > don't understand why Google choose to update Java, .NET and PHP apis
>> > and not Python. It is my "cost to pay", because Python is not yet a
>> > mainstream language.
>> >
>> > I know these constraints, but my project will remain in Python.
>> > Actually, fun is more important for me.
>> >
>> > Some tools like pip, virtualenv, fabric, celery, twisted, tornado...
>> > make me confident about my choice.
>> >
>> > Finally, for me, Python or/and Django are not always a perfect
>> > choice. But, it is just an opinion.
>> >
>> > 2010/8/4 Eugene Wee > > >
>> >
>> > Hi,
>> >
>> > On Wed, Aug 4, 2010 at 3:21 AM, didier rano
>> > mailto:didier.r...@gmail.com>> wrote:
>> > > But, not all good developers
>> > > are able to use efficiently dynamic languages.
>> >
>> > I suspect that there will always be a programming language for
>> which
>> > there exists a good developer who is currently unable to use it
>> > efficiently. Programming languages are tools, and not everyone
>> is
>> > engaged in the same tasks, hence some will be more proficient
>> with
>> > some tools than others. So, find a good developer who is
>> currently
>> > able to use the programming language (and platform, framework,
>> etc)
>> > efficiently, or wait for for your good developer to catch up
>> (which
>> > will happen eventually, if he/she is any good).
>> >
>> > > And, sometimes, to choose an open source framework could be
>> > more problematic
>> > > than proprietary frameworks.
>> >
>> > And, sometimes, to choose a proprietary framework could be more
>> > problematic than open source frameworks. You should show by
>> reasoned
>> > argument that choosing an open source framework tends to lead to
>> > more
>> > problems than choosing a proprietary framework, otherwise you
>> > are just
>> > making a vague assertion that does not really mean anything.
>> >
>> > > Why Google has updated Youtube framework for Java, .NET and
>> > PHP, but not for
>> > > Python ?
>> >
>> > Why did Google support Python for App Engine before Java? Why
>> > does it
>> > still not support .NET and PHP? It really is quite ironic to see
>> > that
>> > you wrote that '"Religions" wars are useless' :)
>> >
>> > Regards,
>> > Eugene
>> >
>> > --
>> > You received this message because you are subscribed to the
>> > Google Groups "Django users" group.
>> > To post to this group, send email to
>> > django-users@googlegroups.com
>> > .
>> > To unsubscribe from this group, send email to
>> > 
>> > django-users+unsubscr...@googlegroups.com
>> > 
>> > > >.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>> >
>> >
>> > --
>> > Didier Rano
>> > didier.r...@gmail.com 
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com
>> > .
>> > To unsubscribe from this group, send email to
>> > 
>> > django-users+unsubscr...@googlegroups.com
>> > 
>> > > >.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django

Re: Django, Rails but a cost to pay ?

2010-08-04 Thread Masklinn
On 2010-08-04, at 17:59 , didier rano wrote:
> About "mainstream language"...
> 
> If you ask to Java, C# developers about Python, then some of them should be
> know Python and have a good definition about it.
> If you ask to Java developers about C#, then all of them should be know it
> and have a good definition about it.
> If you ask to C# developers about Java, then all of them should be know it
> and have a good definition about it.
> If you ask to Python developers about C# or Java, then all of them should be
> know them and have a good definition about them.

So by your definition Fortran is a mainstream language, but Objective-C 
probably isn't?

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

2010-08-04 Thread Daniel França
I'm using Editra now, it seems fine and lightweight and have plugin support.

2010/8/4 Рогалевич (Ковалевич) 

> gedit + plugins + snippets is easier to learn than vim(gvim) and looks more
> beautiful :) , but on windows there is bad support of python plugins (if you
> really need to develop on win)
> vim may be more flexible
> Wing IDE not free. I meant version with django support
> (http://wingware.com/wingide/features)
>
>
> On 4 August 2010 07:15, Alexander Jeliuc  wrote:
>
>> gvim, emacs, eclipse, eric
>>
>>
>> On Wed, Aug 4, 2010 at 6:50 AM, Nick Arnett wrote:
>>
>>>
>>>
>>> On Sun, Jul 18, 2010 at 10:19 AM, Biju Varghese 
>>> wrote:
>>>
 Eclipse is the best IDE for python and django.


>>> I don't know if it is actually the best, but I'm happy with it.
>>>
>>> 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.
>>>
>>
>>  --
>> 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.



Re: Django IDE

2010-08-04 Thread Masklinn
On 2010-08-04, at 06:15 , Alexander Jeliuc wrote:
> gvim, emacs, eclipse, eric

Don't forget pycharm, whose specific Django support is one of the majorly 
pushed features.

-- 
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: Free Django Hosting

2010-08-04 Thread roberto
Free django hosting:
http://www.alwaysdata.com/

Two details:
- It is in French.
- Not sure if it is allowed for commercial sites so please, be
careful.

Good luck !


On Aug 4, 3:38 am, kostia  wrote:
> I'm looking for private person from some government institution/
> university or with his own hosting server. The web site will be
> launched for a couple of months. Than I will find payed hosting
> provider and now I just want the site to be published.

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



overriding model.save()

2010-08-04 Thread Sells, Fred
I would like to prevent saving a new value if the database contains a
specific value.  This is on a per field, per record basis.

If I override the save() method; is there a way to find the existing (in
the DB) values and the new (to be stored) values?

-- 
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, Rails but a cost to pay ?

2010-08-04 Thread didier rano
I think that you know the answer, no ?

Fortran was a mainstream language
Objective-C is not a mainstream language.

But, mainstream language doesn't mean that these languages are the best.

Python is a good language, and same for Java, C#, Objective-C or Fortran.
Cobol is a good language (Hum, sorry but not for me !)


2010/8/4 Masklinn 

> On 2010-08-04, at 17:59 , didier rano wrote:
> > About "mainstream language"...
> >
> > If you ask to Java, C# developers about Python, then some of them should
> be
> > know Python and have a good definition about it.
> > If you ask to Java developers about C#, then all of them should be know
> it
> > and have a good definition about it.
> > If you ask to C# developers about Java, then all of them should be know
> it
> > and have a good definition about it.
> > If you ask to Python developers about C# or Java, then all of them should
> be
> > know them and have a good definition about them.
>
> So by your definition Fortran is a mainstream language, but Objective-C
> probably isn't?
>
> --
> 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.
>
>


-- 
Didier Rano
didier.r...@gmail.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: Django, Rails but a cost to pay ?

2010-08-04 Thread Masklinn
On 2010-08-04, at 19:30 , didier rano wrote:
> I think that you know the answer, no ?
Of course. The answer is that you're making up everything on the spot and 
arbitrarily tagging languages as "mainstream" or "non-mainstream" in a feeble 
attempt to try and support whatever point you believe having.

-- 
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, Rails but a cost to pay ?

2010-08-04 Thread didier rano
Back to django development ?

2010/8/4 Masklinn 

> On 2010-08-04, at 19:30 , didier rano wrote:
> > I think that you know the answer, no ?
> Of course. The answer is that you're making up everything on the spot and
> arbitrarily tagging languages as "mainstream" or "non-mainstream" in a
> feeble attempt to try and support whatever point you believe having.
>
> --
> 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.
>
>


-- 
Didier Rano
didier.r...@gmail.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: Django, Rails but a cost to pay ?

2010-08-04 Thread Steve Holden
On 8/4/2010 1:38 PM, didier rano wrote:
> Back to django development ?
> 
Probably the best idea.

regards
 Steve
-- 
I'm no expert.
"ex" == "has-been"; "spurt" == "drip under pressure"
"expert" == "has-been drip under pressure".

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



Uploading Large Files Through Django

2010-08-04 Thread brodle
Im working on an application which will act as a middleware between my
CMS (multiple) and my Video provider. People will be uploading files
through this django application.

Im currently leveraging Django built in file upload handler with the
default settings for chunking. We run django under mod_wsgi..

Initial test showed that files around 500MB made it up.  We ran into a
couple of examples of files larger than 500MB failing with a
connection reset by peer

[Mon Aug 02 23:09:53 2010] [error] [client 69.2.101.4] (104)Connection
reset by peer: mod_wsgi (pid=4552): Unable to get bucket brigade for
request., referer: http://video-uploads-stage.

We are pretty sure the client failed on this and not the application.

We've just installed the django Gzip middleware to hopefully aid us in
the file transfer by having the client gzip the requests.

I am thinking of leveraging Yahoos Yui Upload to streamline the
process. http://developer.yahoo.com/yui/uploader/

Im curious if anyone has any suggestions around handling file uploads
through 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-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: moving to django 1.2.1

2010-08-04 Thread dadeng
Hi,

I have tried to follow the tutorial for 1.2.1 but i'm having problems
the explanation for adding __unicode__() or __str__() to the class to
make it to list the polls correctly without any success.

addition of this code did not really fix anything in the polls
listings;

lass Poll(models.Model):
# ...
def __unicode__(self):
return self.question

class Choice(models.Model):
# ...
def __unicode__(self):
return self.choice

This is all that it has returned;

[]

What is wrong?

David


On Aug 2, 1:31 pm, tiemonster  wrote:
> Thank you so much for the valuable feedback regare ding my post. I value
> peer review, and take it very seriously. I've updated the article to
> attempt to address your concerns. Please review it at your convenience
> to ensure that your concerns are addressed appropriately.
>
> http://www.tiemonster.info/a/24005/
>
> Regards,
> Mark Cahill
>
> On Jul 31, 11:49 am, Russell Keith-Magee 
> wrote:> On Fri, Jul 30, 2010 at 8:14 PM, tiemonster  
> wrote:
> > > I cover some of the new changes in Django 1.2 in this article:
> > >http://www.tiemonster.info/a/24005/
>
> > > Most of this information comes straight from the changelist. Others
> > > were things that the core developers must have assumed were common
> > > sense, but that I didn't think about when upgrading. If you run across
> > > anything that's not on the list, let me know and I'll update the
> > > article.
>
> > Hi Mark,
>
> > Since this conversation is happening in the context of a backwards
> > compatibility discussion, I want to provide some clarification to a
> > couple of elements of your blog post:
>
> >  * Although we have introduced a new format for defining databases,
> > you aren't required to make any modifications in order to upgrade.
> > Old-style DATABASE_* settings will continue to work, as the release
> > notes describe [1].
>
> > [1]http://docs.djangoproject.com/en/dev/releases/1.2/#specifying-databases
>
> >  * The problem with database caching isn't a backwards incompatible
> > problem; it's a bug with the database cache backend when used with
> > multiple database support. Since Django 1.1 didn't have support for
> > multiple databases, it's impossible for a Django 1.1 project to
> > experience a backwards incompatibility problem here. It is, however, a
> > bug in the a Django 1.2 feature. Ticket #13946 is tracking the
> > problem; it is on my radar, and I've just updated the triage state to
> > ensure that it doesn't get forgotten.
>
> >  * If you have an existing project, the introduction of CSRF
> > protection in Django 1.2 shouldn't pose any obstacle to upgrading.
> > CSRF protection is turned on by default in new projects, but you need
> > to manually turn it on for existing projects (i.e., you need to add
> > the new middleware). If you don't add the new middleware, you don't
> > need to do anything in order to run your project under Django 1.2. The
> > only potential backwards incompatibility is if you have written custom
> > templates to override the default templates provided by Django's admin
> > -- but this is clearly highlighted in the release notes [2].
>
> > [2]http://docs.djangoproject.com/en/dev/releases/1.2/#csrf-protection
>
> >  * Your comments about messages correctly points out that the changes
> > are completely transparent, and require no immediate action for
> > compatibility.
>
> >  * I don't know where you've got your information on the changes to
> > the unit test system, but your comments are (to use a complex Latin
> > term) wrong :-) The example you point to [3] is exactly the same
> > example that existed in the docs for Django 1.1 [4] and Django 1.0
> > [5]. Django's Test Client has never had a dependency on either the
> > base unittest library or Django's own unittest extensions. Django 1.2
> > didn't introduce any significant changes to the test client. There
> > were some changes to the test runner -- the utility that sets up and
> > executes the test environment -- but again, those changes should be
> > completely transparent, and require no immediate change when
> > upgrading.
>
> > [3]http://docs.djangoproject.com/en/1.2/topics/testing/#example
> > [4]http://docs.djangoproject.com/en/1.1/topics/testing/#example
> > [5]http://docs.djangoproject.com/en/1.0/topics/testing/#example
>
> >  * Your point about admin media is generally good advice, but isn't a
> > backwards compatibility problem. Yes, Django 1.2 has new admin media
> > files, and you will need to have a complete and correct checkout of
> > those files served by your media provider (CDN or otherwise).
>
> > As I said previously, we take backwards compatibility very seriously
> > as a project. Unless you have been tinkering with internals or relying
> > on behavior that is buggy, you should be able to upgrade from Django
> > 1.1 to Django 1.2 without being required to make *any* changes to your
> > code. This has been my experience on all projects that I have updated.
> > If anyon

Re: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread André A . Santos
thanks

On Wed, Aug 4, 2010 at 12:28 PM, Xavier Ordoquy wrote:

> This relates to:
>
> http://docs.djangoproject.com/en/dev/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names
>
> Le 4 août 2010 à 17:02, André A. Santos a écrit :
>
> for exemple using MVC parttern how it works ->
>
> M - model (Python)
> V - view (JSP)
> C - controller (Django or also Django on Model tier?)
>
> On Wed, Aug 4, 2010 at 12:00 PM, André A. Santos <
> ti.andreasan...@gmail.com> wrote:
>
>> now i got it... thx
>>
>>
>>
>>
>> On Wed, Aug 4, 2010 at 11:09 AM, Masklinn  wrote:
>>
>>> On 2010-08-04, at 16:04 , André A. Santos wrote:
>>> > hmmm...
>>> > Dr thanks for answering... my doubt is if is better put the business
>>> rules
>>> > code on Python or Django... got it?
>>> >
>>> As Daniel indicated, your question doesn't make sense. Django is Python,
>>> that's like asking whether you should write with a pen or with ink. Your pen
>>> contains ink, so you're writing with ink in both cases.
>>>
>>> Django is simply a Python library, so apart from when you're writing
>>> Django templates you're writing Python code.
>>>
>>> --
>>>  You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To post to this group, send email to django-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.
>>>
>>>
>>
>>
>>  --
>> André Asantos
>> Skype - andredecotia
>> MSN - andre_deco...@hotmail.com
>>
>>
>>
>>
>>
>
>
> --
> André Asantos
> Skype - andredecotia
> MSN - andre_deco...@hotmail.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.
>



-- 
André Asantos
Skype - andredecotia
MSN - andre_deco...@hotmail.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: How to get the model name of an object in template?

2010-08-04 Thread David.D
I just wonder if there's some way requires writing nothing. Just like
an attribute.

thanks.

On Aug 4, 11:53 pm, Scott Gould  wrote:
> Not that I'm aware of, in which case I'd say a tag (or even a filter)
> *is* the "built-in way". No great hardship:
>
> @register.filter
> def class_name(value):
>     return value.__class__.__name__
>
> On Aug 4, 11:13 am, "David.D"  wrote:
>
>
>
> > There's no django's built-in way?
>
> > On Aug 4, 10:37 pm, Scott Gould  wrote:
>
> > > How about writing a simple template tag that takes an object and
> > > returns object.__class__.__name__?
>
> > > On Aug 4, 10:20 am, "David.D"  wrote:
>
> > > >  I did it by adding this to my models:
> > > >         def get_model_name(self):
> > > >                 return self.__class__.__name__
>
> > > > And it works
>
> > > > But I don't want to define the 'get_model_name' method in my model.
>
> > > > Is there a built-in way?
>
> > > > 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: Free Django Hosting

2010-08-04 Thread Mykola Lys
I have one dedicated server of my client where we are hosting Plone/
Django sites.
Just mail me and I believe can help you with hosting for a while.

Bests,
Mykola Lys.

On 3 Сер, 19:57, kostia  wrote:
> I'm looking for a free Django hosting. Please, write me, if you can
> help.
>
> The web site will look like this onehttp://kostia.pythonic.nl

-- 
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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread Renne Rocha
  André,

  It seems that you don't understand what Django is. Your question
make no sense.

  Take a look at this website: www.aprendendodjango.com/ (it is in portuguese)

  It will explain what Django is and what you can do with it.



On Wed, Aug 4, 2010 at 12:02 PM, André A. Santos
 wrote:
> for exemple using MVC parttern how it works ->
>
> M - model (Python)
> V - view (JSP)
> C - controller (Django or also Django on Model tier?)
>
> On Wed, Aug 4, 2010 at 12:00 PM, André A. Santos 
> wrote:
>>
>> now i got it... thx
>>
>>
>>
>> On Wed, Aug 4, 2010 at 11:09 AM, Masklinn  wrote:
>>>
>>> On 2010-08-04, at 16:04 , André A. Santos wrote:
>>> > hmmm...
>>> > Dr thanks for answering... my doubt is if is better put the business
>>> > rules
>>> > code on Python or Django... got it?
>>> >
>>> As Daniel indicated, your question doesn't make sense. Django is Python,
>>> that's like asking whether you should write with a pen or with ink. Your pen
>>> contains ink, so you're writing with ink in both cases.
>>>
>>> Django is simply a Python library, so apart from when you're writing
>>> Django templates you're writing Python code.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-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.
>>>
>>
>>
>>
>> --
>> André Asantos
>> Skype - andredecotia
>> MSN - andre_deco...@hotmail.com
>>
>>
>>
>
>
>
> --
> André Asantos
> Skype - andredecotia
> MSN - andre_deco...@hotmail.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: Announces django-guardian: per object permissions for Django 1.2

2010-08-04 Thread lukaszb
Welll, at the django.contrib.auth there are only those (User and
Group) models for which one may define permission sets and I wanted
guardian to be as simply as possible - so it is not possible to assign
permission to other model even if it "groups  users". At one point I
thought it could be nice to implement some kind of "roles" but I've
finally decided it would be better to stick to facilites provided by
new Django version.

On the other hand, I'm not sure if it is needed to create new
"grouping models" - I often use intermediate models for this (i.e.
Team model with fk to Group among other fields). Let me know if you
have different experience.

On 4 Sie, 15:26, derek  wrote:
> On Aug 4, 1:20 am, lukaszb  wrote:
>
>
>
>
>
> > Hi all,
>
> > I'd like to announce django-guardian - very basic yet usable per
> > object permissions
> > implementation for Django 1.2, using new authorization backend
> > facilities.
>
> > It was created during 2 days sprint, code have been released and may
> > be found athttp://github.com/lukaszb/django-guardian/.
> > Documentation is available athttp://packages.python.org/django-guardian/.
>
> > Currently I think there should be better integration with admin app
> > and some shortcuts (permission assignment/removal)
> > should support table-level permissions as well.
>
> > If you spot a bug or have an idea how to improve this little app,
> > please spare a minute at issue tracker, which is located 
> > athttp://github.com/lukaszb/django-guardian/issues.
>
> > Hope someone would find this useful.
>
> No doubt this will be extremely useful!  For me, integration with the
> Django admin is a must, though, as permissions will need to be
> assigned by users themselves via the standard interface.
>
> One (maybe stupid) question:  Can rights only be assigned to the pre-
> specified "Group", or can any model that handles user grouping (I have
> some custom ones in my app) be used?
>
> 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.



Re: Django IDE

2010-08-04 Thread bagheera
For python/django development i'm using... NetBeans! It fails to  
autocomplete items properly, but still, i find it most comfortable also  
for html, javaScript, CSS.

Sometimes i use Geany, it's really simple, yet nice IDE.
All under Linux.

--
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: Announces django-guardian: per object permissions for Django 1.2

2010-08-04 Thread lukaszb
Thanks for the comment! I really do think that this "backends ready &&
included" parts of Django are extremely useful (and fun to extend if
needed).

About the admin, I haven't really get into admin integration yet as I
cannot answer this: should user with "flatpages.change_flatpage"
permission for flatpage instance be able to edit it at admin if he/she
doesn't have "flatpage.change_flatpage" global permission? I'm just
stuck here - I suppose it would be good to "turn off" ability to
change some objects for user with this global "app.change_obj"
permission removal. On the other hand, wouldn't it be too much to give
such global permission for user if we intend to allow him/her to
change only single object?

Am not sure if I should start such discussion here but I just couldn't
resist :)



On 4 Sie, 01:34, Russell Keith-Magee  wrote:
> On Wed, Aug 4, 2010 at 7:20 AM, lukaszb  wrote:
> > Hi all,
>
> > I'd like to announce django-guardian - very basic yet usable per
> > object permissions
> > implementation for Django 1.2, using new authorization backend
> > facilities.
>
> > It was created during 2 days sprint, code have been released and may
> > be found athttp://github.com/lukaszb/django-guardian/.
> > Documentation is available athttp://packages.python.org/django-guardian/.
>
> > Currently I think there should be better integration with admin app
> > and some shortcuts (permission assignment/removal)
> > should support table-level permissions as well.
>
> > If you spot a bug or have an idea how to improve this little app,
> > please spare a minute at issue tracker, which is located at
> >http://github.com/lukaszb/django-guardian/issues.
>
> > Hope someone would find this useful.
>
> > Take care,
> > Lukasz
>
> Hi Lukasz,
>
> Great stuff! Thanks for taking the effort to implement this and put it
> out in the open. It's a fantastic example of the sort of thing that
> can be very useful without needing to be part of core, which is the
> reason that we put the object-based permissions API into the auth
> backends.
>
> Regarding admin app integration -- integration of object-level
> permissions with the admin app is one area where I am aware there are
> some bugs (or, at least, some areas where the object-based permissions
> API isn't being used as it should). This aspect of Django's admin
> could do with some attention, so if your experience of implementing an
> object-based permissions backend has you contemplating a bigger
> project, auditing the admin for adherence to object-based permissions
> could be an interesting candidate.
>
> 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-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: Must I put the rules logic on Python or Django code and why?

2010-08-04 Thread André A . Santos
wow thank you so much... you have helped me a lot...
AS

On Wed, Aug 4, 2010 at 3:48 PM, Renne Rocha  wrote:

>  André,
>
>  It seems that you don't understand what Django is. Your question
> make no sense.
>
>  Take a look at this website: www.aprendendodjango.com/ (it is in
> portuguese)
>
>  It will explain what Django is and what you can do with it.
>
>
>
> On Wed, Aug 4, 2010 at 12:02 PM, André A. Santos
>  wrote:
> > for exemple using MVC parttern how it works ->
> >
> > M - model (Python)
> > V - view (JSP)
> > C - controller (Django or also Django on Model tier?)
> >
> > On Wed, Aug 4, 2010 at 12:00 PM, André A. Santos <
> ti.andreasan...@gmail.com>
> > wrote:
> >>
> >> now i got it... thx
> >>
> >>
> >>
> >> On Wed, Aug 4, 2010 at 11:09 AM, Masklinn 
> wrote:
> >>>
> >>> On 2010-08-04, at 16:04 , André A. Santos wrote:
> >>> > hmmm...
> >>> > Dr thanks for answering... my doubt is if is better put the business
> >>> > rules
> >>> > code on Python or Django... got it?
> >>> >
> >>> As Daniel indicated, your question doesn't make sense. Django is
> Python,
> >>> that's like asking whether you should write with a pen or with ink.
> Your pen
> >>> contains ink, so you're writing with ink in both cases.
> >>>
> >>> Django is simply a Python library, so apart from when you're writing
> >>> Django templates you're writing Python code.
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Django users" group.
> >>> To post to this group, send email to django-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.
> >>>
> >>
> >>
> >>
> >> --
> >> André Asantos
> >> Skype - andredecotia
> >> MSN - andre_deco...@hotmail.com
> >>
> >>
> >>
> >
> >
> >
> > --
> > André Asantos
> > Skype - andredecotia
> > MSN - andre_deco...@hotmail.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.
>
>


-- 
André Asantos
Skype - andredecotia
MSN - andre_deco...@hotmail.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: TypeError: decoding Unicode is not supported

2010-08-04 Thread sohesado



On Aug 4, 6:48 pm, Alec Shaner  wrote:
> I'm no expert on encodings so I can only suggest some alternatives that
> might get around the issue:
>

> First, maybe you can find something here:http://docs.python.org/howto/unicode

i've read , pretty much everything,  available at docs.python.org
regarding unicode.

> You could try the literal method of generating a unicode string:
>
> path = u'%s%s' % (ROOT, name)
tried it. The problem persists
> Where exactly do you get the UnicodeEncodeError exception when you remove
> the unicode calls?

I get the the exception at this line -> shutil.copytree(ROOT +
'matrix', path)

And the traceback...

Traceback:
File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py" in get_response
  100. response = callback(request,
*callback_args, **callback_kwargs)
File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
decorators.py" in _wrapped_view
  25. return view_func(request, *args, **kwargs)
File "/home/sohesado/codein/wikitool/creators/views.py" in create_wiki
  42.   doku_script.create_wiki(w.name, tmpl,
request.POST['access_policy'], reg)
File "/home/sohesado/codein/wikitool/creators/doku_script.py" in
create_wiki
  10.   create_base(name, reg)
File "/home/sohesado/codein/wikitool/creators/doku_script.py" in
create_base
  16.   shutil.copytree(ROOT + u'matrix', path)
File "/usr/lib/python2.6/shutil.py" in copytree
  146. os.makedirs(dst)
File "/usr/lib/python2.6/os.py" in makedirs
  157. mkdir(name, mode)

Exception Type: UnicodeEncodeError at /wikitool/creators/create_wiki/
Exception Value: 'ascii' codec can't encode characters in position
19-25: ordinal not in range(128)


>
> On Wed, Aug 4, 2010 at 11:00 AM, sohesado  wrote:
> > Well your example clarifies the problem. I removed the unicode calls.
>
> > The initial problem was an  UnicodeEncodeError exception. I tried to
> > solve it by encoding the strings to utf-8. It seems that's not the
> > case.
> > So i'm at square one.
>
> > Note that..
> > -with python manage.py runserver the app runs flawlessly.
> > -With apache+mod-python i get an UnicodeEncodeError.
>
> > So , it is an apache localization issue?
>
> > My /etc/apache2/envvars contains
>
> > --- 
> > -
> > export APACHE_RUN_USER=www-data
> > export APACHE_RUN_GROUP=www-data
> > export APACHE_PID_FILE=/var/run/apache2.pid
>
> > ## The locale used by some modules like mod_dav
> > export LANG='el_GR.UTF8'    <- also tried el_GR.UTF-8 variation
> > export LC_ALL='el_GR.UTF8'
> > ## Uncomment the following line to use the system default locale
> > instead:
> > #. /etc/default/locale
>
> > export LANG
>
> > --- 
> > --
>
> > Have you got any clues what may cause the problem?
>
> > Thank you for your help.
>
> > On Aug 3, 11:31 pm, Alec Shaner  wrote:
> > > unicode gives me nightmares.
>
> > > Taking django out of the picture for a moment:>>> unicode('foo', 'utf-8')
> > > u'foo'
> > > >>> unicode(u'foo', 'utf-8')
>
> > > Traceback (most recent call last):
> > >   File "", line 1, in 
> > > TypeError: decoding Unicode is not supported
>
> > > So I would assume when you run it inside django you're already using a
> > > unicode string. Do you need to pass the encoding argument ('utf-8') to
> > > unicode?
>
> > > On Tue, Aug 3, 2010 at 3:30 PM, sohesado  wrote:
> > > > Hi
>
> > > > I'm currently developing a django project and i've encountered a
> > > > problem regarding Unicode string manipulation.
>
> > > > There is a backend python module in my project that perform's mainly
> > > > shutil (shell utilities) tasks.
>
> > > > I get an TypeError: "decoding Unicode is not supported" exception
> > > > while running the following method
>
> > --- 
> > --
> > > > def create_base(name, reg):
> > > >    path = unicode(ROOT + name, 'utf-8')  error at this line
> > > >    shutil.copytree(ROOT + 'matrix', path)
> > > >    shutil.copystat(ROOT + 'matrix', path)
>
> > > >    f = codecs.open(path + '/conf/local.php', "w", "UTF-8")
> > > >    tmp = unicode(" > > >    f.write(tmp)
> > > >    if not reg:
> > > >        f.write("$conf['disableactions'] = 'register';\n")
>
> > --- 
> > 
>
> > > > The weird thing that puzzles me is that when i test the module in a
> > > > python shell , the method runs flawlessly which yields me to the
> > > > assumption that it's a django thing.
> > > > By the way i use apache+mod-python as a web-server
>
> > > > I can't get adequate information regarding this type of exception. I'm
> > > > stuck , please help.
>
> > > > --
> > > > You received this message because you are sub

Re: multi_db support for doctests? How to enable?

2010-08-04 Thread Reinout van Rees

On 08/04/2010 06:08 PM, Xavier Ordoquy wrote:


The second database should be created. Maybe you want to double check you setup 
a database router.


I *do* have a database router.  The router makes sure that 5 tables end 
up in the second database (and the others end up in the default database).



So far, the only issue I found with testing on multi database is that django 
1.2 expects all the tables are created on the second database which may not 
always be the case (bug reported, I just uploaded a patch for that).


Which patch/ticket is that?  With my router, the second database is 
definitively not filled with all tables: just the 5 that are supposed to 
be in there.


I'll do some experimenting with django versions.  I clearly remember 
adding code to my router to allow django to create those 5 tables in my 
second database, so it *did* work.  Perhaps 1.2.1 broke something that 
1.2betasomething did right?   Gotta drink wine with my wife now, I'll 
test tomorrow :-)



Thanks,

Reinout


--
Reinout van Rees - rein...@vanrees.org - http://reinout.vanrees.org
Programmer at http://www.nelen-schuurmans.nl
"Military engineers build missiles. Civil engineers build targets"

--
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: moving to django 1.2.1

2010-08-04 Thread Michael P. Soulier
On 31/07/10 Russell Keith-Magee said:

> Ok - I'm repeating myself here, but we take backwards compatibility
> *very* seriously. If anyone can point at a specific backwards
> incompatible change that was introduced in Django 1.2, then that is a
> bug that we need to address, and would in all likelihood be a trigger
> for a new point release.

That is awesome, thanks. I can safely push the upgrade and I'll report any
issues found.

Mike
-- 
Michael P. Soulier 
"Any intelligent fool can make things bigger and more complex... It takes a
touch of genius - and a lot of courage to move in the opposite direction."
--Albert Einstein


signature.asc
Description: Digital signature


Odd behavior with reverse()

2010-08-04 Thread Seth
I've just spent the better part of an afternoon dealing with this
issue, then finally figured it out this morning.

Supposing you have this situation (which I saw in a django app that
I've been using lately):

urls.py:
(r'^viewtest1$', 'testapp.views.viewtest1'),
(r'^viewtest2$', 'testapp.views.viewtest2'),

testapp/views.py:
def viewtest1(request):
return HttpResponse("You've reached view1. It's url is %s" %
view1_url)

view1_url = reverse(viewtest1)

def viewtest2(request):
return HttpResponse("You've reached view2.", mimetype="text/
plain")

When you try to load up http://localhost/viewtest1, you get this
error:

ViewDoesNotExist at /viewtest1
Tried viewtest2 in module reverseapp.views. Error was: 'module'
object has no attribute 'viewtest2'

What appears to be happening is that when reverse() is called, it is
presumably importing testapp.views. But, since testapp.views hasn't
been fully loaded at that point, reverse() can't see the any functions
that appear after it in the file, and thus, viewtest2 isn't found.

In my case, I was getting NoReverseMatch errors in my templates for
unrelated views.


So, now that I'm writing this up, I see a little note in the reverse()
documentation which says "don't do it wrong", and I feel like I'm just
complaining now :)

That particular bit of documentation wouldn't have helped my in my
case, since the error originated in a 3rd party app (I was looking
through my own code to see what I did wrong). Anybody else been bitten
by this? Is there a way to make errors like this easier to track down
(especially in templates, where you don't have a stack trace)?


- Seth -

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



importing models to script file

2010-08-04 Thread Tony
Hi, Im trying to import my models to another python file that I am
making to use the database data.  The problem is, I can't import the
models for some reason.  It keeps saying "ImportError: no module named
"  The thing is, it works on my home computer when I do it, but
when I do it on webfaction this seems to happen.  Anyone ever have a
similar problem?  And I have tried including various paths in the py
file with sys.path.append() but that hasnt worked.

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



importing models to script file

2010-08-04 Thread Tony
Hi, Im trying to import my models to another python file that I am
making to use the database data.  The problem is, I can't import the
models for some reason.  It keeps saying "ImportError: Settings cannot
be imported, because environment variable DJANGO_SETTINGS_MODULE is
undefined."
The thing is, the script works on my home computer when I do it, but
when I do it on webfaction this seems to happen.  Anyone ever have a
similar problem?  And I have tried including various paths in the py
file with sys.path.append() but that hasnt worked.  Disregard my first
message, this is actually what the error is.

-- 
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 to get the model name of an object in template?

2010-08-04 Thread v0idnull
i know this isn't what you want, but I'd use the Content Type
middleware.

def getType(self):
if (self._type == None):
self._type = ContentType.objects.get_for_model(self)
return self._type

for me personally this worked out well, but mostly because I have an
abstract model that all my other models extend, so I had to define that
method, once

On Wed, 2010-08-04 at 11:27 -0700, David.D wrote:
> I just wonder if there's some way requires writing nothing. Just like
> an attribute.
> 
> thanks.
> 
> On Aug 4, 11:53 pm, Scott Gould  wrote:
> > Not that I'm aware of, in which case I'd say a tag (or even a filter)
> > *is* the "built-in way". No great hardship:
> >
> > @register.filter
> > def class_name(value):
> > return value.__class__.__name__
> >
> > On Aug 4, 11:13 am, "David.D"  wrote:
> >
> >
> >
> > > There's no django's built-in way?
> >
> > > On Aug 4, 10:37 pm, Scott Gould  wrote:
> >
> > > > How about writing a simple template tag that takes an object and
> > > > returns object.__class__.__name__?
> >
> > > > On Aug 4, 10:20 am, "David.D"  wrote:
> >
> > > > >  I did it by adding this to my models:
> > > > > def get_model_name(self):
> > > > > return self.__class__.__name__
> >
> > > > > And it works
> >
> > > > > But I don't want to define the 'get_model_name' method in my model.
> >
> > > > > Is there a built-in way?
> >
> > > > > 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: Python question about subprocess.Popen() and stdout

2010-08-04 Thread Hassan

> Ok, so it appears that (in Python 2.5 at least) there is no way to capture
> the stdout of subprocess.Popen()

just do this

from subprocess import Popen, PIPE
p = Popen([cmd], stdout=PIPE)
p.stdout.readlines()

thats it!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: TypeError: decoding Unicode is not supported

2010-08-04 Thread Alec Shaner
Ah, maybe that makes more sense then. It does indeed sound like locale issue
with your apache + mod_python envrionment. I see an old django ticket that
sounds pretty similar:

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

Sounds like you're still getting ASCII as the default encoding despite the
env settings in apache?

Out of curiosity I created a view to dump the encoding in my django dev app
by calling locale.getpreferredencoding(). In both apache+mod_wsgi and django
development server it returns UTF-8. My linux box is configured with UTF-8
as the default, so I haven't done anything special with apache. If you put
that in your code and it has UTF-8 in both cases then this issue is beyond
me.

On Wed, Aug 4, 2010 at 4:10 PM, sohesado  wrote:

>
>
>
> On Aug 4, 6:48 pm, Alec Shaner  wrote:
> > I'm no expert on encodings so I can only suggest some alternatives that
> > might get around the issue:
> >
>
> > First, maybe you can find something here:
> http://docs.python.org/howto/unicode
>
> i've read , pretty much everything,  available at docs.python.org
> regarding unicode.
>
> > You could try the literal method of generating a unicode string:
> >
> > path = u'%s%s' % (ROOT, name)
> tried it. The problem persists
> > Where exactly do you get the UnicodeEncodeError exception when you remove
> > the unicode calls?
>
> I get the the exception at this line -> shutil.copytree(ROOT +
> 'matrix', path)
>
> And the traceback...
>
> Traceback:
> File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
> base.py" in get_response
>  100. response = callback(request,
> *callback_args, **callback_kwargs)
> File "/usr/local/lib/python2.6/dist-packages/django/contrib/auth/
> decorators.py" in _wrapped_view
>  25. return view_func(request, *args, **kwargs)
> File "/home/sohesado/codein/wikitool/creators/views.py" in create_wiki
>  42.   doku_script.create_wiki(w.name, tmpl,
> request.POST['access_policy'], reg)
> File "/home/sohesado/codein/wikitool/creators/doku_script.py" in
> create_wiki
>  10.   create_base(name, reg)
> File "/home/sohesado/codein/wikitool/creators/doku_script.py" in
> create_base
>  16.   shutil.copytree(ROOT + u'matrix', path)
> File "/usr/lib/python2.6/shutil.py" in copytree
>  146. os.makedirs(dst)
> File "/usr/lib/python2.6/os.py" in makedirs
>  157. mkdir(name, mode)
>
> Exception Type: UnicodeEncodeError at /wikitool/creators/create_wiki/
> Exception Value: 'ascii' codec can't encode characters in position
> 19-25: ordinal not in range(128)
>
>
> >
> > On Wed, Aug 4, 2010 at 11:00 AM, sohesado  wrote:
> > > Well your example clarifies the problem. I removed the unicode calls.
> >
> > > The initial problem was an  UnicodeEncodeError exception. I tried to
> > > solve it by encoding the strings to utf-8. It seems that's not the
> > > case.
> > > So i'm at square one.
> >
> > > Note that..
> > > -with python manage.py runserver the app runs flawlessly.
> > > -With apache+mod-python i get an UnicodeEncodeError.
> >
> > > So , it is an apache localization issue?
> >
> > > My /etc/apache2/envvars contains
> >
> > >
> ---
> -
> > > export APACHE_RUN_USER=www-data
> > > export APACHE_RUN_GROUP=www-data
> > > export APACHE_PID_FILE=/var/run/apache2.pid
> >
> > > ## The locale used by some modules like mod_dav
> > > export LANG='el_GR.UTF8'<- also tried el_GR.UTF-8 variation
> > > export LC_ALL='el_GR.UTF8'
> > > ## Uncomment the following line to use the system default locale
> > > instead:
> > > #. /etc/default/locale
> >
> > > export LANG
> >
> > >
> ---
> --
> >
> > > Have you got any clues what may cause the problem?
> >
> > > Thank you for your help.
> >
> > > On Aug 3, 11:31 pm, Alec Shaner  wrote:
> > > > unicode gives me nightmares.
> >
> > > > Taking django out of the picture for a moment:>>> unicode('foo',
> 'utf-8')
> > > > u'foo'
> > > > >>> unicode(u'foo', 'utf-8')
> >
> > > > Traceback (most recent call last):
> > > >   File "", line 1, in 
> > > > TypeError: decoding Unicode is not supported
> >
> > > > So I would assume when you run it inside django you're already using
> a
> > > > unicode string. Do you need to pass the encoding argument ('utf-8')
> to
> > > > unicode?
> >
> > > > On Tue, Aug 3, 2010 at 3:30 PM, sohesado 
> wrote:
> > > > > Hi
> >
> > > > > I'm currently developing a django project and i've encountered a
> > > > > problem regarding Unicode string manipulation.
> >
> > > > > There is a backend python module in my project that perform's
> mainly
> > > > > shutil (shell utilities) tasks.
> >
> > > > > I get an TypeError: "decoding Unicode is not supported" exception
> > > > > while running the following method
> >
> > >
> ---
> 

Issue with change_view save redirect

2010-08-04 Thread herbal
I am attempting to change the redirected for the django admin save
button. What I pasted below works on saving an already existing entry
(updating) but not on saving a new one. Any thoughts?



def change_view(self, request, object_id, extra_context=None):
result = super(TodoAdmin, self).change_view(request, object_id,
extra_context)
if not request.POST.has_key('_addanother') and not
request.POST.has_key('_continue'):
result['Location'] = "/"
return result

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

2010-08-04 Thread Carlos Daniel Ruvalcaba Valenzuela
If you are looking for a "Full IDE" I have used Eclipse+PyDev (and
other plugins) and works quite well, completion is reasonable and you
have a wealth of extensions such as VCS support, Mylyn Integration (to
work with remote task/issue managers), HTML editing, etc. It is a
little bloated if you are used to editors and other lightweight IDEs
though, but I can recommend it.

I haven't tried netbeans yet but I only hear good things of it so far.

As far commercial IDEs there is WingIDE and PyCharm, PyCharm is very
Django oriented right now and has very good autocompletion/code
editing tools, it may be the best option but Wing is also preparing
it's Django specific features for next release (available in beta
builds).

Regards,
Carlos Daniel Ruvalcaba Valenzuela

On Wed, Aug 4, 2010 at 12:27 PM, bagheera  wrote:
> For python/django development i'm using... NetBeans! It fails to
> autocomplete items properly, but still, i find it most comfortable also for
> html, javaScript, CSS.
> Sometimes i use Geany, it's really simple, yet nice IDE.
> All under Linux.
>
> --
> 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: how to make readonly in change but editable in add?

2010-08-04 Thread shmengie
Shamefully, I didn't even give it a good once over before posting it.
However, I have read through it, and I'm not too ashamed ;)  More
comments would be nice, but I was more concerned with the results at
the time and it's not terribly complex code, so I think it stands well
on it's own.

I couldn't use this refactoring, because I use readonly=False
depending on circumstance before instantiating the form, this would
create a readonly form which wouldn't be desired.

if kwargs['readonly']: # tests the arg 'readonly' to see if it
evaluates to a True expression.  But before testing it's evaluation,
you need to ensure the arg is in the list, hence '''if
kwargs.has_key('readonly'):'''

My original code may not be perfect but it works ;)


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



Flexible relationships - tips/advice?

2010-08-04 Thread v0idnull
I want to be able to link one model to another model, regardless of
what models they are. Articles can be related to Photos, Videos, other
Articles, etc etc etc.

I have created a Relationship model to represent these relationships,
but I'm unsure if this is the best solution. First off, my
requirements include having a title, description, type, and priority
to further describe the relationship.

Secondly, I am using UUIDs for primary keys so I created a custom
field to represent this (postgresql has a UUID field as well).

Thirdly, I don't plan on using the out-of-box admin console, so
whether or not a particular pattern works well in the admin console or
not is not relevant for me.

The following model accurately represents what I need, and in theory
it works well. I can now have an abstract model that all my other
models inherit, with an addRelationship(self, destination) method and
various other methods to fetch relationships. In this abstract class,
I also have this:

from django.contrib.contenttypes.models import ContentType

class Abstract(models.Model):
...
def getType(self):
if (self._type == None):
self._type = ContentType.objects.get_for_model(self)
return self._type

In order to make my life easier, as you'll see in my model below.

I would like opinions about my approach, I am new to python, and newer
still to Django. There might be things I am overlooking due to my
ignorance.

class Relationship(models.Model):

id = fields.UUID(auto_add=True,primary_key=True, unique=True)
created_by = fields.UUID(db_index=True,null=True,blank=True)
created_on = models.DateField(auto_now=False,auto_now_add=True)
modfied_on = models.DateField(auto_now=True,auto_now_add=False)
title = models.CharField(max_length=255)

source_id = fields.UUID(db_index=True)
source_app_label = models.CharField(db_index=True,max_length=255)
source_model = models.CharField(db_index=True,max_length=255)
destination_id = fields.UUID(db_index=True)
destination_app_label =
models.CharField(db_index=True,max_length=255)
destination_model = models.CharField(db_index=True,max_length=255)

description = models.TextField(null=True,blank=True)
type =
models.CharField(max_length=64,null=True,blank=True,db_index=True)
priority = models.PositiveIntegerField()

Thanks in advance...

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



  1   2   >