Re: limit_choices_to: getting access to current instance

2007-01-31 Thread qhfgva

Well, either I'm not able to follow your example or we are talking
about different things.  In any case here is what I got working as a
first draft.  As a big benefit to me is the fact that I now understand
these inner workings a little better.  I was hoping to get away with
simple wrappers to generic views but now I don't think that will be
the case but it also doesn't worry me.  :)

This is closely adapted from:  http://code.pui.ch/2007/01/07/using-
djangos-newforms/

from django import newforms as forms
from django.newforms import widgets
from django.template import loader, Context
from django.http import HttpResponse

def create_update_animal(request, animal_id=None):
animal = None
if animal_id:
animal = Animal.objects.get(id=animal_id)
animal_form = forms.models.form_for_instance(animal)
else:
animal_form = forms.models.form_for_model(Animal)

if animal:
available_protocols = Protocol.allowed_for_animal(animal)
else:
available_protocols = Protocol.active_list()

protocol_choices = [('','')] + [(p.id,p.number) for p in
available_protocols]
animal_form.base_fields['protocol'].widget.choices =
protocol_choices
if animal:
animal_form.base_fields['protocol'].widget.initial =
animal.protocol_id

if request.method == 'POST':
form = animal_form(request.POST)

if form.is_valid():
form.save()
return HttpResponseRedirect("/")
else:
form = animal_form()
t = loader.get_template('tracker/animal_form.html')

c = Context({ 'form': form, })

return HttpResponse(t.render(c))


If there is a way to do the above just using limit_choices_to, I'd
still like to understand that method.  Also if I'm doing anything
particularly hacky feel free to mock me (but also instruct me as to a
better way).

thanks.


On Jan 30, 5:04 pm, "quentinsf" <[EMAIL PROTECTED]> wrote:
> Sorry, the reference to 'Display' should have been to 'MyObject'


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: finding verbosity in tests.py?

2007-01-31 Thread Russell Keith-Magee

On 2/1/07, yary <[EMAIL PROTECTED]> wrote:
>
> Quick question- how do I find the verbosity in which my tests are
> running? something like "from  import verbosity"?

Verbosity is passed in as a command line argument to the testing
process - it's not visible to the testing methods itself. Verbosity
only affects the reporting level of the test harness (i.e., do I print
out every test that is run, or just the final '3 tests passed'
message).

There is no scheme to pass verbosity down to the individual test cases
- mostly because test cases shouldn't be producing output.

Yours,
Russ Magee %-)

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



finding verbosity in tests.py?

2007-01-31 Thread yary

Quick question- how do I find the verbosity in which my tests are
running? something like "from  import verbosity"?


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: not receiving error email

2007-01-31 Thread jrs

Have you tried the SERVER_EMAIL setting in settings.py?  For me that
did the trick

SERVER_EMAIL = '[EMAIL PROTECTED]'

Without that it was sending the exception emails from
[EMAIL PROTECTED] which my shared provider (webfaction which I
highly recommend) did not like.

jrs

On Jan 31, 6:37 pm, James Tauber <[EMAIL PROTECTED]> wrote:
> I just got an unhandled exception error on my production site but
> didn't receive an email.
>
> I have ADMINS set and django in general has no problem emailing
> (account activation works fine).
>
> Is there something else I need to do to get error emails?
>
> Any other suggestions as to what to look for that would cause the
> error email to not be sent?
>
> James


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: not receiving error email

2007-01-31 Thread James Bennett

On 1/31/07, James Tauber <[EMAIL PROTECTED]> wrote:
> I just got an unhandled exception error on my production site but
> didn't receive an email.

There are some cases where this will happen; for example, the code
which would send the email lives in the handler class, so if the
handler never gets fully instantiated before an exception pops up,
then Django has no chance to send an email or try to recover
gracefully. Generally, when this happens under mod_python you get a
blank white page with some pithy error messages from mod_python
itself, and under FastCGI you'll get errors out of flup instead of
Django.

Beyond that, I've seen plenty of weird interactions of spam filters
and other mail-oriented weirdness causes delays or even drop the
emails outright.

-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Honza Král
this seems more accurate:

def process_request( self, request ):
now = datetime.datetime.now()
# get last_request, defaults to now, when he was never seen before
# you may wish to omit setting last_seen in that case (he
wasn't ever seen)
last_request = request.get( 'last_request', now )
# when did you last see him? when he last requested something! ::
# if you really want to, you can add the 4-hour waiting time
here (only for this line though !!)
request.session['last_seen'] = last_request
# now is the time he is making his last request
request.session['last_request'] = now

no tries, no catches...

On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I think this MAY be working now and I think I even finally wrapped my
> head around what's going on. So, in hopes of helping someone else some
> day (or, alternately, someone pointing out any trouble spots
> remaining), the last_visit middleware:
>
> import datetime
>
> class LastSeen (object):
> def process_request(self, request):
> now = datetime.datetime.now()
> try:
> last_request = request.session['last_request']
> # don't update it too often, every 4 hours should be ok
> if (now - last_request).seconds > (60 * 60 *4):
> request.session['last_seen'] = last_request
> request.session['last_request'] = now
> except KeyError:
> request.session['last_request']  =
> datetime.datetime.now()
> request.session['last_seen'] = datetime.datetime.now()
> except TypeError:
> request.session['last_request']  =
> datetime.datetime.now()
>
> And I'd like to thank Honza, Doug, and everyone else who tried so hard
> to pound this simple thing through my thick skull.
>
> On Jan 31, 8:42 am, "Honza Kr�l" <[EMAIL PROTECTED]> wrote:
> > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > I know I'm dense, and I'm just not seeing this, but isn't that what
> > > I'm doing?
> >
> > > now = datetime.datetime.now()
> > > last_request = request.session['last_request']
> >
> > > if (now - last_request).seconds > (60 * 60 *4):
> > > ...
> >
> > but this line:
> >
> > >  request.session['last_request'] = now
> >
> > is only executed when last_request is lder than 4 hours... hardly
> > seems like always, does it?
> >
> >
> >
> >
> >
> > > On Jan 31, 7:47 am, "Honza Kr?l" <[EMAIL PROTECTED]> wrote:
> > > > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > > > > Ok, but if I update last_request at every request, then won't (now -
> > > > > last_request) ALWAYS be more or less 0?
> >
> > > > not if you update it AFTER the comparison...
> >
> > > > > On Jan 31, 4:16 am, "Honza Kr?l" <[EMAIL PROTECTED]> wrote:
> > > > > > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > > > > > > There's some conceptual thing I'm apparently just not getting. I
> > > > > > > attempted to follow Doug's advice and came up with:
> >
> > > > > > > class LastSeen (object):
> > > > > > > """Middleware that adds various objects to thread local 
> > > > > > > storage
> > > > > > > from the request object."""
> > > > > > > def process_request(self, request):
> > > > > > > now = datetime.datetime.now()
> > > > > > > try:
> > > > > > > last_request = request.session['last_request']
> > > > > > > # don't update it too often, every 4 hours should be 
> > > > > > > ok
> > > > > > >  if (now - last_request).seconds > (60 * 60 *4):
> > > > > > > request.session['last_seen'] = last_request
> > > > > > > request.session['last_request'] = now
> >
> > > > > > you have to update last request at every request, not only when its
> > > > > > too old... if you do it like this it is EXACTLY what you did before
> >
> > > > > > > except KeyError:
> > > > > > > request.session['last_request']  =
> > > > > > > datetime.datetime.now()
> > > > > > >  request.session['last_seen'] = 
> > > > > > > datetime.datetime.now()
> > > > > > > except TypeError:
> > > > > > > request.session['last_request']  =
> > > > > > > datetime.datetime.now()
> > > > > > >  request.session['last_seen'] = 
> > > > > > > datetime.datetime.now()
> >
> > > > > > > Which appears to do the exact same thing I was doing before.
> >
> > > > > > > On Jan 30, 1:07 pm, "Doug Van Horn" <[EMAIL PROTECTED]> wrote:
> > > > > > > > On Jan 30, 11:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > > > > > > wrote:
> >
> > > > > > > > > Well, if I were doing it by hand, every time they came to the 
> > > > > > > > > site I
> > > > > > > > > would set this_visit, and then set last_visit (or last_seen, 
> > > > > > > > > or
> > > > > > > > > whatever) to the previous value of this_visit, and I would 
> > > > > > > > > only do it
> > > 

