capacity planning (server sizing) for Apache+Django+PostgreSQL

2009-09-21 Thread Jan Ostrochovsky

Hello,

are there some calculators or best practises or other tools/methods,
how to size server hardware for Django applications from assumed load
(concurrent users, etc.)?

Thanks in advance for any advice.

Jano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Unique fields that allow nulls

2009-09-09 Thread Jan Ostrochovsky

Karen, thanks for useful workaround.

Another (but little bit sick) workaround I see is to create separate
class for such field, and an optional OneToOneField to that class...

But I see as an ultimate solution to distinguish between NULL and
empty string for CharField and TextField, as I see it, here is reason
to have it.

NULL means undefined (or unknown) value, and its Python equivalent is
probably None.
´´ - empty string - means defined value (and that value is empty
string), and its Python equivalent is empty string.

We can found many many examples, where some entity has some parameter
defined and in that case it must be unique, or it is not defined at
all.

On Sep 9, 4:35 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Wed, Sep 9, 2009 at 9:14 AM, Jan Ostrochovsky <jan.ostrochov...@gmail.com
>
> > wrote:
>
> > Hello,
>
> > I have the exact need, as author of this question:
>
> >http://stackoverflow.com/questions/454436/unique-fields-that-allow-nu...
> > .
>
> I answered on that question because the answer that was there was incorrect.
>
> > I want a value to be unique, if it is not NULL. Database backend
> > allows such construction, but in Django admin I have got this error
> > message when saving form: Business unit with this VAT id already
> > exists.
>
> > As I see it, Django admin is storing empty string (''), and not NULL,
> > as documented here:
> >http://docs.djangoproject.com/en/dev/ref/models/fields/#null,
> > and that is the root cause - empty string is not NULL.
>
> Correct, this is the problem.
>
> > 
>
> > As I found later, this problem is (or was?) discussed also here:
> >http://code.djangoproject.com/ticket/4136.
>
> > Is there any progress in that area? (Some best practise howto...)
>
> > Thanks in advance, any advice is welcome.
>
> I don't know if that ticket will ever be fixed.  In general Django wants to
> store an empty string, not NULL, for empty character fields.  That is not
> going to change and nobody in that ticket has come up with a way to change
> it just for this particular case.
>
> You can work around the existing behavior in your own code by telling admin
> to use a custom form with a custom clean method for the field in question
> which turns the blank string into None.  Then NULLs will be stored in the
> DB, and they willl not compare the same for uniqueness checks.
>
> 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
-~--~~~~--~~--~--~---



Unique fields that allow nulls

2009-09-09 Thread Jan Ostrochovsky

Hello,

I have the exact need, as author of this question:
http://stackoverflow.com/questions/454436/unique-fields-that-allow-nulls-in-django.

I want a value to be unique, if it is not NULL. Database backend
allows such construction, but in Django admin I have got this error
message when saving form: Business unit with this VAT id already
exists.

As I see it, Django admin is storing empty string (''), and not NULL,
as documented here: 
http://docs.djangoproject.com/en/dev/ref/models/fields/#null,
and that is the root cause - empty string is not NULL.



As I found later, this problem is (or was?) discussed also here:
http://code.djangoproject.com/ticket/4136.

Is there any progress in that area? (Some best practise howto...)

Thanks in advance, any advice is welcome.

Jano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: automatic initialization of sample data

2009-09-09 Thread Jan Ostrochovsky

Bill,

thanks for answer, my comments are inline:

On Sep 8, 4:29 pm, Bill Freeman <ke1g...@gmail.com> wrote:
> Well, do you want this to happen every time that the module is imported?  Or
> spend time
> each server start determining that these items are already in the data base
> and skipping
> the initialization?  If not, then you're stuck telling the system when to do
> this anyway (perhaps
> a syncdb extension that does them if it has to create the database?).

