Re: Custom Validation in Django 1.0.2 Final

2009-04-07 Thread Malcolm Tredinnick

On Mon, 2009-04-06 at 23:58 -0700, Harish wrote:
[...]
> If salary is found negative it displays the error message in beginning
> of the form(that is after the message 'Please correct the error below.
> '). Actually it should display the error message in the 'Salary'
> section
> 
> I think, I am missing something here.

Since your field validation appears to only depend on the "salary" form
field, the easiest solution here is to write a clean_salary() method,
rather than using clean(). Then, any ValidationError raised will
automatically be assigned to the salary field.

Have a look at
http://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-a-specific-field-attribute
 and the surrounding documentation for some more information about this. In 
general, the clean() method is only useful if you're validating multiple fields 
simultaneously to check something. When the result of a particular check only 
depends on a single field, best to validate as part of that field's cleaning 
routine.

Regards,
Malcolm



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



Re: Custom Validation in Django 1.0.2 Final

2009-04-07 Thread Harish

Hi, Malcolm...


Thanks a lot... It is working Now..


On Apr 7, 12:05 pm, Malcolm Tredinnick 
wrote:
> On Mon, 2009-04-06 at 23:58 -0700, Harish wrote:
>
> [...]
>
> > If salary is found negative it displays the error message in beginning
> > of the form(that is after the message 'Please correct the error below.
> > '). Actually it should display the error message in the 'Salary'
> > section
>
> > I think, I am missing something here.
>
> Since your field validation appears to only depend on the "salary" form
> field, the easiest solution here is to write a clean_salary() method,
> rather than using clean(). Then, any ValidationError raised will
> automatically be assigned to the salary field.
>
> Have a look 
> athttp://docs.djangoproject.com/en/dev/ref/forms/validation/#cleaning-a...and 
> the surrounding documentation for some more information about this. In 
> general, the clean() method is only useful if you're validating multiple 
> fields simultaneously to check something. When the result of a particular 
> check only depends on a single field, best to validate as part of that 
> field's cleaning routine.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Embedded Django ...

2009-04-07 Thread Mic Pringle

Hi,

I am currently developing a database creation and manipulation tool
for the Mac (similar to Filemaker, Bento, ModelBaker etc) and I'm
looking at embedding Django and using the admin interface for data
input and retrieval. The only concern I have is that I don't require
users, groups, permissions or sessions, and as I understand it, all
this is baked into the admin application, non-optional.

So my question is, how easy/difficult would it be to strip out all of
the above from the admin application ? Would you start by copying the
admin folder from contrib into your own application and just start
ripping this stuff out, line by line, or is there perhaps an easier
way ?

Any help would be greatly appreciated.

Thanks

-Mic

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



User Profile Problem

2009-04-07 Thread hc w
Hii, all 
I just want to add a foreign key--'FourS'-- to the user model .I have modified 
it as following.it works on our dev env in windows but failed in product env in 
linux ( apache2.0.54 +mod_python3.3.1+prefork mode)  .  Can anyone tell me why 
and some solution?  Thanks MODEL: 
from django.db import modelsfrom django.contrib.auth.models import Userfrom 
cyt.glorail.models import FourS
from django.contrib.admin import validation
# Create your models here.#class UserProfile(models.Model):#    user = 
models.ForeignKey(User,unique=True)#    dealer = models.ForeignKey(FourS)#    
class Meta:#        db_table = u'auth_userprofile'   from 
django.contrib.auth.admin import UserAdmin   import datetime   class 
ProfileBase(type):   def __new__(cls, name, bases, attrs):       module 
= attrs.pop('__module__')       parents = [b for b in bases if 
isinstance(b, ProfileBase)]       if parents:           fields = [] 
          for obj_name, obj in attrs.items():               if 
isinstance(obj, models.Field): fields.append(obj_name)               
User.add_to_class(obj_name, obj)            UserAdmin.fieldsets = 
list(UserAdmin.fieldsets)           UserAdmin.fieldsets.append((name, 
{'fields': fields}))       return super(ProfileBase, cls).__new__(cls,
 name, bases, attrs)          class Profile(object):   __metaclass__ = 
ProfileBase class MyProfile(Profile):   dealer = 
models.ForeignKey(FourS)    #dealer = models.IntegerField(null=True, 
blank=True,db_column='dealer_id')        ERROR MESSAGE: 
ImproperlyConfigured at 
/admin/auth/user/1/'UserAdmin.fieldsets[5][1]['fields']' refers to field 
'dealer' that is missing from the form.Request Method: GET Request URL: 
http://192.168.0.116/admin/auth/user/1/ Exception Type: 
ImproperlyConfigured Exception Value: 'UserAdmin.fieldsets[5][1]['fields']' 
refers to field 'dealer' that is missing from the form. Exception Location: 
/usr/local/lib/python2.5/site-packages/django/contrib/admin/validation.py in 
check_formfield, line 254 Python Executable: /usr/local/bin/python Python 
Version: 2.5.4 Python Path: ['/pyweb', 
'/usr/local/lib/python2.5/site-packages/django', 
'/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', 
'/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg',
 '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5', 
'/usr/local/lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', 
'/usr/local/lib/python2.5/lib-dynload',
 '/usr/local/lib/python2.5/site-packages'] 



  ___ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to use email instead of username for user authentication?

2009-04-07 Thread johan.uhIe

The slugify function may also provide you with valid usernames, if you
feed it with first and last name for example. But always be certain,
that the username is unique, just as malcolm described.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python error

2009-04-07 Thread Florian Strzelecki
And... what about that :

DocumentRoot:   '/usr/local/apache2/htdocs'

URI:'/contact.php'
Location:   '/'
Directory:  None
Filename:   '/usr/local/apache2/htdocs/
contact.php'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'

Are you trying to serve a php file with mod_python ?
If you see what I meen. :]

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



RE: Embedded Django ...

2009-04-07 Thread Mic Pringle

Hi,

I've been having a look through the docs and source code and if I'm
right, I could achieve what I need by subclassing AdminSite and
implementing my own 'index' and 'urls' methods.

Can someone confirm whether or not I'm on the right track ?

Thanks,

-Mic


-- Forwarded message --
From: Mic Pringle 
Date: 2009/4/7
Subject: Embedded Django ...
To: django-users@googlegroups.com


Hi,

I am currently developing a database creation and manipulation tool
for the Mac (similar to Filemaker, Bento, ModelBaker etc) and I'm
looking at embedding Django and using the admin interface for data
input and retrieval. The only concern I have is that I don't require
users, groups, permissions or sessions, and as I understand it, all
this is baked into the admin application, non-optional.

So my question is, how easy/difficult would it be to strip out all of
the above from the admin application ? Would you start by copying the
admin folder from contrib into your own application and just start
ripping this stuff out, line by line, or is there perhaps an easier
way ?

Any help would be greatly appreciated.

Thanks

-Mic

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



Re: Django Deployment Methods: Survey (via DjangoSites)

2009-04-07 Thread Oli Warner
Please add Cherokee to the server choices and SCGI to the method choices. I
can't edit my sites (accurately) until you have.

On Tue, Apr 7, 2009 at 10:15 AM, Ross Poulton  wrote:

>
> There are quite a few different ways to deploy Django applications so
> that the big wide world can see them. I'm on a mission to find out
> which methods are most popular, which web servers people are using,
> and what RDBMS is storing the data of Djangonauts world-wide.
>
> Last night I put some changes live on www.DjangoSites.org to let site
> submitters include their deployment details when a site is submitted.
> These details are kept 'anonymous', in that they aren't published with
> website listings.
>
> Once I've got a material number of responses, I will put a page on
> djangosites.org that shows the results in aggregate form, to satisfy
> the curiosity of data geeks everywhere.
>
> What can you do to help?
>
> 1) If your sites are not already listed at DjangoSites: Sign up for an
> account[1] and submit your site[2]. Note that you can use OpenID if
> you're that way inclined.
>
> 2) If your sites ARE already listed, log in to the site[3] and click
> "My Sites" in the header navbar. Click on a website that's yours, then
> click 'Edit'.
>
> So far I've got about 70 responses. I'll be waiting for approx 200
> before publishing a live aggregation page. In the meantime I'll post
> numbers to my blog as time permits.
>
> For more detail about what I'm doing and why, see my blog post from
> last night[4]. For any questions don't hesitate to respond here or via
> e-mail, r...@rossp.org.
>
> With any luck we'll have some neat statistics on Django deployment in
> the real-world within a few weeks. Thanks in advance for your
> submissions!
>
> [1] http://www.djangosites.org/accounts/signup/
> [2] http://www.djangosites.org/submit/
> [3] http://www.djangosites.org/accounts/signin/
> [4] http://www.rossp.org/blog/2009/apr/06/django-deployment/
> >
>

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



Re: Still Learning...!

2009-04-07 Thread dls

Russ - can you name some of the books and blogs that are devoted to
this? I'm interesting in seeing how Django would be used as a
component of a larger site, instead of "being the site". I'm an
embedded engineer, so web programming is still pretty new to me -
which is probably why my response to poor TP was not as clear as it
should be.

Thanks!

-dls

On Apr 6, 8:49 pm, Russell Keith-Magee  wrote:
> On Tue, Apr 7, 2009 at 2:14 AM, dls  wrote:
>
> > I think the easiest way to get started is to follow the "Creating a
> > project" instructions from the Django documentation:
>
> >http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01
>
> > It is my understanding that these steps are necessary if you want to
> > use the Django framework. I think the Django framework is intended to
> > be the skeleton of the webpage with html, javascript, etc.. residing
> > within the framework. Html would reside in places like urls.py and
> > the /templates directory.
>
> This isn't entirely correct.
>
> While Django _can_ operate using the project/app/templates type
> structure described by the tutorial, it doesn't _require_ that
> structure. Django's tools provide tools that generate a skeleton, but
> you aren't required to put everything inside that skeleton - you can
> utilize the full power of PYTHONPATH to structure your code resources
> in the way that makes the most sense for your project.
>
> Where should you "position" your apps? Wherever is convenient. If
> you're only working on a small project, then putting everything in
> your project directory (like the tutorial does) might be appropriate.
> However, if you're planning on making a long term commitment to
> Django, then you should be anticipating the need for code reuse, and
> you should be putting your Django applications into a code repository
> somewhere, external to your project.
>
> > The documentation page listed above is really the best source for
> > starting a brand new project as it talks about database setup, the
> > development server, and some critical components of settings.py. Once
> > you get those running, you will have to give urls.py some attention as
> > it will handle routing the url to the html template.
>
> The tutorial is just that - a tutorial. It gives you enough detail to
> get started and put up a "Hello World" Django project. It isn't
> intended to be a demonstration of best practices for a huge
> multi-application project. If you want advice on what to do for larger
> projects, search around the net for details on reusable Django
> applications - there are lots of blogs, books and lectures that cover
> this topic. You can also learn by example by looking at how big
> projects - like Pinax - address the problem.
>
> Yours,
> Russ Magee %-)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Collapsed inline

2009-04-07 Thread Filip Gruszczyński

OK, thanks. I'll wait patiently for 1.2 then :-)

W dniu 1 kwietnia 2009 17:00 użytkownik Karen Tracey
 napisał:
> 2009/4/1 Filip Gruszczyński 
>>
>> I am creating my own admin for a model and I would to add a collapsed
>> inline.
>>
>> [snip]
>> But I have no idea how to achieve this with an inline. Is it possible
>> in DJango (possibly in 1.0, because this is at the production server,
>> but I can also live with 1.1)
>
> No, currently collapsing inlines is not supported.  There is a ticket for
> this:
>
> http://code.djangoproject.com/ticket/494
>
> that has a relatively recent patch you could try, but at this point this
> will not make it into 1.1, as it is new function and not a bug fix.
>
> Karen
>
> >
>



-- 
Filip Gruszczyński

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



Re: Partially rendering templates.

2009-04-07 Thread Chris Dew

Thanks, that's a useful idea.

Chris.

On Apr 7, 12:34 pm, Malcolm Tredinnick 
wrote:
> On Tue, 2009-04-07 at 03:04 -0700, Chris Dew wrote:
> > Here's a newbie question:
>
> > Is there a way of rendering (a single block of?) a Django template,
> > without it loading in it's parent template(s).
>
> > My purpose is to use a single template to render both a component of a
> > page as an html snippet (for ajax), as well as the whole page (for non-
> > javascript clients).  DRY.
>
> Not directly, no. However, there's an alternate way to think about the
> problem. Make the fragment you're talking about a complete template on
> its own. Then that fragment can be included into the larger template via
> the "include" template tag. So, instead of pulling a small piece out of
> a larger template, treat the smaller piece as a standalone and then
> inject that *into* the larger template.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multi app project and inter app communication

2009-04-07 Thread kRON

