Re: 404 only in Chrome

2011-12-10 Thread Tomasz Zieliński
Can it be a browser caching issue: http://www.google.pl/support/forum/p/Chrome/thread?tid=3bb0a94bfb063745&hl=en ? Best, Tomasz Zielinski -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups

Re: Mysql + Unicode + username curiosity

2011-11-14 Thread Tomasz Zieliński
You might want to check the documention: https://docs.djangoproject.com/en/1.3/ref/databases/#creating-your-database There seem to be issues like this one: "The main thing to be aware of in this case is that if you are using MySQLdb 1.2.2, the database backend in Django will then return bytestr

Odp: Reasons to use managers

2011-06-04 Thread Tomasz Zieliński
If you use manager method, you can keep your schema unchanged/normalized and employ e.g. Memcached or Redis to store the result of your computation. This might or might not fits your use case, of course. -- Tomasz Zielinski pyconsultant.eu -- You received this message because you are subscribed

Odp: Re: Problem uploading images and videos with filenames containing not ascii characters

2011-05-03 Thread Tomasz Zieliński
W dniu wtorek, 3 maja 2011, 21:34:28 UTC+2 użytkownik Ariel napisał: > > Yes, only on the production enviroment. > > > Try to create a file with UTF8 characters in its name, from your code. Then you'll know if those Apache settings are in effect. -- Tomasz Zielinski pyconsultant.eu -- You re

Odp: UnicodeDecodeError with makemessages in django-1.3

2011-05-02 Thread Tomasz Zieliński
I got the same exception, it turned out that our designer put some invalid characters into one of the templates. I figured out which template had been broken, due to the fact that `makemessages` left empty `buggy_template.html.py` file in `buggy_template.html` folder. -- Tomasz Zielinski pycon

Session "rollback" after transaction rollback

2011-03-29 Thread Tomasz Zieliński
How do you handle situation in which exception is raised from view, TransactionMiddleware rolls back the open transaction, but subsequently SessionMiddleware updates session in database with broken data (i.e. something that points to what was rolled back by TransactionMiddleware) ? This is an ed

Re: ManyToMany Intermediate Table on a Separate Database?

2011-03-29 Thread Tomasz Zieliński
(Sorry Daniel, I replied to your private email by accident - the new Google Groups UI misled me.) Actually in MySQL you can easily work around that limitation - you can use database VIEWs as mirrors of tables placed in other databases. -- Tomasz Zielinski pyconsultant.eu -- You received this

Re: Logging visitors/requests and showing it all in a nice report?

2011-03-22 Thread Tomasz Zieliński
On 21 Mar, 14:21, Thomas Weholt wrote: > Is there an app for logging visitors with a nice report, like a report > showing number of visitors for a specific page, users with a specific > browser/OS etc? > I know you want a Djangoish solution, but there is a nice small Apache log analyzer http://ww

Re: orm: operations between models fields

2011-03-21 Thread Tomasz Zieliński
On 19 Mar, 22:49, maxi wrote: > Hi, > > Which is the better way to do this on orm language ? > > select filed1, sum(field2 * field3) > from a_table > group by field1 > I believe this is not possible in the current Django ORM. It would need something like this to work: MyModel.objects.annotate

Re: How to delete ONLY m2m relation?

2011-03-10 Thread Tomasz Zieliński
On 9 Mar, 16:12, Casey Greene wrote: > In that case, I believe you can remove it with > > user.province_set.remove(province) > user.save() > User.save() is unnecessary here because remove() changes m2m intermediate table and save() changes only User table. > > I am going from memory here.  I tri

Re: Tracking Model's History

2011-03-10 Thread Tomasz Zieliński
On 7 Mar, 05:06, Venkatraman S wrote: > Hi, > > Similar to the way, the admin tracks the changes, i was looking for > something which can be used in my app and stumbled on > this > . > Q is : How efficient is this? I mean,

Re: Django 1.2.5 postgres autocommit and contenttype sites tests failures

2011-03-04 Thread Tomasz Zieliński
On 4 Mar, 14:22, David De La Harpe Golden wrote: > On 04/03/11 10:01, Tomasz Zieliński wrote: > > > On 2 Mar, 00:10, Jason Culverhouse wrote: > >> Hi, > >> It seems that the contenttype framework and the sites contribs > >> conflict with using the autocomm

Re: Configuring Django-Sentry to send error mails

2011-03-04 Thread Tomasz Zieliński
On 4 Mar, 05:49, Ajay wrote: > am using django-sentry for logging errors. I also want to enable > throttled error mails to be sent to admins whenever an error occurs. > But I can not get it working. > > a) Normal django error mailing is working. b) but on removing ADMINS > and adding SENTRY_ADMI

