Own threaded management command causes UnboundLocalError at different runs/places

2008-06-19 Thread sector119
Hi ALL! Can I use threaded management commands? I write simple data import command from manage.py. This command use threadpool and I sometimes get UnboundLocalError on some variables (they differ) that they referenced before assignment.. Why It can be so? Thanks! --~--~-~--~~

may be BUG. SyntaxError: non-keyword arg after keyword arg

2008-05-28 Thread sector119
Hi All! My Transaction model have method: def _get_serial(self): return Transaction.objects.filter(commit_date=datetime.date.today(), operator__office=self.operator.office).count() + 1 CAUSE ERROR File "/home/sector119/devel/eps_src/eps/apps/transactions/ models.py"

Re: reverse: TypeError: dict objects are unhashable

2008-05-05 Thread sector119
I use reverse('staticpages-staticpage_delete', kwargs={'object_id': 4}) in my code. It works (the same code) for many models, and only this one doesn't work properly. On May 6, 1:12 am, Lemuel Formacil <[EMAIL PROTECTED]> wrote: > Try this: > > On

reverse: TypeError: dict objects are unhashable

2008-05-05 Thread sector119
ceback (most recent call last): File "", line 1, in File "/home/sector119/devel/django_src/django/core/urlresolvers.py", line 297, in reverse return iri_to_uri(u'/' + get_resolver(urlconf).reverse(viewname, *args, **kwargs)) File "/home/sector119/devel/django

ModelForm + FormPreview + form.save() call in done() never update objects if PK is AutoField

2008-04-24 Thread sector119
Hi ALL! If I use ModelForm + FormPreview + form.save() call in done() it never update objects if PK is AutoField, but always create them, why it can be so? FormPreview doesn't store PK value enywhere (ex.: to use in form.instance.pk to determine that it is an update not create) ? I redefine some

Re: form.save() allways save data, never update

2008-04-24 Thread sector119
done? On Apr 24, 2:25 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-04-24 at 04:21 -0700, sector119 wrote: > > ok I've added instance=object! > > > is it ok, that when I change PK value and call form.save() it create > > new item, and not just

Re: form.save() allways save data, never update

2008-04-24 Thread sector119
Thanks a lot, Malcolm! On Apr 24, 2:25 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-04-24 at 04:21 -0700, sector119 wrote: > > ok I've added instance=object! > > > is it ok, that when I change PK value and call form.save() it create > > new

Re: form.save() allways save data, never update

2008-04-24 Thread sector119
rm = model_form(instance=object) On Apr 24, 1:33 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 2008-04-24 at 03:03 -0700, sector119 wrote: > > Why this code allways create new objects and never update them!? How > > to update objetcs, not create them using for

form.save() allways save data, never update

2008-04-24 Thread sector119
Why this code allways create new objects and never update them!? How to update objetcs, not create them using form.save() Model PK is AutoField. When it not autoincrement field everything works fine! class ModelFormClass(ModelForm): class Meta: model = MyModel if req

can't save m2m fields using MyModel.objects.create(**kwargs) ?

2008-04-23 Thread sector119
Hi All Can I save m2m fields using MyModel.objects.create(**kwargs) ? If kwargs contains 'm2m_field': [Ob1, Obj2, Obj3]. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, se

Re: QS-RF: something strange happens with model inharitance

2008-04-16 Thread sector119
I'm sorry, it was my mistake... I forgot to add abstract = True to Meta, because I do not read http://code.djangoproject.com/browser/django/branches/queryset-refactor/docs/model-api.txt, I think that everything will be just like in python class inharitance... Sorry.. --~--~-~--~~--

Re: QS-RF: something strange happens with model inharitance

2008-04-16 Thread sector119
;bank' 'account' 'bic' 'code' 'service' >>> Organization.__module__ 'organizations.default_organization' ^^ it's strange! it must be organizations.models, because I import Organization from "organizations.models" _not_

Re: QS-RF: maximum recursion depth exceeded in cmp

2008-04-16 Thread sector119
Thanks, Malcolm, everything works fine now, I just remove 'parent' from ordering! I know about django-mptt, but I do not need tree actually, I just want to view relations... With plain ordering... --~--~-~--~~~---~--~~ You received this message because you are subsc

Re: QS-RF: maximum recursion depth exceeded in cmp

2008-04-15 Thread sector119
> One more thing: What are you doing with class Import? That doesn't make any > sense like that to me. It's for my own purposes. I use it to show that data can be imported into this model and to define clean methods like in newforms to clean and normalise imported data :) class Import:

Re: QS-RF: something strange happens with model inharitance

2008-04-15 Thread sector119
tements for me, manage.py sqlall have to show CREATE TATBLE SQL queries and have to show columns from model C, but it don't, only columns from A and B models are shown in create table statement for my table! > Hope that helps, > > Michael > > On Tue, Apr 15, 2008 at 10:52 AM, secto