Hello everyone. I've only recently started developing app with Django
and in Python as well. I have a fair experience in developing web apps
on frameworks in PHP and I'm really trying to make a commitment on
doing my first Django app properly (all the good methodologies and
practices included)

The first bit I can't figure out are Django applications. I know that
they are, in essence, Python modules, but it doesn't say what does
Django do once it encounters an application. Does it add it to the
sys.path? Does it automatically load certain files, or does that have
to be explicitly specified somewhere?

Another question I have is with custom settings. I'd like to have each
application have it's own settings file. How is this then accessed by
the application? Do I have to import /proj/myapp/settings.py in my
main /proj/settings.py file? I figure that this would make the
settings globally available, so /proj/myapp2 can access the settings
from /proj/myapp1, but what if I want to have some application
specific settings that I do not wish to be accessed by other
applications too?

Also I was wondering if there was a Pythonic analogue for the
alternative shorthand conditional syntax '(cond) ? true : false'. I
wanted to do something like:

DEBUG, DATABASE_USER, DATABASE_PORT = if gethostname='development-
server' : True, 'dev-user', '1047' else: None, 'prod-user', '3306'

Thanks a lot, I appreciate any sort of help :)!

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



Partially rendering templates.

2009-04-07 Thread Chris Dew

Here's a newbie question:

Is there a way of rendering (a single block of?) a Django template,
without it loading in it's parent template(s).

My purpose is to use a single template to render both a component of a
page as an html snippet (for ajax), as well as the whole page (for non-
javascript clients).  DRY.

Thanks,

Chris.

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



Re: Partially rendering templates.

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 03:04 -0700, Chris Dew wrote:
> Here's a newbie question:
> 
> Is there a way of rendering (a single block of?) a Django template,
> without it loading in it's parent template(s).
> 
> My purpose is to use a single template to render both a component of a
> page as an html snippet (for ajax), as well as the whole page (for non-
> javascript clients).  DRY.

Not directly, no. However, there's an alternate way to think about the
problem. Make the fragment you're talking about a complete template on
its own. Then that fragment can be included into the larger template via
the "include" template tag. So, instead of pulling a small piece out of
a larger template, treat the smaller piece as a standalone and then
inject that *into* the larger template.

Regards,
Malcolm



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



Re: User Profile Problem

2009-04-07 Thread Dougal Matthews
Why do you want to change the User model?
This might be a useful read for you if you want to store more info about a
user...
http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/4/7 hc w 

> Hii, all
>
> I just want to add a foreign key--'FourS'-- to the user model .I have
> modified it as following.it works on our dev env in windows but failed in
> product env in linux ( apache2.0.54 +mod_python3.3.1+prefork mode)  .  Can
> anyone tell me why and some solution?  Thanks
>
> MODEL:
>
> from django.db import models
> from django.contrib.auth.models import User
> from cyt.glorail.models import FourS
>
> from django.contrib.admin import validation
>
> # Create your models here.
> #class UserProfile(models.Model):
> #user = models.ForeignKey(User,unique=True)
> #dealer = models.ForeignKey(FourS)
> #class Meta:
> #db_table = u'auth_userprofile'
>
> from django.contrib.auth.admin import UserAdmin
> import datetime
> class ProfileBase(type):
> def __new__(cls, name, bases, attrs):
> module = attrs.pop('__module__')
> parents = [b for b in bases if isinstance(b, ProfileBase)]
> if parents:
> fields = []
> for obj_name, obj in attrs.items():
> if isinstance(obj, models.Field): fields.append(obj_name)
>
> User.add_to_class(obj_name, obj)
> UserAdmin.fieldsets = list(UserAdmin.fieldsets)
> UserAdmin.fieldsets.append((name, {'fields': fields}))
> return super(ProfileBase, cls).__new__(cls, name, bases, attrs)
>
> class Profile(object):
> __metaclass__ = ProfileBase
>
> class MyProfile(Profile):
> dealer = models.ForeignKey(FourS)
> #dealer = models.IntegerField(null=True,
> blank=True,db_column='dealer_id')
>
> ERROR MESSAGE:
>
> ImproperlyConfigured at /admin/auth/user/1/
> 'UserAdmin.fieldsets[5][1]['fields']' refers to field 'dealer' that is
> missing from the form.Request Method: GET
> Request URL: http://192.168.0.116/admin/auth/user/1/
> Exception Type: ImproperlyConfigured
> Exception Value: 'UserAdmin.fieldsets[5][1]['fields']' refers to field
> 'dealer' that is missing from the form.
> Exception Location:
> /usr/local/lib/python2.5/site-packages/django/contrib/admin/validation.py in
> check_formfield, line 254
> Python Executable: /usr/local/bin/python
> Python Version: 2.5.4
> Python Path: ['/pyweb', '/usr/local/lib/python2.5/site-packages/django',
> '/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg',
> '/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg',
> '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5',
> '/usr/local/lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk',
> '/usr/local/lib/python2.5/lib-dynload',
> '/usr/local/lib/python2.5/site-packages']
>
>
> --
> 好玩贺卡等你发,邮箱贺卡全新上线! >
> 

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



Re: select_related and 1-to-many relations

2009-04-07 Thread Florian Strzelecki
Hm... something like that :
http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-related-objects
You can reverse a relationship, using "u.*att*_set".

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



Re: Django Deployment Methods: Survey (via DjangoSites)

2009-04-07 Thread Kenneth Gonsalves

On Tuesday 07 April 2009 15:26:44 Oli Warner wrote:
> Please add Cherokee to the server choices and SCGI to the method choices. I
> can't edit my sites (accurately) until you have.

and is there an option to remove a site? One of mine is no longer in 
existence.
-- 
regards
kg
http://lawgon.livejournal.com

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



Re: admin & edit-inlines: how to get ordered_forms in case of error?

2009-04-07 Thread patrickk

just for the record:
http://code.djangoproject.com/ticket/8165

guess this makes (re)ordering of edit-inlines impossible for now (at
least if one wants to preserve the ordering in case of errors).

thanks,
patrick


On 6 Apr., 16:21, patrickk  wrote:
> let´s say I´m having inlines with a field "pub_date" and the ordering
> is set to pub_date. in the admin-interface, I´m changing the pub_date
> for several fields/inlines and trying to save. if there are no errors,
> everyting´s fine. however, if there are errors (somewhere on the page
> and not necessarily within the edit-inlines), the inlines are not
> ordered according to the new pub_dates.
>
> any idea on how to solve this?
>
> thanks,
> patrick
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



File upload validation - not cleaned?

2009-04-07 Thread John Baker

I have a situation that is confusing me. I have a form to upload a
file. From my understanding, when 'clean' is called on the form, the
'file1' field should have already been cleaned and available in
cleaned_data. However, under some circumstances it is, sometimes not.
But when calling is_valid I can get

None
None
None
Total size 0

Which means the file1 was not cleaned. Here is my code..

Shouldn't the file1 be available in cleaned_data to check its size at
this point always?

If not, how can I access the request.FILES from inside the form rather
than the view?

---

(in view)
document_form = DocumentFileUploadForm(request.POST, request.FILES)
if document_form.is_valid():
...

(in forms)
def check_file_size_limit(form):
# calculate and check total size of files on form is not exceeded
size = 0;
for i in range(1, 4):
f = form.cleaned_data.get("file%d" % (i,))
print f
if f is not None:
size += f.size # UploadedFile object is much easier now
print "Total size %d" % (size,)
if size > settings.MAX_FILE_SIZE:
 raise ValidationError("Total file size exceeds the allowed
limit")
return size

class DocumentFileUploadForm(forms.Form):
file1 = forms.FileField(label="Upload CV / Folio", required=False)

def clean(self):
size = check_file_size_limit(self)
if size == 0:
raise ValidationError("Please attach a CV!")

return self.cleaned_data

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



RE: Embedded Django ...

2009-04-07 Thread Mic Pringle

Hi,

Could someone please explain (just a quick overview) how the
authentication process works for the Django admin site ?

Looking through the source I see methods for index and app_index, and
login & display_login_form ... however I cannot see how, when I first
boot up the server and navigate to the '/admin' address (which maps to
the index method) the user is authenticated ?

All I can see in those methods (index and app_index) is that the user
is taken from request.user ?

Is it to do with the authentication middleware ?

Any help will be greatly appreciated.

Thanks,

-Mic


-- Forwarded message --
From: Mic Pringle 
Date: 2009/4/7
Subject: RE: Embedded Django ...
To: django-users@googlegroups.com


Hi,

I've been having a look through the docs and source code and if I'm
right, I could achieve what I need by subclassing AdminSite and
implementing my own 'index' and 'urls' methods.

Can someone confirm whether or not I'm on the right track ?

Thanks,

-Mic


-- Forwarded message --
From: Mic Pringle 
Date: 2009/4/7
Subject: Embedded Django ...
To: django-users@googlegroups.com


Hi,

I am currently developing a database creation and manipulation tool
for the Mac (similar to Filemaker, Bento, ModelBaker etc) and I'm
looking at embedding Django and using the admin interface for data
input and retrieval. The only concern I have is that I don't require
users, groups, permissions or sessions, and as I understand it, all
this is baked into the admin application, non-optional.

So my question is, how easy/difficult would it be to strip out all of
the above from the admin application ? Would you start by copying the
admin folder from contrib into your own application and just start
ripping this stuff out, line by line, or is there perhaps an easier
way ?

Any help would be greatly appreciated.

Thanks

-Mic

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



Re: Running django on a web hosting account

2009-04-07 Thread Sergio Durand

atik escreveu:
> Is there any free hosting site that provide django support?
>   
I know 2 django free hostings:
- Google App Engine[1] - you will need adapt somethings in your code.
- Always Data[2] - they offer django free host with database and ssh 
support but it's in french and you will have only 10 megabytes quota.
I use alwaysdata to deploy my "on development" project to make it 
accessible for other people test it.

[1] http://code.google.com/appengine/
[2] http://www.alwaysdata.com/

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



Django Deployment Methods: Survey (via DjangoSites)

2009-04-07 Thread Ross Poulton

There are quite a few different ways to deploy Django applications so
that the big wide world can see them. I'm on a mission to find out
which methods are most popular, which web servers people are using,
and what RDBMS is storing the data of Djangonauts world-wide.

Last night I put some changes live on www.DjangoSites.org to let site
submitters include their deployment details when a site is submitted.
These details are kept 'anonymous', in that they aren't published with
website listings.

Once I've got a material number of responses, I will put a page on
djangosites.org that shows the results in aggregate form, to satisfy
the curiosity of data geeks everywhere.

What can you do to help?

1) If your sites are not already listed at DjangoSites: Sign up for an
account[1] and submit your site[2]. Note that you can use OpenID if
you're that way inclined.

2) If your sites ARE already listed, log in to the site[3] and click
"My Sites" in the header navbar. Click on a website that's yours, then
click 'Edit'.

So far I've got about 70 responses. I'll be waiting for approx 200
before publishing a live aggregation page. In the meantime I'll post
numbers to my blog as time permits.

For more detail about what I'm doing and why, see my blog post from
last night[4]. For any questions don't hesitate to respond here or via
e-mail, r...@rossp.org.

With any luck we'll have some neat statistics on Django deployment in
the real-world within a few weeks. Thanks in advance for your
submissions!

[1] http://www.djangosites.org/accounts/signup/
[2] http://www.djangosites.org/submit/
[3] http://www.djangosites.org/accounts/signin/
[4] http://www.rossp.org/blog/2009/apr/06/django-deployment/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Multi app project and inter app communication

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 04:36 -0700, kRON wrote:
> Hello everyone. I've only recently started developing app with Django
> and in Python as well. I have a fair experience in developing web apps
> on frameworks in PHP and I'm really trying to make a commitment on
> doing my first Django app properly (all the good methodologies and
> practices included)

Remember to learn to crawl before you can walk. Your first (and even
second and third, most likely) Django application isn't going to be
production quality. Spend some time learning to use Django, then spend
some time looking at options (and there are always options -- no single
best way to do any of this) for splitting up applications and working
with configuration options, etc.

> The first bit I can't figure out are Django applications. I know that
> they are, in essence, Python modules, but it doesn't say what does
> Django do once it encounters an application. Does it add it to the
> sys.path? Does it automatically load certain files, or does that have
> to be explicitly specified somewhere?

Thinking about this as Django "encountering an application" is probably
going to lead to confusion. Django is more of a library than a
framework, from the perspective of somebody writing an application. That
is, you pull things from the Django modules (and your application
modules) as required -- there's relatively little usage of Django
calling something of yours (the exception being the passing of requests
to view functions). The point being that, generally, if you need to use
code from a particular application, you import the appropriate Python
module(s) and use it, just like in normal Python code.