I meant not every time module is imported, only when doing "syncdb" or
"evolve" (Django Evolution). So no checks if items are in database are
needed, database could be dropped and newly created before this
operation.

> You do realize that having initializers as default arguments, that they
> consume virtual memory
> forever, whether the database is already loaded or not.

This is good remark. Solution how to avoid that could be to have
somewhere (maybe in settings) flag, for example LOAD_SAMPLE_DATA=True/
False, and these data would be loaded only when set. Or running syncdb
or evolve could temporarily set this flag to true.

>  That isn't
> significant for loading 3 rows,
> as in your example, but I presume that you're actually loading a much larger
> set.

Larger, but not much. Approximately 0 - 30 items in various classes/
tables.

> I typically have a CSV file, or a pickle of a list of dictionaries, and use
> csv.DictReader or cpickle.load
> in a loop that creates a model instance, populates such fields as have keys
> in the source, and saves
> the instance.  I think that it's less work than figuring out how to
> configure some extension, and if you
> let it be driven by the keys present, the code is pretty generic (at least
> for the pickle; with the CSB
> you typically want to convert some strings to ints, floats, and bools.  You
> can also use XML, but I find
> it more complicated, though attributes could control conversions.)
>
> I've taken to putting that code in a separate load.py file, so that even the
> code isn't loaded in the
> server.  You could also just hand code a list of dictionaries in such a
> file.  I still wind up running the
> code from the manage shell, though you could certainly create, for example,
> a view that imports the
> load.py only if the view is referenced (by someone with enough privelege),
> and runs the code.  Or
> you could figure out how to attach it to syncdb.
>
> But you should probably look at fixtures.  I haven't, as yet, but should.
> They seem to be a supported
> means of initializing a database.

In my previous projects (not in Django), it was common practise to
load some data in CSV or XML.
Django fixtures - I used them several times, but I see it only as
alternative of CSV or XML.

Disadvantage of these traditional approaches is, that data are
maintained separately from code. When the code evolves (e.g. renaming
attributes, moving attributes between classes or packages, ...), the
same changes need to be done in files with sample data, and it seems
tedious to me.

I know, that I cannot avoid traditional approach, when e.g. migrating
production data from one version of application to another version, it
is unthinkable to put production data in the code ;).

But when developing application (currently my case), there is only
relatively small set of sample testing data, and I see as big avantage
and developer's comfort, to be able modify sample data accordingly
with code modification.

If such functionality would become part of Django, or Django
Evolution, I'd be happy.

Jano