Re: QS-RF: maximum recursion depth exceeded in cmp

2008-04-15 Thread sector119
Template error In template /home/sector119/devel/eps_src/eps/templates/base.html, error at line 23 Caught an exception while rendering: maximum recursion depth exceeded in cmp 23 {{ user.office.location.get_type_display }}. 24 {{ user.office.location.name }}, 25

QS-RF: something strange happens with model inharitance

2008-04-15 Thread sector119
I have already created models A and B and tables with trunk, now I installed qs-rf branch and make C model inharit from already created A, B models, but when I run manage.py sqlall my_app_with_C_model I do not see any columns from C model :( But everything works fine if I create all models from s

QS-RF: maximum recursion depth exceeded in cmp

2008-04-15 Thread sector119
I begin testing qs-rf branch and get this exception, why? May be because Office model is tree - has parent = models.ForeignKey('self') field? Exception Type: RuntimeError Exception Value:maximum recursion depth exceeded in cmp Exception Location: /home/secto

Re: how to create many records in a single transaction (or in a few transactions)?

2008-04-04 Thread sector119
http://www.djangoproject.com/documentation/transactions/ On 4 Кві, 13:54, Valery <[EMAIL PROTECTED]> wrote: > Hi all, > > what is the usual Django's way to create many records in a single > transaction (or in a few transactions)? > > I have a list of python dictionaries representing the records t

manage.py and transactions need help

2008-04-01 Thread sector119
HI All! When I use my own command with manage.py and got any psycopg2 exception on commit, not other exception, I can't create any object in model after rollback even if I do transaction.enter_transaction_management() and transaction.managed(True) How can I save and commit data after psycopg2.Op

Re: generic views - newforms

2008-03-30 Thread sector119
When you will read Michael's links on documentation you can use generic views on newforms: http://217.196.165.10/create_update.txt They have create and update preview support also, just use preview=True option. And object_delete can use id's like '1/2/3/4/5/10/128' to use url's like /people/person

Re: IntegrityError on unique_together constraint, save() use INSERT instead of UPDATE

2008-03-25 Thread sector119
.. On 25 Бер, 15:14, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-03-25 at 05:51 -0700, sector119 wrote: > > [...] > > > I try to write my own comand to manage.py which imports data in some > > format to the db. > > I write my own serializer wh

IntegrityError on unique_together constraint, save() use INSERT instead of UPDATE

2008-03-25 Thread sector119
Traceback (most recent call last): File "/home/sector119/devel/eps_src/eps/apps/imports/management/ commands/importdata.py", line 144, in import_source obj.save() File "/home/sector119/devel/django_src/django/core/serializers/ base.py", line 168, in save models.Mo

Re: data import

2008-03-04 Thread sector119
On 4 Бер, 13:33, "Ben Ford" <[EMAIL PROTECTED]> wrote: > How about setting a default value on all of the database tables the you are > specifying in the dict that you're doing the update with? Hi, Ben, those values can't be set as default value for the table column. Each model may have not only o

data import

2008-03-04 Thread sector119
Hi ALL! I need to import data in CSV format into my models everyday ~ 500.000 rows. But my CSV files are uncomplite, I have to append some data to every row. I use something like this to import data into my model: for d in csv.DictReader(...): d.update(my_data) MyModel.objects.create(**d) B

Re: run external script from view

2008-02-22 Thread sector119
"script jobs" and then run > them. That would give you a good asynchronise (spelling?) system. > > cbmeeks > http://codershangout.com > > > On Feb 22, 5:23 am, sector119 <[EMAIL PROTECTED]> wrote: > > Hi ALL! > > > > How to run some python script

run external script from view

2008-02-22 Thread sector119
Hi ALL! How to run some python script from view and not wait and of work of this script, and execute some view code after script call in this view? This python script use django.utils.daemonize.become_daemon to become a daemon. When I run this script from view at _development_ server using os.exe

Re: PostgresSQL v8.3 Non-character data types are no longer automatically cast to TEXT

2008-02-14 Thread sector119
http://code.djangoproject.com/ticket/6605 Malcolm Tredinnick написав: > On Thu, 2008-02-14 at 02:29 -0800, sector119 wrote: > > Due to subject it's not longer possible to use iexact, icontains, > > istartswith, iendswith lookup_type in lookup type with int4, int8,

Re: PostgresSQL v8.3 Non-character data types are no longer automatically cast to TEXT

2008-02-14 Thread sector119
OR ... if lookup_type in ('iexact', 'icontains', 'istartswith', 'iendswith'): format = '%s::text %s' if connection.needs_upper_for_iops: format = 'UPPER(%s::text) %s' else: format = '%s

PostgresSQL v8.3 Non-character data types are no longer automatically cast to TEXT

2008-02-14 Thread sector119
Due to subject it's not longer possible to use iexact, icontains, istartswith, iendswith lookup_type in lookup type with int4, int8, ... filed types! May be we have to add something like this to the db/models/query.py get_where_clause: if lookup_type in ('iexact', 'icontains', 'istartswith', 'ie

Re: how to get raw_id_admin value from foreign key field?

2008-02-06 Thread sector119
def my_callback(field, **kwargs): if field.rel.raw_id_admin: return TextField() else: return field.formfield(**kwargs) On 6 Лют, 11:36, sector119 <[EMAIL PROTECTED]> wrote: > Oh, sorry! I mean foreign key, not primary key :( > > On 6 Лют, 11:32, sector119 <[EMAIL

Re: how to get raw_id_admin value from foreign key field?

2008-02-06 Thread sector119
Oh, sorry! I mean foreign key, not primary key :( On 6 Лют, 11:32, sector119 <[EMAIL PROTECTED]> wrote: > Hi ALL! > > How can I check that model M has some primary key field with > raw_id_admin value set to True? How can I access this option? I'm > tired of looking

how to get raw_id_admin value from foreign key field?

2008-02-06 Thread sector119
Hi ALL! How can I check that model M has some primary key field with raw_id_admin value set to True? How can I access this option? I'm tired of looking for this option using dir() :) P.S. I do not know name of the PK field. I try to substitute ChoiceField with TextField usinc formfield_callback

Re: how to serialize to xml object with many-to-many relationship?

2008-01-24 Thread sector119
Thank you very much! On 24 Січ, 15:58, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > On Jan 24, 2008 9:57 PM, sector119 <[EMAIL PROTECTED]> wrote: > > > > > Hi All! > > > I get a trouble when I try to serialize object with many-to-many > &

how to serialize to xml object with many-to-many relationship?

2008-01-24 Thread sector119
Hi All! I get a trouble when I try to serialize object with many-to-many relationship. All related objects have no values in xml, in db everything is ok, why? 132132 1 2008-01-24 14:51:32 # HERE IS NO VALUES IN OBJECTS, WHY? Thanks! --~--~-~

Re: InterfaceError: connection already closed

2008-01-23 Thread sector119
e_id)=(43683) is not present in table "organizations_organizationservice". Now everything is clear for me :) On 23 Січ, 17:29, sector119 <[EMAIL PROTECTED]> wrote: > Hi All. > > Why I get this error? > It's heppens in person_meter_readings view when request method is

InterfaceError: connection already closed

2008-01-23 Thread sector119
d')) readings = models.PositiveIntegerField(_('Meter readings')) datetime = models.DateTimeField(_('Commit date'), auto_now_add=True, db_index=True) Traceback (most recent call last): File "/home/sector119/devel/django_src/django/core/servers/ basehttp.py&

separate template internationalization problem. where to put locale/ dir?

2008-01-22 Thread sector119
Hi All! All my sources are in the /home/sector119/devel/eps_src/eps All applications are in /home/sector119/devel/eps_src/eps/apps And all my templates are in /home/sector119/devel/eps_src/templates dir which contains app_name dir which contains templates for that application! Where I have to

development server and settings.MEDIA_ROOT

2008-01-18 Thread sector119
Hi All! When I try to get http://127.0.0.1:8000/media/ I got Permission denied: /home/sector119/devel/django_src/django/contrib/admin/media/ But why django use this path but not that was defined at settings.MEDIA_ROOT? part of my urls.py: import settings if settings.DEBUG: urlpatterns

Re: how to pass dynamic number of not named args to the view?

2008-01-17 Thread sector119
it's smart, readable urls and lite regexp :) thanks :) On 17 Січ, 16:52, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Jan 17, 2008 7:19 AM, sector119 <[EMAIL PROTECTED]> wrote: > > > I decide to create delete_many view and I want to pass dyna

how to pass dynamic number of not named args to the view?

2008-01-17 Thread sector119
I decide to create delete_many view and I want to pass dynamic number of args to it using urls: /streets/street/1/delete/ /streets/street/12/3/4/delete/ /streets/street/7/12/43/98/192/delete/ what regexp in urls.py an view definition have I to use in my situation? view definition, I think, have

Form _class_ with more than one field with the same name?

2008-01-15 Thread sector119
Hi All! Is it possible to create (dynamicly) form _class_ with more than one field with _the same_ name? Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email

Re: How to cache pages with GET parameters like /some_page?page=2

2008-01-15 Thread sector119
h), ctx.hexdigest()) On 11 Січ, 17:57, Alex Koshelev <[EMAIL PROTECTED]> wrote: > You can write your own middleware that will be fit all your > requirements > > On 11 янв, 16:45, sector119 <[EMAIL PROTECTED]> wrote: > > > Hi All! > > > In Django docs