Django certainly doesn't do any modification of sys.path for particular
applications. Quite the reverse: it is assumed that applications are
importable using the name you specify in the INSTALLED_APPS list. That
is, your Python path has to already be set up so that you can import all
those things using those names.

The main reason (from an import perspective) that Django needs to know
about the installed applications (the INSTALLED_APPS list) is so that it
can work out reverse relations automatically. If you specify that model
A in application XYZ has a many-to-one relation to model B in
application PQR, Django will also set things up so that model B can
refer back to model A, without needing to also specify something in the
source for model B. This means that when importing model B, Django needs
to look at all the other models in all the installed applications to see
if there are any field pointing to model B (this is done through some
caching, the computation isn't something onerous on every request).

By and large, though, that last paragraph isn't important. The important
part is the first think I mentioned: if you need to use some code from
an application, import it as per normal.

> 
> Another question I have is with custom settings. I'd like to have each
> application have it's own settings file. How is this then accessed by
> the application? Do I have to import /proj/myapp/settings.py in my
> main /proj/settings.py file? I figure that this would make the
> settings globally available, so /proj/myapp2 can access the settings
> from /proj/myapp1, but what if I want to have some application
> specific settings that I do not wish to be accessed by other
> applications too?

Life doesn't really work like that.

Django's "settings" are, intentionally an essentially globally visible
object that anything can read. The reason it's read via a single file is
because there are potentially highly complex interactions between
settings when you're involving multiple applications and we require a
human -- the installing user -- to set things up in an holistic fashion.
At the settings level, it's pretty difficult to remain entirely
orthogonal, due to the intentional global visibility nature of things.

However, if you're just talking about intra-application settings of some
kind that the end-users won't need to touch (making them not really
settings at all), then don't bother user Django's settings
infrastructure. Just put them into a module that you import directly and
access as a normal namespaced Python object.

if these are things that the end-user is meant to configure, then you
should view them as settings an expect/allow them to be configured
however the user wants so that they are ultimately visible in the
settings.py (or whatever the name might be) file that is given to Django
as the module to read the settings from. Django follows Python's
practices here: it's a framework (or language, in Python's case) for
consenting adults. Don't become overly finicky about trying to hide
settings, because you're working at cross-purposes with your users. The
settings aren't meant to be hidden, since they're user configurable.
Other applications aren't going to be wandering the streets at night
looking for randomg settings to co-opt for their own nefarious purposes,
so things can

Re: Still Learning...!

2009-04-07 Thread Russell Keith-Magee

On Tue, Apr 7, 2009 at 7:41 PM, dls  wrote:
>
> Russ - can you name some of the books and blogs that are devoted to
> this? I'm interesting in seeing how Django would be used as a
> component of a larger site, instead of "being the site". I'm an
> embedded engineer, so web programming is still pretty new to me -
> which is probably why my response to poor TP was not as clear as it
> should be.

As always, Google Is Your Friend (tm). Searching for "reusable django
app" will yield plenty of fruit.

However, here are some specific suggestions:

 - James Bennett's "Practical Django Projects" contains a chapter on
building reusable apps. Unfortunately, the first edition of this text
fell out of date fairly quickly, as it was published before Django
v1.0 was finalized. This doesn't affect the discussions of reusable
apps, but if you're looking for good code examples, you would be well
served to wait for the second edition which is currently being
written.

 - James also gave a talk on the subject at DjangoCon 2008:

http://www.youtube.com/watch?v=A-S0tqpPga4

 - James' blog, http://b-list.org is an invaluable resource for Django
generally. He sometimes wanders into discussing reusable apps.

- James and Jacob Kaplan-Moss gave a tutorial as PyCon 2009 on
Real-World Django development; one of the topics they covered was
structuring your application:

 - http://toys.jacobian.org/presentations/2009/pycon/real-world.pdf

 - There are also a few people trying to document exactly what a
well-behaved reusable app must do. This is mostly being extracted from
the best-practice observed during the development of Pinax. Here are
some starter resources:

 * http://ericholscher.com/projects/reusable-app-docs/
 * http://ericholscher.com/projects/django-conventions/

Yours,
Russ Magee %-)

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



Many Questions, some of which are theoretical

2009-04-07 Thread zayatzz

Hello

Im mainly thinking bit ahead here, while im still in the beginning of
writing my first real project/application with django.
If someone could answer all or some of those questions and perhaps
provide examples, then i would greatly appreciate your help and buy
you a beer, whenever you end up near where i live :).

1) Cookies. I read from older posts that there is some kind of django
authentication library/module for holding that kind of information. In
any case, lets say that i dig deep enough into that module and figure
out how to do all that while session is active, but how do i read that
information from browser cookie next time the user comes to this site?

2.1) Since im thinking about creating site with some sort of cms i
want to know what kind of field types should i usefor lengthy texts
like news or basic content articles?
2.2) Is there a point building full scale cms with django or should
that be done with just python? Will django actually hinder such
projects?

3) Are there any examples of pages which get their content from
several views/modules? Or what is the general practice with pages that
load information from different places to one page? You create view
that imports information from several modules and shows it as single
page or is there some way to just reload certain area of a webpage
when visitor clicks a button/link or fills a form.

4) Are there any good examples about how to use javascript/ajax with
django?

5) How can i manage images with django. Are there stuff like gdlib/
imagemagic for django?


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



Re: need a multiselect list box for a static list of options

2009-04-07 Thread Adam Fraser

Yup:
>>> django.get_version()
u'0.97-pre-SVN-unknown'

On Apr 6, 1:45 pm, Alex Gaynor  wrote:
> On Mon, Apr 6, 2009 at 1:40 PM, Adam Fraser  wrote:
>
> > Yeah, I just realized I'm running django 0.97
>
> > On Apr 6, 1:32 pm, Karen Tracey  wrote:
> > > On Mon, Apr 6, 2009 at 11:57 AM, Adam Fraser  > >wrote:
>
> > > > Does anyone have a clue why I can't access ModelAdmin in
> > > > django.contrib.admin?
>
> > > > >>> from django.contrib import admin
> > > > >>> dir(admin)
> > > > ['__builtins__', '__doc__', '__file__', '__name__', '__path__',
> > > > 'models']
>
> > > > ???
>
> > > That's the result I get if my PYTHONPATH is pointing to a 0.96.x version
> > of
> > > Django.
>
> > > Karen
>
> There is no Django .97, presumably you mean some SVN version after .96.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multiple django versions in mod_python

2009-04-07 Thread paul tax

Thanks for your help I fixed the problem by switching to mod_wsgi (I
should have done that sooner) and by using virtualenv.

And the tutorial here:
http://lethain.com/entry/2009/feb/13/the-django-and-ubuntu-intrepid-almanac/

On 4 apr, 18:56, Karen Tracey  wrote:
> On Sat, Apr 4, 2009 at 10:57 AM, pault  wrote:
>
> >  I have one version 1.02 installed in /var/lib/python-support/
> > python2.5/django/ (i am on a debian machine)
> >  and one version 0.96 in the folder of my project.
>
> Specifics of exactly where you have Django 0.96 installed would have been
> helpful here.  Without such specifics people are forced to guess whether
> you've got exactly the right paths specified in your PythonPath directive.
>
>
>
>
>
> > I read the post from Graham but it doesn't seem to work for me it uses
> > the 1.02 version.
>
> >http://groups.google.com/group/django-users/browse_thread/thread/1c5c...
>
> > 
> > PythonInterpreter django.blabla
> > SetHandler python- program
> > PythonHandler django.core.handlers.modpython
> > SetEnv DJANGO_SETTINGS_MODULE blabla.settings
> > PythonDebug On
> > PythonPath "['/home/paul','/home/paul/blabla/django'] + sys.path"
> > 
>
> > How can I get my old sites working through mod_python
>
> Given what you have specified, an import like: "from django import models"
> is going to look for:
>
> /home/paul/django/__init__.py
> /home/paul/blabla/django/django/__init__.py
> continue with same pattern for all of sys.path
>
> I'm guessing the /django you have on the end of the 'blabla' entry is the
> problem, since I suspect that is introducing a 2nd '/django' in the path,
> but since I'm not entirely sure where your 0.96 install is I'm not 100% sure
> of that.
>
> Also be sure that the Apache process has permissions to read the directories
> involved here.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Running django on a web hosting account

2009-04-07 Thread dls

Graham:

> Is WebFaction still using mod_wsgi 2.0 though?
>
> Latest version of mod_wsgi is 2.3 (which is over 6 months old) with
> 2.4 coming out real soon now and with 3.0 to follow not long after
> that.

Yes, the mod_wsgi appears to be frozen at v2.0. Interestingly,
mod_python appears to be up to date at at v3.3.1 - I wonder if
Webfaction "prefers" mod_python to mod_wsgi. As the author of
mod_wsgi, maybe you can persuade them to keep pace with your
upgrades :)

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



Admin action not executed when no objects are selected

2009-04-07 Thread pault

I want to run an action from my admin when I press the GO button
without having to select any objects.

But it seems actions are only triggered when at least one object is
selected. Does anyone know a workaround for this.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom manager and related fields bug

2009-04-07 Thread Trey

Based on the documentation here:
http://docs.djangoproject.com/en/dev/topics/db/managers/#controlling-automatic-manager-types

Default or Pristine managers are created for the access of related
fields on a model. It seems however that in my current version of
django (SVN-10415) that this behavior is broken.

Example:
##VIEW MODELS
class UserViewManager(ViewManager):
def get_query_set(self):
return super(UserViewManager, self).get_query_set().filter
(access__id__lte=1)

class SystemViewManager(ViewManager):
def get_query_set(self):
return super(SystemViewManager, self).get_query_set()

class View(models.Model):
objects = UserViewManager()
system = SystemViewManager()


class ApplicationSettings(models.Model):
browse_view = models.OneToOneField(View, null=True,
limit_choices_to={'owner__id': 0}, default=1, )


AppSettingsForm = modelform_factory
(app_models.LeadApplicationSettings)



The query that is generated when displaying the form is as follows:
SELECT ... FROM [view table]
WHERE ([view table].`access_id` <= 1  AND [view table].`owner_id` = 0)

Notice that the access_id restriction from the manager set to objects
is being used.

To me this behavior seems incorrect according to the docs, as it
should be using the pristine manager which selects ALL related
objects. And at present I don't have a way to work around this since I
don't think I can specify a queryset in the one-to-one field.

I have tried setting "use_for_related_fields = True" to the
SystemManager just as a wild guess but that didn't help, as I expected
it wouldn't.

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



how to make serializers work with db.Model

2009-04-07 Thread Coonay

Background: code on google app engine using django framework,

 i persist data into  google data store(which is not a dbms),there is
an error of "django AttributeError:object has no attribute
'_meta'"  when  reading the queryset and decoding the queryset  using
djago json  serializers.

As you know , the  appengine_helper_for_django project can fit this
gap ,but its performance is very disappointed ,which always take near
1 second to finish its job.so there are 3 options :
1:optimize the helper(but it seems that project is not kind of active)
2:patch the django serializers
3:search a existed module which take cpu time blow 200MS

At present ,i prefer the option 2 and option 3,but i need your help to
get started .thanks you so much
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



.96 Tutorial maxlength/max_length confusion.

2009-04-07 Thread garyrob

I'm doing the .96 tutorial because my company is using version 96.1
for now.

The tutorial has:

class Poll(models.Model):
question = models.CharField(maxlength=200)
pub_date = models.DateTimeField('date published')

class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()


When I run:

python manage.py sql polls

or

python manage.py syncdb

I get:

TypeError: __init__() got an unexpected keyword argument 'maxlength'

Upon investigation, I find that maxlength was changed to max_length in
later django versions. I tried changing the code to use max_length,
and that fixed it.

All would be well and good, except that I'm running Django version
96.1, and the notes I'm finding online say that that version uses
maxlength, as specified in the .96 tutorial -- for instance
http://groups.google.com/group/django-users/browse_thread/thread/d838147cc8bda92f/cba5427c5eb10f91?lnk=gst&q=maxlength+max_length+tutorial+#cba5427c5eb10f91
says that.

I have confirmed that I am running 96.1 by printing django.VERSION
both from python run at the command line, and by actually printing it
directly in the models.py where the polls classes are defined. (To be
precise, it says version 96.094.)

So, I am pretty confused about this.

Thanks in advance for any help.

Gary


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



Re: flat page url problem

2009-04-07 Thread grimmus

After reading other similar posts all i needed to change was my
site_id to 2