not receiving error email

2007-01-31 Thread James Tauber

I just got an unhandled exception error on my production site but  
didn't receive an email.

I have ADMINS set and django in general has no problem emailing  
(account activation works fine).

Is there something else I need to do to get error emails?

Any other suggestions as to what to look for that would cause the  
error email to not be sent?

James

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Different subdomain for each application

2007-01-31 Thread Doug Van Horn

On Jan 31, 4:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> How would you go about using seperate subdomains for certain apps in a
> project? What I would like to do is something like this:
>
> urlpatterns = patterns('',
> (r'^weblog\.[a-z0-9-]+\.[a-z0-9-]{3}',
> include('mysite.blog.urls')),
> (r'^wiki\.[a-z0-9-]+\.[a-z0-9-]{3}', include('mysite.wiki.urls')),
> (r'^code\.[a-z0-9-]+\.[a-z0-9-]{3}', include('mysite.code.urls')),
> (r'^admin\.[a-z0-9-]+\.[a-z0-9-]{3}',
> include('django.contrib.admin.urls')),
> )
>
> This will of course not work as the matching is done against the file
> path and not the domainname.
>
> Cheers,
> Eivind Uggedal


I've thought about this too.  I haven't done anything but I think this
approach might work:

First, create the server aliases in the apache configuration for the
server, like:

ServerAlias code.example.com wiki.example.com admin.example.com

Then, use some middleware to 'inject' that sub-domain into the
request.path (is request.path writable?).  You might end up with:

__www__/
__wiki__/some/request/path/
__code__/another/path/

and url patterns like:

(r'^__www__/', include('apps.www.urls')),
(r'^__wiki__/', include('apps.wiki.urls')),
(r'^__code__/', include('apps.code.urls')),

That /seems/ like it should work.

I suppose you could also dig into the BaseHandler and the way it calls
the RegexURLResolver.resolve method, and pass it the full request
rather than just the path.  You'd probably need to change the
urlpatterns data structure, too.

Anyway, it's all just theory as I've never attempted any of this.  If
you give it a go, let us know as I like the idea of using sub-domains
rather than separate apache virtual servers.


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New Vim files for Django

2007-01-31 Thread Dave Hodder

On Jan 30, 2:04 am, "Honza Král" <[EMAIL PROTECTED]> wrote:
>
> Hi Dave,
> thanks for the work, it's great to see some more colors in my ViM... ;)

No problem Honza, glad it's of some use to you.  :o)

Dave


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Validation discrepancies between admin and newforms

2007-01-31 Thread Waylan Limberg

The admin app is currently being rebuilt to use newforms. No doubt
this, plus many similar issues are being addressed there. Watch the
dev list for discussions and check out the branch here:
http://code.djangoproject.com/browser/django/branches/newforms-admin

On 1/31/07, Kilian CAVALOTTI <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> I just noticed that fields validation occurs at several places, in a
> incoherent fashion: in the admin application, and in newforms/fields.py.
> For instance, a PhoneNumberField has to be XXX-XXX- in the admin,
> while it is handled as an IntegerField in newforms (thus validation fails
> on dashes).
>
> Shouldn't the validation be centralized and occur only in one place? Or is
> this a wanted behaviour, since the admin is a contributed app, and not
> part of django core?
>
> Thanks,
> --
> Kilian
>
> >
>


-- 

Waylan Limberg
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



utf-8 and database models

2007-01-31 Thread Joseph Wenninger

Hi!

I'm using an sqlite database with a model which has a Charfield named 
filepath.

I'm trying to store an "utf-8" string there. I tried passing it as a byte 
string and as a unicode object. Saving works fine, but if I try to access the 
field I'm always getting:

"Could not decode to UTF-8 column 'filepath' with text ."

How do I correctly pass utf-8 strings to a model ? Could somebody give me 
hints how to solve this ?

Kind regards
Joseph Wenninger

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 2 Questions!

2007-01-31 Thread Sebastien Armand [Pink]
Wow, sorry, I copied paste and didn't see the font was so awful!

2007/1/31, Sebastien Armand [Pink] <[EMAIL PROTECTED]>:
>
> So the exact unicode error is:
>
> UnicodeEncodeError at /entreprise/search/ 'ascii' codec can't encode
> character u'\xe9' in position 1: ordinal not in range(128) Request Method:
> POST  Request URL: http://localhost/entreprise/search/  Exception Type:
> UnicodeEncodeError  Exception Value: 'ascii' codec can't encode character
> u'\xe9' in position 1: ordinal not in range(128)  Exception Location: 
> c:\Python25\lib\site-packages\django\db\models\fields\__init__.py
> in , line 25
>
> with the following traceback:
>
> Traceback (most recent call last):
> File "c:\Python25\lib\site-packages\django\template\__init__.py" in
> render_node
>   712. result = node.render(context)
> File "c:\Python25\lib\site-packages\django\template\defaulttags.py" in
> render
>   100. len_values = len(values)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in __len__
>   100. return len(self._get_data())
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> _get_data
>   430. self._result_cache = list(self.iterator())
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in iterator
>   171. select, sql, params = self._get_sql_clause()
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> _get_sql_clause
>   444. joins2, where2, params2 = self._filters.get_sql(opts)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in get_sql
>   574. joins2, where2, params2 = val.get_sql(opts)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in get_sql
>   622. return parse_lookup(self.kwargs.items(), opts)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> parse_lookup
>   743. joins2, where2, params2 = lookup_inner(path, lookup_type, value,
> opts, opts.db_table, None)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> lookup_inner
>   915. params.extend(field.get_db_prep_lookup(lookup_type, value))
> File "c:\Python25\lib\site-packages\django\db\models\fields\__init__.py"
> in get_db_prep_lookup
>   172. return ["%%%s%%" % prep_for_like_query(value)]
> File "c:\Python25\lib\site-packages\django\db\models\fields\__init__.py"
> in
>   25. prep_for_like_query = lambda x: str(x).replace("\\",
> "").replace("%", "\%").replace("_", "\_")
>
>   UnicodeEncodeError at /entreprise/search/
>   'ascii' codec can't encode character u'\xe9' in position 1: ordinal not
> in range(128)
>
> ___
> And finally, here's my search view:
>
> def search_entreprise(request):
> form = EntrepriseSearchForm()
> if request.method=='POST':
> new_data = request.POST.copy()
> form = EntrepriseSearchForm(new_data)
> if form.is_valid():
> data = form.clean_data
> entreprise_list = Entreprise.objects.all()
> if data['domaine']:
>
> entreprise_list=entreprise_list.filter(domaine=data['domaine'])
> if data['entrepriseMere']:
>
> entreprise_list=entreprise_list.filter(entrepriseMere=data['entrepriseMere'])
> if data['nom']:
>
> entreprise_list=entreprise_list.filter(nom__icontains=data['nom'])
> return
> render_to_response('stagesECL/entreprise_list.html',{'list':entreprise_list,})
> return
> render_to_response('stagesECL/entreprise_search.html',{'form':form,})
>
>
> where in this case the only information given is the entreprise name (nom)
> which had the value "hé".
>
> I tried to change the encoding in the html but this doedn't seem to
> help
> Hope somebody knows how to do this!
>
> 2007/1/31, Kenneth Gonsalves <[EMAIL PROTECTED]>:
> >
> >
> >
> > On 30-Jan-07, at 6:26 PM, Sebastien Armand [Pink] wrote:
> >
> > > Example with a school and a student class. Each student has a
> > > foreign key linking to the school where he studies. Through a form,
> > > I get the informations to create the student including the school's
> > > id. When I want to create and save the student, am I obliged to
> > > first hit the database to get the school object and then pass it to
> > > student(school=school_object) or is there a way to just use the ID
> > > as it is?
> >
> > in the database django stores this as school_id - and when you save
> > you can use that by specificaly setting school_id on the save instead
> > of school where django will automatically get and insert the id
> >
> > --
> >
> > regards
> > kg
> > http://lawgon.livejournal.com
> > http://nrcfosshelpline.in/web/
> >
> >
> >
> > > >
> >
>

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en

