Re: form elements css changes on errors

2009-05-04 Thread George Song

On 5/4/2009 10:23 AM, joeygartin wrote:
> I would like to add a css class to form elements if there is an error
> in the form.  Not sure the BEST/EASIEST way to do this.  I would only
> want the attribute added if there was an error and I would like to do
> this in the cleanest way possible.  Meaning I would LIKE to stay away
> from if statements for every form element I have in the HTML and
> rather put the proper code in Python (perhaps forms.py with the form
> declaration), but I am new and not exactly sure how to proceed.

Once you've determined that your form didn't validate, something like 
this should work:

{{{
for field_name in form.errors:
 form.fields[field_name].widget.attrs['class'] = 'error'
}}}

Then just output your form again.

-- 
George

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Adding RSS Feed to planet Django

2009-05-04 Thread Kai Diefenbach

Hi guys,

(sorry, if this is the wrong place, I've sent already two emails to
the provided address in the last couple of weeks without feedback)

is somebody out there, who is able to adding an RSS-Feed to
http://www.djangoproject.com/community/.

The URL of the feed is:

http://www.getlfs.com/feeds/django

Thanks
Kai
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



application profiling

2009-05-04 Thread Vance Dubberly

Having a hard time trying to figure out how to profile a django
application. Doesn't seem to be anything built into django itself that
knows how to report on time spent in methods or sql queries or any
such thing. Please tell me I'm delusional. Pretty Please?

-- 
To pretend, I actually do the thing: I have therefore only pretended to pretend.
  - Jacques Derrida

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ManyToMany with a "through" attribute in the admin profile

2009-05-04 Thread nbv4



On May 4, 12:03 am, George Song  wrote:
> On 5/3/2009 8:17 PM, nbv4 wrote:
>
>
>
> > On May 3, 3:51 pm, Ramiro Morales  wrote:
> >> On Sun, May 3, 2009 at 4:26 PM, nbv4  wrote:
>
> >>> Everything is fine and dandy, except for when I want to use the admin
> >>> interface to create a new route. All I see is a dropdown for the
> >>> "often" field. I have to go to the RouteBase section of the admin to
> >>> add the rest. Normally if there is a ManyToMany field, in the admin
> >>> interface there will be a little green plus sign that you can use to
> >>> create a new object to attach. If the "through" option is used, it
> >>> doesn't show up. Why? Is there a way to change this behavior? Is this
> >>> a bug or is there a reason for this?
> >> See
>
> >>http://docs.djangoproject.com/en/dev/ref/contrib/admin/#working-with-...
>
> > Gee whiz thanks a lot.
>
> > I've got one more problem. How do I access the information from within
> > that intermediate class?
>
> > I can do:
> > --
> > r = Route.objects.get(pk=1)
> > r.bases.all()
> > 
>
> > and r will be a list of all bases. From within that Route object (r),
> > is there anyway to get access to the RouteBase attributes? Something
> > like r.sequence?
>
> The intermediate class is no different than any other many-to-one
> related classes:
> 
>


It's not possible to get those attributes unless I make another query?
Basically I have one object that has a TON of related fields, some
ForeignKey, some ManyToMany. Is it possible to pass just one instance
of that one object to a Template and have access to the whole shebang
through that one object? The link you gave me suggests that, but it
just doesn't seem right...
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages only works when settings.DEBUG = True

2009-05-04 Thread Ronghui Yu
Yes, 404.html and 500.html are there. But they extend from base.html, which
depends on some context variables. I will change them to a simple one and
see if the problem still there.Thanks

On Tue, May 5, 2009 at 12:06 AM, Brian Neal  wrote:

>
> On May 4, 10:28 am, Ronghui Yu  wrote:
> > Hi,All,
> >
> > I am going to use Flatpages app for those simple pages. And everything
> > works fine when settings.DEBUG is True, but when it is turned to False,
> > a URL not configured in urlpatterns will trigger 500, not 404.
>
> Do you have a 404.html error template? You need to have that before
> flatpages will work when DEBUG is False. See the note titled "Ensure
> that your 404 template works" in this section:
>
>
> http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/#module-django.contrib.flatpages
>
> Its also a good idea to have a 500.html error template.
>
> Best,
> BN
>
>
> >
>


-- 
===
Regards
Ronghui Yu

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages only works when settings.DEBUG = True

2009-05-04 Thread Ronghui Yu
That's something I didn't try. It is a good idea to figure out what the
problem is.Thanks

On Tue, May 5, 2009 at 12:01 AM, Masklinn  wrote:

>
> On 4 May 2009, at 17:28 , Ronghui Yu wrote:
> > I don't quite understand why this happens, and how to solve it.
> > Has anybody ever met this problem? And any suggestions?
> >
> > Thanks in advance.
> >
> Setup a local smtp sink and activate the "mail on 500" thing, to see
> why it's erroring out?
>
> >
>


-- 
===
Regards
Ronghui Yu

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: tinymce not displaying on admin template

2009-05-04 Thread Zain Memon
Your TINYMCE_JS_URL is .../site_media/js/tiny_mce/tiny_mce.js while the file
apparently is at .../site_media/tiny_mce/tiny_mce.js.
Zain

On Mon, May 4, 2009 at 9:59 AM, Jesse  wrote:

>
> Hello,
>
> I'm trying to implement django-cms.  The CMS pages in admin display,
> but not with the editing someone without html knowledge will be able
> to use.  I see no tinymce options. I've placed tinymce in several
> places hoping somehow it would display where I need it.
>
> Using this statement in a firefox browser:
> http://127.0.0.1:8000/site_media/tiny_mce/tiny_mce.js
>
> I see this displayed:
> var tinymce=
>
> {majorVersion:"3",minorVersion:"2.3",releaseDate:"2009-04-23",_init:function
> (){var o=this,k=document, etc.
>
> My setting.py file:
> MEDIA_ROOT = 'c:/django/myprograms/site_media/'
> MEDIA_URL = 'http://127.0.0.1:8000/site_media/'
>
> TINYMCE_JS_URL = 'http://127.0.0.1:8000/site_media/js/tiny_mce/
> tiny_mce.js'
> TINYMCE_JS_ROOT = 'c:/django/myprograms/site_media/js/tiny_mce'
> TINYMCE_DEFAULT_CONFIG = {
>'plugins': "table,spellchecker,paste,searchreplace",
>'theme': "advanced",
>'cleanup_on_startup': True,
>'custom_undo_redo_levels': 10,
> }
>
> TINYMCE_SPELLCHECKER = False
> TINYMCE_COMPRESSOR = False
> TINYMCE_FILEBROWSER = True
>
> CMS_USE_TINYMCE = True
>
> INSTALLED_APPS = (
>'cms',
>'tinymce',
>'filebrowser',
> )
>
> I''ve not found any download files with the uppercase TinyMce, but
> only tinymce
> or tiny_mce.
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with cookie on development server

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 15:47 -0700, Andrew Se. Fefelov wrote:
> Hello guys!
> 
> I'v got such problem with development server. I run any app on my dev
> server and it is stuck on Set Cookie response:

Define "stuck". What happens?

The request and response headers you posted look reasonable to me, so a
bit more information is required here.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with cookie on development server

2009-05-04 Thread Andrew Se. Fefelov

Hello guys!

I'v got such problem with development server. I run any app on my dev
server and it is stuck on Set Cookie response:

GET / HTTP/1.0
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/vnd.ms-excel, application/msword, application/vnd.ms-
powerpoint, */*
Accept-Language: en-us
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0
Host: 127.0.0.1

HTTP/1.0 301 MOVED PERMANENTLY
Date: Mon, 04 May 2009 21:05:01 GMT
Server: WSGIServer/0.1 Python/2.5.4
Vary: Accept-Language, Cookie
Content-Type: text/html; charset=utf-8
Location: http://127.0.0.1/about/
Content-Language: en
Set-Cookie:  sessionid=ddff860b18d7c4ebbb5b78435f910757; expires=Mon,
18-May-2009 21:05:01 GMT; Max-Age=1209600; Path=/

Pls, advice me what to do?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



how to redirect a user to a website.

2009-05-04 Thread Aaron

ok, here is what I am working on . I am a noob at this.


I  am trying to make a link counter. I have a ad rotation system. The
ads will have a  tag.

when a user clicks on the ad it would direct them to the url for the
views.py that handels that function.

I also have a form that has hidden inputs that are nothing but values
from variables which is given by the database. I would have another
python function  that is a context processor. It will grab the url
link of the ads webstie.

Now that url gets passed to views.py and that function in views.py
will update the record by first grabbing that record taking the number
out of a field in that record and adding 1 to it.

so if it like 4  in the database then it will update it to 5 .

then after it updates the record it then  redirect the user to a
website for example like www.google.com

the redirect would be getting the veriable value which is the url of
that ad.


So what I want is that when the user clicks the ad graphic it will
update the record and then redirect the user to that ads website.

In basic form I am trying to make a  clicks per link counter.



here is the views.py code:  also I know that it's not a good way to
make repetitive code or functions.

I just made 3 functions to just outline what I need to do.


I have 3 areas where ads appear.


take a look.  Tell me if  I am doing it wrong? If so how would you
count a link. I know how to do it in php but I am new to python and
google app engine and dejango.



def get_ad(request):
if request.method == 'GET':
   url = request.POST['ad']
   query = GqlQuery("SELECT clicks FROM Ad WHERE url = 'url'")
   results =  Ad.get(query)
   number = results + 1
   update = Ad()
   update.clicks = number
   update.put()
   return HttpResponseRedirect('/')

def get_adl(request):
if request.method == 'POST':
   url = request.POST['adl']
   query = GqlQuery("SELECT clicks FROM Adl WHERE url = 'url'")
   results =  Adl.get(query)
   number = results + 1
   update = Adl()
   update.clicks = number
   update.put()
   return HttpResponseRedirect('url')

def get_adr(request):
if request.method == 'POST':
   url = request.POST['adr']
   query = GqlQuery("SELECT clicks FROM Adr WHERE url = 'url'")
   results =  Adr.get(query)
   number = results + 1
   update = Adr()
   update.clicks = number
   update.put()
return HttpResponseRedirect(url)



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



django CommaSeparatedStringField component

2009-05-04 Thread Joshua Partogi
Dear all,
Does anybody know a good CommaSeparatedStringField for django? The one that
I expect is sort of like the CommanSeparatedIntegerField that comes with
django, but for String.

Thank you very much in advance.

-- 
If you can't believe in God the chances are your God is too small.

Read my blog: http://joshuajava.wordpress.com/
Follow us on twitter: http://twitter.com/scrum8

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread Masklinn

On 4 mai 09, at 23:36, Malcolm Tredinnick   
wrote:
> On Mon, 2009-05-04 at 15:41 +0200, Masklinn wrote:
>> On 4 May 2009, at 14:55 , pbzRPA wrote:
>>> On May 4, 1:24 pm, Masklinn  wrote:
>
> [...]
>
 FWIW the `'app.views.showItems'` isn't even necessary, you can just
 pass the view function and reverse will figure out the rest, so

 return HttpResponseRedirect(reverse(showItems))

 is, in fact, sufficient.
>
>>>
>>> That is correct but only if the function resides in the same file  
>>> that
>>> the reverse function is used.
>
>> Unless you import it yes, but in this case the function *does* reside
>> in the same file.
>
> It's still a little fragile to use function references in reverse()
> calls. It works in many situations, but not always. This is because  
> the
> reference you pass in has to be exactly the same reference that the  
> URL
> Conf file has -- and that's only true if they were imported using the
> same path (and how the URL Conf file does the import isn't entirely
> under your control).
>
> Best practice here really has to be providing a name to each URL
> pattern. It's easy to read, easy to debug and works 100% of the time.
> Function references are useful in URL conf files, but they aren't the
> friend of reverse() and there's not a lot we can do about that  
> (because
> that's how Python works).
>
> Regards,
> Malcolm
>
Sorry for the previous mail, misstap.

Anyway thanks for the info, I'll stop suggesting that if there's  
breakage risk, and I'll remember it in case strange things happen in  
my code.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread Masklinn

On 4 mai 09, at 23:36, Malcolm Tredinnick   
wrote:
> On Mon, 2009-05-04 at 15:41 +0200, Masklinn wrote:
>> On 4 May 2009, at 14:55 , pbzRPA wrote:
>>> On May 4, 1:24 pm, Masklinn  wrote:
>
> [...]
>
 FWIW the `'app.views.showItems'` isn't even necessary, you can just
 pass the view function and reverse will figure out the rest, so

 return HttpResponseRedirect(reverse(showItems))

 is, in fact, sufficient.
>
>>>
>>> That is correct but only if the function resides in the same file  
>>> that
>>> the reverse function is used.
>
>> Unless you import it yes, but in this case the function *does* reside
>> in the same file.
>
> It's still a little fragile to use function references in reverse()
> calls. It works in many situations, but not always. This is because  
> the
> reference you pass in has to be exactly the same reference that the  
> URL
> Conf file has -- and that's only true if they were imported using the
> same path (and how the URL Conf file does the import isn't entirely
> under your control).
>
> Best practice here really has to be providing a name to each URL
> pattern. It's easy to read, easy to debug and works 100% of the time.
> Function references are useful in URL conf files, but they aren't the
> friend of reverse() and there's not a lot we can do about that  
> (because
> that's how Python works).
>
> Regards,
> Malcolm

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to add non-model field in admin

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 12:07 -0700, Tomáš Ehrlich wrote:
> Hi there,
> I wonder if is there any way to add extra input field in admin, which
> I don't want to define in model.
> 
> For example, I want to import external files. I have simple blog model
> (title, content, pub_date), but in admin I want to also have file
> input field, to import files.
> 
> Then I can:
> 1) Import external file, parse it and save values (title, content,
> pub_date) to database.
>  or
> 2) Enter values (title, ...) as usuall directly in admin.
> 
> Is there any way how to do this without making admin template for this
> application ?

Firstly, creating an admin template isn't a bad thing. Turns out there's
probably a more direct way to do what you want, but this is the second
time today on this list I've read about somebody wanting to preemptively
avoid a designed-in way to modify the admin. It's like asking "can I do
this in Python without using the 'def' keyword?" :-)

More importantly, though, the trick to this sort of thing is changing
the model form that is given to the ModelAdmin class. You can do
whatever you like in that form, although subclass ModelForm is probably
good thing, since there are some assumptions built into the Admin (and
it's not really onerous). You will probably also need to override one or
both of save_form() and save_model() in your ModelAdmin subclass.
They're not too badly documented in the django.contrib.admin.options
code (as docstrings) and a bit of playing around should reveal what's
going.

I've had a TO-BLOG item floating around for a while to remind me to
write about funky admin customisation along these lines. It's certainly
possible For now, as a bit of a guide, I can point you at [1], which
contains a similarly tricked-out admin page. It replaces some of the
default model fields with an entirely non-model field and then patches
in the necessary inforamtion in save_form() and save_model(). From
memory, the bug mentioned in the "XXX" comment there (line 46) has now
been fixed in Django trunk, too, although I haven't checked that out (I
remember seeing a patch for a ticket go past in the last couple of
weeks, that's all).

[1]
http://github.com/malcolmt/django-acacia/blob/6158e0137b2be9b6fa753eb3466e9d80ea2fae27/acacia/admin.py

Regards,
Malcolm


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to add non-model field in admin

2009-05-04 Thread Tomáš Ehrlich

Hi there,
I wonder if is there any way to add extra input field in admin, which
I don't want to define in model.

For example, I want to import external files. I have simple blog model
(title, content, pub_date), but in admin I want to also have file
input field, to import files.

Then I can:
1) Import external file, parse it and save values (title, content,
pub_date) to database.
 or
2) Enter values (title, ...) as usuall directly in admin.

Is there any way how to do this without making admin template for this
application ?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 15:41 +0200, Masklinn wrote:
> On 4 May 2009, at 14:55 , pbzRPA wrote:
> > On May 4, 1:24 pm, Masklinn  wrote:

[...]

> >> FWIW the `'app.views.showItems'` isn't even necessary, you can just
> >> pass the view function and reverse will figure out the rest, so
> >>
> >>  return HttpResponseRedirect(reverse(showItems))
> >>
> >> is, in fact, sufficient.

> >
> > That is correct but only if the function resides in the same file that
> > the reverse function is used.

> Unless you import it yes, but in this case the function *does* reside  
> in the same file.

It's still a little fragile to use function references in reverse()
calls. It works in many situations, but not always. This is because the
reference you pass in has to be exactly the same reference that the URL
Conf file has -- and that's only true if they were imported using the
same path (and how the URL Conf file does the import isn't entirely
under your control).

Best practice here really has to be providing a name to each URL
pattern. It's easy to read, easy to debug and works 100% of the time.
Function references are useful in URL conf files, but they aren't the
friend of reverse() and there's not a lot we can do about that (because
that's how Python works).

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Enable request timeout?

2009-05-04 Thread Graham Dumpleton



On May 5, 3:36 am, Shadow  wrote:
> Hi,
>
> I'm developing my site at the moment (locally) and it has an infinite
> loop somewhere. But my requests aren't timing out. The apache
> processes just get larger and larger, till I have to kill apache.
>
> I'm guessing I need to set a timeout setting, but I don't know where.
>
> Apache?mod_python? Python? Django?

This isn't really easily done. There are a couple of choices.

The first is to use fastcgi, although implementation needs to support
feature, and configure a request timeout in fastcgi setup. What will
happen is that a specific request takes longer than a certain amount
of time, fastcgi will kill off the whole process. If there are
concurrent requests, they will also be killed.

The second option is to use mod_wsgi in daemon mode. In this case you
need to set inactivity-timeout option. This doesn't work quite the
same as fastcgi and is instead meant to shutdown process if there is
no activity at all, where activity is measured as no reads from input
and no output generated. Do be aware though that if multithreaded
process and there are concurrent requests, they are regarded as
activity. In other words, in mod_wsgi inactivity is measured across
the whole process and not an individual request. If condition is
satisfied then process will be shutdown and replaced with a new one.
While you sort this problem out, you may therefore want to run daemon
mode in single thread/multi process configuration.

In summary, the only option is to kill off whole process through one
means or another, there isn't any way of terminating a specific Python
thread within a process.

End result is that you are just better off fixing your
application. :-)

Graham
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: fail silently: "NoneType object has no attribute...." errors?

2009-05-04 Thread hotani

Thanks Malcolm - getattr() is the one I knew had to be there but
couldn't remember or find it anywhere. And I'm pretty sure I've even
used it before. sheesh.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Separation of apps

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 12:51 -0700, eric.frederich wrote:
> Thanks for the reply.
> 
> You're right that auth.User is not a replacement for a profile.
> Maybe I will make the training app require only that a profile model
> exists and has a particular set of fields like cost-center, manager's
> e-mail, etc.
> This way at least it wouldn't be tied to a particular implementation
> of a profile.
> 
> I would just have things like...
> 
> class Enrollment(models.Model):
> person = models.ForeignKey(settings.AUTH_PROFILE_MODULE)
> offering = models.ForeignKey(Offering)
> 
> If I do this, then do I run into that problem of not being able to
> import the models file?

I probably wasn't clear about the issue with importing the models file.
As you've written things, Python needs to accessing
settings.AUTH_PROFILE_MODULE in order to parse the class definition.
That is, it needs to access settings at import time. This has two
implications:

(1) Once you have accessed settings, you really shouldn't change them.
So code importing that file should do so after making sure the settings
are as they want them.

(2) If somebody is using explicit settings configuration via
django.conf.settings.configure(), they would have to call configure()
*prior* to importing the above file, otherwise the settings might well
not exist yet (and, if they do, they'll contain the wrong values). Code
tends to look neater if you can put all your imports at the top and then
have you executable lines -- including calling settings.configure() --
later on. The above fragment prevents that. Not insurmountable, but not
as neat as possible.

Now, to be practical, in 90%+ of the time, these probably aren't issues.
You'll be using DJANGO_SETTINGS_MODULE or something similar to do the
"normal" settings process.

All that being said, there's a fairly simple solution here. Have the
foreign key point to the auth.User model and then use
person.get_profile() if you need to access the profile object.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Separation of apps

2009-05-04 Thread eric.frederich

Thanks for the reply.

You're right that auth.User is not a replacement for a profile.
Maybe I will make the training app require only that a profile model
exists and has a particular set of fields like cost-center, manager's
e-mail, etc.
This way at least it wouldn't be tied to a particular implementation
of a profile.

I would just have things like...

class Enrollment(models.Model):
person = models.ForeignKey(settings.AUTH_PROFILE_MODULE)
offering = models.ForeignKey(Offering)

If I do this, then do I run into that problem of not being able to
import the models file?

~Eric

On May 4, 3:35 pm, Malcolm Tredinnick 
wrote:
> On Mon, 2009-05-04 at 11:35 -0700, eric.frederich wrote:
> > I wrote an app that consist of an authentication backend and a single
> > model "Profile" (extension of auth.User).  It also has a function
> > which queries ldap to get user information like their manager.  We'll
> > call this app my_custom_backend.  The reason the Profile and
> > authentication are in the same app is because when a user logs in for
> > the first time it creates an auth.User as well as a
> > my_custom_backend.Profile and populates fields like cost center,
> > manager, phone number etc.
>
> > Another app that I have is a training application to register for
> > training courses offered here for engineering (Ansys, AutoCad, MathCad
> > etc.).
>
> > At first they were pretty separated through the use of the setting
> > AUTH_PROFILE_MODULE.
>
> > At the top of my models.py in the training application I had this...
>
> > PROFILE = getattr(settings, 'AUTH_PROFILE_MODULE', 'auth.User')
>
> > And then later on in my models I would have things like...
>
> > class Enrollment(models.Model):
> >     person = models.ForeignKey(PROFILE)
> >     offering = models.ForeignKey(Offering)
>
> > So depending on setting AUTH_PROFILE_MODULE it would either link to
> > my_custom_backend.Profile or auth.User.
>
> > Now as I start writing views and functionality I find the training app
> > directly depending on my_custom_backend.  Like when a user enrolls in
> > an offering of a course the manager needs to get emailed for approval
> > and finding the manager's email is provided by my_custom_backend.
>
> > Is it worth keeping them separated through the AUTH_PROFILE_MODULE
> > abstraction or should I just make the training app completely
> > dependent on my_custom_backend and directly reference
> > my_custom_backend.Profile from within there?
>
> I would make the dependency firm. I'm always very nervous about code
> that does what you're doing here, for a couple of reasons:
>
> Firstly, that setting can never be changed once syncdb is run, since
> changing the setting would require changing the database schema (the
> reference constraint between the tables). Secondly, as a more minor
> point, you've removed the ability to be able to import your models file
> before the settings are available. That's why a bunch of Django's own
> code has "from django.conf import settings" inside functions -- so that
> the module itself can be imported even if the user is going to call
> settings.configure() later on. The second point is relatively minor for
> you at this stage, I suspect, but it's worth keeping in the back of your
> mind.
>
> Realistically, though, the answer to your question comes down to whether
> you'll ever be actually using your code without your particular profile
> module? It sounds like you won't be.
>
> Also, there's kind of an awkward design in what you've got now. The
> auth.User class is not a substitute for an AUTH_PROFILE_MODULE class, as
> the latter has a related field pointing to the former. Lots of your code
> would be easier if you were able to guarantee to yourself that you could
> always call get_profile() on a user object and just have it return the
> right thing. At a minimum, even if not hard-coding in the particular
> profile module, make it a requirement that a profile module exists.
>
> Regards,
> Malcolm
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: fail silently: "NoneType object has no attribute...." errors?

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 11:52 -0700, hotani wrote:
> Most of the errors I'm seeing these days in my application are of the
> "NoneType object has no attribute" variety. While this may be
> helpful on occasion on the development server, I really don't want it
> creeping up on production.
> 
> "Well fix them!" you say. Actually there is nothing to fix. This is
> expected. There are times when I'm calling an attribute of an object
> and it's just not going to be there. I would like to have an empty
> string returned, or 'None'--anything other than a nasty 500 error for
> the user.
> 
> This is a law database. The primary model is "Case". Cases have
> attorneys, judges, and so on. Some of the old cases don't have judges
> (for example). If I call case.judge.last_name, I get a "NoneType
> object has no attribute 'last_name'" error, when all I want is an
> empty string or "None."
> 
> If I try to do "my_wrapper_function(case.judge.last_name)", I end up
> with the same error. Attempting to create something to fix this has
> turned complicated and I'm wondering if there is some obvious way
> around this issue that I'm overlooking.
> 
> Does django have a built-in way of handling these? I know this error
> is handled on the template side, but these issues are in views. If not
> django, is there something in python?

The try...except statement pair are what you're after. If you're
expecting an exception to be raised and know how you want to handle it,
then catch the exception and handle it in the right place.
Alternatively, have a look at the getattr() function in Python.
Something like getattr(case.judge, "last_name", "") will probably be
what you're after.

In any case, all solutions to this are in the Python language. It's
normal attribute access stuff: if you try to access something that isn't
there, you'll get an exception. So either except to handle the
exception, or check the thing is there first. (Why are templates
different, you ask? Because templates aren't Python).

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: data too long in a CharField column

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 08:46 -0700, MS wrote:
> Hi,
> 
> I have a problem with django+postgresql:
> I have a model with a CharField(max_length=255) field, and I'm
> assigning some much longer value to this field, like:
> 
> m = MyModel()
> m.myfield = 'very long text - say 400 chars'
> m.save()
> 
> In save() I'm getting an error "ERROR:  value too long for type
> character varying(255)", and the SQL statement contains the 'very long
> text - say 400 chars' intact.
> 
> I thought that if django knows that a field is restricted to 255
> chars, then it will validate it and
> truncate excessive chars before saving. But it doesn't.

As noted elsewhere in the thread, truncating would be almost always the
wrong solution, since it quietly throws away data.

As for detecting the problem in the first place, form fields will
already pick up this problem if the user is providing data through a
form (it will be a validation error). Right now, model field validation
doesn't exist, so you, as the programmer populating the field, is
expected to make sure the data fits (in the above example, you're
populating the model field directly, so you need to check you're
populating it with something sensible). In fact, even after model field
validation exists, it will still be your responsibility to make sure the
data fits: Django will raise a validation error if it doesn't, but it
won't automatically fix the problem because an appropriate solution is
going to be domain specific.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Separation of apps

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 11:35 -0700, eric.frederich wrote:
> I wrote an app that consist of an authentication backend and a single
> model "Profile" (extension of auth.User).  It also has a function
> which queries ldap to get user information like their manager.  We'll
> call this app my_custom_backend.  The reason the Profile and
> authentication are in the same app is because when a user logs in for
> the first time it creates an auth.User as well as a
> my_custom_backend.Profile and populates fields like cost center,
> manager, phone number etc.
> 
> Another app that I have is a training application to register for
> training courses offered here for engineering (Ansys, AutoCad, MathCad
> etc.).
> 
> At first they were pretty separated through the use of the setting
> AUTH_PROFILE_MODULE.
> 
> At the top of my models.py in the training application I had this...
> 
> PROFILE = getattr(settings, 'AUTH_PROFILE_MODULE', 'auth.User')
> 
> And then later on in my models I would have things like...
> 
> class Enrollment(models.Model):
> person = models.ForeignKey(PROFILE)
> offering = models.ForeignKey(Offering)
> 
> So depending on setting AUTH_PROFILE_MODULE it would either link to
> my_custom_backend.Profile or auth.User.
> 
> Now as I start writing views and functionality I find the training app
> directly depending on my_custom_backend.  Like when a user enrolls in
> an offering of a course the manager needs to get emailed for approval
> and finding the manager's email is provided by my_custom_backend.
> 
> Is it worth keeping them separated through the AUTH_PROFILE_MODULE
> abstraction or should I just make the training app completely
> dependent on my_custom_backend and directly reference
> my_custom_backend.Profile from within there?

I would make the dependency firm. I'm always very nervous about code
that does what you're doing here, for a couple of reasons:

Firstly, that setting can never be changed once syncdb is run, since
changing the setting would require changing the database schema (the
reference constraint between the tables). Secondly, as a more minor
point, you've removed the ability to be able to import your models file
before the settings are available. That's why a bunch of Django's own
code has "from django.conf import settings" inside functions -- so that
the module itself can be imported even if the user is going to call
settings.configure() later on. The second point is relatively minor for
you at this stage, I suspect, but it's worth keeping in the back of your
mind.

Realistically, though, the answer to your question comes down to whether
you'll ever be actually using your code without your particular profile
module? It sounds like you won't be.

Also, there's kind of an awkward design in what you've got now. The
auth.User class is not a substitute for an AUTH_PROFILE_MODULE class, as
the latter has a related field pointing to the former. Lots of your code
would be easier if you were able to guarantee to yourself that you could
always call get_profile() on a user object and just have it return the
right thing. At a minimum, even if not hard-coding in the particular
profile module, make it a requirement that a profile module exists.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL with a variable issue.

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 10:31 -0700, MikeL wrote:
> I figured it out. I had to run cursor.execute for the SET and the
> SELECT line and it managed to remember the @row being 0 between them.
> Though it would be nice if a django solution exists.

You found the Django solution already: use cursor.execute(). We
intentionally don't even attempt to provide things like what you're
doing wrapped up in a Python layer. It's essentially unbounded amounts
of work to come up with an API to hide the use of SQL, come up with SQL
that works on all our backends and is usable by third-party database
backends, etc, etc. Instead, we provide a way for you to talk SQL when
that's the appropriate solution to your problem.

It sounds, from your reply here, that you were originally trying to pass
multiple statements through in a single cursor.execute() call. It's not
well-defined in PEP-249 as to whether database wrappers handle that or
not and the behaviour is a bit database server specific (both in whether
it works and in the how errors are reported, if at all).

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL with a variable issue.

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 11:31 -0700, pbzRPA wrote:
> Hi,
> 
> Could you provide the code of your model and why you would want to use
> a custom sql instead of the django model object.

For the type of query that Mike is asking about, custom SQL is a
reasonable solution. Django cannot really provide a nice way to do a
bunch of complicated direct-SQL stuff, which is why we provide
cursor.execute() in the first place.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ManyToManyField and Manager.exclude()

2009-05-04 Thread Malcolm Tredinnick

On Mon, 2009-05-04 at 09:18 -0700, Riccardo Pelizzi wrote:
> Hello,
> 
> I have a model which looks kinda like this:
> 
> class Host(model):
>   ip = IPAddressField()
> 
> class Domain(model):
>   hosts = ManyToManyField(Host)
> 
> If i want to get all the domains without hosts:
> Domain.objects.filter(hosts=None)
> works.
> 
> Later on in my script i need to get the opposite, all the domains
> having one or more hosts associated. using exclude instead of filter
> with the same condition doesn't work as expected (at least as I
> expected :-P), it just returns an empty queryset. Is there a way to
> formulate the query using the django api? or should i use custom sql?

That should work properly. It works for me using exactly your models
with a few different Host/Domain combinations.

The SQL we currently generate for Domain.objects.exclude(hosts=None) is
a little inefficient, but it's not fundamentally incorrect. It just uses
a couple more tables than it needs to be because the "NULL" case can
take advantage of one particular extra optimisation that isn't in the
code yet. I'm surprised it isn't returning the correct result.

Another to get the same answer, which generates simpler SQL but is
potentially a little less efficient on the database side is

Domain.objects.filter(hosts__isnull=False).distinct()

That's essentially the only case where Django has a "not" filter
available: you can actually filter for "not NULL". The distinct() call
there is important, as for many-to-many fields, you would otherwise get
back one domain object for every host (so repetitions for domains with
multiple hosts), not just the set of domains that have at least one
host.

In any case, I suspect there's something else going on in your
particular case, as the SQL generated should be pulling back the results
you're after and it works with a small example using your models. If you
can use those models, as pasted, to generate an incorrect result, what
is the smallest amount of data (Host & Domain objects) you need to
create to demonstrate the problem. That would be interesting to see.

Regards,
Malcolm


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



fail silently: "NoneType object has no attribute...." errors?

2009-05-04 Thread hotani

Most of the errors I'm seeing these days in my application are of the
"NoneType object has no attribute" variety. While this may be
helpful on occasion on the development server, I really don't want it
creeping up on production.

"Well fix them!" you say. Actually there is nothing to fix. This is
expected. There are times when I'm calling an attribute of an object
and it's just not going to be there. I would like to have an empty
string returned, or 'None'--anything other than a nasty 500 error for
the user.

This is a law database. The primary model is "Case". Cases have
attorneys, judges, and so on. Some of the old cases don't have judges
(for example). If I call case.judge.last_name, I get a "NoneType
object has no attribute 'last_name'" error, when all I want is an
empty string or "None."

If I try to do "my_wrapper_function(case.judge.last_name)", I end up
with the same error. Attempting to create something to fix this has
turned complicated and I'm wondering if there is some obvious way
around this issue that I'm overlooking.

Does django have a built-in way of handling these? I know this error
is handled on the template side, but these issues are in views. If not
django, is there something in python?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: data too long in a CharField column

2009-05-04 Thread pbzRPA

Hi,

I am not sure if truncating the data is a good solution as the user
will be under the impression that all the text was saved whereas only
the first 255 was really saved.

You can add a max_length to your form or modelform field which will
block the user from typing more then the max length.

regards.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



xlrd and UploadedFile error

2009-05-04 Thread James Smagala

Hey All,

Can anyone tell me how to read a Djano UploadedFile .xls file with
xlrd without resorting to explicitly saving the file to the hard
drive?

If I attempt to pass my_file.read() directly to xlrd, the error I get
is:

file() argument 1 must be (encoded string without NULL bytes), not str

Based on that error, it seems that I should be able to cast the value
to some sort of encoded string.  Any suggestions?

Thanks,

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Separation of apps

2009-05-04 Thread eric.frederich

I wrote an app that consist of an authentication backend and a single
model "Profile" (extension of auth.User).  It also has a function
which queries ldap to get user information like their manager.  We'll
call this app my_custom_backend.  The reason the Profile and
authentication are in the same app is because when a user logs in for
the first time it creates an auth.User as well as a
my_custom_backend.Profile and populates fields like cost center,
manager, phone number etc.

Another app that I have is a training application to register for
training courses offered here for engineering (Ansys, AutoCad, MathCad
etc.).

At first they were pretty separated through the use of the setting
AUTH_PROFILE_MODULE.

At the top of my models.py in the training application I had this...

PROFILE = getattr(settings, 'AUTH_PROFILE_MODULE', 'auth.User')

And then later on in my models I would have things like...

class Enrollment(models.Model):
person = models.ForeignKey(PROFILE)
offering = models.ForeignKey(Offering)

So depending on setting AUTH_PROFILE_MODULE it would either link to
my_custom_backend.Profile or auth.User.

Now as I start writing views and functionality I find the training app
directly depending on my_custom_backend.  Like when a user enrolls in
an offering of a course the manager needs to get emailed for approval
and finding the manager's email is provided by my_custom_backend.

Is it worth keeping them separated through the AUTH_PROFILE_MODULE
abstraction or should I just make the training app completely
dependent on my_custom_backend and directly reference
my_custom_backend.Profile from within there?

Thanks,
~Eric
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL with a variable issue.

2009-05-04 Thread pbzRPA

Hi,

Could you provide the code of your model and why you would want to use
a custom sql instead of the django model object.

Regards
Pbzrpa
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: data too long in a CharField column

2009-05-04 Thread MS

>
> If you want that behavior, just truncate `myfield` in `MyModel.save()`
> before calling the super save.
>
> 



Well, if that's THE solution, then I'll post my implementation - maybe
someone will find it useful:


def autotruncate(cls):
oldsave = cls.save
def newsave(self, **kwargs):
for f in self._meta._fields():
if isinstance(f, models.CharField):
val = getattr(self, f.name)
if val is not None:
setattr(self, f.name, val[:f.max_length])
oldsave(self, **kwargs)
cls.save = newsave


To use it, write:
autotruncate(MyModel)

Any comments are welcome.

Regards,
MS

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i've looked at other discussions regarding the error ?unable to open database file?

2009-05-04 Thread Mike Ramirez
On Monday 04 May 2009 10:17:09 am Phil Mocek wrote:
> On Mon, May 04, 2009 at 08:31:34AM -0700, Mike Ramirez wrote:
> > I forgot to mention that sqlite3 expects a file to be there, it
> > can't create one on it's own, using ./manage.py syncdb.
>
> I think you are mistaken.  Can you site some documentation to back
> this claim?
>
No actually I can't, but I can't say that I've had the db created for me 
without an existing sqlite db, I never checked trac to see if this was a bug 
or not (might have been, not worried about it as I doubt this would be a 
django issue, as musch as a pysqlite one). Also since my first problems with 
this, I've just touched an empty file everytime I needed a new sqlite db.



> I'm using Django 1.0, python-sqlite2 2.4.1, and libsqlite3-0
> 3.5.9, and the syncdb command creates an SQLite database for me
> without the need for me to first create an empty file.

dev version of django, python-sqlite2-2.3.3 and same version of libsqlite3.

Mike.

-- 
Age before beauty; and pearls before swine.
-- Dorothy Parker


signature.asc
Description: This is a digitally signed message part.


Enable request timeout?

2009-05-04 Thread Shadow

Hi,

I'm developing my site at the moment (locally) and it has an infinite
loop somewhere. But my requests aren't timing out. The apache
processes just get larger and larger, till I have to kill apache.

I'm guessing I need to set a timeout setting, but I don't know where.

Apache? mod_python? Python? Django?

Thanks in advance.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Custom SQL with a variable issue.

2009-05-04 Thread MikeL

I figured it out. I had to run cursor.execute for the SET and the
SELECT line and it managed to remember the @row being 0 between them.
Though it would be nice if a django solution exists.

Regardless,
MikeL

On May 4, 10:15 am, MikeL  wrote:
> I'm trying to make a query which lists the top 5 rated users along
> with the rating (and rank) of the current user. The top 5 was easy,
> but I'm having a problem getting the rank of the current user. I know
> the sql needed to calculate the rank, but it requires a variable.
>
> SET @row=0;
> SELECT rank from
> (
>         SELECT @row:=...@row+1 as rank, user_id, variant_id
>                 FROM a_table
>                 WHERE variant_id=0
>                 ORDER BY rating DESC
> ) AS A
>         WHERE user_id=0;
>
> I've tried cursor.execute and cursor.fetchone(), but I don't any
> return. I removed the first line and did get a return, only it was
> NULL. Is there anyway to do this with Django's models or a way to get
> the sql above to work?
>
> TIA,
> MikeL
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



form elements css changes on errors

2009-05-04 Thread joeygartin

Disclaimer:  I am new to Django and not the greatest programmer.

I would like to add a css class to form elements if there is an error
in the form.  Not sure the BEST/EASIEST way to do this.  I would only
want the attribute added if there was an error and I would like to do
this in the cleanest way possible.  Meaning I would LIKE to stay away
from if statements for every form element I have in the HTML and
rather put the proper code in Python (perhaps forms.py with the form
declaration), but I am new and not exactly sure how to proceed.

To anyone who replies, if my question annoys you, then simply do not
reply, no need for insults or "read the docs" replies.

To everyone else: Thank you in advance for your help!
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread scott212


I'm not saying that the original OP code didn't work, just that it felt
sloppy to have this lists/delete/item1 url lingering out there. Just looking
for a better way. :)


John Crawford-14 wrote:
> 
> 
> Okay, I'm not sure why the OP code didn't work - it seems like going
> to the URL 'lists/show', with the updated list, would work. So my
> *guess* is that since it's a page the browser already saw and cached,
> that the page just isn't getting refreshed. In other words, if he hit
> the browser-refresh button, the page would display correctly. So the
> redirect is causing the browser to consider it as a new page, and
> thereby refreshes it.
> 
> Is this what's going on, or is there something more complex that I am
> missing? :)
> 
> John C>
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-handle-view-url-situation-%28Newbie%29-tp23363094p23372688.html
Sent from the django-users mailing list archive at Nabble.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i've looked at other discussions regarding the error ?unable to open database file?

2009-05-04 Thread Phil Mocek

On Mon, May 04, 2009 at 08:31:34AM -0700, Mike Ramirez wrote:
> I forgot to mention that sqlite3 expects a file to be there, it
> can't create one on it's own, using ./manage.py syncdb.

I think you are mistaken.  Can you site some documentation to back
this claim?

I'm using Django 1.0, python-sqlite2 2.4.1, and libsqlite3-0
3.5.9, and the syncdb command creates an SQLite database for me
without the need for me to first create an empty file.

-- 
Phil Mocek

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread John Crawford

Okay, I'm not sure why the OP code didn't work - it seems like going
to the URL 'lists/show', with the updated list, would work. So my
*guess* is that since it's a page the browser already saw and cached,
that the page just isn't getting refreshed. In other words, if he hit
the browser-refresh button, the page would display correctly. So the
redirect is causing the browser to consider it as a new page, and
thereby refreshes it.

Is this what's going on, or is there something more complex that I am
missing? :)

John C>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Custom SQL with a variable issue.

2009-05-04 Thread MikeL

I'm trying to make a query which lists the top 5 rated users along
with the rating (and rank) of the current user. The top 5 was easy,
but I'm having a problem getting the rank of the current user. I know
the sql needed to calculate the rank, but it requires a variable.

SET @row=0;
SELECT rank from
(
SELECT @row:=...@row+1 as rank, user_id, variant_id
FROM a_table
WHERE variant_id=0
ORDER BY rating DESC
) AS A
WHERE user_id=0;

I've tried cursor.execute and cursor.fetchone(), but I don't any
return. I removed the first line and did get a return, only it was
NULL. Is there anyway to do this with Django's models or a way to get
the sql above to work?

TIA,
MikeL
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



tinymce not displaying on admin template

2009-05-04 Thread Jesse

Hello,

I'm trying to implement django-cms.  The CMS pages in admin display,
but not with the editing someone without html knowledge will be able
to use.  I see no tinymce options. I've placed tinymce in several
places hoping somehow it would display where I need it.

Using this statement in a firefox browser:
http://127.0.0.1:8000/site_media/tiny_mce/tiny_mce.js

I see this displayed:
var tinymce=
{majorVersion:"3",minorVersion:"2.3",releaseDate:"2009-04-23",_init:function
(){var o=this,k=document, etc.

My setting.py file:
MEDIA_ROOT = 'c:/django/myprograms/site_media/'
MEDIA_URL = 'http://127.0.0.1:8000/site_media/'

TINYMCE_JS_URL = 'http://127.0.0.1:8000/site_media/js/tiny_mce/
tiny_mce.js'
TINYMCE_JS_ROOT = 'c:/django/myprograms/site_media/js/tiny_mce'
TINYMCE_DEFAULT_CONFIG = {
'plugins': "table,spellchecker,paste,searchreplace",
'theme': "advanced",
'cleanup_on_startup': True,
'custom_undo_redo_levels': 10,
}

TINYMCE_SPELLCHECKER = False
TINYMCE_COMPRESSOR = False
TINYMCE_FILEBROWSER = True

CMS_USE_TINYMCE = True

INSTALLED_APPS = (
'cms',
'tinymce',
'filebrowser',
)

I''ve not found any download files with the uppercase TinyMce, but
only tinymce
or tiny_mce.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Anyone else having issues with filter_horizontal in trunk?

2009-05-04 Thread Brandon Taylor

I was modifying the form submission with some Ajax code that busted
the filter_horizontal apparently. Preventing the default action of the
form with jQuery is not a good idea :)

On May 4, 10:41 am, Brandon Taylor  wrote:
> Hi George,
>
> I wonder what the deal is then. I've noticed this issue on two apps
> I'm working on. The only thing those apps have in common is that I'm
> also leveraging jQuery and overriding the change_form.html template.
>
> I guess I'll just make a new app and start adding things until it
> breaks.
>
> On May 4, 10:30 am, George Song  wrote:
>
> > On 5/4/2009 8:24 AM, Brandon Taylor wrote:
>
> > > filter_vertical also appears to be suffering the same problem.
>
> > > On May 4, 10:23 am, Brandon Taylor  wrote:
> > >> Hi everyone,
>
> > >> When I specify filter_horizontal for any ManyToMany field on a model
> > >> using Django trunk, and that field is required, admin will not allow
> > >> me to save the choice(s). it will tell me the field is required, no
> > >> matter how many choices I select.
>
> > >> If I remove the filter_horizontal, and I make selection(s), the form
> > >> will submit properly.
>
> > >> Anyone else seeing the same issue?
>
> > I just tested it in my app and it's fine.
>
> > --
> > George
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i've looked at other discussions regarding the error ?unable to open database file?

2009-05-04 Thread bconnors

touch worked for me.

thanks


On May 4, 11:31 am, Mike Ramirez  wrote:
> I forgot to mention that sqlite3 expects a file to be there, it can't create
> one on it's own, using ./manage.py syncdb.  To do so I use touch, tho you can
> also do the same thing with vi, if you save it as an empty file (just tested
> it). echo "" > testing.db might work also.
>
> [gufym...@sylia testing]$ rm testing.db
> [gufym...@sylia testing]$ vi testing.db
> [gufym...@sylia testing]$ ./manage.py syncdb
> Creating table django_content_type
> Creating table django_session
> Creating table django_site
> Creating table testfun_testfun
>
> -- In vi I just typed :wqa  to quit it.
>
> Mike  
> --
> I used to think I was indecisive, but now I'm not so sure.
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error loading sqlite3

2009-05-04 Thread Gonzalo Petersen

I found a post that supposedly fixes the broken sqlite3 package.
" adding sqlite-devel to BuildRequires fixes the problem "

could someone help me do that??

here is the link to the post.
https://bugzilla.novell.com/show_bug.cgi?id=228733#c7

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: offline population of django auth user table

2009-05-04 Thread Jeff

Thanks to both of you, both of these answers were very helpful.

Jeff

On May 2, 10:26 am, Malcolm Tredinnick 
wrote:
> There are a couple of different solutions to this problem. Ultimately,
> it comes down to providing the necessary information so that Django can
> use your settings to determine the database name and backend and things
> like that. Here are a few possibilities:

Carl Karsten wrote:
> Here is some code from my mygrate.py program - it should be all you
> need, let me know (cc me, cuz I don't monitor this list) if you need
> more.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ManyToManyField and Manager.exclude()

2009-05-04 Thread Riccardo Pelizzi

Hello,

I have a model which looks kinda like this:

class Host(model):
  ip = IPAddressField()

class Domain(model):
  hosts = ManyToManyField(Host)

If i want to get all the domains without hosts:
Domain.objects.filter(hosts=None)
works.

Later on in my script i need to get the opposite, all the domains
having one or more hosts associated. using exclude instead of filter
with the same condition doesn't work as expected (at least as I
expected :-P), it just returns an empty queryset. Is there a way to
formulate the query using the django api? or should i use custom sql?

thanks
Riccardo

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages only works when settings.DEBUG = True

2009-05-04 Thread Brian Neal

On May 4, 10:28 am, Ronghui Yu  wrote:
> Hi,All,
>
> I am going to use Flatpages app for those simple pages. And everything
> works fine when settings.DEBUG is True, but when it is turned to False,
> a URL not configured in urlpatterns will trigger 500, not 404.

Do you have a 404.html error template? You need to have that before
flatpages will work when DEBUG is False. See the note titled "Ensure
that your 404 template works" in this section:

http://docs.djangoproject.com/en/dev/ref/contrib/flatpages/#module-django.contrib.flatpages

Its also a good idea to have a 500.html error template.

Best,
BN


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Flatpages only works when settings.DEBUG = True

2009-05-04 Thread Masklinn

On 4 May 2009, at 17:28 , Ronghui Yu wrote:
> I don't quite understand why this happens, and how to solve it.
> Has anybody ever met this problem? And any suggestions?
>
> Thanks in advance.
>
Setup a local smtp sink and activate the "mail on 500" thing, to see  
why it's erroring out?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: data too long in a CharField column

2009-05-04 Thread George Song

On 5/4/2009 8:46 AM, MS wrote:
> I have a problem with django+postgresql:
> I have a model with a CharField(max_length=255) field, and I'm
> assigning some much longer value to this field, like:
> 
> m = MyModel()
> m.myfield = 'very long text - say 400 chars'
> m.save()
> 
> In save() I'm getting an error "ERROR:  value too long for type
> character varying(255)", and the SQL statement contains the 'very long
> text - say 400 chars' intact.
> 
> I thought that if django knows that a field is restricted to 255
> chars, then it will validate it and
> truncate excessive chars before saving. But it doesn't. How can I get
> rid of that problem?

If you want that behavior, just truncate `myfield` in `MyModel.save()` 
before calling the super save.



-- 
George

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Flatpages only works when settings.DEBUG = True

2009-05-04 Thread Ronghui Yu
Hi,All,

I am going to use Flatpages app for those simple pages. And everything
works fine when settings.DEBUG is True, but when it is turned to False,
a URL not configured in urlpatterns will trigger 500, not 404. This
happens on both Apache2 and the Django native testing server. Here is
some outputs from ./manage.py runserver

[04/May/2009 23:21:24] "GET /cases/ HTTP/1.1" 500 10947
[04/May/2009 23:21:25] "GET /cases/css/css.css HTTP/1.1" 500 10947
[04/May/2009 23:21:26] "GET /cases/images/bj.gif HTTP/1.1" 500 10947
[04/May/2009 23:21:26] "GET /cases/images/logo.gif HTTP/1.1" 500 10947
[04/May/2009 23:21:27] "GET /cases/images/name.gif HTTP/1.1" 500 10947
[04/May/2009 23:21:27] "GET /cases/images/icon.gif HTTP/1.1" 500 10947

/cases/ is one of the flatpage url in the database.

I don't quite understand why this happens, and how to solve it.
Has anybody ever met this problem? And any suggestions?

Thanks in advance.


-- 
Ronghui Yu 

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



data too long in a CharField column

2009-05-04 Thread MS

Hi,

I have a problem with django+postgresql:
I have a model with a CharField(max_length=255) field, and I'm
assigning some much longer value to this field, like:

m = MyModel()
m.myfield = 'very long text - say 400 chars'
m.save()

In save() I'm getting an error "ERROR:  value too long for type
character varying(255)", and the SQL statement contains the 'very long
text - say 400 chars' intact.

I thought that if django knows that a field is restricted to 255
chars, then it will validate it and
truncate excessive chars before saving. But it doesn't. How can I get
rid of that problem?

Thanks,
MS

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Anyone else having issues with filter_horizontal in trunk?

2009-05-04 Thread Brandon Taylor

Hi George,

I wonder what the deal is then. I've noticed this issue on two apps
I'm working on. The only thing those apps have in common is that I'm
also leveraging jQuery and overriding the change_form.html template.

I guess I'll just make a new app and start adding things until it
breaks.

On May 4, 10:30 am, George Song  wrote:
> On 5/4/2009 8:24 AM, Brandon Taylor wrote:
>
> > filter_vertical also appears to be suffering the same problem.
>
> > On May 4, 10:23 am, Brandon Taylor  wrote:
> >> Hi everyone,
>
> >> When I specify filter_horizontal for any ManyToMany field on a model
> >> using Django trunk, and that field is required, admin will not allow
> >> me to save the choice(s). it will tell me the field is required, no
> >> matter how many choices I select.
>
> >> If I remove the filter_horizontal, and I make selection(s), the form
> >> will submit properly.
>
> >> Anyone else seeing the same issue?
>
> I just tested it in my app and it's fine.
>
> --
> George
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django setting problem on windows

2009-05-04 Thread zayatzz

Posting because i just set up httpd.conf on linux computer few days
ago and it took me a while to get it working as i wanted to.

If i just compare the way how i set it up and how you did it Then the
difference is that you have no pythonpath like Malcolm said and
location should be either "/web/" or "/"

Take a look at 2nd example here :http://docs.djangoproject.com/en/dev/
howto/deployment/modpython/

Thats the one i used to get it working.

Alan

On May 3, 8:24 am, online  wrote:
> I have mod_python set working fine with apache.
>
> I have django setting as following at apache
> 
> 
>     ServerAdmin webmas...@dummy-host2.li
>     DocumentRoot "C:/depot/projects/web/"
>     ServerName web
>     ServerAlias *.web
>     ErrorLog "logs/dummy-host2.li-error_log"
>     CustomLog "logs/dummy-host2.li-access_log" common
>
> 
>     SetHandler python-program
>     PythonHandler django.core.handlers.modpython
>     SetEnv DJANGO_SETTINGS_MODULE web.settings
>     PythonOption django.root "C:/depot/projects/web/"
>     PythonDebug On
> 
>
>   
>     SetHandler None
>   
>
>   
>     SetHandler None
>   
>
> 
> -
>
> But I always got error
>
> "ImportError: Settings cannot be imported, because environment
> variable DJANGO_SETTINGS_MODULE is undefined.
> "
>
> Thanks for any help!
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i've looked at other discussions regarding the error ?unable to open database file?

2009-05-04 Thread Mike Ramirez

I forgot to mention that sqlite3 expects a file to be there, it can't create 
one on it's own, using ./manage.py syncdb.  To do so I use touch, tho you can 
also do the same thing with vi, if you save it as an empty file (just tested 
it). echo "" > testing.db might work also.

[gufym...@sylia testing]$ rm testing.db
[gufym...@sylia testing]$ vi testing.db
[gufym...@sylia testing]$ ./manage.py syncdb
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table testfun_testfun

-- In vi I just typed :wqa  to quit it.

Mike  
-- 
I used to think I was indecisive, but now I'm not so sure.


signature.asc
Description: This is a digitally signed message part.


Re: Anyone else having issues with filter_horizontal in trunk?

2009-05-04 Thread George Song

On 5/4/2009 8:24 AM, Brandon Taylor wrote:
> filter_vertical also appears to be suffering the same problem.
> 
> On May 4, 10:23 am, Brandon Taylor  wrote:
>> Hi everyone,
>>
>> When I specify filter_horizontal for any ManyToMany field on a model
>> using Django trunk, and that field is required, admin will not allow
>> me to save the choice(s). it will tell me the field is required, no
>> matter how many choices I select.
>>
>> If I remove the filter_horizontal, and I make selection(s), the form
>> will submit properly.
>>
>> Anyone else seeing the same issue?

I just tested it in my app and it's fine.

-- 
George

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i've looked at other discussions regarding the error ?unable to open database file?

2009-05-04 Thread Mike Ramirez
On Monday 04 May 2009 08:16:58 am bconnors wrote:
> I deleted the file and
> When I do python manage.py syncdb  and the message ends up with:


You should be using touch, vi might work, if you save it as an empty file, but 
touch is the best.  example:


[gufym...@sylia testing]$ ls
__init__.py  __init__.pyc  manage.py  settings.py  settings.pyc  testfun  
testing.db  urls.py
[gufym...@sylia testing]$ rm testing.db
[gufym...@sylia testing]$ touch testing.db
[gufym...@sylia testing]$ ./manage.py syncdb
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table testfun_testfun

--

settings.py - DB settings:

DATABASE_ENGINE = 'sqlite3'   
# 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = 'testing.db' # Or path to database file if using 
sqlite3.   
DATABASE_USER = '' # Not used with sqlite3. 

DATABASE_PASSWORD = '' # Not used with sqlite3. 

DATABASE_HOST = '' # Set to empty string for localhost. Not used 
with sqlite3.  
DATABASE_PORT = '' # Set to empty string for default. Not used 
with sqlite3.   

Mike
-- 
 I know. Unless htere is a cookie monster somewhere between us tat 
muches the amil.
 amil/mail
 muches/munches tat/that htere/there
 heheh
 problems? :)
* Myxie needs an ircii addon that pipes teh command line through ispell :)
-- Seen on #Debian


signature.asc
Description: This is a digitally signed message part.


Re: Anyone else having issues with filter_horizontal in trunk?

2009-05-04 Thread Brandon Taylor

filter_vertical also appears to be suffering the same problem.

On May 4, 10:23 am, Brandon Taylor  wrote:
> Hi everyone,
>
> When I specify filter_horizontal for any ManyToMany field on a model
> using Django trunk, and that field is required, admin will not allow
> me to save the choice(s). it will tell me the field is required, no
> matter how many choices I select.
>
> If I remove the filter_horizontal, and I make selection(s), the form
> will submit properly.
>
> Anyone else seeing the same issue?
>
> TIA,
> Brandon
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Anyone else having issues with filter_horizontal in trunk?

2009-05-04 Thread Brandon Taylor

Hi everyone,

When I specify filter_horizontal for any ManyToMany field on a model
using Django trunk, and that field is required, admin will not allow
me to save the choice(s). it will tell me the field is required, no
matter how many choices I select.

If I remove the filter_horizontal, and I make selection(s), the form
will submit properly.

Anyone else seeing the same issue?

TIA,
Brandon
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread scott212


You guys are awesome, it's always great to find a great new framework and
then find out it has a great community as well. I can't wait to try this
tonight. Thanks again!



Masklinn wrote:
> 
> 
> On 4 May 2009, at 14:55 , pbzRPA wrote:
>> On May 4, 1:24 pm, Masklinn  wrote:
>>> On 4 May 2009, at 12:47 , pbzRPA wrote:
>>>
 I would do the following.
>>>
 from django.http import HttpResponseRedirect
 from django.core.urlresolvers import reverse
>>>
 def deleteItems(request, item):
>>>
return HttpResponseRedirect(reverse('app.views.showItems'))
>>>
>>> FWIW the `'app.views.showItems'` isn't even necessary, you can just
>>> pass the view function and reverse will figure out the rest, so
>>>
>>>  return HttpResponseRedirect(reverse(showItems))
>>>
>>> is, in fact, sufficient.
>>
>> That is correct but only if the function resides in the same file that
>> the reverse function is used.
> Unless you import it yes, but in this case the function *does* reside  
> in the same file.
> 
> > 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/How-to-handle-view-url-situation-%28Newbie%29-tp23363094p23370540.html
Sent from the django-users mailing list archive at Nabble.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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i've looked at other discussions regarding the error ?unable to open database file?

2009-05-04 Thread bconnors


I deleted the file and
When I do python manage.py syncdb  and the message ends up with:
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", li
ne 304, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 1
95, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 2
22, in execute
output = self.handle(*args, **options)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 3
51, in handle
return self.handle_noargs(**options)
  File "/usr/lib/python2.5/site-packages/django/core/management/
commands/syncdb.
py", line 49, in handle_noargs
cursor = connection.cursor()
  File "/usr/lib/python2.5/site-packages/django/db/backends/
__init__.py", line 8
1, in cursor
cursor = self._cursor()
  File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
base.py", li
ne 170, in _cursor
self.connection = Database.connect(**kwargs)
sqlite3.OperationalError: unable to open database file
pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite$

is it my settings.py which for database has “# Django settings for
mysite project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@domain.com'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
'postgresql', 'my
sql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = '/django-trunk/build/lib/django/bin/
mysite' # Or pat
h to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used wit
h sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with
sqlite3.

# Local time zone for this installation. Choices can be found here:
@
"settings.py" 81 lines, 2871 characters



On May 4, 10:01 am, Phil Mocek 
wrote:
> On Mon, May 04, 2009 at 05:33:05AM -0700, bconnors wrote:
> > I created a mysite.db in my directory by vi.
>
> It's highly unlikely that you will be able to create a valid
> SQLitedatabaseusing a text editor.  You should delete thatfile,
> then expect it to be created when you run the 'syncdb' command.
>
> --
> Phil Mocek
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Easy display of table of data without a backing model

2009-05-04 Thread JL

Another hack would be to make your data structure look 'enough' like a
Django model such that the generic views would work for you.  Remember
that Python follows duck-typing principles so if your data structures
looks enough like querysets and data models, then you could use the
generic views.  I doubt you'd be able to do enough to use admin but
definitely the generic views.  You could probably lift a lot of the
Admin css too.

On May 3, 4:12 am, Richard Davies 
wrote:
> P.S. An obvious hack would be to save all my data from memory into a
> Django model, then do the view based on the model.
>
> I'd like to avoid that if at all possible, both because it's ugly to
> save data into the database just to pass it to a view and also because
> I'd then get into all kinds of issues with keeping the data in the
> database in sync with updates to the data in memory.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i've looked at other discussions regarding the error ?unable to open database file?

2009-05-04 Thread Phil Mocek

On Mon, May 04, 2009 at 05:33:05AM -0700, bconnors wrote:
> I created a mysite.db in my directory by vi.

It's highly unlikely that you will be able to create a valid
SQLite database using a text editor.  You should delete that file,
then expect it to be created when you run the 'syncdb' command.

-- 
Phil Mocek

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Recommendation of wiki plugin

2009-05-04 Thread Ben Lau

Hi,

  I am building a website that will hold on google app engine. The
website need a wiki module, but there
have few django wiki module available. Could somebody recommend a one for use?

That is my requirements:
- Able to upload file
- No anonymous editing
- History tracking. Able to check who edited the page , diff the
version , and revert.

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread Masklinn

On 4 May 2009, at 14:55 , pbzRPA wrote:
> On May 4, 1:24 pm, Masklinn  wrote:
>> On 4 May 2009, at 12:47 , pbzRPA wrote:
>>
>>> I would do the following.
>>
>>> from django.http import HttpResponseRedirect
>>> from django.core.urlresolvers import reverse
>>
>>> def deleteItems(request, item):
>>
>>>return HttpResponseRedirect(reverse('app.views.showItems'))
>>
>> FWIW the `'app.views.showItems'` isn't even necessary, you can just
>> pass the view function and reverse will figure out the rest, so
>>
>>  return HttpResponseRedirect(reverse(showItems))
>>
>> is, in fact, sufficient.
>
> That is correct but only if the function resides in the same file that
> the reverse function is used.
Unless you import it yes, but in this case the function *does* reside  
in the same file.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do I set a foreign key as a primary key?

2009-05-04 Thread pbzRPA



On May 4, 3:07 pm, pbzRPA  wrote:
> On May 3, 6:52 pm, Malcolm Tredinnick 
> wrote:
>
>
>
> > On Sun, 2009-05-03 at 09:03 -0700, Thierry wrote:
> > > I have the following model:
>
> > > class Person(models.Model):
> > >     person = models.ForeignKey(User)
> > >     age = models.IntegerField()
>
> > > How can I set the above foreign key to be my primary key so that my
> > > Person table only contains two columns (person, age)?
>
> > The same way you set any other model field to be a primary key. Have a
> > look at the model fields documentation for the common options for all
> > fields:http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fi...
>
> > Regards,
> > Malcolm
>
> class Person(models.Model):
>      person = models.ForeignKey(User, primary_key = True)
>      age = models.IntegerField()

You should also use the "db_column" option so that the model does not
look for a "person_id" field.

class Person(models.Model):
 person = models.ForeignKey(User, primary_key = True, db_column =
'person')
 age = models.IntegerField()

Regards
Pbzrpa

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How do I set a foreign key as a primary key?

2009-05-04 Thread pbzRPA



On May 3, 6:52 pm, Malcolm Tredinnick 
wrote:
> On Sun, 2009-05-03 at 09:03 -0700, Thierry wrote:
> > I have the following model:
>
> > class Person(models.Model):
> >     person = models.ForeignKey(User)
> >     age = models.IntegerField()
>
> > How can I set the above foreign key to be my primary key so that my
> > Person table only contains two columns (person, age)?
>
> The same way you set any other model field to be a primary key. Have a
> look at the model fields documentation for the common options for all
> fields:http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fi...
>
> Regards,
> Malcolm

class Person(models.Model):
 person = models.ForeignKey(User, primary_key = True)
 age = models.IntegerField()
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread pbzRPA



On May 4, 1:24 pm, Masklinn  wrote:
> On 4 May 2009, at 12:47 , pbzRPA wrote:
>
> > I would do the following.
>
> > from django.http import HttpResponseRedirect
> > from django.core.urlresolvers import reverse
>
> > def deleteItems(request, item):
>
> >    return HttpResponseRedirect(reverse('app.views.showItems'))
>
> FWIW the `'app.views.showItems'` isn't even necessary, you can just  
> pass the view function and reverse will figure out the rest, so
>
>      return HttpResponseRedirect(reverse(showItems))
>
> is, in fact, sufficient.

That is correct but only if the function resides in the same file that
the reverse function is used.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sequence number generation

2009-05-04 Thread mettwoch

Read, re-read and then ask a question ;-). So I'm answering my
question myself: Use the TransactionMiddleware to tie together the two
updates.

On Apr 29, 3:20 pm, mettwoch  wrote:
> Hi,
>
> I'm rather new to Django (and webapp development) and I'd appreciate
> any advice on the following problem.
>
> I've a model named 'document' that can hold any kind of documents like
> customer invoices, supplier invoices, goods returned, ..., but I've to
> ensure that the customer invoices be numbered in sequence regardless
> of the fact that there may be one customer invoice entered in the
> system and then some supplier invoices and then again some customer
> invoices. I've also a model holding the 'document type'. That model
> could hold an Integer Field that is incremented at the creation of
> every document type separately, but that has to be done in a
> transaction together with the document creation:
>
> begin-transaction
>     document_type['customer invoice'].number += 1
>     d = document(number = document_type['customer invoice'].number,
> document_type = 'customer invoice', ...
>     ...
> end-transaction
>
> Is that kind of mechanism working? Do you have any other suggestion?
>
> Kind regards
> Marc
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: i've looked at other discussions regarding the error “unable to open database file”

2009-05-04 Thread bconnors

pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite$

DATABASE_ENGINE = 'sqlite3'   # 'postgresql_psycopg2',
'postgresql', 'my
sql', 'sqlite3' or 'ado_mssql'.
DATABASE_NAME = '/django-trunk/build/lib/django/bin/mysite/mysite/
mysite.db'
 # Or path to database file if using sqlite3.
DATABASE_USER = '' # Not used with sqlite3.
DATABASE_PASSWORD = '' # Not used with sqlite3.
DATABASE_HOST = '' # Set to empty string for localhost.
Not used wit
h sqlite3.
DATABASE_PORT = '' # Set to empty string for default. Not
used with
sqlite3.
I created a mysite.db in my directory by vi. Because I looked at an
earlier discussion that said:
For your DATABASE_NAME, try using an absolute path without the tilde
(~)
shortcut, that might solve it:
DATABASE_NAME = '/home/ssk/Projects/mysites/mysite/mysite.db'
So is that mysites/mysite/mysite.db a real file?

I made a mysite directory and mysite.db, but get same error when I do
python manage.py syncdb :
File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
base.py", li
ne 170, in _cursor
self.connection = Database.connect(**kwargs)
sqlite3.OperationalError: unable to open database file


On May 4, 8:08 am, bconnors  wrote:
> I’m getting the error “unable to open database file”
>
> I have sqlite3:
>
> pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite$ python
> Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
> >>> import sqlite3
>
> I have in ubuntu:
> "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3
>
> I saw an earlier chat with:
> For your DATABASE_NAME, try using an absolute path without the tilde
> (~)
> shortcut, that might solve it:
> DATABASE_NAME = '/home/ssk/Projects/mysites/mysite/mysite.db'
> So is that mysites/mysite/mysite.db a real file?
>
> I have my django working in:
> Django-trunk/build/lib/django/bin/mysite
> When I do pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite$
> python manage.py runserver
> I get the message starting with:
> It worked!
> Congratulations on your first Django-powered page.
> When I do python manage.py syncdb I get:
> File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
> base.py", li
> ne 170, in _cursor
>     self.connection = Database.connect(**kwargs)
> sqlite3.OperationalError: unable to open database file
> pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite$
>
> sorry for the bother, but what can i do?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



i've looked at other discussions regarding the error “unable to open database file”

2009-05-04 Thread bconnors

I’m getting the error “unable to open database file”

I have sqlite3:

pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite$ python
Python 2.5.2 (r252:60911, Jul 31 2008, 17:28:52)
[GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sqlite3

I have in ubuntu:
"/usr/lib/python2.5/site-packages/django/db/backends/sqlite3


I saw an earlier chat with:
For your DATABASE_NAME, try using an absolute path without the tilde
(~)
shortcut, that might solve it:
DATABASE_NAME = '/home/ssk/Projects/mysites/mysite/mysite.db'
So is that mysites/mysite/mysite.db a real file?

I have my django working in:
Django-trunk/build/lib/django/bin/mysite
When I do pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite$
python manage.py runserver
I get the message starting with:
It worked!
Congratulations on your first Django-powered page.
When I do python manage.py syncdb I get:
File "/usr/lib/python2.5/site-packages/django/db/backends/sqlite3/
base.py", li
ne 170, in _cursor
self.connection = Database.connect(**kwargs)
sqlite3.OperationalError: unable to open database file
pubu...@pubuntu:~/django-trunk/build/lib/django/bin/mysite$

sorry for the bother, but what can i do?

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: annotation and grouping

2009-05-04 Thread omat * gezgin.com

Thanks for the detailed reply Russ.

I added a boolean field to the model to specify the most current entry
for the user, updated with save(), thus letting me to fetch records of
the most current entries with a simple query.

I think de-normalization and avoiding expensive complex aggregate
queries is the most civilized way to go.


Best,
oMat



On Apr 29, 3:12 pm, Russell Keith-Magee 
wrote:
> On Wed, Apr 29, 2009 at 4:08 PM,omat wrote:
>
> > Hi all,
>
> > I would like to fetch the latest entries for each user from a model
> > like:
>
> > class Entry(models.Model):
> >    user = models.ForeignKey(User)
> >    entry = models.TextField()
> >    date = models.DateTimeField(auto_now_add=True)
>
> > Is it possible with the current API with a single query?
>
> Not easily. You can get the date of the most recent entry for each user:
>
> Entry.objects.values('user').annotate(Max('date'))
>
> but you can't get the full entry object for each date without using
> extra() or doing some other join gymnastics.
>
> > I.e., wouldn't it be great to have something like:
>
> > Entry.objects.annotate(Max('added'), group_by=['user']).filter
> > (date=date__max)
>
> And what does this mean in SQL? Once you've posed your original
> question in SQL, you may see why your proposal isn't really viable.
>
> If you're a MySQL user, I'm sure your initial suggestion will be something 
> like:
>
> SELECT id, user_id, entry, MAX("date") FROM entries GROUP BY user_id
>
> The problem is that while this is legal for MySQL (and SQLite), this
> isn't legal SQL on other backends (notably Postgres; I'm pretty sure
> Oracle is in the same boat). The problem is that Postgres requires
> that every field that isn't an aggregate be part of the GROUP BY
> clause. This is for a very good reason - which value for id and entry
> should be included in the result set?
>
> If the problem isn't clear, consider the following slightly modified query:
>
> SELECT id, user_id, entry, MAX("date"), MIN("date") FROM entries GROUP
> BY user_id
>
> Now - which entry and ID should be included in the results? The one
> corresponding to the MAX or the MIN?
>
> The problem here is that SQLite and MySQL are lax when it comes to the
> relational algebra. For simple cases, this laxness may not matter, but
> for non-trivial cases it matters a great deal.
>
> To address the group_by suggestion specifically - we deliberately
> avoided adding explicit support for group_by. Django's ORM attempts to
> look like a collection of Objects, not a wrapper around SQL. GROUP BY
> is a very SQL heavy concept that doesn't have much meaning with other
> backends.
>
> In order to do this in a purely relational sense, you need to use an
> inner query to build the table of userid-max date, then join this
> result with the original entries to select the rows where the user ids
> and dates match. However, queries like this aren't easy to compose in
> using pure Django ORM syntax.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread Masklinn

On 4 May 2009, at 12:47 , pbzRPA wrote:
> I would do the following.
>
> from django.http import HttpResponseRedirect
> from django.core.urlresolvers import reverse
>
> def deleteItems(request, item):
>
>return HttpResponseRedirect(reverse('app.views.showItems'))

FWIW the `'app.views.showItems'` isn't even necessary, you can just  
pass the view function and reverse will figure out the rest, so

 return HttpResponseRedirect(reverse(showItems))

is, in fact, sufficient.

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to handle view/url situation (Newbie)

2009-05-04 Thread pbzRPA

I would do the following.

from django.http import HttpResponseRedirect
from django.core.urlresolvers import reverse

def deleteItems(request, item):

return HttpResponseRedirect(reverse('app.views.showItems'))
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Databrowse

2009-05-04 Thread Russell Keith-Magee

On Mon, May 4, 2009 at 3:58 PM, skyl  wrote:
>
> Who is working on databrowse?  What is the status?  Does anyone have
> links where I can trac this app?

django.contrib.databrowse is part of the Django core. This means that
it is part of the normal Django development process. Anyone wishing to
contribute to databrowse is free to do so. Any problems are logged in
Django's Trac instance [1].

[1] http://bit.ly/j5zr2

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django custom operators DB Backend

2009-05-04 Thread pbzRPA

I would like to know if anyone knows how to create custom operators
for querysets.

Currently you can do something like:

foo.objects.filter(myfield__icontains = x)

I would like to add my own operator so I can do something like:

foo.objects.filter(myfield__converttext = x)

where "converttext" would be my own operator. Currently there a few
operators in the django/db/backends/mysql/base.py:

operators = {
   'exact': '= %s',
   'iexact': 'LIKE %s',
   'contains': 'LIKE BINARY %s',
   'icontains': 'LIKE %s',
   'regex': 'REGEXP BINARY %s',
   'iregex': 'REGEXP %s',
   'gt': '> %s',
   'gte': '>= %s',
   'lt': '< %s',
   'lte': '<= %s',
   'startswith': 'LIKE BINARY %s',
   'endswith': 'LIKE BINARY %s',
   'istartswith': 'LIKE %s',
   'iendswith': 'LIKE %s',
   }

I would like to add to this dict without modifying the django code.

Any help would be appreciated.
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unhandled Exception

2009-05-04 Thread Jarek Zgoda

Wiadomość napisana w dniu 2009-05-04, o godz. 11:04, przez Raashid:

> An unhandled exception was thrown by the application.
> I m getting this error on form submit even though same code is working
> fine locally. I m using django and cherokee web server .


This is caused by error thrown by flup before django's 500 handler is  
loaded, eg. something wrong with your settings module. To see the  
actual error you can start the app with runfcgi debug=true.

-- 
We read Knuth so you don't have to. - Tim Peters

Jarek Zgoda, R&D, Redefine
jarek.zg...@redefine.pl


--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Unhandled Exception

2009-05-04 Thread Raashid

An unhandled exception was thrown by the application.
I m getting this error on form submit even though same code is working
fine locally. I m using django and cherokee web server .

Thanks in anticipation
Raashid Malik

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: models.py general help

2009-05-04 Thread sanket agarwal
The solution to the problem was to extend the Python's save method... here's
a snippet of the following:

def save(self, force_insert=False, force_update=False):
"""Update the size field and save the record"""

if self.filepath:
self.filesize=os.path.getsize(self.filepath)/(1024.0*1024.0) #
Size in MB's
super(Files, self).save(force_insert,force_update)

So this closes the thread as far as my query is concerned :)

On Sun, May 3, 2009 at 8:07 PM, Michael  wrote:

> On Sun, May 3, 2009 at 9:15 AM, Sanket Agarwal wrote:
>
>>
>> 
>
>
>> class Files(models.Model):
>>
>>"""Uploads area, all files to be ready for user use are put here"""
>>
>>
>>filepath = models.FilePathField(_('Choose
>> File'),path="/home/sanket/
>> Music")
>>filedescription = models.CharField(_('File
>> Description'),max_length=100)
>>filetype = models.CharField(_('File
>> Type'),max_length=1,choices=FILETYPE_CHOICE)
>>
>>fileuploadtime = models.DateTimeField(_('File Upload Time'))
>>
>>def __unicode__(self):
>>return self.filepath
>>
>>class Admin:
>>list_display  =
>> ('filepath','filesize','fileuploaddate','fileuploadtime')
>>list_filter   = ('fileuploaddate')
>>
>>def getSizeFromFilePath(filepath):
>>return os.path.getsize(filepath)
>>
>>filesize = getSizeFromFilePath(filepath)
>>
>
> A few things. One if you want a method to be available outside a class, the
> first argument is always 'self', which is the class instance itself. That is
> why the filepath isn't working there. Second to add a property to a class
> you need to declare it as a property, otherwise you are changing the class
> itself, not the instance.
>
> Take a look at the class documentation:
> http://docs.python.org/tutorial/classes.html
> and the property builtin:
> http://docs.python.org/library/functions.html#property
>
> Other than that, that appears to be the right idea to accomplish what you
> are looking for.
>
> I hope that helps,
>
> Michael
>
>
> >
>

--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Databrowse

2009-05-04 Thread skyl

Who is working on databrowse?  What is the status?  Does anyone have
links where I can trac this app?
--~--~-~--~~~---~--~~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---