On Apr 6, 10:36 am, grimmus  wrote:
> Hi,
>
> I was experimenting locally using flatpages. I didnt add anything
> extra into the urls.py file to handle these pages and they displayed
> correctly in the browser (using the django runserver)
>
> When i deploy my app to apache i get the error : The current URL, ,
> didn't match any of these.
>
> My urls.py looks like
>
> from django.conf.urls.defaults import *
> from django.contrib import admin
> from django.conf import settings
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>      (r'^admin/(.*)', admin.site.root),
>      (r'^contact/$', 'allergy.contact.views.contact'),
>      (r'^contact/thanks/$','allergy.contact.views.thanks'),
>      (r'^_resources/(?P.*)$', 'django.views.static.serve',
>         {'document_root': settings.MEDIA_ROOT}),
> )
>
> The flat page i added has a url like : '/' (so it's available at the
> root of the domain)
>
> Is there something else i need to add for this to work properly on
> apache (compared to runserver) ?
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Still Learning...!

2009-04-07 Thread TP

Thanks for the help guys, much appreciated!

I have now made a simple HTML web page.

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



Re: .96 Tutorial maxlength/max_length confusion.

2009-04-07 Thread garyrob

Following up on my previous message in this thread, after changing
maxlength to max_length,

python manage.py sql polls

works, but

python manage.py syncdb

results in

sqlite3.OperationalError: near ""choice"": syntax error.

This seems odd since the code for the choice class was pasted right
out of the tutorial (except for the maxlength fix). Note that earlier
in the tutorial, before putting the tutorial code into polls/
models.py, I did run syncdb and it did successully create the tables
for django.contrib.auth etc. So the sqlite3 installation appears to be
fine.

I don't know what to do at this point. Right now it seems as if the
tutorial simply doesn't work.

Gary



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



Re: .96 Tutorial maxlength/max_length confusion.

2009-04-07 Thread James Bennett

On Tue, Apr 7, 2009 at 9:33 AM, garyrob  wrote:
> I'm doing the .96 tutorial because my company is using version 96.1
> for now.

Well, first things first, you should upgrade both yourself and your
company to 0.96.3, because there have been security updates in the
0.96 series.

> TypeError: __init__() got an unexpected keyword argument 'maxlength'

Second, here's the actual code from the Django 0.96.1 release; you'll
notice that it most certainly is "maxlength" and not "max_length":

http://code.djangoproject.com/browser/django/tags/releases/0.96.1/django/db/models/fields/__init__.py#L59

This indicates that no matter what you may think, you have another
version of the Django code installed somewhere on your computer and
it's being picked up (or perhaps you have a corrupt or partial install
-- e.g., you may have some files from one version of Django, and other
files from another).



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

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



Re: .96 Tutorial maxlength/max_length confusion.

2009-04-07 Thread J. Cliff Dyer

On Tue, 2009-04-07 at 10:24 -0500, James Bennett wrote:
> On Tue, Apr 7, 2009 at 9:33 AM, garyrob  wrote:
> > I'm doing the .96 tutorial because my company is using version 96.1
> > for now.
> 
> Well, first things first, you should upgrade both yourself and your
> company to 0.96.3, because there have been security updates in the
> 0.96 series.
> 
> > TypeError: __init__() got an unexpected keyword argument 'maxlength'
> 
> Second, here's the actual code from the Django 0.96.1 release; you'll
> notice that it most certainly is "maxlength" and not "max_length":
> 
> http://code.djangoproject.com/browser/django/tags/releases/0.96.1/django/db/models/fields/__init__.py#L59
> 
> This indicates that no matter what you may think, you have another
> version of the Django code installed somewhere on your computer and
> it's being picked up (or perhaps you have a corrupt or partial install
> -- e.g., you may have some files from one version of Django, and other
> files from another).
> 
> 
> 

Try doing ./manage.py shell

>>> import django
>>> django.version

and see what it prints out.




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



Multiple Primary Key

2009-04-07 Thread sandravigo

Hello, I want to know how I can to declarate multiple primary key in
my model
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Dallas Django sprint 4/18 - 4/19 at CoHabitat

2009-04-07 Thread Jeremy Dunck

We've firmed up the Dallas Django sprint plans:

Django 1.1 is around the corner, but there are lots of bugs left to
squash. Come meet the other Django people around Dallas and check out
Cohabitat, the great coworking spot in uptown.

We'll start Saturday, April 18, 2009 at 9:00am through Sunday, April
19, 2009 around 5:00pm

Cohabitat
2517 Thomas Ave.
Dallas, TX

If you'd like to go, please let me know, or mark it in Facebook:
http://www.facebook.com/event.php?eid=81320026376&ref=nf

While you're considering, maybe you'll also want to come out to the
Crawfish boil and party the night before:
http://www.facebook.com/event.php?eid=61382229537

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



Re: .96 Tutorial maxlength/max_length confusion.

2009-04-07 Thread garyrob

> Try doing ./manage.py shell
>
> >>> import django
> >>> django.version
>
> and see what it prints out.

(0, 96.094, None)


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



Re: Multiple Primary Key

2009-04-07 Thread Alex Gaynor
On Tue, Apr 7, 2009 at 11:53 AM, sandravigo  wrote:

>
> Hello, I want to know how I can to declarate multiple primary key in
> my model
> >
>
Django doens't support multiple column primary keys.  This is the subject of
ticket #373 in Django's trac.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Manual transactions in command

2009-04-07 Thread Peter Bengtsson

Why doesn't this work?

from django.core.management.base import BaseCommand
from django.db import transaction
class Command(BaseCommand):
help = "bla bla"

def handle(self, *app_labels, **options):
from myapp.models import MyModel

transaction.enter_transaction_management()
MyModel.objects.create(name=u'FOO')
transaction.rollback()

When I run that command it does NOT roll back the transaction and
after running it I get an entry of FOO in my postgresql database.

I couldn't find any documentation for using django.db.transcation in
non-views so I guessed this was the way to run it.
(Using django trunk)

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



Re: User Profile Problem

2009-04-07 Thread hc w
Hi , Dougal

I did read django's offical recommendation of user profile.  just don't want to 
add one more table for one more attribute.and some say the way I present is 
helpful to understand the magic of Django. unfortunately this way seems not 
recommended by offical group.  I just want to know is this a bug of mod_python 
or maybe the problem lies somewhere else?  thanks a lot anyway! 

Best Regards,

/sky

--- 09年4月7日,周二, Dougal Matthews  写道:

发件人: Dougal Matthews 
主题: Re: User Profile Problem
收件人: django-users@googlegroups.com
日期: 2009年4月7日,周二,下午8:33

Why do you want to change the User model?
This might be a useful read for you if you want to store more info about a 
user...http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users


Dougal


---
Dougal Matthews - @d0ugal 
http://www.dougalmatthews.com/




2009/4/7 hc w 


Hii, all 
I just want to add a foreign key--'FourS'-- to the user model .I have modified 
it as following.it works on our dev env in windows but failed in product env in 
linux ( apache2.0.54 +mod_python3.3.1+prefork mode)  .  Can anyone tell me why 
and some solution?  Thanks

 MODEL: 
from django.db import modelsfrom django.contrib.auth.models import Userfrom 
cyt.glorail.models import FourS


from django.contrib.admin import validation
# Create your models here.#class UserProfile(models.Model):#    user = 
models.ForeignKey(User,unique=True)

#    dealer = models.ForeignKey(FourS)#    class
 Meta:#        db_table = u'auth_userprofile'   from django.contrib.auth.admin 
import UserAdmin   import datetime   class ProfileBase(type):   def 
__new__(cls, name, bases, attrs):   

        module = attrs.pop('__module__')       parents = [b for b in bases 
if isinstance(b, ProfileBase)]       if parents:           fields = []  
             for obj_name, obj in attrs.items():   

                if isinstance(obj, models.Field): fields.append(obj_name)   
            User.add_to_class(obj_name, obj)            UserAdmin.fieldsets = 
list(UserAdmin.fieldsets)   

            UserAdmin.fieldsets.append((name, {'fields': fields}))       
return super(ProfileBase,
 cls).__new__(cls, name, bases, attrs)          class Profile(object):  
 __metaclass__ = ProfileBase class MyProfile(Profile):   dealer = 
models.ForeignKey(FourS)

    #dealer = models.IntegerField(null=True, 
blank=True,db_column='dealer_id')        ERROR MESSAGE: 
ImproperlyConfigured at /admin/auth/user/1/

'UserAdmin.fieldsets[5][1]['fields']' refers to field 'dealer' that is missing 
from the form.Request Method: GET Request URL: 
http://192.168.0.116/admin/auth/user/1/ 

Exception Type: ImproperlyConfigured Exception Value: 
'UserAdmin.fieldsets[5][1]['fields']' refers to field 'dealer' that is missing 
from the form. Exception Location:
 /usr/local/lib/python2.5/site-packages/django/contrib/admin/validation.py in 
check_formfield, line 254 Python Executable: /usr/local/bin/python Python 
Version: 2.5.4 Python Path: ['/pyweb', 
'/usr/local/lib/python2.5/site-packages/django', 
'/usr/local/lib/python2.5/site-packages/setuptools-0.6c9-py2.5.egg', 
'/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.2-py2.5-linux-i686.egg',
 '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5', 
'/usr/local/lib/python2.5/plat-linux2', '/usr/local/lib/python2.5/lib-tk', 
'/usr/local/lib/python2.5/lib-dynload', 
'/usr/local/lib/python2.5/site-packages'] 






好玩贺卡等你发,邮箱贺卡全新上线!












  ___ 
  好玩贺卡等你发,邮箱贺卡全新上线! 
http://card.mail.cn.yahoo.com/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Manual transactions in command

2009-04-07 Thread Peter Bengtsson

Crap! Just as I closed this message I found another group post and the
answer was to do::

transaction.enter_transaction_management()
transaction.managed(True)



On Apr 7, 5:24 pm, Peter Bengtsson  wrote:
> Why doesn't this work?
>
> from django.core.management.base import BaseCommand
> from django.db import transaction
> class Command(BaseCommand):
>     help = "bla bla"
>
>     def handle(self, *app_labels, **options):
>         from myapp.models import MyModel
>
>         transaction.enter_transaction_management()
>         MyModel.objects.create(name=u'FOO')
>         transaction.rollback()
>
> When I run that command it does NOT roll back the transaction and
> after running it I get an entry of FOO in my postgresql database.
>
> I couldn't find any documentation for using django.db.transcation in
> non-views so I guessed this was the way to run it.
> (Using django trunk)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: .96 Tutorial maxlength/max_length confusion.

2009-04-07 Thread garyrob

> This indicates that no matter what you may think, you have another
> version of the Django code installed somewhere on your computer and
> it's being picked up (or perhaps you have a corrupt or partial install
> -- e.g., you may have some files from one version of Django, and other
> files from another).
>

You were right. I deleted my django installation and reinstalled .
96.3. And now the problems I was having have disappeared.

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



Re: select_related and 1-to-many relations

2009-04-07 Thread Eric

Thanks, although that reverses the logic, and only lets me select the
most recent for one table. The example is actually simplified, my User
object example actually has multiple items associated with it, for
example, I want to show a User, most recent Item, most recent
LogEntry, etc.

On Apr 7, 4:54 am, Florian Strzelecki 
wrote:
> Hm... something like that 
> :http://docs.djangoproject.com/en/dev/topics/db/queries/#backwards-rel...
> You can reverse a relationship, using "u.*att*_set".
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to use email instead of username for user authentication?

2009-04-07 Thread pkenjora

Hi,

  Why not remove the '@' filter and allow the specific project
developer the freedom to use email as username?  What was the
reasoning behind this?

  I always like Django because it didn't try to force development down
a specific path.  All developers have their own way and every project
is unique, for a long time Django accommodated that.  I'm a bit
worried about where this is going...

  I'm worried that the workarounds just introduce unnecessary
complexity.  We are currently upgrading to Django 1.02 and will most
likely strip the limiting logic instead of working around it.  I will
have a patch available for anyone interested later today.

- Paul

On Apr 2, 7:11 pm, Malcolm Tredinnick 
wrote:
> On Thu, 2009-04-02 at 19:04 -0700, Timboy wrote:
> > What's the best way to add users with an auto generating username? ie:
> > Taub.John, Smith.Tim, Smith.Tim2
>
> You can do it however you like, since the user will never see it.
> Something as simple as taking the email address, replacing "@" with "AT"
> and "." with "DOT" might work.
>
> One thing I did for a client was take the email address, trip off
> everything after the "@" and then continue adding a number to the end of
> the username until it was unique. So if t...@example.com registered
> first, he would be username "tim" and t...@foo.bar.org would be username
> "tim1", since "tim" was already in use. Since all registration is
> normally done through one or two places, it only required setting up the
> registration form handling view and writing a management command tool to
> add a user manually. These days, I might also add some admin overrides,
> but I didn't need that at the time.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: blank=True on Char/TextFields

2009-04-07 Thread Magus

