Re: reloading models in the shell

2008-06-12 Thread Mike H
That does indeed work, just remember you can only reload modules, not individual classes you've imported from a module. Mike On 12 Jun 2008, at 09:52, Gregor Müllegger wrote: > > Maybe the builtin function ``reload`` might help you: > http://docs.python.org/lib/built-in-funcs.html > > I have

Re: How to modify contrib.auth models etc

2008-05-09 Thread Mike H
http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-model/ You can create a profile model that holds all the information you need, then in your settings specify APP_PROFILE_MODULE which will define a OneToOne relationship from the auth user to your profile model. It will the

Re: Filefield upload_tol

2008-05-05 Thread Mike H
I can replicate this by putting in a file path that does not exist in the HIP form. The validation fails for the file field but the error is not rendered. edit_inline is known to be buggy - some validation faliures on models that are being edited inline aren't rendered, but the user is tol

Re: cut-and-paste traceback error actually the error from the time before --

2008-04-29 Thread Mike H
Are you using firefox? I think this is a "helpful" feature of firefox where if you fill out a form and refresh the page, it remembers the form content so you don't have to fill it in again. So if you get an error page, fix the problem, refresh and get a different error, firefox messes up t

Re: New Project : Django Sites Integration

2008-04-27 Thread Mike H
Oh, and it automatically filters the model's querysets by the current site. Kinda important that it does that, and I forgot to mention it, heh. Cheers, Mike On 27 Apr 2008, at 18:29, Mike H wrote: > > Hi all, > > I've been putting together a si

New Project : Django Sites Integration

2008-04-27 Thread Mike H
hout modification! The project is at http://code.google.com/p/django-sites-integration/ I know it's probably going to be of limited appeal, but it was very useful for me, so hopefully someone else will have use for it. Cheers, Mike H --~--~-~--~~~---~--~-

Re: Clearing the cache

2008-03-29 Thread Mike H
On 29 Mar 2008, at 17:49, Sebastjan Trepca wrote: > > I would use signals for this. For example, you could hook on post_save > signal, so whenever a model gets saved, you refresh the cache etc. Unfortunately it's not as simple as that, we cache groups of models, querysets, portions of html tha

Clearing the cache

2008-03-29 Thread Mike H
Hi, I have models, views and managers that cache various things in the application we're building. It all works fantastically, once everything is cache we got zero queries run until the cache expires. However, if the cache is turned on while we run our unit tests, things start failing as

Re: How are you storing binary data in db

2008-03-27 Thread Mike H
On 27 Mar 2008, at 19:31, shabda wrote: > > Considering that BlobField is not supported, what are you using to > store binary data. Recipes, snippets .. In all cases, whether it's a binary file uploaded by the user or a binary file generated by the application, I store it in a file on disk a

Re: MySQL-python-1.2.2 errors

2008-03-25 Thread Mike H
I had the same problem just this morning. Commenting out #ifndef uint #define uint unsigned int #endif from _mysql.c fixed it for me, and all the django tests pass with a mysql backend afterwards, so I should be safe :) Cheers, Mike On 25 Mar 2008, at 15:04, Karen Tracey wrote: > On Tue, M

Re: Python using django framework

2008-03-23 Thread Mike H
Hi, Dates are a little confusing at first when you come to python from VB or PHP. In python, a date is not a string, but an object. Here's some example code : import datetime now = datetime.datetime.now() some_date = datetime.datetime(2008,1,1,0,0) if now == some_date: they were the

Re: How to put some data from view the form

2008-02-22 Thread Mike H
Hi, Don't implement __init__ yourself, you can pass initial data to the form like this : form = MyForm(initial={'someArg': 'value',}) Hope that helps, Mike On 22 Feb 2008, at 10:14, Mintaka wrote: > > Hi > > I would like to put some data from view to form when I create it. > Standard way

Re: Preferred Schema Evolution Tool

2007-11-27 Thread Mike H
SmileyChris wrote: > On Nov 26, 1:03 pm, LorenDavie <[EMAIL PROTECTED]> wrote: > >> Not sure if SmileyChris is this guy, but I've had good success with >> this project: >> >> http://www.aswmc.com/dbmigration/ >> > > As Mike H said, d