Re: Need help with this basic query (annotate vs aggregate)

2011-03-04 Thread Tomasz Zieliński
On 4 Mar, 01:19, Steven Sacks wrote: > Here is my model: > > class PlaylistTag(models.Model): >     playlist = models.ForeignKey(Playlist) >     tag = models.CharField(max_length=128) >     tag_count = models.PositiveIntegerField(default=1) > > The way this model works is simple. If you add a ta

Re: Django 1.2.5 postgres autocommit and contenttype sites tests failures

2011-03-04 Thread Tomasz Zieliński
On 2 Mar, 00:10, Jason Culverhouse wrote: > Hi, > It seems that the contenttype framework and the sites contribs > conflict with using the autocommit:True database option.   Do you really need that autocommit? Django has its own concept of autocommit, which seems to just work most of the time. Wi

Re: Override default django Registration email

2011-03-04 Thread Tomasz Zieliński
On 3 Mar, 14:23, bruno desthuilliers wrote: > On 3 mar, 13:39, Kenneth Gonsalves wrote: > > > On Thu, 2011-03-03 at 00:36 -0800, pols wrote: > > > Anyone knows how to override djangos default registration email.I > > > need to alter it to sent as html email instead of text email.As i am a > > >

Re: What apps or snippets to use for Facebook and Twitter registration, login and posting?

2011-03-03 Thread Tomasz Zieliński
On 2 Mar, 18:30, Jason Culverhouse wrote: > On Mar 2, 2011, at 8:28 AM, Rodrigo Cea wrote: > > > I am developing a site that I want to link with Facebook and Twitter. > > https://github.com/flashingpumpkin/django-socialregistration(note the forks) > Personally I like django-socialregistration,

Re: How to reduce DB queries?

2011-03-01 Thread Tomasz Zieliński
On 27 Lut, 16:26, galago wrote: > In template in main loop I want to display all technologies assigned to the > each site. Technologies are assigned by m2m relation. So I run subloop as > You can see in code above. I want to reduce the number of queries executed > by those subqueries. I want to

Re: django cache (memcache) items are not readable between processes

2011-02-26 Thread Tomasz Zieliński
Looks like you don't really use memcached backend or your memcached daemon is down. -- Tomasz Zielinski pyconsultant.eu -- 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 unsub

Re: Change language on login

2011-02-21 Thread Tomasz Zieliński
On 21 Lut, 21:50, "Mishen'ka" wrote: > Hello all, > > I have make a site with translated menu items etc. > Now i want to change the language on login. > > By example i'm from the netherlands and want the Dutch language. > or i'm from america, so i want English as language. > > So i have change f

Re: New project, debating postgresql or MySQL (Amazon RDS), does it matter to Django?

2010-06-26 Thread Tomasz Zieliński
On 25 Cze, 19:13, Eric Chamberlain wrote: > Hello, > > We have a new project and are debating whether to use postrgresql (Amazon > EC2) or MySQL with InnoDB tables (Amazon RDS).  It looks like our TCO would > be much lower using Amazon RDS. > > Our past Django experience has been with postgresql

IntegrityError: (1062, “Duplicate entry ‘1830327 -1792993’ for key ‘some_instance_A_id’”) but no UNIQ UE constraint

2010-06-24 Thread Tomasz Zieliński
Maybe someone here knows this problem: http://stackoverflow.com/questions/3079890/integrityerror-1062-duplicate-entry-1830327-1792993-for-key-some-instance ? It happens rarely, randomly (although it might not be really random) and currently I don't have idea what to look for to fix it (it also d

Re: how to avoid "in" query for large sets?