looking for a django contractor (Chicago area)

2007-01-31 Thread Kumar McMillan

Dear Djangoists,

the company I work for is looking for a new contractor to work on a
"phase 2" of a django app now in production.  You are the captain of
the ship but will be working alongside a team of pythonists and
rubyists, a handful of whom will be available to conduct code reviews.
_

Company: Leapfrog Online
Location: Evanston, IL (Chicago)
Budget: $75 - $135 / hour
Time frame: Immediate need. 1 to 3 month contract.

Description
We have immediate need for a Python/Django programmer to help develop
and maintain a new public-facing web application (first generation
already in production). This is a 40-hour/week contract commitment,
working on-site in our Evanston office with our project manager, DBA,
sys admin, design shop and business stakeholders in an Agile, open
source environment. You must be demonstrably well-versed in Python
programming, database usage (PostgreSQL), unit testing and test-driven
development and Subversion. Demonstrable experience with the Django
web framework is a big plus. You don't need to have any web design
experience beyond the familiarity with HTML, CSS, Javascript and
graphics needed by any web-based application developer. We will only
consider contracting with a local developers who can work on-site for
this contract. Please send sample code, hourly rates and references.

To apply
Send email to [EMAIL PROTECTED] (you can CC me as well)


thanks for reading,
Kumar

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New Vim files for Django

2007-01-31 Thread Dave Hodder

On Jan 31, 4:34 pm, Andrew Diederich <[EMAIL PROTECTED]> wrote:
>
> Is the htmldjango.vim 1.05 version the right one to grab?  i.e. are
> they all supposed to do the same thing, and that one is the latest?

Hi Andrew,

You should download both htmldjango.vim 1.05 and django.vim 1.04 and
place them in your Vim syntax directory.  (Typically that's ~/.vim/
syntax under Unix, and C:\Program Files\Vim\vimfiles\syntax under
Windows.)  htmldjango.vim 1.05 requires django.vim 1.04 to work
properly.

Perhaps I need to sort out my version numbering to make it less
confusing!

The htmldjango.vim 0.1 file is for automatic indentation and not a
syntax file.  It's entirely optional.  You can place it in ~/.vim/
indent (or vimfiles\indent).  Try typing gg=G to see it in
action.  :o)

Regards,

Dave


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



fixing css issues

2007-01-31 Thread backdoc

I'm brand new to Django.  And, I was having a problem getting my CSS
working.  I searched the archives here and I saw lots of references
from people having the same problems with CSS and some debates on how
to go about making it work.  But, I never saw anyone spell out exactly
how they got it working.  So, here's my verbose run down of what I did
to get my css rendered.  If any of it is incorrect, I trust that
someone will correct me.

This is based upon the fact that I have Django installed at:
/usr/local/src/ and that I've already made it past the part of the
installation documentation that instructs you to symlink it to the
site-packages directory

There are 3 directories (css, js and img) that you want to Apache to
serve as static pages (without going through mod_python).  All 3
directories are in the following path:
/usr/local/src/django_src/django/contrib/admin/media/

Step 1.
I navigated to my DocumentRoot directory and ran:
ln -s /usr/local/src/django_src/django/contrib/admin/media/ media

Alternative to step 1, I saw someone in the archives suggested putting
the following in your  stanza:
alias /media /usr/local/src/django_src/django/contrib/admin/media/

Step 2.
chown -R myApacheUser:myApacheUser /usr/local/src/django_src/django/
contrib/admin/media/
note: I never saw someone say it was OK to do this, but I had to to
make mine work.

Step 3.
add this to my  for this site:

 SetHandler None


Step 4.
retstart Apache
/etc/init.d/apache2 restart


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: fundamental issues with configuring Apache and mod_python

2007-01-31 Thread darren
Thanks  I took your configuration and was able to configure mine
accordingly.  I still don't completely understand it, but at least I can get
to the admin page and the poll page.  And, now I can finish the tutorial.  I
don't think that I have some permissions correct though because my pages
don't have any style.  So, I think I must need to open access to the Apache
user to wherever the style sheets are stored.

Here's the configuration that worked for me:


ServerName www.myDomain.com
ServerAlias myDomain.com *.myDomain.com
DocumentRoot /usr/local/www/myDomain.com/docroot
# # for django

SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE linkshare.settings
PythonDebug On
PythonPath "['/usr/local/www/myDomain.com/'] + sys.path"



For anyone searching the archives for this topic, the keys to my problem
were the following:

I moved the separate  directive into my  directory.
So, now the are combined.  This next part is a complete assumption.  But,
this is how it looks like to me.
The value for the  directive is appended to the DocumentRoot
directive to construct the path on the file system that you want Python to
handle.  So, I set mine to "/".
The "SetEnv DJANGO_SETTINGS_MODULE linkshare.settings" line is either
apparently relative to the path you add to the  directive, which
is appended to the the DocumentRoot, or it is appended to the PythonPath.

Thanks Alex


On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
> Hi!
>
> On Jan 31, 6:47 pm, "backdoc" <[EMAIL PROTECTED]> wrote:
> > I am trying to experiment with django.  And, I'm at a loss.  My
> > problem is that I just don't conceptually understand how to match up
> > where everything is supposed to go on the filesystem and how to
> > configure Apache and mod_python to be aware of it.
>
> Its not clear for me where the problem is (since you see /polls).
> Just for reference here is config of my site:
>
> 
>   ServerName alex.koval.kharkov.ua
>   ServerAdmin [EMAIL PROTECTED]
>   CustomLog /var/log/apache2/alex.koval.kharkov.ua-access_log combined
>   DocumentRoot /var/www/alex.koval.kharkov.ua/PersonalWebSite/htdocs
>   
> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> PythonPath "sys.path+['/var/www/alex.koval.kharkov.ua/
> PersonalWebSite/','
> /var/www/alex.koval.kharkov.ua/']"
> SetEnv DJANGO_SETTINGS_MODULE PersonalWebSite.settings
> SetEnv LANG en_EN
> SetEnv LC_ALL C
> PythonDebug Off
>   
>   
> SetHandler None
>   
>   Alias /static "/var/www/alex.koval.kharkov.ua/PersonalWebSite/
> htdocs/"
>   
> SetHandler None
>   
> 
>
> Source code of my site can be seen here:
> http://code.koval.kharkov.ua/browser/PersonalWebSite/trunk
>
>
>
> >
>

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Doug Van Horn

On Jan 30, 7:01 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> There's some conceptual thing I'm apparently just not getting. I
> attempted to follow Doug's advice and came up with:
>
> [snip]
>
> Which appears to do the exact same thing I was doing before.

I may have misled you with the ordering of things in my post.  I think
it would go more like this:

def process_request(self, request):
if (now - last_request) > 4 hours: # if the last request is over 4
hours old...
last_seen = last_request # then that's when I last saw this
session
   last_request = now # update the last_request variable on each
request

Thus you have, "If the last request was over 4 hours ago, then that's
when I last saw this session, therefore I should update this session's
'last_seen' variable to be that 4+ hour old last_request.  Next, I
should update the 'last_request' variable to now."