How to cache pages with GET parameters like /some_page?page=2

2008-01-11 Thread sector119
Hi All! In Django docs I read that the cache middleware caches every page that _doesn't_ have GET or POST parameters. But I want to cache pages which has GET parameters - some views which data were _paginated_ and which urls have page=N GET parameters. How can I do that? Thanks. --~--~-

TypeError: Cannot resolve keyword '' into field. Choices are: ...

2007-12-29 Thread sector119
pus, block, appartment, first_name, last_name, middle_name, hd, population, space, rooms, privilege, comment Exception Location: /home/sector119/devel/django_src/django/db/models/ query.py in lookup_inner, line 1044 Python Executable: /usr/bin/python2.5 Python Version: 2.5.1 I got this

db-api question

2007-12-25 Thread sector119
Hi! I have model with some field: person_id - Integer, service_id - Integer, datetime - DateTime (timestamp) and some other. How can I get all _LATEST BY datetime field_ services for person_id = 130960 ?? I have to get only: 2 | 2007-12-25 16:15:20.006126+02 3 | 2007

what for is queryset._clone() ?

2007-12-24 Thread sector119
Hi, All! When and why I have to use _clone() on queryset? I notice that it using in django.views.generic.object_list, but not in object_detail for example, why? In both views queryset is passed as argument. --~--~-~--~~~---~--~~ You received this message because yo