>
> Bill
>
> On Mon, Sep 7, 2009 at 4:43 AM, Jan Ostrochovsky <jan.ostrochov...@gmail.com
>
> > wrote:
>
> > Thanks Bill, yes, that is one possible solution, when implementing
> > such feature from the scratch.
>
> > I am only asking, if there is some existing framework for such need,
> > which I see as common.
>
> > For example some add-on to Django, which will do this for me. Let's
> > imagine additional option for any field of Django model, e.g.:
>
> > class Person(models.Model):
> >  firstname = models.CharField(max_length=30, initial_values="John,
> > Bill, Peter")
> >  lastname = models.CharField(max_length=70, initial_values="Smith,
> > Clinton, Parker")
> >  ...
>
> > Django with such add-on could be able to build initial database from
> > these values, for example when running syncdb or other way.
>
> > Am I more readable now?
>
> > Jano
>
> > On Aug 20, 10:09 pm, Bill Freeman <ke1g...@gmail.com> wrote:
> > > Perhaps I'm not understanding correctly, but how about, assuming you have
> > a
> > > function
> > > run_data_inits() that calls your chain of init_s

Re: multi-table inheritance - how to access child object methods/attributes

2009-09-09 Thread Jan Ostrochovsky

Manfre, thanks.

It seems like ultimate solution, on the other hand, it seems quite low
level and adds more complexity, which should be added not only for
__unicode__() but also for each method or attribute, which I'd handle
this way.

I meant, if here is something like that:

document_object.some_method_name()
document_object.some_attribute

when such method or attribute does not exist for Document object, it
will look in the child class[es recursively].

Jano

On Sep 8, 5:14 pm, Manfre <mman...@gmail.com> wrote:
> This digs through _meta to figure any related fields and tries each
> until one works.
>
> class Document(models.Model):
>     ...
>
>     def __unicode__(self):
>         name_map = self._meta._name_map
>
>         subs = [x for x in name_map if isinstance(name_map[x][0],
> RelatedObject)]
>
>         for field in subs:
>             try:
>                 sub = getattr(self, field, None)
>                 return sub.__unicode__()
>             except ObjectDoesNotExist:
>                 pass
>
>         return u'Document {0}'.format(self.id)
>
> On Sep 8, 9:01 am, Jan Ostrochovsky <jan.ostrochov...@gmail.com>
> wrote:
>
> > Ugly workaround:
>
> > class Document(models.Model):
> >         pass
> >         def __unicode__(self):
> >                 if self.accountingdocument:
> >                         return self.accountingdocument.__unicode__()
> >                 else:
> >                         return self.__class__.__name_ + ' ' + self.id_
>
> > But I'd prefer solution, where Document class does not know about its
> > child classes (AccountingDocument, etc.). Any idea?
>
> > On Sep 8, 8:31 am, Jan Ostrochovsky <jan.ostrochov...@gmail.com>
> > wrote:
>
> > > Hello,
>
> > > class Document(models.Model):
> > >   ...
>
> > > class AccountingDocument(Document):
> > >   ...
>
> > > How am I able to access methods an attributes of some
> > > AccountingDocument instance (e.g. its __unicode__()) from Document
> > > instance? How am I able to retrieve child object from its parent?
>
> > > I tried to search on the web, but I am not a lot wiser after that...
>
> > > Thanks in advance.
>
> > > Jano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-table inheritance - how to access child object methods/attributes

2009-09-08 Thread Jan Ostrochovsky

Ugly workaround:

class Document(models.Model):
pass
def __unicode__(self):
if self.accountingdocument:
return self.accountingdocument.__unicode__()
else:
return self.__class__.__name_ + ' ' + self.id_

But I'd prefer solution, where Document class does not know about its
child classes (AccountingDocument, etc.). Any idea?

On Sep 8, 8:31 am, Jan Ostrochovsky <jan.ostrochov...@gmail.com>
wrote:
> Hello,
>
> class Document(models.Model):
>   ...
>
> class AccountingDocument(Document):
>   ...
>
> How am I able to access methods an attributes of some
> AccountingDocument instance (e.g. its __unicode__()) from Document
> instance? How am I able to retrieve child object from its parent?
>
> I tried to search on the web, but I am not a lot wiser after that...
>
> Thanks in advance.
>
> Jano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: Error in setting up psycopg2

2009-09-08 Thread Jan Ostrochovsky

Hi Simon,

I had also problems with psycopg2 on Mac OS X. First with development
server (python manage.py runserver), and when solved, later also with
Apache.

Finally I decided for Linux on production server (with Apache), and
let Mac OS X on development workstations (with runserver).

If such setup is suitable also for you, maybe these howtos will be
also useful:
http://sharpe-s-postgres.blogspot.com/2009/09/how-to-install-postgresql-module-for.html
http://sharpe-s-django.blogspot.com/2009/09/deployment-of-django-project-using.html

If you will need some support with Linux or PostgreSQL, do not
hesitate to contact me directly.

Jano

On Aug 25, 1:19 pm, Simon Lee  wrote:
> Hi Thomas,
>
> I did a Google search and did as one suggestion:
> $ export PYTHONPATH=$HOME/:$PYTHONPATH
> $ export DJANGO_SETTINGS_MODULE=mysite3.settings
> $ python
>
> >>> from django.contrib.sessions.backends import db
>
> It works with no error. The same thing works if I do "python manage.py
> shell" without the export.
>
> That does not solve my problem though. I changed myapp.wsgi to the
> following:
>
> --
>
> import os, sys
> sys.path.append('/Users/simonlee')
> os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite3.settings'
> import django.core.handlers.wsgi
> application = django.core.handlers.wsgi.WSGIHandler()
>
> --
>
> It shows the following error in my log:
>
> [Tue Aug 25 19:12:24 2009] [info] [client 127.0.0.1] mod_wsgi
> (pid=170, process='', application='www.test-hago-group.com|'): Loading
> WSGI script '/Users/simonlee/mysite3/apache/myapp.wsgi'.
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] mod_wsgi
> (pid=170): Exception occurred processing WSGI script '/Users/simonlee/
> mysite3/apache/myapp.wsgi'.
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1] Traceback (most
> recent call last):
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/core/handlers/wsgi.py", line 241, in __call__
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     response =
> self.get_response(request)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/core/handlers/base.py", line 73, in get_response
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     response =
> middleware_method(request)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/contrib/sessions/middleware.py", line 10, in process_request
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     engine =
> import_module(settings.SESSION_ENGINE)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/utils/importlib.py", line 35, in import_module
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     __import__
> (name)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/contrib/sessions/backends/db.py", line 2, in 
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     from
> django.contrib.sessions.models import Session
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/contrib/sessions/models.py", line 4, in 
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     from
> django.db import models
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/db/__init__.py", line 41, in 
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     backend =
> load_backend(settings.DATABASE_ENGINE)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/db/__init__.py", line 17, in load_backend
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     return
> import_module('.base', 'django.db.backends.%s' % backend_name)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/utils/importlib.py", line 35, in import_module
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     __import__
> (name)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]   File "/Library/
> Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/
> django/db/backends/postgresql_psycopg2/base.py", line 22, in 
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]     raise
> ImproperlyConfigured("Error loadingpsycopg2module: %s" % e)
> [Tue Aug 25 19:12:24 2009] [error] [client 127.0.0.1]
> ImproperlyConfigured: 