Please apply a liberal amount of sodium chloride to this as I haven't
done this in the past and I certainly haven't coded and tested it.
But, from the psuedo-code above, it reads correct, I think.  :-)


Doug Van Horn
http://www.maydigital.com/  |  http://www.limapapa.com/


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: E-mailing forms

2007-01-31 Thread Ramdas S
Make sure your settings.py file has this. Please fill accordingly

DEFAULT_FROM_EMAIL =
EMAIL_HOST =
EMAIL_PORT =
EMAIL_HOST_USER =
EMAIL_HOST_PASSWORD =

On 1/31/07, Mike <[EMAIL PROTECTED]> wrote:
>
>
> There's also a documentation section for this topic located here:
>
> Sending e-mail
> http://www.djangoproject.com/documentation/email/
>
>
> >
>

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread [EMAIL PROTECTED]

I think this MAY be working now and I think I even finally wrapped my
head around what's going on. So, in hopes of helping someone else some
day (or, alternately, someone pointing out any trouble spots
remaining), the last_visit middleware:

import datetime

class LastSeen (object):
def process_request(self, request):
now = datetime.datetime.now()
try:
last_request = request.session['last_request']
# don't update it too often, every 4 hours should be ok
if (now - last_request).seconds > (60 * 60 *4):
request.session['last_seen'] = last_request
request.session['last_request'] = now
except KeyError:
request.session['last_request']  =
datetime.datetime.now()
request.session['last_seen'] = datetime.datetime.now()
except TypeError:
request.session['last_request']  =
datetime.datetime.now()

And I'd like to thank Honza, Doug, and everyone else who tried so hard
to pound this simple thing through my thick skull.

On Jan 31, 8:42 am, "Honza Král" <[EMAIL PROTECTED]> wrote:
> On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > I know I'm dense, and I'm just not seeing this, but isn't that what
> > I'm doing?
>
> > now = datetime.datetime.now()
> > last_request = request.session['last_request']
>
> > if (now - last_request).seconds > (60 * 60 *4):
> > ...
>
> but this line:
>
> >  request.session['last_request'] = now
>
> is only executed when last_request is lder than 4 hours... hardly
> seems like always, does it?
>
>
>
>
>
> > On Jan 31, 7:47 am, "Honza Kr?l" <[EMAIL PROTECTED]> wrote:
> > > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > > > Ok, but if I update last_request at every request, then won't (now -
> > > > last_request) ALWAYS be more or less 0?
>
> > > not if you update it AFTER the comparison...
>
> > > > On Jan 31, 4:16 am, "Honza Kr?l" <[EMAIL PROTECTED]> wrote:
> > > > > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > > > > > There's some conceptual thing I'm apparently just not getting. I
> > > > > > attempted to follow Doug's advice and came up with:
>
> > > > > > class LastSeen (object):
> > > > > > """Middleware that adds various objects to thread local storage
> > > > > > from the request object."""
> > > > > > def process_request(self, request):
> > > > > > now = datetime.datetime.now()
> > > > > > try:
> > > > > > last_request = request.session['last_request']
> > > > > > # don't update it too often, every 4 hours should be ok
> > > > > >  if (now - last_request).seconds > (60 * 60 *4):
> > > > > > request.session['last_seen'] = last_request
> > > > > > request.session['last_request'] = now
>
> > > > > you have to update last request at every request, not only when its
> > > > > too old... if you do it like this it is EXACTLY what you did before
>
> > > > > > except KeyError:
> > > > > > request.session['last_request']  =
> > > > > > datetime.datetime.now()
> > > > > >  request.session['last_seen'] = datetime.datetime.now()
> > > > > > except TypeError:
> > > > > > request.session['last_request']  =
> > > > > > datetime.datetime.now()
> > > > > >  request.session['last_seen'] = datetime.datetime.now()
>
> > > > > > Which appears to do the exact same thing I was doing before.
>
> > > > > > On Jan 30, 1:07 pm, "Doug Van Horn" <[EMAIL PROTECTED]> wrote:
> > > > > > > On Jan 30, 11:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > > > > > wrote:
>
> > > > > > > > Well, if I were doing it by hand, every time they came to the 
> > > > > > > > site I
> > > > > > > > would set this_visit, and then set last_visit (or last_seen, or
> > > > > > > > whatever) to the previous value of this_visit, and I would only 
> > > > > > > > do it
> > > > > > > > once, when they first come to the site.
>
> > > > > > > The question, then, is how to determine "when they first come to 
> > > > > > > the
> > > > > > > site."
>
> > > > > > > Right now, you determine that by saying, "If the last_seen 
> > > > > > > variable is
> > > > > > > older than 4 hours, then this user was last seen right now."  Note
> > > > > > > that they may have clicked just a second ago, when the last_seen
> > > > > > > variable was 3:59:59 old.  Their next click will bump the 
> > > > > > > 'last_seen'
> > > > > > > variable.  Not what you want.
>
> > > > > > > You probably want to store the most recent request timestamp as 
> > > > > > > part
> > > > > > > of the session.  Something like:
>
> > > > > > > request.session['last_request'] = datetime.now()
>
> > > > > > > Then, you need to figure out when your 'last_seen' session 
> > > > > > > variable
> > > > > > > should be updated.  It might be something like:
>
> > > > > > > if (now - last_request) > (60 * 60 * 4):  # if the 

Re: E-mailing forms

2007-01-31 Thread Mike

There's also a documentation section for this topic located here:

Sending e-mail
http://www.djangoproject.com/documentation/email/


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: E-mailing forms

2007-01-31 Thread [EMAIL PROTECTED]

In the view, you need
from django.core import mail, validators

then something like
def save(self, message, from, to):
mail.send_mail("Email title, whatever that is",
   message,
   from,
   [to],
   fail_silently = False
)


The real key is mail.send_mail. Note that message needs to be the
message, whatever that is. Both message and from may be variables you
pass in. The 'To' field MUST be a list, even if it's only one person.
The above is just pseudo-code, and probably won't work, but like I
said, mail.send_mail is the key.

On Jan 31, 11:24 am, "ChelleBell" <[EMAIL PROTECTED]> wrote:
> I have made a form, that is up and running partially. What I am
> looking to do is this form will be a sign up for a camp, but what i
> was wondering is if there is a way that the form can be e-mailed to
> someone after a person has filled it out. I cannot find anywhere on
> the django site that tells me how to go about doing this. I don't
> really know a whole lot about django so if there is any possible way
> to explain it to someone who has no prior experience using django that
> would be a GREAT help! Thanks!


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: fundamental issues with configuring Apache and mod_python

2007-01-31 Thread [EMAIL PROTECTED]

Hi!

On Jan 31, 6:47 pm, "backdoc" <[EMAIL PROTECTED]> wrote:
> I am trying to experiment with django.  And, I'm at a loss.  My
> problem is that I just don't conceptually understand how to match up
> where everything is supposed to go on the filesystem and how to
> configure Apache and mod_python to be aware of it.

Its not clear for me where the problem is (since you see /polls).
Just for reference here is config of my site:


  ServerName alex.koval.kharkov.ua
  ServerAdmin [EMAIL PROTECTED]
  CustomLog /var/log/apache2/alex.koval.kharkov.ua-access_log combined
  DocumentRoot /var/www/alex.koval.kharkov.ua/PersonalWebSite/htdocs
  
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonPath "sys.path+['/var/www/alex.koval.kharkov.ua/
PersonalWebSite/','
/var/www/alex.koval.kharkov.ua/']"
SetEnv DJANGO_SETTINGS_MODULE PersonalWebSite.settings
SetEnv LANG en_EN
SetEnv LC_ALL C
PythonDebug Off
  
  
SetHandler None
  
  Alias /static "/var/www/alex.koval.kharkov.ua/PersonalWebSite/
