Re: problems with get_or_create

2010-03-25 Thread Malcolm Tredinnick
On Thu, 2010-03-25 at 15:58 +, Tom Evans wrote: [...] > > He is describing this situation: > > >>> User.objects.get(username='tevans...@googlemail.com') > > >>> User.objects.get_or_create(username='tevans...@googlemail.com') > (, False) > >>> User.objects.get(username='tevans...@googlemail.c

Re: problems with get_or_create

2010-03-25 Thread Malcolm Tredinnick
On Thu, 2010-03-25 at 11:22 +0530, Kenneth Gonsalves wrote: > hi, > > I have a model like this: > > name - unique > slno - not null > mode - not null > > If the instance does not exist and I give all three values to get_or_create, > it works > > if the instance exists, and I give values for sl

Re: Need for an internationalization/translation system not request-based

2009-08-13 Thread Malcolm Tredinnick
On Thu, 2009-08-13 at 10:11 +0200, Jarek Zgoda wrote: > Wiadomość napisana w dniu 2009-08-13, o godz. 09:38, przez Enrico > Sartorello: > > > Nice information, so we can go ahead working with activate() :-) > > > > Let me ask you one more question: in your code, i see you're using > > django.

Re: new session ID is created for every request from IE 7

2009-08-12 Thread Malcolm Tredinnick
On Wed, 2009-08-12 at 19:21 -0700, humble wrote: > Hi, > > I am writing a web application that involves session management with > the corporate backend module. I wrote my own authentication backend > plugin to satisfy the corporate requirement, not the default > authentication backend. I use file

Re: problem with openid

2009-08-12 Thread Malcolm Tredinnick
On Thu, 2009-08-13 at 07:22 +0530, Kenneth Gonsalves wrote: > hi, > > was trying out django_openidconsumer and get this error: > > complete() takes exactly 3 arguments (2 given) - I cannot figure it out as > this > is the definition of complete: > > def complete(request, on_success=None, on_f

Re: AutoRefresh model field (filled in by a trigger)

2009-08-12 Thread Malcolm Tredinnick
On Wed, 2009-08-12 at 04:55 -0700, Evgeny wrote: > Hi, > I have some fields in a model which are filled in by before_insert > trigger. > Is there any right way to autorefresh them after the object is > inserted, besides requesting a new instance of the object by > model.objects.get() method? You

Re: Need for an internationalization/translation system not request-based

2009-08-12 Thread Malcolm Tredinnick
On Wed, 2009-08-12 at 15:48 +0200, Jarek Zgoda wrote: [...] > As translation.activate() is process-wide, this approach is not > safe in multithreaded environment if using static translation (not > request-based). This is not correct. The translation.activate() call is thread-specific and defi

Re: Inheritance at runtime (per model instance)

2009-08-12 Thread Malcolm Tredinnick
On Wed, 2009-08-12 at 14:24 +0200, Thomas Guettler wrote: > Hi Malcolm and others, > > Malcolm Tredinnick schrieb: [...] > > You already have the content type table for referring to other model > > objects. Why not use that so that you can maintain some referential > &

Re: Inheritance at runtime (per model instance)

2009-08-12 Thread Malcolm Tredinnick
On Wed, 2009-08-12 at 11:39 +0200, Thomas Guettler wrote: > Hi, > > I am writing a workflow engine. The base workflow is stored in the DB. > But some code needs to written for most workflows. > > This means I need code for a model instance (an not code per mode class). > > To make this most pyt

Re: Ajax in Django

2009-08-12 Thread Malcolm Tredinnick
On Wed, 2009-08-12 at 11:47 +0300, Jani Tiainen wrote: > HB kirjoitti: > > Hey, > > Why Django doesn't provide integration with Ajax out of the box (like > > Rails and Wicket)? > > It all depends what you mean by "integration"? > > You can use (model)forms with Ajax, or use any other means if yo

Re: dates with a different format in the db

2009-08-12 Thread Malcolm Tredinnick
On Wed, 2009-08-12 at 00:24 -0700, Vokial wrote: > You've been very helpful, thanks. > The problem here is that i have to use these fields as proper > DateFields because i have to do some operations with these dates, like > making monthly/daily reports, searching entries in a specific period > of

Re: unique_together with None

2009-08-12 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 23:36 -0700, gentlestone wrote: > Thank you for the explanation. Seems to be the correct solution of the > problem (NULL, v1) != (NULL, v1) is overwrite the save method and > check for existence of (NULL, v1) before saving a new instance of > (NULL, v1). What I don't understa

Re: problem with django_openid

2009-08-11 Thread Malcolm Tredinnick
On Wed, 2009-08-12 at 07:10 +0530, Kenneth Gonsalves wrote: > hi > was trying to install django_openid on latest svn head. I am getting this > error - do not know whether it is mine or openid's The main error I see here is a complete failure to use cut-and-paste view from the debug screen when p

Re: syncdb with ForeignKey to_field outputs statements in wrong order

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 12:00 -0700, physicsnick wrote: > Actually they don't need to be unique (and I don't want them to be > unique). MySQL does not require that foreign keys be unique; only that > they be indexed. > > I am actually using this for a temporal database. There are many > instances o