I agree with Lee. There should be a way for a developer to store NULL
into a char field. At the moment null flag has no effect for a
CharField. Generally saying an empty string is not the same a not
defined value = NULL. It's pity that the according ticket is closed
with won't fix http://code.djangoproject.com/ticket/9590

Magus

On Feb 13, 2:31 pm, Lee Braiden  wrote:
> 2009/2/13 Praveen :
>
> > Avoid usingnullon string-based fields such as CharField and
> > TextField unless you have an excellent reason.
>
> What exactly is the reasoning behind this advice?  It seems to me that
> one would very rarely want to store an empty string.  For example, if
> a user doesn't enter a surname, that does not mean that their surname
> is "", unless they're Cher.
>
> --
> Lee

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



save message text with registered character

2009-04-07 Thread CrabbyPete

I am trying to save a message that has  a registered trademark
character in it, like Coke is a registered trademark.
I get a DjangoDecodeError. How do I prevent this from happening?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: save message text with registered character

2009-04-07 Thread Karen Tracey
On Tue, Apr 7, 2009 at 1:29 PM, CrabbyPete  wrote:

>
> I am trying to save a message that has  a registered trademark
> character in it, like Coke is a registered trademark.
> I get a DjangoDecodeError. How do I prevent this from happening?


Wild guess: a decode error sounds like you are passing in a bytestring
somewhere, and furthermore one that is not utf-8 encoded, as Django
generally assumes utf-8 encoding for bytestrings. If you'd like a more
educated guess you'll have to supply a few more details of what exactly it
is your code is doing.

Karen

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



Re: how to use email instead of username for user authentication?

2009-04-07 Thread pkenjora

Hi Again,

  Here is what we used to get around the email restriction.  It works
very well for authenticating through your application, Admin is a
different story.  In our case the users who register online never need
to log into admin.  If yours do, then you will have to strip logic
from several files.

In /django/contrib/auth/backends.py modify the following function

def authenticate(self, **credentials):
try:
user = None
if 'username' in credentials:
  user = User.objects.get(username=credentials
['username'])
else:
  user = User.objects.get(email=credentials['email'])

if user.check_password(credentials['password']):
return user

except User.DoesNotExist:
return None

Then when authenticating all you have to do is use:

user = authenticate(email=email, password=password)

or you can fall back on...

user = authenticate(username=email, password=password)

Either way thats all it takes, works like a charm now.  There was even
a patch for this many months back, too bad Django developers went the
exact opposite way...

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

Should we re-open the ticket? Either way, if you want email
authentication leave feedback...

-Paul


On Apr 7, 10:16 am, pkenjora  wrote:
> Hi,
>
>   Why not remove the '@' filter and allow the specific project
> developer the freedom to use email as username?  What was the
> reasoning behind this?
>
>   I always like Django because it didn't try to force development down
> a specific path.  All developers have their own way and every project
> is unique, for a long time Django accommodated that.  I'm a bit
> worried about where this is going...
>
>   I'm worried that the workarounds just introduce unnecessary
> complexity.  We are currently upgrading to Django 1.02 and will most
> likely strip the limiting logic instead of working around it.  I will
> have a patch available for anyone interested later today.
>
> - Paul
>
> On Apr 2, 7:11 pm, Malcolm Tredinnick 
> wrote:
>
> > On Thu, 2009-04-02 at 19:04 -0700, Timboy wrote:
> > > What's the best way to add users with an auto generating username? ie:
> > > Taub.John, Smith.Tim, Smith.Tim2
>
> > You can do it however you like, since the user will never see it.
> > Something as simple as taking the email address, replacing "@" with "AT"
> > and "." with "DOT" might work.
>
> > One thing I did for a client was take the email address, trip off
> > everything after the "@" and then continue adding a number to the end of
> > the username until it was unique. So if t...@example.com registered
> > first, he would be username "tim" and t...@foo.bar.org would be username
> > "tim1", since "tim" was already in use. Since all registration is
> > normally done through one or two places, it only required setting up the
> > registration form handling view and writing a management command tool to
> > add a user manually. These days, I might also add some admin overrides,
> > but I didn't need that at the time.
>
> > Regards,
> > Malcolm
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Design question: model functions / business logic / django admin

2009-04-07 Thread chachra

Hi,

I have a basic design question.

If I have a model say

class Account(models.Model):
  users = models.ManyToManyField(User)

  def add_user(user):
self.users.add(user)
do_something_here()


Now in my app code I always call add_user() to add a user to the
account since do_something_here would get called also, which is part
of my business logic.

2 questions:
+ how do I prevent to make a mistake in the future and do
account.users.add() etc. and by-pass the business logic

+ How do I expose Account model in django admin and not be worried
that add_user() won't be called and hence ultimately do_something_here
won't be called either. django admin is cool, but I can't get my
head around it screwing all my business logic.

I am using signals in a few places, which gets me around problem #2 in
most cases, but now all.

Cheers!
Sumit


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



Re: Untouched admin templates throwing TemplateSyntaxError

2009-04-07 Thread Jacolyte

On Apr 6, 9:34 pm, Karen Tracey  wrote:
> I suspect something's gone wrong with your context processor settings, or
> their operation.
>
> It's unclear to me from what you wrote if you wrote your own context
> processor to get MEDIA_URL or are simply using the provided one that does
> this:
>
> http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-c...

You're right, there was a problem with my context processor. I used a
snippet from this URL:
http://stackoverflow.com/questions/557460/django-having-middleware-communicate-with-views-templates

This is the line that was causing the problem:
'DJANGO_ROOT': request.META['SCRIPT_NAME'],

> If the former, I'd switch to the latter.  If you're already using the
> built-in one, I'd still try removing it and seeing if that fixes the issue.
> If it does, then you can look more closely at how they're being configured
> -- these two certainly don't usually interfere with each other.
>
> Karen

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



Re: mod_python error

2009-04-07 Thread skunkwerk

problem solved - i needed to refresh the page in my browser to see the
debug log.

thanks!

On Apr 7, 1:59 am, Florian Strzelecki 
wrote:
> And... what about that :
>
> DocumentRoot:   '/usr/local/apache2/htdocs'
>
> URI:            '/contact.php'
> Location:       '/'
> Directory:      None
> Filename:       '/usr/local/apache2/htdocs/
> contact.php'
> PathInfo:       ''
>
> Phase:          'PythonHandler'
> Handler:        'django.core.handlers.modpython'
>
> Are you trying to serve a php file with mod_python ?
> If you see what I meen. :]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Stuck in Tutorial Part 2: can't find django/contrib/admin/templates

2009-04-07 Thread ab3...@gmail.com

I'm working through the tutorial and got stuck near the end of part 2.
It says:

"Now copy the template admin/base_site.html from within the default
Django admin template directory (django/contrib/admin/templates) into
an admin subdirectory ..."

I cannot figure out what they mean by directory django/contrib/admin/
templates

This looks like a relative path, but relative to what? When I created
my project there were no subdirectories called django.

What are they talking about?

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



Re: Stuck in Tutorial Part 2: can't find django/contrib/admin/templates

2009-04-07 Thread Alex Gaynor
On Tue, Apr 7, 2009 at 2:42 PM, ab3...@gmail.com  wrote:

>
> I'm working through the tutorial and got stuck near the end of part 2.
> It says:
>
> "Now copy the template admin/base_site.html from within the default
> Django admin template directory (django/contrib/admin/templates) into
> an admin subdirectory ..."
>
> I cannot figure out what they mean by directory django/contrib/admin/
> templates
>
> This looks like a relative path, but relative to what? When I created
> my project there were no subdirectories called django.
>
> What are they talking about?
>
> >
>
It's relative to wherever you installed Django itself.  If you aren't sure
where django is intalled on your system(perhaps a package manager installed
it) you can do import django; django.__file__ which shows the __init__ file
in the django/ directory of that path.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Stuck in Tutorial Part 2: can't find django/contrib/admin/templates

2009-04-07 Thread Daniel Roseman

On Apr 7, 7:42 pm, "ab3...@gmail.com"  wrote:
> I'm working through the tutorial and got stuck near the end of part 2.
> It says:
>
> "Now copy the template admin/base_site.html from within the default
> Django admin template directory (django/contrib/admin/templates) into
> an admin subdirectory ..."
>
> I cannot figure out what they mean by directory django/contrib/admin/
> templates
>
> This looks like a relative path, but relative to what? When I created
> my project there were no subdirectories called django.
>
> What are they talking about?

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



Re: Multiple Primary Key

2009-04-07 Thread maeck

You can use the meta variable unique_together.
This will do something like this, however, does not work for existing
datamodels.



On Apr 7, 9:06 am, Alex Gaynor  wrote:
> On Tue, Apr 7, 2009 at 11:53 AM, sandravigo  wrote:
>
> > Hello, I want to know how I can to declarate multiple primary key in
> > my model
>
> Django doens't support multiple column primary keys.  This is the subject of
> ticket #373 in Django's trac.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: mod_python error

2009-04-07 Thread skunkwerk

thanks guys,
the error isn't just with .php pages so i don't think that's the
problem.  i've turned on debug mode, and put back 500.html, but I'm
not seeing a debug page... just the 500 page template with no
tracebacks or anything.  how do i see the regular django debug page?

On Apr 7, 1:59 am, Florian Strzelecki 
wrote:
> And... what about that :
>
> DocumentRoot:   '/usr/local/apache2/htdocs'
>
> URI:            '/contact.php'
> Location:       '/'
> Directory:      None
> Filename:       '/usr/local/apache2/htdocs/
> contact.php'
> PathInfo:       ''
>
> Phase:          'PythonHandler'
> Handler:        'django.core.handlers.modpython'
>
> Are you trying to serve a php file with mod_python ?
> If you see what I meen. :]
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to keep the translations for the templates from different applications separately?

2009-04-07 Thread Valery

Hi

no answers... does it mean that it is impossible in Django to separate
the template translations from different applications?..

regards,
Valery