Re: Preferred Schema Evolution Tool

2007-11-25 Thread Mike H
That one is me. It's intended as a stop-gap until a more pythonic, as you say, evolution tool is officially working. Due to the complexity of automatically generating migrations and the amount of time I have to spend on it, the dbmigration tool will only ever be a way of automatically applyin

Re: template problem in windows

2007-10-08 Thread Mike H
Hi Dushyant, From the default settings.py : TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. '', ) so you need to have

Re: Derived, read-only attributes in the admin

2007-09-16 Thread Mike H
For these derived values, I usually have an attribute of the model that is updated at save time. You could have an 'order_total' on your Order model, and whenever you save an OrderLine, it updates the order_total on its associated Order and saves the order. Then it just becomes another attrib

Re: Custom validation for models in admin

2007-09-11 Thread Mike H
Sorry, I should have said that I'd already tried a custom validator. Unfortunately, validators don't provide the functionality I need. I need to check in the database to see if there are any pages, other than the one I am saving, that have start and end dates that overlap with the one I am sa

Custom validation for models in admin

2007-09-11 Thread Mike H
Hi all, I have a model which needs some non-standard checks before it gets saved. The class looks like this : class Page(models.Model): name = models.CharField(maxlength=30) content = models.TextField() start_date = models.DateField() end_date = models.DateField() When I save th

DbMigration 0.04 released

2007-07-26 Thread Mike H
Hi all, A bugfix release of DbMigration has been made, you can find it at http://www.aswmc.com/dbmigration/ Apologies to those that downloaded 0.03, it was a corrupt release and I've been without an internet connection recently while I moved house, just got my connection back, so here's the fi

Re: case sensitive usernames

2007-07-11 Thread Mike H
Oh boy, lack of sleep made me get my examples mixed up a little. Obviously to any half awake mind, the 'Neil' with an L and the 'NeiI' with an i example is irrelevant. However, a 'neil' 'Neil' situation could sitll arise, with a per user slug prone to problems in that case. Lesson for today

database connections

2007-06-23 Thread Mike H
Hi all, It looks like we're going to start work on a very high profile site and I'm investigating performance tweaks we can make to ensure we can handle the load :) One of the areas I'm concerned about is having to make a connection to the database for every request, and I'd be very grateful

Re: Django DbMigration 0.03 released

2007-06-10 Thread Mike H
Whoops, sorry about that! The download was a .tar.gz instead of a .tgz - all fixed now :) Cheers, Mike Kent Johnson wrote: > Mike H wrote: > >> Hi all, >> >> We've just released an update to the django dbmigration project. This >> release cleans up

Custom mod_python handlers with Django

2007-06-09 Thread Mike H
Hi all, I've posted the first in a series of posts about how to implement your own mod_python handlers using Django. I started it because I wanted to serve resized images without hitting the database, running middleware etc., but still have access to the django project settings (so I could re

Re: django.contrib.auth.views.login failing cookie test

2007-06-09 Thread Mike H
cations to the session during that view, and so the session is not saved or a cookie set. Looks like i'll need to implement my own view :) Mike Malcolm Tredinnick wrote: > Hey Mike, > > On Sat, 2007-06-09 at 16:53 +0100, Mike H wrote: > >> Malcolm Tredinnick wr

Re: django.contrib.auth.views.login failing cookie test

2007-06-09 Thread Mike H
Malcolm Tredinnick wrote: > Assuming you have the SessionMiddleware installed, you will have a > session created whenever you access a page that Django is responsible > for. > > Thanks, exactly what I needed to know :) This is not happening. After the first page view, I have no session. Mike

Re: django.contrib.auth.views.login failing cookie test

2007-06-09 Thread Mike H
. set_test_cookie on SessionWrapper is not getting called. When should it be getting called? As I say, after the first page view, I have not had a session started for me. Should I have? Mike It appears that when Mike H wrote: > Hi Malcolm, > > I'm more than willing to help track down the error

Re: django.contrib.auth.views.login failing cookie test