Re: How to get this auto-field id value

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 17:27 -0700, David wrote: > Any tips/suggestions are highly appreciated... One tip is to wait more than eight hours before posting "please help me" yet again. > > > > On Aug 11, 9:26 am, David wrote: > > Just a little more information. The autoField id is in the model >

Re: dates with a different format in the db

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 08:58 -0700, Vokial wrote: > Hi! > In a db i have, already filled up with data, i have a varchar field > which contains dates formatted like "mmdd". Is there a way to make > Django recognise that field as a proper DateField even if the > formatting is different than the u

Re: Standalone script with django's ORM and multiprocessing

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 03:12 -0700, prabhu S wrote: [...] > Why do you close the connection in > every process? Can you not just close once in parent? That would also work. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscrib

Re: Standalone script with django's ORM and multiprocessing

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 11:06 +0200, Spajderix wrote: > Hi! > > I've written a standalone script, which looks throught a table in db for > tasks to perform. It then starts subprocesses for each task it founds > using multiprocessing.Process class from python. Everything's fine when > there is on

Re: Bad DateTime for LANGUAGE_CODE = 'sk'

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 02:03 -0700, gentlestone wrote: > also local flavors SKRegionSelect and SKDistrictSelect do not work, > I'm afraid Please file tickets for these items (one issue per ticket) if they don't already exist. There is a localflavor component in Trac that is worth scanning the titl

Re: looping over forms in a formset

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 01:12 -0700, bnl wrote: [...] > Apologies that I'm not asking my questions in the way you'd like, > but believe me, I am cutting it down a lot ... and I appreciate that > it's still not obvious where the errors are (I would have found > them otherwise). In this case, I had cu

Re: Sort by output of arbitrary method

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 00:29 -0700, Harish wrote: > Hi Friends, > > According to the django tutorial: > "You can click on the column headers to sort by those values -- except > in the case of the was_published_today header, because sorting by the > output of an arbitrary method is not supported. "

Re: Project Organization

2009-08-10 Thread Malcolm Tredinnick
On Mon, 2009-08-10 at 20:51 -0700, MattR wrote: > Are there any best practices documents to organizing large Django > projects? > > Should the view code be in a file called views.py? It seems like this > file could get rather large and hard to manage, is there some > suggested way to break it up

Re: Timezones in Django

2009-08-10 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 00:08 -0400, Vitaly Babiy wrote: > Hey guys, > I am working on an application that needs to be timezone aware. Is > there support for this with in django I can't seem to find anything > except for a few third party packages. i am trying to find something > that is in django

Re: adding a model to show up in admin

2009-08-10 Thread Malcolm Tredinnick
On Mon, 2009-08-10 at 20:43 -0700, zignorp wrote: > Hello, > I just added a model to models.py, > > class Topic (models.Model): > topic = models.CharField(max_length=180, blank=True, null=True) > > def __unicode__(self): > return self.topic > > I can see it in the mode

Re: imitating a spreadsheet (kind of) with formsets

2009-08-10 Thread Malcolm Tredinnick
On Mon, 2009-08-10 at 19:07 -0700, Chris Curvey wrote: > What I want to do is have a series of forms, all next to each other in > table format, like this: > > Car Honda Toyota Chevy > Price $12,000$14,000 $10,000 > MPG 30 2826 > Color Blue

Re: Dumping Large Databases