htdocs/"
  
SetHandler None
  


Source code of my site can be seen here:
http://code.koval.kharkov.ua/browser/PersonalWebSite/trunk



--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



E-mailing forms

2007-01-31 Thread ChelleBell

I have made a form, that is up and running partially. What I am
looking to do is this form will be a sign up for a camp, but what i
was wondering is if there is a way that the form can be e-mailed to
someone after a person has filled it out. I cannot find anywhere on
the django site that tells me how to go about doing this. I don't
really know a whole lot about django so if there is any possible way
to explain it to someone who has no prior experience using django that
would be a GREAT help! Thanks!


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New Vim files for Django

2007-01-31 Thread Igor Guerrero
On 1/31/07, Andrew Diederich <[EMAIL PROTECTED]> wrote:

> Is the htmldjango.vim 1.05 version the right one to grab?  i.e. are
> they all supposed to do the same thing, and that one is the latest?
>

htmldjango.vim 
*0.1 *is for the indent

you should put it in ~/.vim/indent/
-- 
:::lxuser 391715:::
http://igordevlog.blogspot.com/

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



fundamental issues with configuring Apache and mod_python

2007-01-31 Thread backdoc

I am trying to experiment with django.  And, I'm at a loss.  My
problem is that I just don't conceptually understand how to match up
where everything is supposed to go on the filesystem and how to
configure Apache and mod_python to be aware of it.

I am running Apache2 on Ubuntu Edgy with mod_python 3.2.8.  And, I
have gotten my Django pages to render in a text based web browser
(with the builtin web server).

Here's a little information about what my file system looks like:

/usr/local/www/myDomain.com/docroot(where my HTML went before
Django  --  my DocumentRoot)
/usr/local/www/myDomain.com/linkshare   (where I put my Django project
files)
/usr/local/www/myDomain.com/linkshare/polls(where I put the polls
app I've created from the tutorial)
/usr/local/lib/python2.4/site-packages/django(where I installed
Django)

So, I am confused what I should use for the paths for some of the
directives (look for the 3 places I put "whatGoesHere" in the snippet
from apache2.conf below):


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE whatGoesHere.settings
PythonDebug On



DocumentRoot /usr/local/www/myDomain.com/docroot
ServerName www.myDomain.com
ServerAlias myDomain.com *. myDomain.com
PythonPath "['whatGoesHere'] + sys.path"


Do I need a DocumentRoot directive in my VirtualHost?

My urls.py file looks like the following.  I assume it's right because
http://localhost:8000/polls works in my text browser.  Although,
http://localhost:8000/ doesn't render.  I'm not sure how to get a
default view.
urlpatterns = patterns('',
(r'^polls/$', 'linkshare.polls.views.index'),
(r'^polls/(?P\d+)/$',
'linkshare.polls.views.detail'),
(r'^polls/(?P\d+)/results/$',
'linkshare.polls.views.results'),
(r'^polls/(?P\d+)/vote/$',
'linkshare.polls.views.vote'),
# Uncomment this for admin:
(r'^admin/', include('django.contrib.admin.urls')),


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IPython Shell does not see database changes made by views.

2007-01-31 Thread Michael Radziej

Ivan Sagalaev:
> Paul Childs wrote:
>> I wanted to do some checks through the shell, which I was opened
>> during my unit testing, and found that after making some queries using
>> Django objects there appeared to be no changes in the database. When I
>> checked the database using its admin tool the changes were there.
> 
> This sounds like caching in querysets.

If it's not that, then it might be that it's because you have an
open transaction in the python shell, and you see only data that had
been committed before the transaction started. You get around it
with a commit in the shell. I think we had that on this mailing list
before, so search a bit for more details.

Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100

http://www.noris.de - The IT-Outsourcing Company

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: New Vim files for Django

2007-01-31 Thread Andrew Diederich

On Sunday, January 28, 2007, 9:54:18 AM, Dave Hodder wrote:

> Updated syntax files for the Vim editor are available here:
>  http://www.vim.org/scripts/script.php?script_id=1487

Is the htmldjango.vim 1.05 version the right one to grab?  i.e. are
they all supposed to do the same thing, and that one is the latest?

-- 
Andrew Diederich


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: What user does django server runs?

2007-01-31 Thread HenrikG

Well, I solved my connection problems. It seems I had two versions of
PostgreSQL installed and I had created the database with one version
and was running the server with the other version. When I used the
"createdb" command for both versions, one of them said that the
database was corrupt. So I removed the database and recreated it with
the newest PostgreSQL and suddenly everything worked!

I had some problems getting PostgreSQL to work when I installed it, so
I tried several source codes and packages before it worked. That's
probably why I had two different versions.


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Independent sql-evolution module

2007-01-31 Thread tonich

Sorry for the duplication


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django & eclipse step-by-step (python 2.5) ?

2007-01-31 Thread Steven Armstrong

Bram - Smartelectronix wrote:
> hey everyone,
> 
> 
> ( I hope you saw the question mark at the end of the subject ;-) )
> 
> working in eclipse, it would be so wonderful to get auto completion and 
> all those other goodies working. Auto completion works just fine for 
> everything django (i.e. django.*) but no matter what I try there's no 
> auto completion inside the project/app.
> 
> Does anyone have a nice step-by-step guide to get this up and running? I 
> seem to see this question asked a lot of times all over the web, but not 
> one real, concise answer.
> 
> 
> thanks a lot for any pointers,
> 
> 
>   - bram
> 

You have to add the source folder of your project/apps to the pydev 
projects PYTHONPATH. That should do the trick.

hth
Steven

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: IPython Shell does not see database changes made by views.

2007-01-31 Thread Ivan Sagalaev

Paul Childs wrote:
> I wanted to do some checks through the shell, which I was opened
> during my unit testing, and found that after making some queries using
> Django objects there appeared to be no changes in the database. When I
> checked the database using its admin tool the changes were there.

This sounds like caching in querysets. When you do things like this:

 objects = Model.objects.all()
 for obj in objects:
   print obj

The 'objects' once evaluated don't look into database again, it keeps 
the result itself. To query database again just create a new queryset 
from the Model's manager:

 objects = Model.objects.all()

I.e. each 'Model.objects.something...' will create a fresh queryset that 
will query database again.

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



IPython Shell does not see database changes made by views.

2007-01-31 Thread Paul Childs

During unit testing I made changes to data in the database through my
Django app.

I wanted to do some checks through the shell, which I was opened
during my unit testing, and found that after making some queries using
Django objects there appeared to be no changes in the database. When I
checked the database using its admin tool the changes were there.

To yield the expected results I had to exit from the shell and restart
it. I then executed my queries using Django objects and all the
changes were there.

Does anyone know how to "refresh" or better yet "auto refresh" the
shell so I don't have to shut down and restart it every time I make a
change to data outside of it.

I'm using IPython 0.7.2 , MySQL 5.0.27, and a dev version of Django
from a couple of weeks ago.

Thanks in advance,
/Paul


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Multilingual content - status update

2007-01-31 Thread [EMAIL PROTECTED]

Hi,

the library is getting very close to being actually usable in real
projects.

There were several changes in the last few days.  It is now possible
to:

1. use language codes in methods that until now accepted only language
   IDs;

2. create query sets with default language set, so that the following
   tests pass:

   >>> c_en = Category.objects.all().for_language('en')
   >>> c_pl = Category.objects.all().for_language('pl')
   >>> c_en.get(name__contains='1').name
   'category 1'
   >>> c_pl.get(name__contains='1').name
   'kategoria 1'

   >>> [c.name for c in  c_en.order_by('name')]
   ['category 2', 'category 1']
   >>> [c.name for c in c_pl.order_by('-name')]
   ['kategoria 2', 'kategoria 1']

   Objects created using such a queryset also have a default language
   set:

   >>> c = c_en.get(id=1)
   >>> c.name = 'test'
   >>> (c.name, c.name_en, c.name_pl)
   ('test', 'test', 'kategoria 1')

   >>> c = c_pl.get(id=1)
   >>> c.name = 'test'
   >>> (c.name, c.name_en, c.name_pl)
   ('test', 'category 1', 'test')

3. order the admin list view according to the value of translatable
   column; this requires a small and generic patch to Django, see
   http://code.djangoproject.com/ticket/3397

   You can still use the library without any changes to Django source,
   the only difference will be that translatable columns will not be
   sortable.  I hope the patch will be included, though, because there
   are more use cases for the patch than django-multilingual :)