Re: psycopg2.OperationalError: FATAL: role "root" does not exist

2009-09-08 Thread Jan Ostrochovsky

How exactly did you put your database user? What is content of your
pg_hba.conf?
Maybe some parts of this could be helpful:
http://sharpe-s-postgres.blogspot.com/2009/09/how-to-install-and-configure-postgresql.html/

On Sep 7, 11:15 pm, Zico  wrote:
> On Tue, Sep 8, 2009 at 3:06 AM, Angel Cruz  wrote:
>
> > You don't have a user account named 'root' in your database.  You should
> > probably use another user besides root.  Change your settings.py file to
> > the
> > correct database user?
>
> Ok, if i put my database user "fixmystreet" .. which is the exact user..
> then this error comes:
>
> *psycopg2.InternalError: current transaction is aborted, commands ignored
> until end of transaction block*
>
> --
> Best,
> Zico
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: PostgreSQL or MySQL, What are the +'s and -'s?

2009-09-08 Thread Jan Ostrochovsky

I won't compare PostgreSQL and MySQL as whole, because:
- I do not know MySQL so well, as PostgreSQL
- another flamewar could arise ;)

I am only saying: my experience with Django+PostgreSQL is far better,
than Django+MySQL, see
http://groups.google.com/group/django-users/browse_thread/thread/3abfd993c3c976f9/2e410d567d4ba2db#2e410d567d4ba2db.
If you will need some help with PostgreSQL, do not hesitate to contact
me directly.

Jano