2009-08-10 Thread Malcolm Tredinnick
On Mon, 2009-08-10 at 17:02 -0700, Chris wrote: > I'm trying to dump a 3GB MySQL database using manage.py dumpdata, but > it's getting killed after 2 hours. Is there any way to get it to use > less memory/cpu so it doesn't get killed and completes the dump? Is there some particular reason you nee

Re: Multiple application instances?

2009-08-10 Thread Malcolm Tredinnick
On Mon, 2009-08-10 at 12:20 -0700, Andrin Riiet wrote: > In the django documentation -> URL dispatcher -> Defining URL > namespaces it reads "When you need to deploy multiple instances of a > single application, it can be helpful to be able to differentiate > between instances" > > I am unable to

Re: Passing optional URL params to reverse() function

2009-08-10 Thread Malcolm Tredinnick
On Mon, 2009-08-10 at 11:28 -0700, nabucosound wrote: > Hi all: > > I have a URLconf url entry like this: > > > url( > regex=r'^(?P\w+)/(?P[-\w]+)/$', > view='show_post', > name='show_post', > kwargs={'msg': None}, > ), > > > and I want to call it with Http

Re: looping over forms in a formset

2009-08-10 Thread Malcolm Tredinnick
On Mon, 2009-08-10 at 08:59 -0700, bnl wrote: > hi folks > > I have a formset, which I want to display using a customised template > for the forms. > > This works: > > {{formset.mangement_form}} > {% for form in formset.forms %} > {{form}} > {% endfor %} > > The following displays ok, let's

Re: select_related(field) doesn't use the default manager of the field

2009-08-09 Thread Malcolm Tredinnick
On Sat, 2009-08-08 at 22:00 -0700, Gleber wrote: [...] > When I override the get_query_set() adding extra fields, these fields > aren't available if I execute: > ModelB.objects.all().select_related('ref') This is true. > This is a bug? Not necessarily. It's intentional behaviour at the moment

Re: override save()

2009-08-09 Thread Malcolm Tredinnick
On Sun, 2009-08-09 at 13:35 -0700, Léon Dignòn wrote: > Hi, > > I have a ModelForm of my UserProfile model with two additional fields. > I need to override save(), to save the additional fields to the > django.contrib.auth.model.User model. > I tried to do that with a subclass of my UserProfile m

Re: Continuing problems running Django when not site Root.

2009-08-08 Thread Malcolm Tredinnick
On Sat, 2009-08-08 at 13:41 -0700, Streamweaver wrote: > Let me clarify. This method handles the RequestContext obviously since > it's a login but what I mean is the SCRIPT_NAME variable isn't set for > the template and can't be read as far as I can tell. Nothing is automatically set for a templa

Re: Bug with model get_*_display() methods?