On Apr 4, 7:07 pm, Valery  wrote:
> Hi
>
> How could one keep the translations for the templates from different
> apps separately? According to Django docs (http://www.djangobook.com/
> en/2.0/chapter19/) one could put the application's translations in a
> correspondent application folder, but it has a few to do with
> templates whereas the very templates carry the larger part of texts to
> be translated. I am puzzled.
>
> there are two ways that look for me somewhat feasible:
>
> 1. keep all applications outside of project tree and try to attach
> them in some "pluggable" way, e.g. like middleware (sounds odd to me)
>
> 2. use LOCALE_PATHS to point to myproject/templates/application-N/
> locale/ where the translations are stored (this didn't work for me)
>
> P.S. In fact I have cross-posted this question from pinax-user group
>
> regardsValery
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



problem altering a model and the corresponding table

2009-04-07 Thread Margie

I am trying to add an integer 'priority' field to one of my models

I added the field like this in models.py:

class Task(models.Model):
PRIORITY_CHOICES = (
(1, _('1 (Critical)')),
(2, _('2 (High)')),
(3, _('3 (Normal)')),
(4, _('4 (Low)')),
(5, _('5 (Very Low)')),
)

priority = models.IntegerField(choices=PRIORITY_CHOICES,
default=3, blank=3,
   help_text=_('1 = Highest Priority,
5 = Low Priority'),)

Then I modified the .db file (sqlite3) like this:

> ALTER TABLE chipvision_task ADD COLUMN priority integer;

But when I run syncdb (using a fixture generated off the the original
db) I get an error:

  File "/tools/aticad/1.0/external/python-2.5.1/lib/python2.5/site-
packages/django/utils/simplejson/decoder.py", line 208, in JSONObject
raise ValueError(errmsg("Expecting property name", s, end - 1))
ValueError: Expecting property name: line 2178 column 3 (char 41357)

Anyone know what I am doing wrong? I also tried adding the priority
field to my .json fixture, but still get this error.

Margie

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



Re: blank=True on Char/TextFields

2009-04-07 Thread julianb

On Feb 12, 5:35 pm, tow  wrote:
> class TextData(models.Model):
>      text = models.TextField(blank=True)
>
> obj = TextData()
> obj.text = None
> obj.save()
>
> gives me an IntegrityError. Why? I don't care that whether that's
> saved as a Null or an zero-length string, I just want Django to save
> back my data according to whatever convention it's using for this
> field - the docs tell me if I do blank=True, then it'll use an empty
> string and not bother distinguishing nulls; or at least so they imply
> to me. But apparently it is trying to distinguish nulls, because it's
> given me an IntegrityError. I was expecting Django to coerce the None
> to an empty string before saving.

The key to success here is using default="".
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



How to widen the text fields in the admin pages for editing records

2009-04-07 Thread Mac

Any pointers to the documentation for getting the text fields larger
for CharField data?  They're kinda puny for columns that are defined
to have up to 255 characters.  Thanks!

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



Re: Multi app project and inter app communication

2009-04-07 Thread kRON

I guess you've cleared up what Django is and is not for me.

I sat down today and finally chewed through the documentation without
giving up at any point. I guess I was assuming Django would be doing a
lot of magic in the background and the 'one Django project composing
of multiple Django apps' bit made me go off on an overly imaginative
roll. I can't be blamed nor held responsible :)!! The documentation
doesn't make it readily available that all that Django does that could
concern us is chew the initial urlconf and from then on it's our show.
Viewing Django more as a library, the applications as simply packages
and focusing on the Python imports for linking it all up made
everything perfectly clear in the end.

Thanks for hitting me with it Malcom!

On Apr 7, 2:56 pm, Malcolm Tredinnick 
wrote:
> On Tue, 2009-04-07 at 04:36 -0700, kRON wrote:
> > Hello everyone. I've only recently started developing app with Django
> > and in Python as well. I have a fair experience in developing web apps
> > on frameworks in PHP and I'm really trying to make a commitment on
> > doing my first Django app properly (all the good methodologies and
> > practices included)
>
> Remember to learn to crawl before you can walk. Your first (and even
> second and third, most likely) Django application isn't going to be
> production quality. Spend some time learning to use Django, then spend
> some time looking at options (and there are always options -- no single
> best way to do any of this) for splitting up applications and working
> with configuration options, etc.
>
> > The first bit I can't figure out are Django applications. I know that
> > they are, in essence, Python modules, but it doesn't say what does
> > Django do once it encounters an application. Does it add it to the
> > sys.path? Does it automatically load certain files, or does that have
> > to be explicitly specified somewhere?
>
> Thinking about this as Django "encountering an application" is probably
> going to lead to confusion. Django is more of a library than a
> framework, from the perspective of somebody writing an application. That
> is, you pull things from the Django modules (and your application
> modules) as required -- there's relatively little usage of Django
> calling something of yours (the exception being the passing of requests
> to view functions). The point being that, generally, if you need to use
> code from a particular application, you import the appropriate Python
> module(s) and use it, just like in normal Python code.
>
> Django certainly doesn't do any modification of sys.path for particular
> applications. Quite the reverse: it is assumed that applications are
> importable using the name you specify in the INSTALLED_APPS list. That
> is, your Python path has to already be set up so that you can import all
> those things using those names.
>
> The main reason (from an import perspective) that Django needs to know
> about the installed applications (the INSTALLED_APPS list) is so that it
> can work out reverse relations automatically. If you specify that model
> A in application XYZ has a many-to-one relation to model B in
> application PQR, Django will also set things up so that model B can
> refer back to model A, without needing to also specify something in the
> source for model B. This means that when importing model B, Django needs
> to look at all the other models in all the installed applications to see
> if there are any field pointing to model B (this is done through some
> caching, the computation isn't something onerous on every request).
>
> By and large, though, that last paragraph isn't important. The important
> part is the first think I mentioned: if you need to use some code from
> an application, import it as per normal.
>
>
>
> > Another question I have is with custom settings. I'd like to have each
> > application have it's own settings file. How is this then accessed by
> > the application? Do I have to import /proj/myapp/settings.py in my
> > main /proj/settings.py file? I figure that this would make the
> > settings globally available, so /proj/myapp2 can access the settings
> > from /proj/myapp1, but what if I want to have some application
> > specific settings that I do not wish to be accessed by other
> > applications too?
>
> Life doesn't really work like that.
>
> Django's "settings" are, intentionally an essentially globally visible
> object that anything can read. The reason it's read via a single file is
> because there are potentially highly complex interactions between
> settings when you're involving multiple applications and we require a
> human -- the installing user -- to set things up in an holistic fashion.
> At the settings level, it's pretty difficult to remain entirely
> orthogonal, due to the intentional global visibility nature of things.
>
> However, if you're just talking about intra-application settings of some
> kind that the end-users won't need to touch (making them not really
> settings

Help DjangoDecode Error

2009-04-07 Thread CrabbyPete

I keep getting this message when I try to save a record to my database
DjangoDecodeError: 'utf8' codec can't decode byte 0xae in position 268

I have __unicode__ defined in my models. I changed mysql to use utf8.
I don't know what else to do

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



Best Practices - Model Changes on Production servers

2009-04-07 Thread Adam Nelson

Is there a page that has any sort of list of Django rollout
methodologies and best practices with regards to that issue?

I'm trying to deploy some major model changes and although I'm fine
doing everything manually, it would be nice to have some help (even
just an ALTER TABLE generator).

I've found Fabric (http://www.nongnu.org/fab/) which is geared more
towards large deployments where scripting is more time-efficient than
just doing things 'in real time'.  My biggest need right now is to get
an ALTER TABLE generator.

Please let me know if one exists.

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



Re: Best Practices - Model Changes on Production servers

2009-04-07 Thread Alex Gaynor
On Tue, Apr 7, 2009 at 5:22 PM, Adam Nelson  wrote:

>
> Is there a page that has any sort of list of Django rollout
> methodologies and best practices with regards to that issue?
>
> I'm trying to deploy some major model changes and although I'm fine
> doing everything manually, it would be nice to have some help (even
> just an ALTER TABLE generator).
>
> I've found Fabric (http://www.nongnu.org/fab/) which is geared more
> towards large deployments where scripting is more time-efficient than
> just doing things 'in real time'.  My biggest need right now is to get
> an ALTER TABLE generator.
>
> Please let me know if one exists.
>
> Thanks,
> Adam
> >
>
There are several projects for schema evolution, the 2 most popular are
Django-evolution and South.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Something is eating memory. How to track it down?

2009-04-07 Thread AndyB

I've got a Django app that seems to eat up a lot of memory. I posted a
message on Stack Overflow and it got a little sidetracked into a
debate about the merits of WSGI and Apache in Worker MPM mode.

Webfaction have assured me that playing around withthat kind of thing
is not going to make a significant difference and that my app is to
blame.

Googling around Python and memory profiling led me to heapy but the
documentation for that is written in ancient Sumerian Even this very
helpful page ( 
http://blog.redinnovation.com/2008/03/07/debugging-django-memory-leak-with-trackrefs-and-guppy
) wasn't quite simple enough for my meagre understanding of Python
internals.

I am hoping for some way to list all the objects in memory. I'm sure I
can do this with with heapy but I don't really understand what it is
telling me.

Should I persevere or is there something a bit easier to understand
that I could be using?

Maybe I am I just too dense for the task at hand :-(

Maybe it's getting late and I deserve a nice gin and tonic...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Something is eating memory. How to track it down?

2009-04-07 Thread Christian Joergensen

AndyB wrote:
> I've got a Django app that seems to eat up a lot of memory. I posted a
> message on Stack Overflow and it got a little sidetracked into a
> debate about the merits of WSGI and Apache in Worker MPM mode.

First thing - make sure DEBUG is set to off.

If that's not the problem, Let me take a wild shoot in the dark; are you 
by any chance looping through a large queryset?

I recently had a proces hog about 1.8 GB RAM when looping through a 
queryset with approx. 350k items as:

for obj in Model.objects.all():
 do_something(obj)

I rewrote it to:

objs = Model.objects.all().values_list("id", flat=True)
for obj_id in objs:
 obj = Model.object.get(pk=obj_id)
 do_something(obj)

... and my RAM usage was below 30 MB at all time.

> Maybe it's getting late and I deserve a nice gin and tonic...

Cheers,

-- 
Christian Joergensen
http://www.technobabble.dk

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



Re: Something is eating memory. How to track it down?

2009-04-07 Thread Alex Gaynor
On Tue, Apr 7, 2009 at 6:02 PM, Christian Joergensen  wrote:

>
> AndyB wrote:
> > I've got a Django app that seems to eat up a lot of memory. I posted a
> > message on Stack Overflow and it got a little sidetracked into a
> > debate about the merits of WSGI and Apache in Worker MPM mode.
>
> First thing - make sure DEBUG is set to off.
>
> If that's not the problem, Let me take a wild shoot in the dark; are you
> by any chance looping through a large queryset?
>
> I recently had a proces hog about 1.8 GB RAM when looping through a
> queryset with approx. 350k items as:
>
> for obj in Model.objects.all():
> do_something(obj)
>
> I rewrote it to:
>
> objs = Model.objects.all().values_list("id", flat=True)
> for obj_id in objs:
> obj = Model.object.get(pk=obj_id)
> do_something(obj)
>
> ... and my RAM usage was below 30 MB at all time.
>

You also executed 350k SQL queries.  A better idea would be to start with:

for obj in Model.objects.all().iterator():
   do_something(obj)


>
> > Maybe it's getting late and I deserve a nice gin and tonic...
>
> Cheers,
>
> --
> Christian Joergensen
> http://www.technobabble.dk
>
> >
>
Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: Merging apps

2009-04-07 Thread TiNo
>
>  Do I have to bite the bullet and merge the databases , views files,
>>
> settings etc etc?
>
>
(message got stuck in drafts so replying a little late...)

As Django is currently not able to deal with multiple databases [1], yes,
you will have to merge all data into one database.

Views are part of an app, and you wouldn't have to update those, apart from
some url-lookups maybe.

Your settings.py and urls.py will have to be update to resp. reflect the
changes in db-connections en template location, and put all apps under the
correct url.

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

TiNo


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



Re: Something is eating memory. How to track it down?

2009-04-07 Thread Christian Joergensen

Alex Gaynor wrote:
>> I recently had a proces hog about 1.8 GB RAM when looping through a
>> queryset with approx. 350k items as:
>>
>> for obj in Model.objects.all():
>> do_something(obj)
>>
>> I rewrote it to:
>>
>> objs = Model.objects.all().values_list("id", flat=True)
>> for obj_id in objs:
>> obj = Model.object.get(pk=obj_id)
>> do_something(obj)
>>
>> ... and my RAM usage was below 30 MB at all time.
>>
> 
> You also executed 350k SQL queries.  A better idea would be to start with:

Well, that in itself shouldn't cause that much RAM usage - just longer 
execution time.

My guess, without looking at the queryset implementation, is that they 
cache earlier, passed by items.

> for obj in Model.objects.all().iterator():
>do_something(obj)

Thank you. I didn't know about that function. That is certainly prettier 
than my "hack" :)

I assumed that was the default behaviour when iterating. There shouldn't 
be any need to cache previous items, as there (to my knowledge).is no 
way to retrieve previous items from a python iterator.

Regards,

-- 
Christian Joergensen
http://www.technobabble.dk

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



Re: Something is eating memory. How to track it down?

2009-04-07 Thread andybak

I've got no really huge tables - the entire db is under 6meg and the
site isn't even public yet so traffic is minimal. Memory just doesn't
seem to go down. (until the process get's restarted by maxchild or by
me killing it).

I have been labouring under the assumption that memory gets freed
eventually and I could ignore the messy details (heck why do you think
I'm not a C++ programmer).

It's a bit of a needle in a haystack at this point. Surely I can do
better than blindly optimize things on the off-chance that I find the
root of the problem?

Andy

On Apr 7, 11:04 pm, Alex Gaynor  wrote:
> On Tue, Apr 7, 2009 at 6:02 PM, Christian Joergensen  wrote:
>
> > AndyB wrote:
> > > I've got a Django app that seems to eat up a lot of memory. I posted a
> > > message on Stack Overflow and it got a little sidetracked into a
> > > debate about the merits of WSGI and Apache in Worker MPM mode.
>
> > First thing - make sure DEBUG is set to off.
>
> > If that's not the problem, Let me take a wild shoot in the dark; are you
> > by any chance looping through a large queryset?
>
> > I recently had a proces hog about 1.8 GB RAM when looping through a
> > queryset with approx. 350k items as:
>
> > for obj in Model.objects.all():
> >     do_something(obj)
>
> > I rewrote it to:
>
> > objs = Model.objects.all().values_list("id", flat=True)
> > for obj_id in objs:
> >     obj = Model.object.get(pk=obj_id)
> >     do_something(obj)
>
> > ... and my RAM usage was below 30 MB at all time.
>
> You also executed 350k SQL queries.  A better idea would be to start with:
>
> for obj in Model.objects.all().iterator():
>    do_something(obj)
>
>
>
> > > Maybe it's getting late and I deserve a nice gin and tonic...
>
> > Cheers,
>
> > --
> > Christian Joergensen
> >http://www.technobabble.dk
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to widen the text fields in the admin pages for editing records

2009-04-07 Thread Brian Neal

On Apr 7, 3:04 pm, Mac  wrote:
> Any pointers to the documentation for getting the text fields larger
> for CharField data?  They're kinda puny for columns that are defined
> to have up to 255 characters.  Thanks!

You do it by supplying your own widget to the form field. See:

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

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



Re: How to widen the text fields in the admin pages for editing records

2009-04-07 Thread Mac

On Apr 7, 6:56 pm, Brian Neal  wrote:
> On Apr 7, 3:04 pm, Mac  wrote:
>
> > Any pointers to the documentation for getting the text fields larger
> > for CharField data?  They're kinda puny for columns that are defined
> > to have up to 255 characters.  Thanks!
>
> You do it by supplying your own widget to the form field. See:
>
> http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms

Thanks.  I can see how that works if I'm creating my own forms, but
how would I go about modifying the widgets for the forms that ship
with the built-in admin application?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



error handling

2009-04-07 Thread skunkwerk

Hi,
   is there any way to log errors (regardless of whether Debug is true
or false) instead of just displaying a debug trace/emailing the
admins?  is there some setting somewhere, or would I have to write
some additional code like this: http://www.djangosnippets.org/snippets/639/
to get it working?

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



Re: Many Questions, some of which are theoretical

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 06:46 -0700, zayatzz wrote:
> Hello
> 
> Im mainly thinking bit ahead here, while im still in the beginning of
> writing my first real project/application with django.
> If someone could answer all or some of those questions and perhaps
> provide examples, then i would greatly appreciate your help and buy
> you a beer, whenever you end up near where i live :).
> 
> 1) Cookies. I read from older posts that there is some kind of django
> authentication library/module for holding that kind of information. In
> any case, lets say that i dig deep enough into that module and figure
> out how to do all that while session is active, but how do i read that
> information from browser cookie next time the user comes to this site?

You're looking at too low a level. The basic session management
application that comes with Django (django.contrib.sessions) provides
the layer between the browser cookie identifier and information you've
stored in the session. Note that the data is stored server-side, not in
the cookie itself: the cookie provides only the session identifier to
retrieve the session information from the session storage. There are
other ways to do session (you're not required to use Django's session
application, after all), but for many purposes, the Django default app
is sufficient and make life very easy.

> 
> 2.1) Since im thinking about creating site with some sort of cms i
> want to know what kind of field types should i usefor lengthy texts
> like news or basic content articles?

Worth reading the documentation on the basic model field types for
information like this. The TextField pretty much screams out for use
here.

> 2.2) Is there a point building full scale cms with django or should
> that be done with just python? Will django actually hinder such
> projects?

You can use Django for this. In fact, the original usage of Django is
for the commercial product (still being used by a lot of companies)
called Ellington, which is a CMS.

> 
> 3) Are there any examples of pages which get their content from
> several views/modules? 