2010-05-24 Thread Tomasz Zieliński
On 24 Maj, 08:58, Daniel Roseman wrote: > > User.objects.filter(id__in=Quiz.objects.filter(score__gt=90)) > Nice thing, is it documented somewhere (I think I haven't this before) ? -- Tomasz Zielinski http://pyconsultant.eu -- You received this message because you are subscribed to the Googl

Re: Uploaded File Security

2010-05-20 Thread Tomasz Zieliński
On 20 Maj, 04:19, Mike Dewhirst wrote: > > If it has to be secure rather than just wishful thinking the webserver > must demand credentials. If you are using Apache, that means .htaccess > files which point to a list of credentials for each group. > What is the difference between long, random f

MySQL and transaction savepoint

2010-05-17 Thread Tomasz Zieliński
I've just discovered that MySQL supports savepoints. If so, then what is the reason of Django MySQL backend not supporting it? Is this Django limitation, MySQLdb limitation or there is some other reason? -- Tomasz Zieliński http://pyconsultant.eu -- You received this message because yo

Re: Inconsistency between DB Query Results Between Threads

2010-04-28 Thread Tomasz Zieliński
On 28 Kwi, 22:04, Jared Smith wrote: > Using Django DB API I have two threads one that increments a counter getting > stored to the database and then another thread that is reading this counter. > > T1(Thread 1) increments > T2(Thread 2) reads > > I have found that if I increment and store the c

Re: I want "DEBUG = False" but still get the DEBUG data logged

2010-04-27 Thread Tomasz Zieliński
On 27 Kwi, 14:52, Tomasz Chmielewski wrote: > Am 27.04.2010 14:08, Tom Evans wrote: > > > If DEBUG is False, it will email any errors to ADMINS - is this not > > sufficient? > > Technically, should be fine, thanks. > > But I just checked, and I'm not getting any emails. > >      ADMINS = ( >  

Re: Non-conventional use of django templates.

2010-04-17 Thread Tomasz Zieliński
On 16 Kwi, 19:22, Paweł Roman wrote: > > Did anyone use a django template language in that fashion in a web > application that, itself is written in django? Does it make sense? Is > it safe? > I did, but it's been used by trusted set of users, so there were not that many safety measures built i

Re: TemplateSyntaxError in the admin pages

2010-04-05 Thread Tomasz Zieliński
On 5 Kwi, 10:25, Martin Lundberg wrote: > File "/home/marlun/.virtualenvs/django/lib/python2.6/site-packages/ > django/template/debug.py" in render_node >   81.             raise wrapped > > Exception Type: TemplateSyntaxError at /admin/timetrack/work/ > Exception Value: Caught an exception whi

Re: cascade deletion happens before pre_delete signal is sent?

2010-04-03 Thread Tomasz Zieliński
On 3 Kwi, 16:05, msoulier wrote: > I have a model A, which has a ForeignKey to model B. > > A --> B > > When B is deleted I want to save the As that are pointing at B by > repointing them at a different B if possible. To do this I have a > pre_delete signal registered for B models. Unfortuna

Re: transactions

2010-03-31 Thread Tomasz Zieliński
On 31 Mar, 06:04, Continuation wrote: > On Mar 30, 8:33 am, Tomasz Zieliñski > > wrote: > > If you take a look at TransactionMiddleware source: > > >http://code.djangoproject.com/browser/django/tags/releases/1.1.1/djan... > > > then you'll see that it's just commit_on_success in disguise: > > >

Re: transactions

2010-03-30 Thread Tomasz Zieliński
On 30 Mar, 07:24, Continuation wrote: > If I have a view function that transfers money from savings to > checking account, is @transaction.commit_on_success the recommend way > to manage the transaction? > > So something like: > > @transaction.commit_on_success > def transfer(request): >     ... >

Re: Multiple tables, is Django suited for this?

2010-03-30 Thread Tomasz Zieliński
Just an idea based on my experience - I'm able to plug on/off tables on the fly, using database VIEWs. Such VIEW can be bound to Django model with Meta: managed = False, and you can bind anything you want to it (I mean - arbitrary SELECT). -- Tomasz Zielinski http://pyconsultant.eu -- You receiv

Re: model design and derived classes - need advice please?

2010-02-02 Thread Tomasz Zieliński
On 2 Lut, 16:06, Simon Davies wrote: > Hi > > I am writing a web shop.  I have a shopping cart class, which has a > many to many relationship to an item class, the item class has three > derived classes.  The basic schema is shown below: > > class Item(models.Model): >         title = models.CharF

Re: Gathering performance statistics

2010-02-02 Thread Tomasz Zieliński
On 2 Lut, 00:22, gkelly wrote: > Hello, > > I'm wondering if anyone knows of an existing middleware that does the > following: > > - collects usage and performance statistics (i.e. logs each request to > a URL and its response time) > - performs some simple summaries of logged data > > Or, if anyo

Re: where can i see the tables created in sqlite database

2010-02-02 Thread Tomasz Zieliński
You can also google for "sqlite database browser", which is simple but nice GUI tool for browsing SQLite databases. -- Tomasz Zielinski http://pyconsultant.eu -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: Select *Latest* Grade Information for every Student

2010-01-31 Thread Tomasz Zieliński
On 29 Sty, 03:16, marsanyi wrote: > The joy of annotate().  In Django 1.1 and above: > > result = Student.objects.annotate(latest = models.Max('grades__date')) > > gives you the recordset, sans test_name.  Any advances on this? > I would suggest: students = Student.objects.annotate(latest_grad

Re: getting the object with max value

2010-01-25 Thread Tomasz Zieliński
On 25 Sty, 07:38, Kenneth Gonsalves wrote: > hi, > > I have a model 'Player' and a Model 'Handicap'. Handicap will have several > fields, one of which is a foreign key to player. Now I need to get the > Handicap > instance when the player had the highest handicap. I can use Max to find the > high

Re: unexpected Error: OperationalError: no such column: ...

2010-01-20 Thread Tomasz Zieliński
On 20 Sty, 20:52, HWM-Rocker wrote: > o...@olaf-laptop:~/workspace/truemen$ ./manage.py shell Not touching you question, you could try shell_plus from django- extensions, it load all models on startup, saving you a lot of typing. Moreover you could try ipython (which is used by shell/shell_plus

Re: Load template tags if installed?

2010-01-16 Thread Tomasz Zieliński
On 16 Sty, 20:31, "Aaron C. de Bruyn" wrote: > Am I missing an easy way to check if an application is installed > so I can make decisions in a template? > > I have an application that currently requires the comments framework > and django-attachments. > > I would rather make them optional dependin

Re: Custom filters and partial mark_safe?

2010-01-15 Thread Tomasz Zieliński
On 15 Sty, 10:28, Andrew Turner wrote: > I have a custom filter parses a CharField for usernames marked with > '@', and replaces them with a hyperlink to their profile page:- > > (...) > > I'm trying to mark_safe only the hyperlinks so that they are not > autoescaped, but mark_safe only seems to w

Re: Querysets returns wrong result when using threading.

2010-01-15 Thread Tomasz Zieliński
On 15 Sty, 05:33, James Bennett wrote: > On Thu, Jan 14, 2010 at 10:26 PM, Kieran Brownlees > wrote: > > Basic example of format: > > Main Thread: print objects.all() > > Spawned Thread: print objects.all() -- same as main thread > > Main Thread: objects.create(newObj) > > Main Thread: print.o

Re: How to pass raw sql results (cursor.fetchall()) to the template?

2010-01-15 Thread Tomasz Zieliński
On 14 Sty, 23:01, Ken wrote: > Newb question here.  How do I pass raw sql results to my template? > The sql results contains a two column queryset with several rows . > > Below doesn't work.  How do I make this work?  Do I need to parse the > results into an array and then pass to the template? >

Re: need for caching POST requests

2010-01-13 Thread Tomasz Zieliński
On 13 Sty, 11:09, Hinnack wrote: > there must be done more then this - e.g. the value of the key the data is > stored in cache has to be calculated from POST vars > instead of URL alone Why don't you take a look yourself: http://code.djangoproject.com/browser/django/tags/releases/1.1.1/django/co

Re: Model inheritance

2010-01-13 Thread Tomasz Zieliński
On 12 Sty, 20:52, a b wrote: > Hi, > > I have three models: > Product > SimpleProduct that extends Product > GroupProduct that extends Product and have ManyToMany relation with > SimpleProduct > > The reason to use the base Product model is so I can use paging. > Is it possible to make a query tha

Re: Migrating Many-To-Many Relationship

2010-01-13 Thread Tomasz Zieliński
On 12 Sty, 22:53, David Nolen wrote: > When migrating an existing db how do you create a proper join table > for a ManyToMany field. I think I've got it mostly worked out except > for the bit that looks like this in Django generated SQL: > > CREATE TABLE `blog_posts_authors` ( >   `id` int(11) N

Re: m2m in views

2010-01-13 Thread Tomasz Zieliński
On 12 Sty, 23:24, shaner wrote: > I'm trying to make a model's detail view, take movies for example; > actors are m2m to movies > > this works but it doesn't feel right is there, i pass this context to > the template where i for loop through the actor list > > >>> Movie.objects.filter(pk=movie_i

Re: need for caching POST requests

2010-01-13 Thread Tomasz Zieliński
On 13 Sty, 07:54, hinnack wrote: > Hi, > > I need to cache POST requests, too, on certain requests. > The requests are not changing data, but imagine an XMLRPC > service (that is based on POST requests only per spec anyway) uses > functions, that always return the same like 2 + 2 SHOULD always >

Best way to fix django admin preview of flatpage attached to multiple sites

2010-01-11 Thread Tomasz Zieliński
I have flatpage attached to multiple sites. Its admin preview chooses arbitrary site, which is quite obvious after debugging up to lines 35-36 of django.contrib.contenttypes.views.shortcut(). What would be the best way of fixing this problem? I see that mentioned shortcut() function receives requ

Re: Mysterious transactions wrapping views without middleware.

2010-01-11 Thread Tomasz Zieliński
On 10 Sty, 02:38, apramanik wrote: > Thanks! That partially fixes my problem. I wrapped a function with > commit_on_success and it doesn't rollback the changes if it throws an > IntegrityError coming from PostgresSQL: > > @transaction.commit_on_success >     def add_destination( self, placemark,

Re: How to get ModelAdmin given a Model

2010-01-11 Thread Tomasz Zieliński
On 11 Sty, 16:23, Marco Rogers wrote: > I'm reposting this from earlier to see if I have better luck. I need > to be able to get the ModelAdmin associated with a model at runtime. > Similar to how django.db.models.get_model allows you to retrieve a > model. > >     admin_class = get_admin(Model) >

Re: text in translation strings?

2010-01-11 Thread Tomasz Zieliński
On 10 Sty, 12:59, Andreas Pfrengle wrote: > I'm having a template, where a link shall be inside a translation- > marked text. I see two ways how to accomplish this, but both don't > work: > 1. {% trans "You need to login before > you can do anything" %} (...) > 2. {% blocktrans %}You need to log

Re: Handling Vector/Array Data in Forms

2010-01-09 Thread Tomasz Zieliński
On 9 Sty, 01:23, datta wrote: > I am using Django for a scientific applicaition. If I have to > transport a vector/array 'to' a form, dismantle it and display the > relevant information, it is easy. But how I capture vectors/array > datatypes 'from' the HTML forms (submitted by the user) in the >

Re: Creating UML diagram from my django models

2010-01-09 Thread Tomasz Zieliński
On 9 Sty, 15:46, Gaffar Durmaz wrote: > i wanna creating UML or ER diagram from my models.. > is there any tools to creating automatically ? > so i use Eclipse IDE.. maybe eclipse plugins or other.. I'm not sure if this would satisfy you: http://code.google.com/p/django-command-extensions/wiki/G

Re: request.LANGUAGE_CODE-sensitive choices in forms.ChoiceField?

2010-01-07 Thread Tomasz Zieliński
On Jan 7, 4:23 pm, Andreas Pfrengle wrote: > On 7 Jan., 13:22, Tomasz Zieliñski > > > > MyForm(forms.Form): > > >     myfield = forms.ChoiceField(choices=CHOICES) > > > 1. Maybe you could use ModelChoiceField: > > >http://docs.djangoproject.com/en/dev/ref/forms/fields/#modelchoicefield > > > 2.

Re: auth unit tests fail because sites isn't used

2010-01-07 Thread Tomasz Zieliński
On Jan 6, 10:01 pm, msoulier wrote: > I can't find anywhere in the django docs where it says that > django.contrib.auth uses django.contrib.sites, but when I run my unit > tests I get this > > (...) > > -- > Ran 45 tests in 22.37

Re: request.LANGUAGE_CODE-sensitive choices in forms.ChoiceField?

2010-01-07 Thread Tomasz Zieliński
On Jan 7, 1:04 pm, Andreas Pfrengle wrote: > Hello, > > I am trying to implement a ChoiceField that's choices shall be > calculated during form instantiation in the view depending on the > users preferred language (according to request.LANGUAGE_CODE from > LocaleMiddleware). > > Example forms.py:

Re: Saving several copies of an object

2010-01-05 Thread Tomasz Zieliński
On 5 Sty, 19:11, Matthias Kestenholz wrote: > 2010/1/5 Tomasz Zieliński : > > > > > > > > > On 5 Sty, 18:16, pjmorse wrote: > > >> This is done by looping over the list of languages and saving a > >> NewsTrans in each language. The source

Re: Project optimisation stage: Advice to boost speed of database queries across tables?

2010-01-05 Thread Tomasz Zieliński
On 4 Sty, 07:30, Sam Walters wrote: > Hi Tomasz > Yes, i have followed a raw sql approach now im looking at my test data > to see which objects have multiple rows and cleaning that up. > > Its a shame that '__in' has limited use under these scenarios: > > directories = search_querySet.distinct()

Re: database password in settings.py

2010-01-05 Thread Tomasz Zieliński
On 5 Sty, 17:49, Eric Chamberlain wrote: > There's nothing special about settings.py.  You could do something like: > > from Crypto.Cipher import Blowfish > > blowme = Blowfish.new(SECRET_KEY) > DATABASE_PASSWORD = blowme.decrypt(ENCRYPTED_PASSWORD) > > Securing SECRET_KEY is left as an exercise

Re: Saving several copies of an object

2010-01-05 Thread Tomasz Zieliński
On 5 Sty, 18:16, pjmorse wrote: > > This is done by looping over the list of languages and saving a > NewsTrans in each language. The source language is marked as already > translated, the other two are not (that is, they still need > translating). > > The problem is that this is done with ns.sa

Re: button for filtering the admin changelist based on callable

2010-01-03 Thread Tomasz Zieliński
On 30 Gru 2009, 20:29, TeenSpirit83 wrote: > Hi, > I have a callable in the modeladmin for an object XX. > Now I want to add a tool button (or something clickable) for filtering > the changelist displaying only the object having value less than > 30. > How would you implement somthing li

Re: Project optimisation stage: Advice to boost speed of database queries across tables?

2010-01-03 Thread Tomasz Zieliński
On 31 Gru 2009, 01:56, Sam Walters wrote: > for s in search_querySet: >         address_info = s.address_set.all() #.select_related(depth=2) - > yes i can/will put select related here but it really does not help > that much 20% tops >         #address_info is usually 2-3 rows from an address tabl

Re: Project optimisation stage: Advice to boost speed of database queries across tables?

2010-01-03 Thread Tomasz Zieliński
On 30 Gru 2009, 16:41, Nick Arnett wrote: > > E.g.: SELECT `common_addresstype`.`id`, `common_addresstype`.`adrtype` FROM > `common_addresstype` WHERE `common_addresstype`.`id` IN (1,6,8,52,173) > > I imagine there's an ORM query that will do the same thing, but I know MySQL > far better than I

Re: Custom template tag for a chaptered document?

2010-01-03 Thread Tomasz Zieliński
On 30 Gru 2009, 01:26, Stodge wrote: > I need to write a custom tag. I have a hierarchy of objects that I > want to turn into a chaptered document. But I want to be able to build > and display the document in a template AND generate a PDF or other > format from a view. Can I write a custom templat

Re: How to unregister model?

2009-11-24 Thread Tomasz Zieliński
That patch is a hack that requires modifying live instance of Django, moreover I don't know what is influenced by it as I'm not that familiar with inner workings of model layer, so using it would be troublesome for me. So it seems that I have to write custom delete()s, using raw SQL.. -- Tomasz Z

Re: How to unregister model?

2009-11-24 Thread Tomasz Zieliński
On 24 Lis, 22:42, Tim Valenta wrote: > > I want my unmanaged models to literally disappear from Django sight, > > and then re-appear on demand. > > That sounds rather hack-ish... I'm not sure Django can do that > exactly.  I'm not familiar with the situation, exactly, so I'm unsure > of what you m

Re: How to unregister model?

2009-11-24 Thread Tomasz Zieliński
On 24 Lis, 22:18, Tim Valenta wrote: > Sorry for double-post. > > Additionally, you might experiment with the Meta class attribute, > "abstract = True" on your wrapper models.   Thank you, I know about 'abstract' and I am using but unfortunately it doesn't help me much. What I need is the ability

Re: How to unregister model?

2009-11-24 Thread Tomasz Zieliński
On 24 Lis, 22:15, Tim Valenta wrote: > If you're not doing anything fancy with AdminSite objects (ie, you're > only using the default admin site), then do this: > > # assuming you've already done: from django.contrib import admin > admin.site.unregister(MyModel) > The 'unregister' word seems to h

How to unregister model?

2009-11-24 Thread Tomasz Zieliński
Is there a way to unregister model from being seen by Django model manager? I have some unmanaged models that are wrappers around read-only database views and also have foreign keys to 'real' models. Now, when I'm trying to delete instance of 'real' model that is referenced by unmanaged model, I'm

Re: Problem with unmanaged models and unit testing

2009-11-24 Thread Tomasz Zieliński
Thank you for you responses, I think I spotted the problem. My unmanaged model is in fact wrapper for database view. It also inherits from Django abstract model that has ManyToManyField-s onboard. When trying to test my app, syncdb.py in line 93 tries to actually add foreign key pointing from m2m

Re: Many to many relation - parents without any children

2009-11-15 Thread Tomasz Zieliński
; - where articles=ManyToManyField('Article') > > This is so elegant, so i have to upgrade to 1.1 now... :) > > Thank you Tomasz > My pleasure. Upgrade should be straightforward and painless, assuming you're on 1.0 now. -- Tomasz Zieliński http://pyconsultant.eu --

Re: Many to many relation - parents without any children

2009-11-14 Thread Tomasz Zieliński
ite sql in the model if possible. How about something like this (should work, although I haven't checked it): Author.objects.annotate(article_num=Count('articles')).filter (article_num=0) - where articles=ManyToManyField('Article') -- Tomasz Zieliński http://pyconsultant.

Re: Need help with Query: Q Objects and .extra()

2009-11-13 Thread Tomasz Zieliński
tra( where=['title_tsv @@ plainto_tsquery(%s)'], params=[term])) art_list_results2 = art_list_published.filter (tags__name__icontains=term) art_list_results_merged = set(art_list_results1+art_list_results2) - I'm not sure if set will work here (IMO it should), but it&#

[1.1] Problem with unmanaged models and unit testing

2009-11-13 Thread Tomasz Zieliński
f.errorhandler(self, exc, value) File "C:\Python26\lib\site-packages\MySQLdb\connections.py", line 35, in defaulterrorhandler raise errorclass, errorvalue _mysql_exceptions.OperationalError: (1005, "Can't create table 'test_myproject.#sql-710_139' (errno: 150)") Table name #sql-710_139 d

Re: QuerySet Question

2009-11-12 Thread Tomasz Zieliński
%endfor%} - but it's only good for small apps, as a temp solution. -- Tomasz Zieliński http://pyconsultant.eu -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To