2009-08-08 Thread Malcolm Tredinnick
On Sat, 2009-08-08 at 12:09 -0700, Margie wrote: [...] > Question: If want to use a special widget for a ChoiceField, is it > true that I need to instantiate the ChoiceField (or TypedChoiceField), > rather than just setting the .widget attribute on the one that is by > default created for me (due

Re: generate sql query from ORM

2009-08-08 Thread Malcolm Tredinnick
On Sat, 2009-08-08 at 07:26 -0700, Lokesh wrote: > Hi, > > Need help in generating the sql query i.e generated by django at > runtime from ORM > > from django.contrib.auth.models import User > class UserBasicDetails(models.Model): > user_id = models.OneToOneField(User, primary_key=True, >

Re: Django documentation site is SLOW

2009-08-08 Thread Malcolm Tredinnick
On Sat, 2009-08-08 at 00:14 -0700, Thierry wrote: > Hi, > > Just wanted to add my own testimony: I too, noticed serious > performance issues with Firefox when consulting Django documentation. "Performance issues" could many a myriad of things. Is it slow to render, or slow to load the data? Or s

Re: Bug with model get_*_display() methods?

2009-08-08 Thread Malcolm Tredinnick
Hi Margie, On Fri, 2009-08-07 at 23:17 -0700, Margie wrote: > > Hmmm, ok, after digging around I realize that full_clean was not > setting cleaned_data for the status field to an integer value; > cleaned_data['status'] was just getting set to something like u'1'. > > I am in fact using sqllite,

Re: Continuing problems running Django when not site Root.

2009-08-07 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 14:44 -0700, Streamweaver wrote: [...] > Is there anyway around this? Anyone know if fixing this on the Django > roadmap? It was fixed over a year ago (before Django 1.0 came out). If you are using anything later than that, you don't have to do *anything* to worry about SCR

Re: Bug with model get_*_display() methods?

2009-08-07 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 11:40 -0700, Margie wrote: > I see inconsistencies in how get_*_display() works based on whether > the object is a recently saved object. Probably an example describes > this best: > > My model contains this: > > class Task(models.Model): > > STATUS_CHOICES = ( >

Re: Date-based generic view not working

2009-08-07 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 13:36 -0700, Thomas Jaggi wrote: > Well, after setting 'allow_future' to true everything works fine. > Since the entries were created today I don't really get this. I'm > using the 'pub_date' as 'date_field' and it's definitely NOT in the > future... Did you set the timezone

Re: very interesting query... i need some help

2009-08-07 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 06:15 -0700, talpay...@gmail.com wrote: > i have come up with one of the most interesting query i have ever > seen. > > I want to do this : > > products = products.filter(productdetail__detail_value__gte = > first_value) > products = products.filter(productdetail__detail_va

Re: user.objects.create is not checking for duplicate emails

2009-08-07 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 17:02 +0300, Mirat Bayrak wrote: > no i am talking about User model in django! The Django user model does not enforce unique email addresses, since email addresses aren't necessarily one-to-one with real-world people: there are various legitimate situations where different u

Re: Model field option "max_length" is not respected (Sqlite backend)?

2009-08-07 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 01:24 -0700, Thierry wrote: > Hi, > > I have a model roughly defined as such (FK fields do not appear for > simplicity): > > class FieldChange(models.Model): > old_value = models.CharField(max_length=50) > new_value = models.CharField(max_length=50) > > Using SQLit

Re: multi-table inheritance and modification of OneToOneField options

2009-08-07 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 00:30 -0700, Jan Ostrochovsky wrote: > 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

Re: DateInput widget, format attr & ugettext

2009-08-06 Thread Malcolm Tredinnick
On Fri, 2009-08-07 at 11:56 +1000, Malcolm Tredinnick wrote: > On Thu, 2009-08-06 at 08:06 -0700, cArkraus wrote: > > Hey all, > > > > I cant seem to get my (non-model-)forms datefield localized. > > > > Here's my first attempt: > > some_date = fiel

Re: DateInput widget, format attr & ugettext

2009-08-06 Thread Malcolm Tredinnick
On Thu, 2009-08-06 at 08:06 -0700, cArkraus wrote: > Hey all, > > I cant seem to get my (non-model-)forms datefield localized. > > Here's my first attempt: > some_date = fields.DateField(widget=widgets.DateInput(format=ugettext > ('%d.%m.%Y'))) This would do the translation when the file is imp

Re: How-to use SelectMultiple widget with CommaSeparatedIntegerField ?

2009-08-06 Thread Malcolm Tredinnick
On Thu, 2009-08-06 at 07:35 -0700, nono wrote: > I was reading my post and though it was not very clear > > My model uses CommaSeparatedIntegerField to store some integer values. > I want my users to use SelectMultiple widget to create/update those > integer so I put a ChoiceField with widget=Sel

Re: multi-table inheritance and modification of OneToOneField options

2009-08-06 Thread Malcolm Tredinnick
On Thu, 2009-08-06 at 07:15 -0700, Jan Ostrochovsky wrote: > 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 OneToOneFi

Re: Get current user outside a view / without an request object

2009-08-06 Thread Malcolm Tredinnick
On Thu, 2009-08-06 at 03:33 -0700, krylatij wrote: > Why do you think so? It's bad encapsulation practice, for a start. It breaks Python's namespacing habits. In this particular case, however, go back and read the original poster's message. Having the user in threadlocals doesn't solve any probl

Re: django queryset based on when data created

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 21:41 -0700, Joru wrote: > Everytime I edit some data, the data order in queryset changed into > the newest edited > Is it posible to get queryset that ordered based when the data created > without having to add creation date for sorting purpose The order results are returne

Re: Admin site images not coming up in 1.1

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 21:09 -0700, emy_66 wrote: > Hi, > > Just migrating my application to 1.1. Everything works fine except the > images inside the admin site are not showing up. Any ideas why this > may be? Everything worked with 1.0.1 and 1.0.2 I think. Remember that the admin images and CSS

Re: multiple projects shared database

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 17:59 +0100, Robin Becker wrote: > My boss wants to have two different django controlled websites with a common > database. Is there a way to do this? > > We are already running multiple websites into a single django project and > because they have a disambiguating term in

Re: apache ok (mod_wsgi) bue some issue with admin backend

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 11:50 +0200, Salvatore Leone wrote: > Hello again... > > > I have my site working with mod_wsgi, but I still have some problem > using the admin interface and managing uploaded files. > > On the admin side all static files aren't loaded. So there is no css and > you can

Re: Unit test failing with 302 instead of 200, using Django's TestCase class

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 10:45 +0100, Paulo Almeida wrote: > Ok, so with APPEND_SLASH = False , I get a 404 (so no > response['location']) , but the response.context still has all the > variables like MEDIA_URL, LANGUAGES, LANGUAGE_BIDI, and not the ones > it should have. It still has also: > > {'r

Re: overwrite User model

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 01:43 -0700, Shuge Lee wrote: > django.contrib.auth.models.User > > I don't like models.User, but I like Admin view, and I will keep admin > view in my application. > > How to overwirte models.User You can't. Django relies on the existing User model. There are *plenty* of

Re: HttpResponseRedirect and encoding

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 01:32 -0700, alecs wrote: > Sorry :( > > return HttpResponseRedirect(path) brings Internal Server Error: > > > cat /var/log/apache2/error.log [... snip ...] I can't immediately see why Python's urljoin() function is trying to do encoding/decoding at the point this explod

Re: Select_related and foreign keys

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 18:27 +1000, Brian May wrote: > On Wed, Aug 05, 2009 at 04:34:49PM +1000, Malcolm Tredinnick wrote: > > since it returns a *new* queryset that you cannot save to anything in > > the template. > > errr... What about: > > {% with object.objec

Re: HttpResponseRedirect and encoding

2009-08-05 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 01:12 -0700, alecs wrote: > I'm trying to download via GET a file with name in russian and getting > Internal Server Error: > > upfile = UpFile.objects.get(file_hash=file_hash) > path = os.path.join(settings.UPLOAD_ROOT, request.user.username, > upfile.file_name) > return Ht

Re: Can i rise 404 from my middleware ?

2009-08-04 Thread Malcolm Tredinnick
On Wed, 2009-08-05 at 09:29 +0300, Mirat Can Bayrak wrote: > On Tue, 4 Aug 2009 16:47:37 -0500 > Alex Gaynor wrote: [...] > > Right now there is a bug in django's middleware where it doesn't > > correct catch exceptions: http://code.djangoproject.com/ticket/6094. > than... what should i do?

Re: need help with model design and table relationship

2009-08-04 Thread Malcolm Tredinnick
On Tue, 2009-08-04 at 14:40 -0700, Unnamed_Hero wrote: > > > And you still haven't reduced it to a simple case that fails with a > > specific piece of data at the interactive prompt. You are trying to > > debug through three layers of curtains here. Why not remove the extra > > layers and work di

Re: Getting at the fields querysets of a form in a formset

2009-08-04 Thread Malcolm Tredinnick
On Tue, 2009-08-04 at 14:30 -0700, bnl wrote: > Hi Folks > > I'm trying to move up from a complex form based on a model declaration > to a model formset built on the same idea. > > I have a model which has some stuff that looks something like > > class Vocab(models.Model): > ''' Holds the v

Re: Select_related and foreign keys

2009-08-04 Thread Malcolm Tredinnick
On Tue, 2009-08-04 at 09:05 -0700, Joe LB wrote: > Hi all, > > I'm trying to access the related objects in the template by using > > {{ _set.select_related}} This isn't particularly useful in a template. Select_related() doesn't change the values you have access to and it isn't going to s

Re: subclassed ModelForms initial values behavior changed from 1.1beta to 1.1

2009-08-04 Thread Malcolm Tredinnick
On Tue, 2009-08-04 at 22:23 +0800, Russell Keith-Magee wrote: > On Mon, Aug 3, 2009 at 3:46 AM, David Haas wrote: > > > > It looks like the change happened between rev. 10189 & 10190: 10189 > > displays the value, 10190 doesn't. > > > > Unfortunately, I don't think I can give you a completely unbi

Re: Multiple instances of the same form on one page: how to get the right POST data?

2009-08-04 Thread Malcolm Tredinnick
On Tue, 2009-08-04 at 07:07 -0700, Berco Beute wrote: > I'm trying to add multiple instances of the same form on one page, > each with its own submit button. I know how to use the 'prefix' > argument for a form to differentiate between forms, but I can't figure > out how to get the right data when

Re: Multiple Logins

2009-08-04 Thread Malcolm Tredinnick
On Tue, 2009-08-04 at 06:28 -0700, lfrodrigues wrote: > Hi, > > I've developed a special Auth backend for a internal communication > protocol. Everything was ok but now the requirements changed and I > need to allow on the same browser (in diferent tabs) several logged > users. > > How can I hav

Re: Specifying a join table for a customized query

2009-08-04 Thread Malcolm Tredinnick
On Tue, 2009-08-04 at 18:41 -0700, Daybreaker wrote: > See a recent thread here: > > http://groups.google.com/group/django-users/browse_thread/thread/0ee03167b7b5e873/850ac8304bf952b4#850ac8304bf952b4 > > and this query: > > mymodel.objects.extra(select={'ordering_field': 'IF(STRCMP > (bbs_tag.

Re: Apache and mod_wsgi on Ubuntu

2009-08-04 Thread Malcolm Tredinnick
On Tue, 2009-08-04 at 17:12 -0700, Steve1234 wrote: > I am trying to setup Apache and mod_wsgi on Ubuntu to run Django > content. I generated a minimum project using "django-admin.py > startproject mysite" creating the project in my home folder. Running > the development server works and shows the

Re: Django profiling logs (Like rails Mongrel logs) ?

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 22:05 -0700, Kedare wrote: > Hello, > Is there any wait to implement the same kind of logging that Rails > provide, by example : > > Processing BlogController#list (for 127.0.0.1 at 2007-02-23 > 00:58:56) [GET] > Parameters: {"action"=>"list", "controller"=>"blog"}

Re: formset consisting of multiple models/forms

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 20:29 -0700, sico wrote: > Hi, > > Just to clarify here, I really want to keep using forms.ModelForm to > avoid having to redefine any data types and labels. I could create a > single form that has all the fields I want and use that in a formset. > But then I have to duplic

Re: Changing domain cookie

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 17:51 +0100, Chris McCormick wrote: > Hi All, > > I have a strange issue happening with domain cookies. On the site I'm working > on we previously didn't have SESSION_COOKIE_DOMAIN set and so the cookie > defaulted to "Host: mysite.com" We have a bunch of users logged in wit

Re: need help with model design and table relationship

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 08:27 -0700, Unnamed_Hero wrote: [...] > And I still get > Caught an exception while rendering:relation "C12B_boss" doesn't > exist And you still haven't reduced it to a simple case that fails with a specific piece of data at the interactive prompt. You are trying to debug

Re: Aggregates over reverse relationships?

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 17:45 +0300, Shai Berger wrote: > Hi all, > > With the new aggregates in django 1.1, I wonder if there's an easy way to > aggregate over reverse relationships. As an example, assume a simplistic > representation of a set of teams: > > class Team(models.Model): > nam

Re: UserProfile and select_related

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 08:10 -0700, lfrodrigues wrote: > Isn't there any way to cache profile data on User side? This already happens when you call get_profile(). If you mean using a mass query, then you have just asked if there is a select_related() equivalent for reverse relations. For the answ

Re: Using email instead of username in extended "User" model?

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 13:13 -0700, Dana wrote: > Ok, I understand the login part but what about registration? Wouldn't > the user's need a username still? Or am I misunderstanding... And what > about Django admin, it would still need a username correct? Nothing stops you from creating a random st

Re: Date format in modelform.

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 11:08 -0700, zayatzz wrote: > Hello. > > I have this in my form (modelform) for birth_date field: > birth_date = forms.DateField(('%d/%m/%Y',), label='Birth Date', > required=False ), which overrides this in model: > > birth_date = models.DateField(help_text="birth date", >

Re: Date/time field styling?

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 11:29 -0700, mhulse wrote: > Hello, > > {{ form.start }} > > For example, outputs this: > > > > > I have tried: > > {{ form.start_0 }} and {{ form.start_1 }}, but that outputs absolutely > nothing. :) > > Is it possible to split up the two fields so I can handle them >

Re: 'str' object is not callable

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 09:51 -0700, Dolph wrote: > hey Ronghui, > > Thanks for the reply. I couldnt get your first suggestion to work, I > get "name 'coltrane_category_detail' is not defined". Also, Which is exactly what the problem is. In the first email you posted, you don't have any view calle

Re: why is not IntegrityError an attribute of models?

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 07:36 -0700, dnedbaylo wrote: [...] > I was thinking about a case where try clause contains couple of save() > calls of different models and each model has unique field. And there > is no way to catch specific to model IntegrityError, > you can catch only "general" IntegrityE

Re: many to many model

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 03:49 -0700, elminio wrote: > Hi, > tahnks for reply I added additional ManyToManyfield to one table and > admin panel looks ok but in fact even using syncdb new intermediate > table wasn't created. > Is there anything else I should do ? Syncdb does not incrementally update

Re: need help with model design and table relationship

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 03:19 -0700, Unnamed_Hero wrote: > Thanks for your reply. > > And the point is that (forgot to say)... the boss field in c12b table > doesn't exists, it is virtual and exists only in my model. When you add a ManyToManyField to a Django model, it doesn't create a column in t

Re: UserProfile and select_related

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 02:48 -0700, alant...@neei.uevora.pt wrote: > Hello, > > I'm displaying lot of user profile picture with are on a user profile > (i'm using contrib.auth). So for each picture I have a query for the > user profile. > > I wanted to use User.objects.filter(stuff).select_relate

Re: Non html safe chars on urls,

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 12:27 +0300, Mirat Bayrak wrote: > Hi i have an account system that you have to validate your email after > you created an account. My validation url is lik : > www.foo.com/account/confirm/username/keyyy > > But there is a problem, sometimes username contains non htm

Re: many to many model

2009-08-03 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 02:24 -0700, elminio wrote: > Hello, > > My problem is that I have (for example), a model teacher - subject > many to many. So that I made additional table named teacherSubject > with both ids. Instead of thinking about what database tables would be created, use Django's OR

Re: Caching template fragments without specifying expiration time

2009-08-02 Thread Malcolm Tredinnick
On Mon, 2009-08-03 at 01:00 -0400, Nick Fishman wrote: > > and suggests otherwise). It might not be too difficult to add support > > for an optional timeout, although the error checking requires a lot of > > care. > > I think that's the main problem. Since arguments to {% cache %} aren't > named,

Re: Retrieving the values from query set

2009-08-02 Thread Malcolm Tredinnick
On Sun, 2009-08-02 at 21:59 -0700, bvemu wrote: [...] > Is there a django way of retrieving only the values as a list and not > the fieldname Have a look at the values_list() method. That does what you are after. http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list-fields Reg

Re: locking up development server

2009-08-02 Thread Malcolm Tredinnick
On Sun, 2009-08-02 at 21:01 -0700, Rusty Greer wrote: > i added a column to one of my tables in my db. i added the column in > the model definition, then i went into mysql and added the column with > what i think is the appropriate alter table command. > the command i used was: > alter table db

Re: Using email instead of username in extended "User" model?

2009-08-02 Thread Malcolm Tredinnick
On Sun, 2009-08-02 at 20:21 -0700, Dana wrote: > Oops i mean username, not password. > > Im not clear on how I can get this to override the django login > functionality. Im reading more up on custom auth backends but Ill > admit it's a little confusing. You write a custom authentication function

Re: need help with model design and table relationship

2009-08-02 Thread Malcolm Tredinnick
On Sun, 2009-08-02 at 14:08 -0700, Unnamed_Hero wrote: > I have a table with a list of corporations; each corp has a field with > it unique number. > There is a table, filled with people, each record contains a field > with a corp's unique field (where each person works) > > Task: when displaying

Re: Caching template fragments without specifying expiration time

2009-08-02 Thread Malcolm Tredinnick
On Sun, 2009-08-02 at 04:25 -0400, Nick Fishman wrote: > I was wondering if it's possible to not specify the expiration time > when using the {% cache %} tag to cache template fragments. With the > low-level API, cache entries will expire after a timeout configured in > CACHE_BACKEND. Is it possib

Re: Template and substitute

2009-08-02 Thread Malcolm Tredinnick
On Sat, 2009-08-01 at 19:29 -0700, David wrote: > Hi, > > When I tested sql of MySQL in Python interactive shell, I got an > error of "not enough arguments for format string". I checked the > arguments however I could not find anything wrong. > > Can anybody give me a clue? > > Thanks so much.

Re: using the stable api

2009-08-02 Thread Malcolm Tredinnick
On Sat, 2009-08-01 at 19:59 +, Faheem Mitha wrote: > Hi Malcolm, > > Thanks for the helpful reply. > > On Sat, 01 Aug 2009 12:24:29 +1000, Malcolm Tredinnick > wrote: > > > On Fri, 2009-07-31 at 11:42 -0400, Faheem Mitha wrote: [...] > >> 3

Re: Stopping people loging in twice

2009-07-31 Thread Malcolm Tredinnick
On Fri, 2009-07-31 at 20:56 -0700, django user wrote: > So is there a viable django solution for this problem? You can implement your own session support. It's not that difficult. Django is just a layer on top of Python, so there's a Django solution to any computable problem. Django's default con

Re: Stopping people loging in twice

2009-07-31 Thread Malcolm Tredinnick
On Fri, 2009-07-31 at 19:43 -0700, django user wrote: > I'm interested in a solution for this as well. > > I am thinking that a good way might be to rewrite the auth middleware > to check and see if a user login for this user exists and if it does > then remove that login and log in the current u

Re: Dynamic Choices for ChoiceField

2009-07-31 Thread Malcolm Tredinnick
On Fri, 2009-07-31 at 16:31 -0700, mviamari wrote: > Hello, > > I'm trying to make a form for data entry into my database that uses > ChoiceFields for foreign keys. Obviously, the ideal choice would be > ModelChoiceField, however I'm not using the django ORM, so I've > assumed that's not going t

Re: how to get some related data from different tables to one queryset?

2009-07-31 Thread Malcolm Tredinnick
On Fri, 2009-07-31 at 14:42 -0700, Unnamed_Hero wrote: > I have something like this: > > class Translation1(models.Model): > code = models.IntegerField(primary_key=True) > description = models.CharField() > > class Translation2(models.Model): > code = models.IntegerField(primary_key=

Re: using the stable api

2009-07-31 Thread Malcolm Tredinnick
On Fri, 2009-07-31 at 11:42 -0400, Faheem Mitha wrote: > > Hi everybody, > > I upgraded from somewhere around Django 1.0 to 1.0.2, and some things > broke and had to be changed. In the following, f is an object of class > 'django.core.files.uploadedfile.TemporaryUploadedFile'. I need to > > 1

Re: "join" query in Django?

2009-07-31 Thread Malcolm Tredinnick
On Thu, 2009-07-30 at 23:42 -0700, Asinox wrote: > Thanks Malcom for replay, but, is not working for me, i think that is > simple just .filter("field1__field2"), but i cant make the join i try > with .filter("field1__field2") where the field1 is the PK and the > field2 is the FK. > > here is my q

Re: How to save a model...

2009-07-30 Thread Malcolm Tredinnick
On Thu, 2009-07-30 at 12:33 -0700, zayatzz wrote: > ... Hello! > > I have a model (profile) which's only required field is its foreignkey > - django.contrib.auth.User. > > Following the example of forementioned model and its manager i created > manager for the profile: > > class ProfileManager(

Re: "join" query in Django?

2009-07-30 Thread Malcolm Tredinnick
On Thu, 2009-07-30 at 21:23 -0700, Asinox wrote: > Hi, guys, how or where is the "join" query in Django? > > i think that Django dont have "join"..but how ill make join? SQL-level joins happen automatically when required. You specify your queryset in terms of filter() and exclude() calls and Dj

Re: Custom Manage.py Commands

2009-07-30 Thread Malcolm Tredinnick
On Thu, 2009-07-30 at 17:18 -0700, mviamari wrote: > I'm trying to create a custom manage.py command for my project. The > example in the documentation only shows how to do this for custom > commands inside of an app. Is it possible to do the same at the > project level? The concept doesn't par

Re: Simple query on a ManyToMany field?

2009-07-30 Thread Malcolm Tredinnick
On Thu, 2009-07-30 at 18:14 -0600, Adam Olsen wrote: > Suppose I have the following models: > > class Tag(models.Model): > card = models.ForeignKey('Card') > name = models.CharField(max_length=10) > > class Card(models.Model): > # whatever > > Say I have a list, like the following: w

  1   2   3   4   5   6   7   8   9   10   >