2007-06-09 Thread Mike H
s the session only get started once i submit the login form? Cheers, Mike Malcolm Tredinnick wrote: > On Sat, 2007-06-09 at 15:48 +0100, Mike H wrote: > >> Hi, >> >> I'm trying to use the provided login view for my new application, >> but whenever I use it, t

django.contrib.auth.views.login failing cookie test

2007-06-09 Thread Mike H
Hi, I'm trying to use the provided login view for my new application, but whenever I use it, the first time i submit the login request, AuthenticationForm returns the error "Your Web browser doesn't appear to have cookies enabled. Cookies are required for logging in." The second time i submit t

Django DbMigration 0.03 released

2007-06-09 Thread Mike H
Hi all, We've just released an update to the django dbmigration project. This release cleans up the code a little and improves the parsing of SQL migrations. Homepage and downloads at: http://www.aswmc.com/dbmigration/ Thanks to Chris Beaven for his patches :) MikeH --~--~-~--~~

Using Django outside of Django

2007-04-30 Thread Mike H
Hi all, I'm sure this has been discussed elsewhere, but common terms like "using" "django" "models" and "scripts" make it hard to find! ;) I've written a nice multi-user mp3 jukebox for our office, it lets users add tracks to their playlist and then interleaves the playlists so that everyone

Re: Finding out which fields changed

2007-04-26 Thread Mike H
Hi Vincent, It sounds to me like you need a pre_save signal to check if the width and/or height of the model you're about to save is different from the one currently stored in the database, and if they are different, regenerate the thumbnail. Something like : in_db = Model.objects.get(pk=s

Re: Django Schema Migration

2007-04-22 Thread Mike H
migration if there is a problem with the code that depends on it. Perhaps a combination of both would be good? By the way, my dbmigration should have no problems with older versions of django, I just haven't tested it with them. The patch for management.py would need changing though. Ch

Re: Django Schema Migration

2007-04-20 Thread Mike H
Hi again, The docs have been updated with the points you raised. Cheers! Mike On 4/20/2007, "Mike H" <[EMAIL PROTECTED]> wrote: > > >Ah, yes, the docs aren't clear on this at the moment, but the automatic >schema creation does not run if you use migrati

Re: Django Schema Migration

2007-04-20 Thread Mike H
Ah, yes, the docs aren't clear on this at the moment, but the automatic schema creation does not run if you use migrations for an application. You will have to create a migration that creates the tables. (Just use 'python manage.py sqlall' to get the sql for the migration) The reason for this is

Re: Django Schema Migration

2007-04-20 Thread Mike H
Mike On 4/20/2007, "Russell Keith-Magee" <[EMAIL PROTECTED]> wrote: > >On 4/20/07, Mike H <[EMAIL PROTECTED]> wrote: >> >> Before I release the code, I want to make the migrator call 'install' >> from django.core.management if it doesn'

Re: Django Schema Migration

2007-04-20 Thread Mike H
Hi David, The python functionality is there so that you can manipulate the models directly or run more complex dynamic sql if you need to. Let's say that your app is called "myapp" and you want to do something special to all User records with an aol email address, but that something special is

Re: Django Schema Migration

2007-04-20 Thread Mike H
the migration code. Mike On 4/20/2007, "Mike H" <[EMAIL PROTECTED]> wrote: > > >Ah, thanks for the heads up! > >Unfortunately, syncdb will install the latest SQL for all installed >applications (as far as I am aware). Is there a way just to install the >schem

Re: Django Schema Migration

2007-04-20 Thread Mike H
Yeah, eventually I'd like to have the migrations define column additions, deletions and renames using the models from Django. However this is my first foray into the internals of Django so I would have a lot of reading to do! I'm wondering if the schema-evolution branches would have code I can re

Re: Django Schema Migration

2007-04-20 Thread Mike H
Hi all, Release 0.01 of the migration module can be downloaded from http://www.aswmc.com/dbmigration/ as well as a patch to integrate it into the syncdb command. It seems to be working well for the developers here, so here's hoping it's useful for some other people too :) MikeH --~--~

Re: Django Schema Migration