The question doesn't make sense from the terminology you're using. A
"view" function is just a function that is used as the entry point for
processing a particular request. After identifying the URL requested,
processing has to go somewhere and that somewhere is called a view
function. The view can happily call other functions to collect the data
it leaves. When the initial view function returns, that returned data is
what is sent back to the client.

> Or what is the general practice with pages that
> load information from different places to one page? 

Collect the information however you like and pull it all together before
rendering it via a template (or some other way to final content that
goes into an HttpResponse object).

> You create view
> that imports information from several modules and shows it as single
> page or is there some way to just reload certain area of a webpage
> when visitor clicks a button/link or fills a form.

Ajax is supported, since that is just another HTTP call. There's also
support  for detecting if a call is an Ajax-style call or not (there's
an is_ajax() method on the HttpRequest object.

> 
> 4) Are there any good examples about how to use javascript/ajax with
> django?

Yes. Google is your friend here.

> 
> 5) How can i manage images with django. Are there stuff like gdlib/
> imagemagic for django?

You can certainly use either of those if you like. The standard Python
imaging library is called the Python Imaging Library (PIL) and Django
uses that for things like determining the size of an uploaded image.
Again, a quick read of the model documentation would probably give you
some immediate benefits here. That sort of thing is mentioned when the
ImageField is described.

There is a *lot* of documentation for Django, the majority of it pitched
at a level that somebody learning the framework can pick things up when
they're paying attention. Lots of code fragments and more complete
examples. Well worth taking a few evenings to read through what's there.

Regards,
Malcolm


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



Re: Admin action not executed when no objects are selected

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 06:55 -0700, pault wrote:
> I want to run an action from my admin when I press the GO button
> without having to select any objects.
> 
> But it seems actions are only triggered when at least one object is
> selected. Does anyone know a workaround for this.

What you're after are not admin actions then, since admin actions are
things that apply to multiple objects at once (they're basically batch
operations).

However, the templates used in the admin are all customisable and
overridable, usually on a per-app and even per-model basis. So you can
easily add your own extra button(s) that perform some action. Adding
your own URL handling to the admin is also documented. Best to use the
upcoming 1.1 release (e.g. 1.1-beta now) for that, since it's all much
easier.

Regards,
Malcolm



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



Re: how to use email instead of username for user authentication?

2009-04-07 Thread felix
I use an EmailBackend for auth, found on django snippets
http://www.djangosnippets.org/snippets/74/
(though the one pkenjora posted looks the same but slightly better.)

and a generate_username to create a clean unique username when creating
accounts,
also found on django snippets

http://www.djangosnippets.org/snippets/723/


I sure wish djangosnippets had a google search box attached.


On Tue, Apr 7, 2009 at 10:38 AM, johan.uhIe <
johan.u...@student.hpi.uni-potsdam.de> wrote:

>
> The slugify function may also provide you with valid usernames, if you
> feed it with first and last name for example. But always be certain,
> that the username is unique, just as malcolm described.
> >
>

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



Re: Admin action not executed when no objects are selected

2009-04-07 Thread Alex Gaynor
On Tue, Apr 7, 2009 at 8:04 PM, Malcolm Tredinnick  wrote:

>
> On Tue, 2009-04-07 at 06:55 -0700, pault wrote:
> > I want to run an action from my admin when I press the GO button
> > without having to select any objects.
> >
> > But it seems actions are only triggered when at least one object is
> > selected. Does anyone know a workaround for this.
>
> What you're after are not admin actions then, since admin actions are
> things that apply to multiple objects at once (they're basically batch
> operations).
>
> However, the templates used in the admin are all customisable and
> overridable, usually on a per-app and even per-model basis. So you can
> easily add your own extra button(s) that perform some action. Adding
> your own URL handling to the admin is also documented. Best to use the
> upcoming 1.1 release (e.g. 1.1-beta now) for that, since it's all much
> easier.
>
> Regards,
> Malcolm
>
>
>
> >
>
When this feature was implemented it was discussed whether the actions
should be called if no items were selected.  The conclusion was no, since
it's not very intuitive for the same UI element to control 2 types of
actions(those that happen to regardless of whats selected and those that are
applied to selected objects).  What you really want is an extra link the
object-tools part of the page.
http://docs.djangoproject.com/en/dev/obsolete/admin-css/?from=olddocs#object-toolsexplains
how to get them there(the part of the page that warns this is no
longer applicable, isn't applicable for this).

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

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



Re: how to use email instead of username for user authentication?

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 10:16 -0700, pkenjora wrote:
> Hi,
> 
>   Why not remove the '@' filter and allow the specific project
> developer the freedom to use email as username?  What was the
> reasoning behind this?

One reason is that usernames can be made to be unique, since you're
selecting a new username and if the one you choose is already taken, you
can choose another one. You cannot, however, easily change your email
address and there are cases of different people sharing a single email
address or the same person needing/wanting to create multiple accounts.

Another reason is likely simply historical; usernames that *aren't*
email addresses are much more readable and traditional in social-based
sites and that was what was used in the initial implementation. The
uniqueness problem mentioned above is very real, however, so Django is
protecting people from doing dumb things here. If you want to work
around that, it's possible and fairly easy, but not heavily advisable.

>   I always like Django because it didn't try to force development down
> a specific path.  All developers have their own way and every project
> is unique, for a long time Django accommodated that.  I'm a bit
> worried about where this is going...

It's not "going" anywhere. The username requirements have been the same
since the very first day you used Django. Don't frame this as something
slipping out of control, please.

> 
>   I'm worried that the workarounds just introduce unnecessary
> complexity.

Almost as if you shouldn't workaround a valid constraint, isn't it? :-)

Regards,
Malcolm


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



Re: blank=True on Char/TextFields

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 10:26 -0700, Magus wrote:
> I agree with Lee. There should be a way for a developer to store NULL
> into a char field. At the moment null flag has no effect for a
> CharField. Generally saying an empty string is not the same a not
> defined value = NULL. It's pity that the according ticket is closed
> with won't fix http://code.djangoproject.com/ticket/9590

If you do your research, you'll discover that

(a) the people making the decisions on this issue are well aware that
blank is not the same as NULL, which is, in fact, precisely the reason
why null=True is not supported there, and

(b) The reason this is the way it is is because Django is initially and
still primarily use for web-browser-based applications. A blank form
field is ambiguous -- is it blank or null? to provide both options and
remove the abiguity requires yet another UI option.

(b) If you really want a character field that also supports NULL and
you're happy to handle the UI or default behaviour however you want,
there's nothing stopping you. Writing custom fields is very easy,
particularly for something like this. So just go ahead and Do It(tm).

Regards,
Malcolm



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



Re: How to widen the text fields in the admin pages for editing records

2009-04-07 Thread TiNo
On Wed, Apr 8, 2009 at 1:54 AM, Mac  wrote:

>
> On Apr 7, 6:56 pm, Brian Neal  wrote:
> > On Apr 7, 3:04 pm, Mac  wrote:
> >
> > > Any pointers to the documentation for getting the text fields larger
> > > for CharField data?  They're kinda puny for columns that are defined
> > > to have up to 255 characters.  Thanks!
> >
> > You do it by supplying your own widget to the form field. See:
> >
> > http://docs.djangoproject.com/en/dev/ref/forms/widgets/#django.forms
>
> Thanks.  I can see how that works if I'm creating my own forms, but
> how would I go about modifying the widgets for the forms that ship
> with the built-in admin application?


You can override the ModelAdmin.form attribute to provide your own
customized form.
See: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form

TiNo

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



Iterating over a field using widget=ChekboxSelectMultiple

2009-04-07 Thread Jim

Hello,

I have this form.

class SearchForm(forms.Form):
search=forms.CharField(widget=widgets.SearchWidget)
search_type=forms.MultipleChoiceField
(widget=CheckboxSelectMultiple,choices=[('a','A'),('b','B'),])

In the template I want to say something like this.
  
Search {{fm.search}}
Type {% for k in ??? %}{{k}} {% endfor %}

but I cannot make out what goes in that last .. .  Could I
ask someone to help me with a hint?  I'd be very grateful.

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



Re: How to widen the text fields in the admin pages for editing records

2009-04-07 Thread Mac

On Apr 7, 8:15 pm, TiNo  wrote:

> You can override the ModelAdmin.form attribute to provide your own
> customized form.
> See:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#form

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



Re: Something is eating memory. How to track it down?

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 15:20 -0700, andybak wrote:
> I've got no really huge tables - the entire db is under 6meg and the
> site isn't even public yet so traffic is minimal. Memory just doesn't
> seem to go down. (until the process get's restarted by maxchild or by
> me killing it).

That's completely normal behaviour for Unix-like memory management. Once
memory is freed, it is returned to the process for later reuse (so a
subsequent malloc() call by that process will reuse memory that is had
earlier freed). This helps avoid some causes of memory fragmentation and
allows for contiguous large blocks to be malloc-ed by other processes.

It's also precisely why long running processes are often designed to
have their memory using portions restart periodically. It's the act of
exiting the process at the system level which returns the memory to the
system pool.

Regards,
Malcolm



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



Re: Iterating over a field using widget=ChekboxSelectMultiple

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 17:28 -0700, Jim wrote:
> Hello,
> 
> I have this form.
> 
> class SearchForm(forms.Form):
> search=forms.CharField(widget=widgets.SearchWidget)
> search_type=forms.MultipleChoiceField
> (widget=CheckboxSelectMultiple,choices=[('a','A'),('b','B'),])
> 
> In the template I want to say something like this.
>   
> Search {{fm.search}}
> Type {% for k in ??? %}{{k}} {% endfor %} tr>
> 
> but I cannot make out what goes in that last .. .  Could I
> ask someone to help me with a hint?  I'd be very grateful.

Sounds like you're after the functionality that is currently missing and
is the the ultimate solution of ticket #9230. For now, there's no
particularly good workaround beyond writing your own widget or manually
writing the HTML.

Regards,
Malcolm



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



Re: Stuck in Tutorial Part 2: can't find django/contrib/admin/templates

2009-04-07 Thread ab3...@gmail.com

Thanks! You have unlocked the rest of the tutorial for me. I
appreciate your help.