4. use the translatable fields to create filters spanning multiple
   tables, like `somemodel.filter(category__name__contains='2')`,

5. assign directly to translatable fields in different language
   versions.  These two have the same effect:

   c.set_name('category name', 'en')
   c.name_en = 'category name'

The last big piece missing is a better inline editor for translated
content.  Right now it is still a hack that works correctly mostly for
instances created by the admin interface.  I hope to have this working
soon.

-mk


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Independent sql-evolution module

2007-01-31 Thread tonich

http://groups.google.com/group/django-users/web/sqlev.tar.bz2

This module provides sql evolution for django models. It is based on
the
sql-evoluition branch.
To be used do NOT NEED TO MAKE CHANGES IN DJANGO SOURCE CODE!!!  Just
extract files into your project directory, copy sqlev_manage.py file
from sqlev directory to one level up, change your model and run
# ./sqlev_manage.py sqlev 

./sqlev_manage.py is modified standard manage.py file. it adds "sqlev"
command and replaces "inspectdb" command. Other commands still works
as
it's originals.

Limitations: support only MySQL database.

Module is not well tested and still have ugly design, inherited from
the
sql-evolution branch. But it works for me.


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Honza Král
On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I know I'm dense, and I'm just not seeing this, but isn't that what
> I'm doing?
>
> now = datetime.datetime.now()
> last_request = request.session['last_request']
>
> if (now - last_request).seconds > (60 * 60 *4):
> ...

but this line:
>  request.session['last_request'] = now

is only executed when last_request is lder than 4 hours... hardly
seems like always, does it?

>
>
>
> On Jan 31, 7:47 am, "Honza Kr�l" <[EMAIL PROTECTED]> wrote:
> > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > Ok, but if I update last_request at every request, then won't (now -
> > > last_request) ALWAYS be more or less 0?
> >
> > not if you update it AFTER the comparison...
> >
> >
> >
> >
> >
> > > On Jan 31, 4:16 am, "Honza Kr?l" <[EMAIL PROTECTED]> wrote:
> > > > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> > > > > There's some conceptual thing I'm apparently just not getting. I
> > > > > attempted to follow Doug's advice and came up with:
> >
> > > > > class LastSeen (object):
> > > > > """Middleware that adds various objects to thread local storage
> > > > > from the request object."""
> > > > > def process_request(self, request):
> > > > > now = datetime.datetime.now()
> > > > > try:
> > > > > last_request = request.session['last_request']
> > > > > # don't update it too often, every 4 hours should be ok
> > > > >  if (now - last_request).seconds > (60 * 60 *4):
> > > > > request.session['last_seen'] = last_request
> > > > > request.session['last_request'] = now
> >
> > > > you have to update last request at every request, not only when its
> > > > too old... if you do it like this it is EXACTLY what you did before
> >
> > > > > except KeyError:
> > > > > request.session['last_request']  =
> > > > > datetime.datetime.now()
> > > > >  request.session['last_seen'] = datetime.datetime.now()
> > > > > except TypeError:
> > > > > request.session['last_request']  =
> > > > > datetime.datetime.now()
> > > > >  request.session['last_seen'] = datetime.datetime.now()
> >
> > > > > Which appears to do the exact same thing I was doing before.
> >
> > > > > On Jan 30, 1:07 pm, "Doug Van Horn" <[EMAIL PROTECTED]> wrote:
> > > > > > On Jan 30, 11:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > > > > wrote:
> >
> > > > > > > Well, if I were doing it by hand, every time they came to the 
> > > > > > > site I
> > > > > > > would set this_visit, and then set last_visit (or last_seen, or
> > > > > > > whatever) to the previous value of this_visit, and I would only 
> > > > > > > do it
> > > > > > > once, when they first come to the site.
> >
> > > > > > The question, then, is how to determine "when they first come to the
> > > > > > site."
> >
> > > > > > Right now, you determine that by saying, "If the last_seen variable 
> > > > > > is
> > > > > > older than 4 hours, then this user was last seen right now."  Note
> > > > > > that they may have clicked just a second ago, when the last_seen
> > > > > > variable was 3:59:59 old.  Their next click will bump the 
> > > > > > 'last_seen'
> > > > > > variable.  Not what you want.
> >
> > > > > > You probably want to store the most recent request timestamp as part
> > > > > > of the session.  Something like:
> >
> > > > > > request.session['last_request'] = datetime.now()
> >
> > > > > > Then, you need to figure out when your 'last_seen' session variable
> > > > > > should be updated.  It might be something like:
> >
> > > > > > if (now - last_request) > (60 * 60 * 4):  # if the last request is 
> > > > > > 4+
> > > > > > hours old...
> > > > > > request.session['last_seen'] = last_request
> >
> > > > > > Handle your base case, where there is no 'last_request' (and thus no
> > > > > > last_seen), and you should be good.
> >
> > > > > > Hope that helps.
> >
> > > > > > And remember the advice listed by an earlier post-er.  Design your
> > > > > > algorithm on paper.  Think it through.  Write some psuedo code.  Run
> > > > > > some mental 'unit tests'.  Then go code it.
> >
> > > > > > Regards,
> >
> > > > > > Doug Van Horn, Presidenthttp://www.maydigital.com/~~ 
> > > > > > http://www.limapapa.com/
> >
> > > > --
> > > > Honza Kr?l
> > > > E-Mail: [EMAIL PROTECTED]
> > > > ICQ#:   107471613
> > > > Phone:  +420 606 678585
> >
> > --
> > Honza Kr?l
> > E-Mail: [EMAIL PROTECTED]
> > ICQ#:   107471613
> > Phone:  +420 606 678585
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For 

Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread [EMAIL PROTECTED]

I know I'm dense, and I'm just not seeing this, but isn't that what
I'm doing?

now = datetime.datetime.now()
last_request = request.session['last_request']

if (now - last_request).seconds > (60 * 60 *4):
...
 request.session['last_request'] = now