2007-04-20 Thread Mike H
nctions. The vast majority of the migrations (we're up to >number 191) simply execute SQL statements, but the few times we've >wanted the help of the model classes, it has been very helpful to have >the full power of Python available to us. > >--Ned. > >Mike H wrote: >

Django Schema Migration

2007-04-19 Thread Mike H
Hi all, I've been working on a tool to give me an automated way of altering the schemas on servers I deploy my django applications to. I know about the schema-evolution branch, but the current approach of that isn't completely automated and the work seems to have stopped on it. The approach I h

Re: Most efficient way to handle two level deep relationships

2007-04-06 Thread Mike H
ead_slug) > >Also, if you want to reduce DB load you could have your ForeignKey to >User directly, rather than Profile... but I don't know if you >reference profile elsewhere. > >Good luck! > -- Ben > >[0] http://www.djangoproject.com/documentation/db-api/#select

Most efficient way to handle two level deep relationships

2007-04-06 Thread Mike H
Hi all, I'm implementing a simple forum which looks like this, but I'm concerned about how many queries are going to get run, and if there is a more efficient way o structuring my view : from django.contrib.auth.models import User class Profile(models.Model): ... some attributes here, avat

Schema evolution

2007-03-19 Thread Mike H
Hi all, Does anyone know what the plans for the schema evolution branch are? Can we expect to see its ideas and code in 1.0? I ask as having to write a patch runner to update live schemas is the only part of working with Django that is an annoyance :) Mike --~--~-~--~~

Re: Outputting navigation

2007-03-05 Thread Mike H
Actually, after a nice strong cup of coffee, I figured I was doing this completely the wrong way. I added a get_pages method to the category which returns a queryset, then I supply the categories to the template and let the template ask the category for the pages. Mike On 3/5/2007, "M

Outputting navigation

2007-03-05 Thread Mike H
Hi all, I have a list of wiki pages, each one has a category. I want to output them in a list, grouped by category. So far I am looping through each page and putting them into a dict, so the end result looks like this : {'category_name': [page1,page2,page3],} Now I want to loop round that in

Re: About to defect, need MS SQL Server patch for 0.96pre or 0.95

2007-03-01 Thread Mike H
ll not work >correctly because SQL Server 2000 doesn't naively support the limit offset >functionality that other DBs do. I think that SQL Server 2005 does have >that functionality, but so many people still use SQL Server 2000 that a >solution that accommodates both has to be cre

Re: About to defect, need MS SQL Server patch for 0.96pre or 0.95

2007-03-01 Thread Mike H
On 3/1/2007, "Sean De La Torre" <[EMAIL PROTECTED]> wrote: >With the exception of dataset paging, it is feature complete and stable. Excuse the dumb question, but does that mean that generic paginated views will not work, or will just be quite inefficient? Thanks, Mike >On 3/1/07, Jeremy

Re: Using HTML/CSS as templates

2007-02-27 Thread Mike H
I'm taking a guess that your css is meant to be served as a static file through your webserver and not a django view? If I'm right about that, and you're using apache+mod_python, check out the "Serving Media" section at http://www.djangoproject.com/documentation/modpython/ You need to tell your

Re: Database changes

2007-02-20 Thread Mike H
For me, if there was a way to simply add missing columns that would be enough. Any data manipulation should be done by a patch runner that can be tested and automated, but simply adding missing columns to a table I think should be done by syncdb. The way I have approached this when producing ORM

Re: Authenticate during middleware call

2007-02-11 Thread Mike H
Hi all, I figured out the problem I was having, the example in the documentation I followed for doing the authentication backend didn't have the first 'self' argument, so the authentication was never triggered. Mike On 2/10/2007, "Mike H" <[EMAIL PROTECTED]&g

Authenticate during middleware call

2007-02-10 Thread Mike H
Hi all, I am putting together a system where logging in and out is triggered by calls from a seperate application. The other application posts a username and a session id to my application, and sets a cookie so that when the user visits my site, my app sees the cookie, looks up which username i

passing arguments to the login_required decorator

2007-02-07 Thread Mike H
Hi all, I am using the login_required decorator form django.contrib.auth.decorators, but I want to override the second argument which specified which url it should redirect to if the user is not logged in. I'm pretty new to python and everything I've tried so far has just resulted in a syntax o