Using formtools.preview get AttributeError: 'ModelFormPreviewClass' object has no attribute 'has_header'

2007-12-17 Thread sector119
te an object I get this: Traceback (most recent call last): File "/home/sector119/devel/django_src/django/core/servers/ basehttp.py", line 277, in run self.result = application(self.environ, self.start_response) File "/home/sector119/devel/django_src/django/core/servers/ baseht

Re: URLconf: Invalid syntax when using naming URL patterns

2007-12-13 Thread sector119
Thank you! I miss "url" at the beginning of all patterns :) On 13 Грд, 17:14, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Dec 13, 2007 9:58 AM, sector119 <[EMAIL PROTECTED]> wrote: > > > urlpatterns = patterns('django.views.generic&#x

Re: URLconf: Invalid syntax when using naming URL patterns

2007-12-13 Thread sector119
I use django current trunk, if this info is needed. On 13 Грд, 16:58, sector119 <[EMAIL PROTECTED]> wrote: > Hi all! > > When I try to use Naming URL patterns I get error: > Exception Type: ImproperlyConfigured > Exception Value:Error while importing UR

URLconf: Invalid syntax when using naming URL patterns

2007-12-13 Thread sector119
Hi all! When I try to use Naming URL patterns I get error: Exception Type: ImproperlyConfigured Exception Value:Error while importing URLconf 'locations.urls': invalid syntax (urls.py, line 13) Exception Location: /home/sector119/devel/django_src/django/core/ urlre

Re: ordering. missing FROM-clause entry for table "locations_location"

2007-12-07 Thread sector119
more errors.. when I try to retrive some data: % python2.5 manage.py shell >>> from organizations.models import Organization >>> offices = list(Organization.objects.all()) File "/home/sector119/devel/django_src/django/db/models/sql/ query.py", line 524, in find_orde

Re: ordering. missing FROM-clause entry for table "locations_location"

2007-12-07 Thread sector119
When I try to use admin in queryset-refactor branch I get errors with handle_legacy_orderlist. It was removed from django.db.models.query, but still use in django/ contrib/admin/views/main.py at ChangeList.get_ordering.. On 7 Грд, 01:21, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Thu, 200

ordering. missing FROM-clause entry for table "locations_location"

2007-12-06 Thread sector119
Hi! I use current trunk and I can't order by location field. When I try, I'he get an error: missing FROM-clause entry for table "locations_location" LINE 1: ... FROM "organizations_organizationoffice" ORDER BY "locations... ^ Exception Location: /home/s

management.py and post_syncdb

2007-11-26 Thread sector119
Hi! I need to provide some initial data for my model. I decided to use signals.post_syncdb for this. % cat locations/management.py # -*- coding:utf-8 -*- from django.dispatch import dispatcher from django.db.models import signals from locations import models as locations_app DEFAULT_LOCATION =

using create_update.update_object with formtools.preview

2007-07-04 Thread sector119
is it possible? or it's possible to use formtools.preview only with newforms models? --~--~-~--~~~---~--~~ 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@googlegrou

global tags. tag not only for one app

2007-07-04 Thread sector119
Hi Is it possible to create a global tag not only for one app? I use paginator tag for my streets app, but I need to use it for other, like people, organizations, ... How can I load and use paginator tag if I have templatetags/paginator.py only in my streets application? --~--~-~--~