On Jan 31, 7:47 am, "Honza Král" <[EMAIL PROTECTED]> wrote:
> On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > Ok, but if I update last_request at every request, then won't (now -
> > last_request) ALWAYS be more or less 0?
>
> not if you update it AFTER the comparison...
>
>
>
>
>
> > On Jan 31, 4:16 am, "Honza Kr?l" <[EMAIL PROTECTED]> wrote:
> > > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > > > There's some conceptual thing I'm apparently just not getting. I
> > > > attempted to follow Doug's advice and came up with:
>
> > > > class LastSeen (object):
> > > > """Middleware that adds various objects to thread local storage
> > > > from the request object."""
> > > > def process_request(self, request):
> > > > now = datetime.datetime.now()
> > > > try:
> > > > last_request = request.session['last_request']
> > > > # don't update it too often, every 4 hours should be ok
> > > >  if (now - last_request).seconds > (60 * 60 *4):
> > > > request.session['last_seen'] = last_request
> > > > request.session['last_request'] = now
>
> > > you have to update last request at every request, not only when its
> > > too old... if you do it like this it is EXACTLY what you did before
>
> > > > except KeyError:
> > > > request.session['last_request']  =
> > > > datetime.datetime.now()
> > > >  request.session['last_seen'] = datetime.datetime.now()
> > > > except TypeError:
> > > > request.session['last_request']  =
> > > > datetime.datetime.now()
> > > >  request.session['last_seen'] = datetime.datetime.now()
>
> > > > Which appears to do the exact same thing I was doing before.
>
> > > > On Jan 30, 1:07 pm, "Doug Van Horn" <[EMAIL PROTECTED]> wrote:
> > > > > On Jan 30, 11:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > > > wrote:
>
> > > > > > Well, if I were doing it by hand, every time they came to the site I
> > > > > > would set this_visit, and then set last_visit (or last_seen, or
> > > > > > whatever) to the previous value of this_visit, and I would only do 
> > > > > > it
> > > > > > once, when they first come to the site.
>
> > > > > The question, then, is how to determine "when they first come to the
> > > > > site."
>
> > > > > Right now, you determine that by saying, "If the last_seen variable is
> > > > > older than 4 hours, then this user was last seen right now."  Note
> > > > > that they may have clicked just a second ago, when the last_seen
> > > > > variable was 3:59:59 old.  Their next click will bump the 'last_seen'
> > > > > variable.  Not what you want.
>
> > > > > You probably want to store the most recent request timestamp as part
> > > > > of the session.  Something like:
>
> > > > > request.session['last_request'] = datetime.now()
>
> > > > > Then, you need to figure out when your 'last_seen' session variable
> > > > > should be updated.  It might be something like:
>
> > > > > if (now - last_request) > (60 * 60 * 4):  # if the last request is 4+
> > > > > hours old...
> > > > > request.session['last_seen'] = last_request
>
> > > > > Handle your base case, where there is no 'last_request' (and thus no
> > > > > last_seen), and you should be good.
>
> > > > > Hope that helps.
>
> > > > > And remember the advice listed by an earlier post-er.  Design your
> > > > > algorithm on paper.  Think it through.  Write some psuedo code.  Run
> > > > > some mental 'unit tests'.  Then go code it.
>
> > > > > Regards,
>
> > > > > Doug Van Horn, Presidenthttp://www.maydigital.com/~~ 
> > > > > http://www.limapapa.com/
>
> > > --
> > > Honza Kr?l
> > > E-Mail: [EMAIL PROTECTED]
> > > ICQ#:   107471613
> > > Phone:  +420 606 678585
>
> --
> Honza Kr?l
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Honza Král
On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Ok, but if I update last_request at every request, then won't (now -
> last_request) ALWAYS be more or less 0?

not if you update it AFTER the comparison...

>
>
> On Jan 31, 4:16 am, "Honza Kr�l" <[EMAIL PROTECTED]> wrote:
> > On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> > > There's some conceptual thing I'm apparently just not getting. I
> > > attempted to follow Doug's advice and came up with:
> >
> > > class LastSeen (object):
> > > """Middleware that adds various objects to thread local storage
> > > from the request object."""
> > > def process_request(self, request):
> > > now = datetime.datetime.now()
> > > try:
> > > last_request = request.session['last_request']
> > > # don't update it too often, every 4 hours should be ok
> > >  if (now - last_request).seconds > (60 * 60 *4):
> > > request.session['last_seen'] = last_request
> > > request.session['last_request'] = now
> >
> > you have to update last request at every request, not only when its
> > too old... if you do it like this it is EXACTLY what you did before
> >
> >
> >
> > > except KeyError:
> > > request.session['last_request']  =
> > > datetime.datetime.now()
> > >  request.session['last_seen'] = datetime.datetime.now()
> > > except TypeError:
> > > request.session['last_request']  =
> > > datetime.datetime.now()
> > >  request.session['last_seen'] = datetime.datetime.now()
> >
> > > Which appears to do the exact same thing I was doing before.
> >
> > > On Jan 30, 1:07 pm, "Doug Van Horn" <[EMAIL PROTECTED]> wrote:
> > > > On Jan 30, 11:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > > wrote:
> >
> > > > > Well, if I were doing it by hand, every time they came to the site I
> > > > > would set this_visit, and then set last_visit (or last_seen, or
> > > > > whatever) to the previous value of this_visit, and I would only do it
> > > > > once, when they first come to the site.
> >
> > > > The question, then, is how to determine "when they first come to the
> > > > site."
> >
> > > > Right now, you determine that by saying, "If the last_seen variable is
> > > > older than 4 hours, then this user was last seen right now."  Note
> > > > that they may have clicked just a second ago, when the last_seen
> > > > variable was 3:59:59 old.  Their next click will bump the 'last_seen'
> > > > variable.  Not what you want.
> >
> > > > You probably want to store the most recent request timestamp as part
> > > > of the session.  Something like:
> >
> > > > request.session['last_request'] = datetime.now()
> >
> > > > Then, you need to figure out when your 'last_seen' session variable
> > > > should be updated.  It might be something like:
> >
> > > > if (now - last_request) > (60 * 60 * 4):  # if the last request is 4+
> > > > hours old...
> > > > request.session['last_seen'] = last_request
> >
> > > > Handle your base case, where there is no 'last_request' (and thus no
> > > > last_seen), and you should be good.
> >
> > > > Hope that helps.
> >
> > > > And remember the advice listed by an earlier post-er.  Design your
> > > > algorithm on paper.  Think it through.  Write some psuedo code.  Run
> > > > some mental 'unit tests'.  Then go code it.
> >
> > > > Regards,
> >
> > > > Doug Van Horn, Presidenthttp://www.maydigital.com/~~  
> > > > http://www.limapapa.com/
> >
> > --
> > Honza Kr?l
> > E-Mail: [EMAIL PROTECTED]
> > ICQ#:   107471613
> > Phone:  +420 606 678585
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread [EMAIL PROTECTED]

Ok, but if I update last_request at every request, then won't (now -
last_request) ALWAYS be more or less 0?


On Jan 31, 4:16 am, "Honza Král" <[EMAIL PROTECTED]> wrote:
> On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
>
>
> > There's some conceptual thing I'm apparently just not getting. I
> > attempted to follow Doug's advice and came up with:
>
> > class LastSeen (object):
> > """Middleware that adds various objects to thread local storage
> > from the request object."""
> > def process_request(self, request):
> > now = datetime.datetime.now()
> > try:
> > last_request = request.session['last_request']
> > # don't update it too often, every 4 hours should be ok
> >  if (now - last_request).seconds > (60 * 60 *4):
> > request.session['last_seen'] = last_request
> > request.session['last_request'] = now
>
> you have to update last request at every request, not only when its
> too old... if you do it like this it is EXACTLY what you did before
>
>
>
> > except KeyError:
> > request.session['last_request']  =
> > datetime.datetime.now()
> >  request.session['last_seen'] = datetime.datetime.now()
> > except TypeError:
> > request.session['last_request']  =
> > datetime.datetime.now()
> >  request.session['last_seen'] = datetime.datetime.now()
>
> > Which appears to do the exact same thing I was doing before.
>
> > On Jan 30, 1:07 pm, "Doug Van Horn" <[EMAIL PROTECTED]> wrote:
> > > On Jan 30, 11:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > wrote:
>
> > > > Well, if I were doing it by hand, every time they came to the site I
> > > > would set this_visit, and then set last_visit (or last_seen, or
> > > > whatever) to the previous value of this_visit, and I would only do it
> > > > once, when they first come to the site.
>
> > > The question, then, is how to determine "when they first come to the
> > > site."
>
> > > Right now, you determine that by saying, "If the last_seen variable is
> > > older than 4 hours, then this user was last seen right now."  Note
> > > that they may have clicked just a second ago, when the last_seen
> > > variable was 3:59:59 old.  Their next click will bump the 'last_seen'
> > > variable.  Not what you want.
>
> > > You probably want to store the most recent request timestamp as part
> > > of the session.  Something like:
>
> > > request.session['last_request'] = datetime.now()
>
> > > Then, you need to figure out when your 'last_seen' session variable
> > > should be updated.  It might be something like:
>
> > > if (now - last_request) > (60 * 60 * 4):  # if the last request is 4+
> > > hours old...
> > > request.session['last_seen'] = last_request
>
> > > Handle your base case, where there is no 'last_request' (and thus no
> > > last_seen), and you should be good.
>
> > > Hope that helps.
>
> > > And remember the advice listed by an earlier post-er.  Design your
> > > algorithm on paper.  Think it through.  Write some psuedo code.  Run
> > > some mental 'unit tests'.  Then go code it.
>
> > > Regards,
>
> > > Doug Van Horn, Presidenthttp://www.maydigital.com/~~  
> > > http://www.limapapa.com/
>
> --
> Honza Kr?l
> E-Mail: [EMAIL PROTECTED]
> ICQ#:   107471613
> Phone:  +420 606 678585


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django uploading framework vs tramline