On Sep 8, 2:58 am, Jason Beaudoin  wrote:
> On Fri, Sep 4, 2009 at 4:29 PM, Joshua Russo  wrote:
> > I personally don't have any experience with PostgreSQL and I'm generally
> > working in a mixed MS and Linux environment. I'm interested to hear peoples
> > views on the pluses and minuses of the two different systems. I'm a bit of a
> > query geek too. How does that play in? I know in MySQL there are limitations
> > on where you can use subqueries. Is that true with PostgreSQL? (Ya I could
> > just look that one up but it's just an example.)
>
> While I don't have a whole lot of experience with either, the main issue I
> have against MySQL is it's adherence (lack, that is) to the SQL standard.
> Moving a MySQL dB--> postgreSQL needn't be so messy.
>
> I'm also a bit weary of MySQL having been bought up.
>
> Cheers,
>
> ~Jason
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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, MySQL, unicode

2009-09-08 Thread Jan Ostrochovsky

Hi Tracy,

less than two months ago, we were trying to use MySQL in our Django
project (because we were not successful with installation of
PostgreSQL adapter for Python psycopg2 on Mac OS X).

We had similar problems as you have, and ugly, but only found,
solution was to add encode (or decode? I do not remember exactly) to
many places in the code. usually in __unicode_() definitions.

And there were also other problems with MySQL, e.g. Django Evolution
does not work with MySQL so well, as with PostgreSQL.

Happily, in the end we wer successful with psycopg2 installation, and
we are very satisfied now, when using PostgreSQL, not MySQL.

Really, my personal experience is: Django and Django Evolution run
better on PostgreSQL. If you will decide to go this way and need some
support with PostgreSQL, does not hesitate to contact me directly.
Good luck!

Jano

On Sep 8, 5:11 am, Tracy Reed  wrote:
> On Mon, Sep 07, 2009 at 02:33:44AM -0700, ray spake thusly:
>
> > We were constantly getting decoding errors so we now use BeautifulSoup
> > to tidy the xml up before any processing.
>
> Wish I could implement a solution like that but I am just pulling
> times out of emails, not processing (X)HTML. I am amazed that over the
> course of almost three weeks poking around on IRC, in the docs, and on
> this mailing list nobody knows the answer. The most useful info I have
> received so far is "set your database to use utf-8", "django handles
> unicode for you", and "your code is broken". Indeed it is. If only I
> could figure out why and what the proper way to handle unicode with
> django and MySQL is.
>
> --
> Tracy Reedhttp://tracyreed.org
>
>  application_pgp-signature_part
> < 1KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-table inheritance - how to access child object methods/attributes

2009-09-08 Thread Jan Ostrochovsky

Hello,

class Document(models.Model):
  ...

class AccountingDocument(Document):
  ...

How am I able to access methods an attributes of some
AccountingDocument instance (e.g. its __unicode__()) from Document
instance? How am I able to retrieve child object from its parent?

I tried to search on the web, but I am not a lot wiser after that...

Thanks in advance.

Jano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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: automatic initialization of sample data

2009-09-07 Thread Jan Ostrochovsky

Thanks Bill, yes, that is one possible solution, when implementing
such feature from the scratch.

I am only asking, if there is some existing framework for such need,
which I see as common.

For example some add-on to Django, which will do this for me. Let's
imagine additional option for any field of Django model, e.g.:

class Person(models.Model):
  firstname = models.CharField(max_length=30, initial_values="John,
Bill, Peter")
  lastname = models.CharField(max_length=70, initial_values="Smith,
Clinton, Parker")
  ...

Django with such add-on could be able to build initial database from
these values, for example when running syncdb or other way.

Am I more readable now?

Jano

On Aug 20, 10:09 pm, Bill Freeman <ke1g...@gmail.com> wrote:
> Perhaps I'm not understanding correctly, but how about, assuming you have a
> function
> run_data_inits() that calls your chain of init_sample_data() functions:
>
> $ python manage.py shell
>
> >>> import myproject.myapp.models as m
> >>> m.run_data_inits()
> >>> ^D
>
> Bill
>
> On Thu, Aug 20, 2009 at 9:25 AM, Jan Ostrochovsky <
>
> jan.ostrochov...@gmail.com> wrote:
>
> > Hello,
>
> > we are in the initial phase of software project, and data model and
> > names of attributes are changing very often, and very often we need to
> > create new database and fill it with the same sample data for testing.
> > We want to automate this creation of sample data.
>
> > Our idea: add into each models.py method e.g. init_sample_data() to
> > each model class, and put sample data there (with well handled
> > dependencies - ForeignKey, etc.) and each time we change model, we
> > will aslo change concerned init_samle_data(). We will run these
> > chained init_sample_data() for each class in the script.
>
> > The question is: is there some existing solution for this (in Django
> > or its extensions), which we can use, and not reinvent it, or not? Any
> > idea?
>
> > (We are using Django Evolution, which is good help, but only when
> > changes are not too dramatic.)
>
> > Thanks in advance.
>
> > Jan Ostrochovsky
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



automatic initialization of sample data

2009-08-20 Thread Jan Ostrochovsky

Hello,

we are in the initial phase of software project, and data model and
names of attributes are changing very often, and very often we need to
create new database and fill it with the same sample data for testing.
We want to automate this creation of sample data.

Our idea: add into each models.py method e.g. init_sample_data() to
each model class, and put sample data there (with well handled
dependencies - ForeignKey, etc.) and each time we change model, we
will aslo change concerned init_samle_data(). We will run these
chained init_sample_data() for each class in the script.

The question is: is there some existing solution for this (in Django
or its extensions), which we can use, and not reinvent it, or not? Any
idea?

(We are using Django Evolution, which is good help, but only when
changes are not too dramatic.)

Thanks in advance.

Jan Ostrochovsky
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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-table inheritance and modification of OneToOneField options

2009-08-07 Thread Jan Ostrochovsky

Thank you, Malcolm.

In fact, our current design was, as you recommended:

Subject ---one-to-one-null-false--- Address ---one-to-one-null-true---
Payment (Invoice)

I want to use generic views and to join Subject+Address in the same
form, and model inheritance seemed to me as most straightforward
solution for this need, but as you do not recommend it, I will look
for another solution... e.g. form inheritance, as I found it here
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#form-inheritance
or here http://www.djangosnippets.org/snippets/703/.

Jano

On Aug 7, 3:50 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Thu, 2009-08-06 at 07:15 -0700, Jan Ostrochovsky wrote:
> > Hello,
>
> >http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-in...
> > says:
> > The inheritance relationship introduces links between the child model
> > and each of its parents (via an automatically-created OneToOneField).
>
> >http://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield
> > says: Multi-table inheritance is implemented by adding an implicit one-
> > to-one relation from the child model to the parent model...
>
> > The question is: how can I set options of that implicit OneToOneField?
> > Most interesting is null=True / null=False.
>
> You don't. Model inheritance is a Python-level thing and things like
> "optional" inheritance doesn't existence for Python inheritance. It's a
> shortcut for emulating Python class inheritance as much as possible.
>
> If you want this level of control, model the relations explicitly and
> set the options on the OneToOneField to whatever you like.
>
> 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-table inheritance and modification of OneToOneField options

2009-08-06 Thread Jan Ostrochovsky

Hello,

http://docs.djangoproject.com/en/dev/topics/db/models/#multi-table-inheritance
says:
The inheritance relationship introduces links between the child model
and each of its parents (via an automatically-created OneToOneField).

http://docs.djangoproject.com/en/dev/ref/models/fields/#onetoonefield
says: Multi-table inheritance is implemented by adding an implicit one-
to-one relation from the child model to the parent model...

The question is: how can I set options of that implicit OneToOneField?
Most interesting is null=True / null=False.

(I want to "inherit" to one class optionally (Invoice Address) and to
one class it is required (Residence Address). Base class is Address.)

Thanks in advance.

Jan Ostrochovsky

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