Re: Optimizing queries

2009-11-08 Thread Tomasz Zieliński
r = Item.objects.filter(buyer=u) - and then do something with those lists? -- Tomasz Zieliński http://pyconsultant.eu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to t

Re: How to remove " " from text for email

2009-11-08 Thread Tomasz Zieliński
On 8 Lis, 21:41, zweb wrote: > I have > > description|safe|striptags > > but description has some " " in addition to html tags. How do I > strip that off? There is 'cut' built-in filter. In never used it but looking at its source code it looks to me

Re: DRY: max length not taken from Model.field when using ModelForm

2009-11-07 Thread Tomasz Zieliński
uld be useless. On the other hand it would be nice if we could write something like: first_name = forms.CharField(max_length=copy_from_model) -- Tomasz Zieliński http://pyconsultant.eu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: token.split_contents() behavior

2009-11-07 Thread Tomasz Zieliński
ogether. The more straightforward token.contents.split() wouldn't be as robust, as it would naively split on all spaces, including those within quoted strings. It's a good idea to always use token.split_contents(). """ So - yes, it is intended -- Tomasz Zieliński http://p

Re: Feedback on Django1.1.1

2009-11-07 Thread Tomasz Zieliński
But I remember migrating from 0.9 to 1.0 and that wasn't as smooth as 1.0->1.1. -- Tomasz Zieliński http://pyconsultant.eu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To p

Re: A simple database project

2009-11-07 Thread Tomasz Zieliński
it in no longer that a few days (learning included), even for pre-intermediate programmer. -- Tomasz Zieliński http://pyconsultant.eu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group.

Re: syncdb fails to update Not NULL property in PostgreSQL 8.4

2009-10-21 Thread Tomasz Zieliński
On 21 Paź, 19:20, "Thomas B. Higgins" wrote: > Using the SVN trunk version of Django, I have observed that if a model > IntegerField or FloatField is changed by adding "null=True" syncdb > does not update the Not NULL property of the column using PostgeSQL > 8.4. Is this correct behavior, or a b

Re: JOINs with Django ORM

2009-10-20 Thread Tomasz Zieliński
On 20 Paź, 08:37, "Michael P. Jung" wrote: > > I was unclear, but SQL should explain what I want to do - select > > all ObjectRevision-s that are latest in Object-s that they belong to. > > Moreover, I want to do this in with one ORM query, without resorting > > to SQL or splitting the query to

Re: JOINs with Django ORM

2009-10-19 Thread Tomasz Zieliński
On 19 Paź, 20:21, Daniel Roseman wrote: > > You can't do this in one query with Django's ORM. > > One way of doing it in two queries might be to get use .annotate() to > add the max id of the related objectrevision for each revision, then > get all those objectrevisions (untested): > >    objects

Re: JOINs with Django ORM

2009-10-19 Thread Tomasz Zieliński
On 19 Paź, 17:52, Daniel Roseman wrote: > On Oct 19, 4:17 pm, Tomasz Zieliński > > > It's not clear what you mean by 'all latest ObjectRevisions'. Do you > mean all ObjectRevisions for a particular object? If so: >     myobject.objectrevision_set.all() I was unc

JOINs with Django ORM

2009-10-19 Thread Tomasz Zieliński
Say I have Object model, which has ObjectRevision-s (ObjectRevision has ForeignKey to Object). I want to fetch from database all latest ObjectRevision-s. In SQL I can do it like this: SELECT r1.some_data FROM objectrevision r1 LEFT OUTER JOIN objectrevision nr2 ON (r1.object_id = r2.object_id AND

Re: Django methodologies and best practices

2009-10-19 Thread Tomasz Zieliński
On 19 Paź, 12:00, bruno desthuilliers wrote: > On 18 oct, 23:15, Mike Ramirez wrote: > > Or write a custom migration script, or just fire your favorite db > client and issue a couple SQL queries. > > > I tend to start with the models first and when I add a field, I just use > > alter > > to u

Re: Django methodologies and best practices

2009-10-18 Thread Tomasz Zieliński
On 18 Paź, 15:48, bruno desthuilliers wrote: > > a first working implementation of my models (remember you can test > your models from the interactive shell and/or python scripts). Or write unit tests, which are more suited for testing than loose bunch of scripts -- Tomasz Zielinski, http://py

Re: Problem in installing database adapter.

2009-10-18 Thread Tomasz Zieliński
I don't remember how I installed it (mysqldb or python-mysqldb), but assuming that this is the correct module, then it's possible that it's for different Python version that you are actually using. For example, default Python for Ubuntu 8 is, iirc, 2.5.2, while you might be using 2.4 or 2.6 for y

Re: How to restrict True value to only one row in table column

2009-10-18 Thread Tomasz Zieliński
Maybe you can use something like this: http://stackoverflow.com/questions/1346765/unique-constraint-that-allows-empty-values-in-mysql This would probably mean converting is_master to: is_master = models.BooleanField(null=True, blank=True, unique=True) - and possibly overriding save to convert

Re: Django SAAS projects

2009-10-18 Thread Tomasz Zieliński
There is also second issue to consider - single database is a potential security threat (one customer might be able to access data of second customer if you have a bug in your code). -- Tomasz Zielinski, http://pyconsultant.eu --~--~-~--~~~---~--~~ You received t

Re: Django methodologies and best practices

2009-10-18 Thread Tomasz Zieliński
It surely depends on your input. If you have detailed specification of user interface, then writing URLconfs is probably more or less no- brainer, and also the design can often be quite obvious. On the other hand, if you're starting in 'fluid' environment and project doesn't have a direction, the

Re: about django.core.mail.send_mail

2009-10-09 Thread Tomasz Zieliński
On 9 Paź, 05:15, li kai wrote: > Can I send email using others' mail account following these steps? > > 1. I fill my own mail account and password in settings.py. > > 2. When using "send_mail(subject, message, sender, recipients)", I set > sender to  a different mail account. This depends on y

Re: Automatic primary keys at model inheritance

2009-10-09 Thread Tomasz Zieliński
> > the primary key counters for Restaurant and Bar classes are separated, which > causes me troubles, because I want a Place to be Restaurant or Bar not both. > I'm not sure if this is what you need, but take a look here: http://docs.djangoproject.com/en/dev/topics/db/models/#id8 -- Tomasz Zie

Re: "Lost" sessions

2009-07-25 Thread Tomasz Zieliński
In case someone suffers from this -I found the problem: http://code.djangoproject.com/ticket/11555 -- Tomasz Zieliński http://pyconsultant.eu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users"

Re: "Lost" sessions

2009-07-25 Thread Tomasz Zieliński
One more thing - out of sudden it turns out that session can be "lost" even if no external redirect is involved. So basically first request, without any session cookie set, seems to have some dummy session id, because only subsequent sessions ids survive. --~--~-~--~~~-

"Lost" sessions

2009-07-25 Thread Tomasz Zieliński
is lost, so it seems like something connected to IP) Is this some known issue with Django or maybe internet gateways(?) - or I have a bug myself? (I'm not messing with Django session code in any way) -- Tomasz Zieliński, http://pyconsultant.eu --~--~-~--~~~---~--~-

Re: "Lost" sessions

2009-07-25 Thread Tomasz Zieliński
I've just noticed that my fake URLs point to existing sites --~--~-~--~~~---~--~~ 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

Re: Django, MySQL - bug?

2009-07-20 Thread Tomasz Zieliński
imary key for INSERT that causes Warning. One thing that is different here from Django scenario is that Warning is not being thrown, does someone know how to turn on raising Warning exceptions in MySQLdb? -- Tomasz Zieliński http://pyconsultant.eu --~--~-~--~~~---~--

  1   2   >