Re: following relationships forward in queries

2010-01-15 Thread Daniel Roseman
On Jan 15, 5:43 am, Michael Thon wrote: > I have an Model with a field that is a oneToOne relationship with a model in > another app: > > class SensePost (models.Model): >     feedjackpost = models.OneToOneField(Post, blank=True, null=True) >     ... > > I'm trying to to write a filter query that

Custom filters and partial mark_safe?

2010-01-15 Thread Andrew Turner
I have a custom filter parses a CharField for usernames marked with '@', and replaces them with a hyperlink to their profile page:- def hyperlink_usernames(note): for word in note.split(): if '@' in word: try: User.objects.get(username=word.strip('@'))

Re: following relationships forward in queries

2010-01-15 Thread Michael Thon
Here is the Post model, from the feedjack app class Post(models.Model): feed = models.ForeignKey(Feed, verbose_name=_('feed'), null=False, blank=False) title = models.CharField(_('title'), max_length=255) link = models.URLField(_('link'), ) content = models.TextField(_('content'),

Application template inheritance and customization

2010-01-15 Thread Olivier Guilyardi
Hi everyone, I'm working on a Django application, Telemeta, which is currently deployed in 4 projects. Each of these projects have special requirements in regard to presentation and data display, so that the application templates need to be slightly customized. For this purpose I have used templa

Re: following relationships forward in queries

2010-01-15 Thread Daniel Roseman
On Jan 15, 9:40 am, Michael Thon wrote: > Here is the Post model, from the feedjack app > > class Post(models.Model): >     feed = models.ForeignKey(Feed, verbose_name=_('feed'), null=False, > blank=False) >     title = models.CharField(_('title'), max_length=255) >     link = models.URLField(_('

Re: Documentation for graphic designers

2010-01-15 Thread Nick Lo
> I'd like to know if there is manual or "How to Guide" for graphic > designers working with django. Django 1.0 Template Development might be useful: http://www.packtpub.com/django-1.0-template-design-practical-guide/book As a reviewer says: "The book does a good job of focusing in on the Djan

Re: Only Email + Password ( without username )

2010-01-15 Thread Matt Schinckel
On Jan 14, 8:12 pm, Alexander Dutton wrote: > On 14/01/10 09:51, nameless wrote:> I am asking whether is a good solution to > having 2 fields with the > > same value ( username and email ) because both are required. > > Or is there another solution ? > > This depends on whether you don't want dis

Re: Test fixtures loaded ~100 times faster by overwriting BaseDatabaseCreation.create_test_db + question

2010-01-15 Thread Matt Schinckel
On Jan 14, 11:07 pm, Russell Keith-Magee wrote: > On Thu, Jan 14, 2010 at 4:43 PM, Piotr Czachur wrote: > > Guys, > > I was really unhappy to see how slow fixtures are loaded before every > > test. I'm not talking about initial_data stuff that is loaded just in > > beginning, and then reset by ro

Re: Best way to track user presence

2010-01-15 Thread David De La Harpe Golden
E17 wrote: > I wouldn't like to use cron, as running full python execution stack is > quite expensive in terms of performance. For the same reason I don't > like to run this code on [every] request handlers. > > Seems to me like better solution would be to use some outer deamon or > deamon-like p

Top 10 tips to a new Django developer. correct approach?

2010-01-15 Thread Sebastian Pawlus
Hi I've found something like "Top 10 tips to a new Django developer" http://blog.dpeepul.com/2009/08/31/top-10-tips-to-a-new-django-developer/ I'm really blasted by first point "Don’t put project name in the imports". is this point correct? Django site and core developers http://github.com/jaco

Re: Top 10 tips to a new Django developer. correct approach?

2010-01-15 Thread Dougal Matthews
If you want your app to be shipped individually and re-used then you shouldn't use the project name. If you make a reusable app and release it then I want to use it, I don't want to have to include the project namespace, i just want the app. However, its your shipping the project as a whole then i

AnnArbor.com is looking for a Django Developer

2010-01-15 Thread hass
AnnArbor.com is seeking a full-time developer to help create the best local site for Ann Arbor and Washtenaw County MI. The main responsibility for our web developers is to take ideas -- from the staff and your own -- and turn them into reality. Some highlights of things we've launched in the last

Re: Top 10 tips to a new Django developer. correct approach?

2010-01-15 Thread Sebastian Pawlus
I see but i thing there is more than my personal preference. http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE mysite.settings PythonOption django.root /mysite

Re: Top 10 tips to a new Django developer. correct approach?

2010-01-15 Thread Mike Ramirez
On Friday 15 January 2010 03:52:16 Sebastian Pawlus wrote: > I see but i thing there is more than my personal preference. > > http://docs.djangoproject.com/en/dev/howto/deployment/modpython/ > > > > SetHandler python-program > PythonHandler django.core.handlers.modpython > SetEnv DJ

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: Best way to track user presence

2010-01-15 Thread E17
I think you are right, the built-in session timeout would be the best and the most ideologically correct solution. Thank you) On Jan 15, 4:27 am, Shawn Milochik wrote: > Use the built-in session timeout. Probably a good idea in any case, to   > protect your data and user privacy. > > If they don'

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: Best way to track user presence

2010-01-15 Thread E17
I know of celery, it's a good software, but little too complicated and expensive for the task I'm asking about. I'll probably use built-in session timeout, as Shawn suggests. But I think eventually I'll come back to celery when my demands will rise as I'll have a need for delayed processing in my D

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

displaying object contents in template help

2010-01-15 Thread grimmus
Hi, I have a view that gets the latest videos: videos = Video.objects.filter(category=category,active=1).order_by ('-hit_count') In my template i would like the first result to appear in the primary block and the other results to appear in the secondary block {% block primary %} SHOW FI

Re: displaying object contents in template help

2010-01-15 Thread Daniel Roseman
On Jan 15, 1:47 pm, grimmus wrote: > Hi, > > I have a view that gets the latest videos: > >     videos = Video.objects.filter(category=category,active=1).order_by > ('-hit_count') > > In my template i would like the first result to appear in the primary > block and the other results to appear in t

Re: following relationships forward in queries

2010-01-15 Thread Michael Thon
On Jan 15, 2010, at 11:26 AM, Daniel Roseman wrote: > On Jan 15, 9:40 am, Michael Thon wrote: >> Here is the Post model, from the feedjack app >> >> class Post(models.Model): >> feed = models.ForeignKey(Feed, verbose_name=_('feed'), null=False, >> blank=False) >> title = models.CharFie

Transaction managed block ended with pending COMMIT/ROLLBACK found in Admin

2010-01-15 Thread Ben Scherrey
Happens only on our Postgres 8.4 environment and not sqlite (which I think doesn't really enforce such things anyway). We've got some admin pages that generate TransactionManagementError exceptions saving simple data. Happens 100% once it starts but another, otherwise identical install, won't h

Re: displaying object contents in template help

2010-01-15 Thread grimmus
Excellent, thanks for the useful info On Jan 15, 3:00 pm, Daniel Roseman wrote: > On Jan 15, 1:47 pm, grimmus wrote: > > > > > Hi, > > > I have a view that gets the latest videos: > > >     videos = Video.objects.filter(category=category,active=1).order_by > > ('-hit_count') > > > In my template

Re: Problem when trying to validate a field in a ModelAdmin which has inline forms

2010-01-15 Thread Marco Rogers
I've never had to do this but it sounds you want to work with Form.clean() in stead of Form.clean_is_approved(). From the docs: "The Form subclass’s clean() method. This method can perform any validation that requires access to multiple fields from the form at once." So in your clean method

Postgres and "autocommit"

2010-01-15 Thread apramanik
I turned autocommit on for our Django project and our unittests fail unless we put "transaction.rollback" in our tearDown. Any idea why? After fixing that I also noticed that our unittests are *much* slower. Is it because they're mainly doing deletes and writes (we also load in fixtures via YAML) a

Re: Top 10 tips to a new Django developer. correct approach?

2010-01-15 Thread fordprefect
I think it depends on requirements; not everything has to be a reusable app ! For example, if you have a number of interdependent apps as part of a larger system,and breaking them up makes no sense, housing them under a single package is good practice. What you should avoid is using the same name

Re: Problem when trying to validate a field in a ModelAdmin which has inline forms

2010-01-15 Thread Gabriel Reis
Hey Marcos, In the clean() method of my ClipModelForm class I couldn't manage how to reach the ClipDescriptions that are coming from the inline ClipDescriptionInline. I think I can't validate there. I spent the whole day trying and I couldn't fix. Any help would be very handy! Thanks for your ate

Re: Transaction managed block ended with pending COMMIT/ROLLBACK found in Admin

2010-01-15 Thread Ben Scherrey
Another data point: transaction error occurs when using the admin ui via the web browser (presumably any but specfiically both Chrome & Firefox 3.5.7) but never via manage.py's shell. What would be going on differently in Admin? Is this a bug in history? A conflict with Postgres? Are we the only on

Anyone have provisioning documentation for a LeadTek BVA8055?

2010-01-15 Thread Eric Chamberlain
Hi, A friend has a few hundred LeadTek BVA8055's and need to know how to bulk provision them. There isn't much documentation on the web. Anyone know how to bulk provision these devices? -- Eric Chamberlain -- You received this message because you are subscribed to the Google Groups "Dj

OS X 10.6 Snow Leopard Setup Tutorial

2010-01-15 Thread Jonathan Eatherly
Hi all, Anyone who has ever tried to install a working Django stack on OS X 10.6 knows it can be quite a nuisance. I took the time out of my day to fix this and wrote my own setup tutorial. There are many other tutorials out but frankly they all suck. If you follow my tutorial, you will have my

Re: Transaction managed block ended with pending COMMIT/ROLLBACK found in Admin

2010-01-15 Thread Ben Scherrey
SOLVED: As it turns out, admin demands you have an entry in the local User table even if, as is the case with us, you've implemented a different auth system, don't user any of the local auth tables and have defined AUTHENTICATION_BACKENDS in settings.py. Our backend will now create a record in the

Re: import error on dateutil.parser

2010-01-15 Thread newspaper-django-lackey
Okay, On our production server we used apt-get to install django and python- dateutil. In an attempt to avoid having to add the path to every wsgi settings file I tried several things: I put a symbolic link called dateutil from /usr/lib/python2.5/site- packages to /usr/share/python-support/pytho

Should Django handle uploaded files in PUT as well as POST?

2010-01-15 Thread Malcolm Box
Hi, I'm working on a REST-full API that allows an uploaded file to be PUT to a URL. I also need to support the X-Http-Method-Override header to turn a POST request into a PUT for clients (Flash, mobile etc) that can't do PUT. At the moment I've got the API working with POST requests, and am now

Re: OS X 10.6 Snow Leopard Setup Tutorial

2010-01-15 Thread Malcolm Box
On Fri, Jan 15, 2010 at 6:37 PM, Jonathan Eatherly < jonathan.eathe...@gmail.com> wrote: >One of these days I would like to make a DMG that sets up > everything for the user. If anyone would be interested in a DMG single > setup executable please let me know and maybe I will make it a weekend

Re: Can't connect to MySQL server

2010-01-15 Thread Malcolm Box
Hi, On Thu, Jan 14, 2010 at 10:36 AM, Hans.Rauch wrote: > Hi, > > we have two separate django- and mysql-servers. Most of the time we > got no problems. From time to time we get an email with the following > error-message: OperationalError: (2003, "Can't connect to MySQL server > on '..' (4)").

Re: OS X 10.6 Snow Leopard Setup Tutorial

2010-01-15 Thread Matt Schinckel
On Jan 16, 8:41 am, Malcolm Box wrote: > On Fri, Jan 15, 2010 at 6:37 PM, Jonathan Eatherly < > > jonathan.eathe...@gmail.com> wrote: > >    One of these days I would like to make a DMG that sets up > > everything for the user. If anyone would be interested in a DMG single > > setup executable ple

Save, Signals and Models

2010-01-15 Thread Victor Loureiro Lima
Here is the deal: class MyModel ( models.Model ): title = models.CharField( max_length = 100 ) only_me = models.BooleanField( default = False ) Question: Whats the proper way to guarantee that no matter how many MyModel's are available in the database, only one of them will have the only_me

Re: Save, Signals and Models

2010-01-15 Thread Gabriel Reis
Hey Victor, I can think that a trivial way (I am not sure if it is the best) to do that is to overwrite the save() method of your model: class MyModel(models.Model): title = models.CharField(max_length=100) only_me = models.Boolean(default=False) def save(self): if self.only_

Re: Save, Signals and Models

2010-01-15 Thread Victor Loureiro Lima
I think that will not work,when I call the obj.save() I will inevitably step again into my own save() method and the only_me wont be set as False yet, thus the same problem would occur again and again until I get the maximum depth error. I dont think thats an option, ahev you tested this solution?

Re: Save, Signals and Models

2010-01-15 Thread Mike Ramirez
Add in an if statement, one that while cycling through the only_me=True list, ignores the current model you're saving. def save(self): if self.only_me: only_me_true = MyModel.objects.filter(only_me=True) for obj in only_me_true:

Customizing Admin Forms Question

2010-01-15 Thread Joel Davis
I've got a couple of questions about customizing the admin pages... First, is there a way to specify the layout/template for an admin form by hand? I've got a Model that has a bunch of optional fields, including a bunch of TextAreas, and the form is huge and jumbled. I'd like to make a custom temp

Re: Save, Signals and Models

2010-01-15 Thread Victor Loureiro Lima
I did exactelly that, instead of using id I used the slug, which is also unique, so I skipped it, but the problem still occurs. Either my logic is wrong, or some dumb mistake, but I think that wouldnt work either. Victor Lima 2010/1/15 Mike Ramirez > Add in an if statement, one that while cycl

Re: Save, Signals and Models

2010-01-15 Thread Mike Ramirez
On Friday 15 January 2010 17:08:06 Mike Ramirez wrote: > Add in an if statement, one that while cycling through the only_me=True > list, ignores the current model you're saving. > > def save(self): > if self.only_me: > only_me_true = MyModel.objects.filter(only_me=True

Re: Save, Signals and Models

2010-01-15 Thread Mike Ramirez
On Friday 15 January 2010 17:11:23 Victor Loureiro Lima wrote: > I did exactelly that, instead of using id I used the slug, which is also > unique, so I skipped it, > but the problem still occurs. Either my logic is wrong, or some dumb > mistake, but I think that wouldnt work either. > > Victor Li

Re: Postgres and "autocommit"

2010-01-15 Thread Russell Keith-Magee
On Sat, Jan 16, 2010 at 1:38 AM, apramanik wrote: > I turned autocommit on for our Django project and our unittests fail > unless we put "transaction.rollback" in our tearDown. Any idea why? > After fixing that I also noticed that our unittests are *much* slower. > Is it because they're mainly doi

Re: Should Django handle uploaded files in PUT as well as POST?

2010-01-15 Thread Russell Keith-Magee
On Sat, Jan 16, 2010 at 6:32 AM, Malcolm Box wrote: > Hi, > > I'm working on a REST-full API that allows an uploaded file to be PUT to a > URL.  I also need to support the X-Http-Method-Override header to turn a > POST request into a PUT for clients (Flash, mobile etc) that can't do PUT. > > At th

Re: Querysets returns wrong result when using threading.

2010-01-15 Thread Kieran Brownlees
Firstly thank you, secondly, how to get around it? I assume I need to force a commit for the transaction my thread is using, but querysets don't appear to have a documented method to do that. Thank you On Jan 16, 1:52 am, Tomasz Zieliński wrote: > On 15 Sty, 05:33, James Bennett wrote: > > > On