2007-01-31 Thread [EMAIL PROTECTED]

Tramline would be the best choice unless the #2070 patch is applied

On 31 Jan, 05:00, "Chatchai Neanudorn" <[EMAIL PROTECTED]> wrote:
> Hi
>   Are there comparing performance of uploading between django itseft and
> tramlime. What is the best way, installation and proformace are subject of
> comparing.
>
> Thank
> Chatchai


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms, foreignKeys & constraints

2007-01-31 Thread ak

Sorry, this:

On Jan 31, 3:24 pm, "ak" <[EMAIL PROTECTED]> wrote:
> FormClass.base_fields['foreign_key_field'].widget = 
> forms.ChoiceField(choices=[(obj.id, obj.name) for obj in

must be:
FormClass.base_fields['foreign_key_field'] =
forms.ChoiceField(choices=[(obj.id, obj.name) for obj in
MyModel.objects.filter(...)])


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: subclassing a Field

2007-01-31 Thread [EMAIL PROTECTED]

You cannot add custom database field types without altering the db
backend code.


On 31 Jan, 09:58, Antonio <[EMAIL PROTECTED]> wrote:
> hi all,
>
> I've created a TYPE in PostgreSQL :
>
> Composite type "utente.datirim"
> Column|  Type
> -+
> nome| text
> turno   | time without time zone
> comandante  | text
> disormeggio | time without time zone
> arrivo  | time without time zone
> fine| time without time zone
> inizio  | time without time zone
> attracco| time without time zone
>
> I'm trying to create a new Field in Django to map a database table into a
> model ... I've tryied to subclass Field, but I've got errors when I 'syncdb'.
>
> There's a tutorial about this procedure ?? It's possible ??
>
> tanks in advance ..
>
> PS sorry for my english ...
>
> --
> #include 
> int main(void){char 
> c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
> 101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
> 116,46,105,116,62,10,10,0};printf("%s",c);return 0;}


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: newforms, foreignKeys & constraints

2007-01-31 Thread ak

You can create your own ChoiceField with your own set of choices and
replace default property to your own
For example:

FormClass = forms.models.form_for_model(MyModel)
FormClass.base_fields['foreign_key_field'].widget =
forms.ChoiceField(choices=[(obj.id, obj.name) for obj in
MyModel.objects.filter(...)])

something like this


--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Help with Last Seen (why doesn't this work???)

2007-01-31 Thread Honza Král
On 1/31/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> There's some conceptual thing I'm apparently just not getting. I
> attempted to follow Doug's advice and came up with:
>
> class LastSeen (object):
> """Middleware that adds various objects to thread local storage
> from the request object."""
> def process_request(self, request):
> now = datetime.datetime.now()
> try:
> last_request = request.session['last_request']
> # don't update it too often, every 4 hours should be ok
>  if (now - last_request).seconds > (60 * 60 *4):
> request.session['last_seen'] = last_request
> request.session['last_request'] = now

you have to update last request at every request, not only when its
too old... if you do it like this it is EXACTLY what you did before

> except KeyError:
> request.session['last_request']  =
> datetime.datetime.now()
>  request.session['last_seen'] = datetime.datetime.now()
> except TypeError:
> request.session['last_request']  =
> datetime.datetime.now()
>  request.session['last_seen'] = datetime.datetime.now()
>
>
> Which appears to do the exact same thing I was doing before.
>
>
>
> On Jan 30, 1:07 pm, "Doug Van Horn" <[EMAIL PROTECTED]> wrote:
> > On Jan 30, 11:23 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
> >
> > > Well, if I were doing it by hand, every time they came to the site I
> > > would set this_visit, and then set last_visit (or last_seen, or
> > > whatever) to the previous value of this_visit, and I would only do it
> > > once, when they first come to the site.
> >
> > The question, then, is how to determine "when they first come to the
> > site."
> >
> > Right now, you determine that by saying, "If the last_seen variable is
> > older than 4 hours, then this user was last seen right now."  Note
> > that they may have clicked just a second ago, when the last_seen
> > variable was 3:59:59 old.  Their next click will bump the 'last_seen'
> > variable.  Not what you want.
> >
> > You probably want to store the most recent request timestamp as part
> > of the session.  Something like:
> >
> > request.session['last_request'] = datetime.now()
> >
> > Then, you need to figure out when your 'last_seen' session variable
> > should be updated.  It might be something like:
> >
> > if (now - last_request) > (60 * 60 * 4):  # if the last request is 4+
> > hours old...
> > request.session['last_seen'] = last_request
> >
> > Handle your base case, where there is no 'last_request' (and thus no
> > last_seen), and you should be good.
> >
> > Hope that helps.
> >
> > And remember the advice listed by an earlier post-er.  Design your
> > algorithm on paper.  Think it through.  Write some psuedo code.  Run
> > some mental 'unit tests'.  Then go code it.
> >
> > Regards,
> >
> > Doug Van Horn, Presidenthttp://www.maydigital.com/ ~~  
> > http://www.limapapa.com/
>
>
> >
>


-- 
Honza Kr�l
E-Mail: [EMAIL PROTECTED]
ICQ#:   107471613
Phone:  +420 606 678585

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



subclassing a Field

2007-01-31 Thread Antonio

hi all,

I've created a TYPE in PostgreSQL :

Composite type "utente.datirim"
Column|  Type
-+
nome| text
turno   | time without time zone
comandante  | text
disormeggio | time without time zone
arrivo  | time without time zone
fine| time without time zone
inizio  | time without time zone
attracco| time without time zone

I'm trying to create a new Field in Django to map a database table into a
model ... I've tryied to subclass Field, but I've got errors when I 'syncdb'.

There's a tutorial about this procedure ?? It's possible ??

tanks in advance ..

PS sorry for my english ...

-- 
#include 
int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
116,46,105,116,62,10,10,0};printf("%s",c);return 0;}

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



possible bug when editing an object: foreign key "_id" part gone

2007-01-31 Thread Benedict Verheyen

Hi,

i think i might have encountered a possible bug but i'm not sure though.
Editing an object and leaving a mandatory field empty results in the
form "forgetting" the foreign keys. It doesn't actually forget but it ommits the
"_id" part and thus the values are not displayed on the form.
The first time you edit, it works.

I encountered it using this scenario:
1. Edit object
2. Delete/blank a mandatory field
3. Save the object
4. You get an error complaining that the field is mandatory
   Note that the foreign key fields are now blank

For instance, in my case i have a form with 2 foreign keys. The first
time i edit,
they are called room_id and doctor_id in manipulator.form.__dict__
When i delete the mandatory field and save, manipulator.form.__dict__
contains room and doctor instead of room_id and doctor_id and thus they
don't set the foreignkeys anymore on the field and the foreign key
fields are left
blank.

Is anyone else able to reproduce it?
How can we work around it?

I think i'm on version 0.96 (rev 4067)

Thanks,
Benedict

--~--~-~--~~~---~--~~
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 this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---