On Apr 7, 12:57 pm, Alex Gaynor  wrote:
> On Tue, Apr 7, 2009 at 2:42 PM, ab3...@gmail.com  wrote:
>
> > I'm working through the tutorial and got stuck near the end of part 2.
> > It says:
>
> > "Now copy the template admin/base_site.html from within the default
> > Django admin template directory (django/contrib/admin/templates) into
> > an admin subdirectory ..."
>
> > I cannot figure out what they mean by directory django/contrib/admin/
> > templates
>
> > This looks like a relative path, but relative to what? When I created
> > my project there were no subdirectories called django.
>
> > What are they talking about?
>
> It's relative to wherever you installed Django itself.  If you aren't sure
> where django is intalled on your system(perhaps a package manager installed
> it) you can do import django; django.__file__ which shows the __init__ file
> in the django/ directory of that path.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



A long way ...

2009-04-07 Thread mettwoch

Hi,

I've been watching Django and other Python frameworks a few years ago
and stopped at version 0.96. Last year I started to look at a web
framework to move an old M$ Access Inventory application to a more
stable and universal architecture. Turbogears was the choice and a few
weeks ago I rediscovered Django and now I feel bad! I've spent
hours and hours to build an admin interface in TG and Django 1.+ now
has everything I missed in 0.96. Guys, I'm back to Django!

There's nothing time critical with that app because the Access thing
does the trick, but I'd like to do it all the right way this time!

So I've a set of questions:

- Might SQLite be a viable choice for an "ERP" type application with a
lot of updates? I've experienced lock problems with SQLite in other
frameworks using SQLObject!

- We use multiple languages in my country (FR, EN, DE, ...). Is
Unicode the right choice (UTF-8)?

- Could a project be "ERP" and the applications "FO" and "BO" (Front-
and Back-Office)? Would the model be located in the project rather
than in one of the applications as per default? The model is shared by
FO and BO and doesn't especially belong to one of these! BO will be
mostly "Django admin" style + some business reports and some OLAP
while FO is essentially Point-Of-Sales stuff!

- What might be a typical Dev/Test/Prod environment with Django?
Multiple db schemes prj_dev, prj_tst, prj_prd?

I'd like to be up and producing code soon because the db Model is
mature and the migration strategy is clear in my head, but I need some
guidance to set me on track with the Django philosophy.

Thanks for any help

Marc
a devoted Pythonist since version 1.5.2


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



for loop appending objects

2009-04-07 Thread thedja

Good day to you all,

Im using
q = Person.objects.filter(pk=query)

and i have this inside a FOR statement. So every time the loop starts
again q gets rewritten instead of adding the new objects.

for stuff in box:
for thing in things:
 if stuff==thing:
   q = Person.objects.filter(pk=thing)


Please can someone help me with this. I have looked alot on django
query references and djangobook but dont know what to do.
I dont want to store the objects in a list because I think there must
be a way to do this like merging or joining queries.

I would need to get the query added to the next one on each loop
instad of overwritting it

any advice is welcome

thedja



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



"id may not be NULL" during save in one-to-many relationship

2009-04-07 Thread Hostile Fork

Hello djangoists!

Code has been coming along pretty well in my first django project.
But I hit a snag with a one-to-many relationship in my model.

When I do something like this:

f = Foo()
b = Bar(foo=f)
f.save()
b.save() # error here

I get an error like "foos_bar.foo_id may not be NULL" during b.save
().  Basically it seems to still think that f has a null ID, even
though it was issued one in the f.save() call on the line before.
Changing to this works:

f = Foo()
f.save()
b = Bar(foo=f)
b.save() # works fine

Is this expected behavior, or do I have something configured wrong?  I
was kind of hoping to create a lot of objects in memory and defer
saving any of them until all the code had finished, as a sort of poor-
man's transaction...

Thanks!
---
http://hostilefork.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
-~--~~~~--~~--~--~---



"python2.5 manage.py syncdb" ...No module named _sqlite3

2009-04-07 Thread George

Hi-

I'm pretty sure this shouldn't happen; but the error is no doubt my
fault. Maybe something about the doc doesn't apply to my system? I
have pkgsrc python2.5 and Django 1.0.2

# python2.5 manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/pkg/lib/python2.5/site-packages/django/core/management/
__init__.py", line 340, in execute_manager
utility.execute()
  File "/usr/pkg/lib/python2.5/site-packages/django/core/management/
__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/pkg/lib/python2.5/site-packages/django/core/management/
base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/pkg/lib/python2.5/site-packages/django/core/management/
base.py", line 218, in execute
self.validate()
  File "/usr/pkg/lib/python2.5/site-packages/django/core/management/
base.py", line 246, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/pkg/lib/python2.5/site-packages/django/core/management/
validation.py", line 22, in get_validation_errors
from django.db import models, connection
  File "/usr/pkg/lib/python2.5/site-packages/django/db/__init__.py",
line 34, in 
(settings.DATABASE_ENGINE, ", ".join(map(repr,
available_backends)), e_user)
django.core.exceptions.ImproperlyConfigured: 'sqlite3' isn't an
available database backend. Available options are: 'creation.pyo',
'dummy', 'postgresql', 'util.pyo'
Error was: No module named _sqlite3

# ls /usr/pkg/lib/python2.5/sqlite3/
dbapi2.py  dbapi2.pyc  dbapi2.pyo  __init__.py  __init__.pyc
__init__.pyo  test

# which python2.5
/usr/pkg/bin/python2.5

# grep sqlite3 settings.py
DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '/usr/local/dtest/dtest.db' # Or path to
database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used with sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with sqlite3.


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



Clarifications for apps and models

2009-04-07 Thread Thierry

I'll be referring to the example in the Django documentation here.  I
will extend on the "books" application in the "mysite" project by
creating a new app called "music" so that the structure looks like the
following:

mysite/
books/
models.py - Contains Publisher, Author, Book
music/
models.py - Contains Artist, Album

Let's also assume that the Publisher model from books also publish
music.  How can I can refer to Publisher from music/models.py?   Is
there a place under mysite where I can have a common models.py used by
all my apps?  For example, is mysite/models.py a viable option?

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



model inheritance and column ordering

2009-04-07 Thread rvr

Is there a way to specify a field in an abstract base class, but have
the corresponding column appear last in the table's column list?

class A(models.Model):
ts = models.DateTimeField(default=datetime.now())
class Meta:
abstract = True

class B(A):
blah = CharField()

I'd like the 'ts' column to come after the 'blah' column. I see that
there is some notion of ordering in the models documentation, but
somehow I don't see how to accomplish this. Thanks for the help.

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



0.96 admin inline - post-save on saved related items

2009-04-07 Thread Earthtalker

Hello -

I have a model called Category with a related model called Photos
pointing to it, and edited inline in the admin.
I have some processing I want to do after changes are saved for
Category and its related Photos items, but adding this code after super
(Category, self).save() doesn't seem to be working... I have to SAVE
AND CONTINUE EDITING, then SAVE again... I have tried accessing these
items as self.photos_set.all(), and as Photos.objects.filter
(category=self)... but nothing seems to work.

When are these related records saved in the admin as inline edited
items? How cat I get there?

Thanks very much... cheers!
- Thomas

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



Click-wrap license (seeking django application)

2009-04-07 Thread Social Network in DJango

I'm interested in activating a click-wrap license, similar to what you
get when you install a new program or package, on a pc or osx.

The core issues I've identified so far:
* Acceptance to move on
* Pagenation for convenient viewing
* A reasonable default formatting for what was a word document
* Handling unusual characters such as " and '
* Minimal changes to the text to be able to update it from word as the
original changes

* Using it at registration or while already using the site

I look forward to you input.

Thank you in advance,

Jonathan

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



Uploading music or videos (seeking django package)

2009-04-07 Thread Social Network in DJango

I'd like to upload music and/or photos and/or videos to my website,
with the emphasis on mp3.

Please let me know what BSD license package you can recommend.

Thank you in advance,

Jonathan

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



Re: A long way ...

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 14:31 -0700, mettwoch wrote:
> Hi,
> 
> I've been watching Django and other Python frameworks a few years ago
> and stopped at version 0.96. Last year I started to look at a web
> framework to move an old M$ Access Inventory application to a more
> stable and universal architecture. Turbogears was the choice and a few
> weeks ago I rediscovered Django and now I feel bad! I've spent
> hours and hours to build an admin interface in TG and Django 1.+ now
> has everything I missed in 0.96. Guys, I'm back to Django!
> 
> There's nothing time critical with that app because the Access thing
> does the trick, but I'd like to do it all the right way this time!
> 
> So I've a set of questions:
> 
> - Might SQLite be a viable choice for an "ERP" type application with a
> lot of updates? I've experienced lock problems with SQLite in other
> frameworks using SQLObject!

SQLite isn't a particularly strong choice for concurrent access
situations. For predominantly single-user access, things are better.
There's still some locking overhead, since it is file-based, rather than
network server based. If you want a high performance database, use a
high performance database (MySQL or PostgreSQL, for example). If you
want an embeddable system, SQLite is awesome.

> 
> - We use multiple languages in my country (FR, EN, DE, ...). Is
> Unicode the right choice (UTF-8)?

Yes.

> 
> - Could a project be "ERP" and the applications "FO" and "BO" (Front-
> and Back-Office)?

You're using a lot of buzzwords. What do you mean? Those terms can (and
do) mean pretty much anything to many people. Can you ask a more
concrete question about what problem you're trying to solve?

>  Would the model be located in the project rather
> than in one of the applications as per default?

Models live inside applications. Period. If you've got something with a
model in it that you want to be usable through Django, you have to put
the containing module into the INSTALLED_APPS setting, which makes it,
by definition, an application.

A Django "project" is just a collection of applications, a settings file
and a root URL conf file.


>  The model is shared by
> FO and BO and doesn't especially belong to one of these! BO will be
> mostly "Django admin" style + some business reports and some OLAP
> while FO is essentially Point-Of-Sales stuff!

I fell you might be thinking about this in the wrong terms. Drop the
concept of "ownership", since that's irrelevant to running code. If two
pieces of functionality -- possibly accessible via different web servers
or whatever -- need to use the same application, then that's no problem.
Just put the application into the INSTALLED_APPS setting for both of
them.

> 
> - What might be a typical Dev/Test/Prod environment with Django?
> Multiple db schemes prj_dev, prj_tst, prj_prd?

That's possible. Separate machines is also pretty common -- development
on a local machine, roll out to a staging system, then deploy. Dev and
staging might well have databases and webserver and caching servers
could all be on the same machine. Then in production, things might be
split up over multiple machines a bit more.

> 
> I'd like to be up and producing code soon because the db Model is
> mature and the migration strategy is clear in my head, but I need some
> guidance to set me on track with the Django philosophy.

The general guidance I give to everybody about this is to not sweat the
small stuff too much. What you write in your first few applications
isn't going to be the same as what you would write a month or two or 24
down the track. There are lots of ways to do things, which is good. So
pick something that works, be prepared to experiment and don't worry if
it's not necessarily what other people are doing, because there are
multiple right answers.

Regards,
Malcolm


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



Re: for loop appending objects

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 14:57 -0700, thedja wrote:
> Good day to you all,
> 
> Im using
> q = Person.objects.filter(pk=query)
> 
> and i have this inside a FOR statement. So every time the loop starts
> again q gets rewritten instead of adding the new objects.
> 
> for stuff in box:
> for thing in things:
>  if stuff==thing:
>q = Person.objects.filter(pk=thing)
> 

Sounds like you might be wanting to extract all Person objects with pk
values in a list, so build up the list, then query:

pk_vals = []
for stuff in box:
   for thin in things:
  if stuff == thing:
pk_vals.append(thing)
q = Person.objects.filter(pk__in=pk_vals)

Regards,
Malcolm



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



Re: Clarifications for apps and models

2009-04-07 Thread Malcolm Tredinnick

On Tue, 2009-04-07 at 18:29 -0700, Thierry wrote:
> I'll be referring to the example in the Django documentation here.  I
> will extend on the "books" application in the "mysite" project by
> creating a new app called "music" so that the structure looks like the
> following:
> 
> mysite/
> books/
> models.py - Contains Publisher, Author, Book
> music/
> models.py - Contains Artist, Album
> 
> Let's also assume that the Publisher model from books also publish
> music.  How can I can refer to Publisher from music/models.py?   Is
> there a place under mysite where I can have a common models.py used by
> all my apps?  For example, is mysite/models.py a viable option?

Django models are, for the most part, simply Python classes. So if you
want to refer to a model (class) from somewhere, else, simply import it
and use it.

Thus, in music/models.py:

from books import models as book_models

...
# Refer to Publisher like this
book_models.Publisher

You could even directly import Publisher into the namespace (from
books.models import Publisher). My preference is for the PEP 8 style of
importing the module (helps avoid circular import problems, too), but
that's clearly not everybody's way.

Regards,
Malcolm



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



  1   2   >