Re: custom method in models.py

2011-07-15 Thread Kenneth Gonsalves
On Fri, 2011-07-15 at 11:14 -0700, Suprnaturall wrote: > class Category(models.Model): > name = models.CharField(max_length=250) > > def get_short_name(): > return name[0,20] def get_short_name(self) -- regards KG http://lawgon.livejournal.com Coimbatore LUG rox

Re: blog breack after 10 post x__x

2011-07-15 Thread Venkatraman S
What you need is a paginator, which paginates through the objects. Try using endless_pagination. Its an awsum app. -V -- 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

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Venkatraman S
The below email contents can go into the django wiki? Explained in a lucid manner. Actually, it would be awesome, if someone from this group can volunteer to extract useful text explanations from this ML and put in the wiki. I would have done it, but i lost my password, and i dont see a 'forgot

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Russell Keith-Magee
On Fri, Jul 15, 2011 at 5:18 PM, Paul Walsh wrote: > I am pretty new to Django - new enough to be developing my first Django app > on 1.3. So, I am basing all my work on class-based generic views, and have > never used the older generic view functions. > A problem I have is

Re: django.core.urlresolvers.reverse capturing group before include behavior

2011-07-15 Thread Jian Chang
try this: reverse("mysites.views.index") 2011/7/16 Squeesh > I have run into an issue using reverse() to lookup named urls with > capturing groups before an include(). > > Code: > > mysite/urls.py > from django.conf.urls.defaults import * > > urlpatterns =

Re: blog breack after 10 post x__x

2011-07-15 Thread Jian Chang
2011/7/16 Jian Chang > django doesn't have, > but you can extent based on django.core.paginator.Paginator.The attachment > is what i use, you can change it by your needs > > > > > 2011/7/16 Kase > >> realy i dont know how to expres this.. >> >> i

Re: blog breack after 10 post x__x

2011-07-15 Thread Jian Chang
django doesn't have, but you can extent based on django.core.paginator.Paginator.The attachment is what i use, you can change it by your needs 2011/7/16 Kase > realy i dont know how to expres this.. > > i need this > (is a blog app) > > 1) post > 2)post > 3)post > ... >

blog breack after 10 post x__x

2011-07-15 Thread Kase
realy i dont know how to expres this.. i need this (is a blog app) 1) post 2)post 3)post ... 10)post page 1,2,3,4,5,6,7,8.last when clic 2 list of post are 11)post 12)post 20)post django have somthing to do this in the easiest my code is the (obius) {%for x in post%}

django.core.urlresolvers.reverse capturing group before include behavior

2011-07-15 Thread Squeesh
I have run into an issue using reverse() to lookup named urls with capturing groups before an include(). Code: mysite/urls.py from django.conf.urls.defaults import * urlpatterns = patterns('', url(r'^$', 'views.index', name='root'),

Re: installing django

2011-07-15 Thread Javier Guerra Giraldez
On Fri, Jul 15, 2011 at 3:40 PM, Andre Terra wrote: > Do you have a strong reason for running windows on your host? > Developing/deploying django on linux is about a billion times easier. could be wrong; but i think the hard part is not because of the OS, but because of

Re: custom method in models.py

2011-07-15 Thread bruno desthuilliers
On 15 juil, 20:14, Suprnaturall wrote: > Hi, > > I'm wondering if like in play or symfony you can develop special > method for each class/table in the models.py and use them in your > template. Of course. A model is "just" a Python class (well, with some "magic" but...). >

Re: installing django

2011-07-15 Thread Andre Terra
Do you have a strong reason for running windows on your host? Developing/deploying django on linux is about a billion times easier. Cheers, André On Fri, Jul 15, 2011 at 5:35 PM, Charles wrote: > I have a windows account on Hostgator.com and would like to install and >

Re: filter cache output

2011-07-15 Thread Rob
On Jul 15, 8:57 pm, Nan wrote: > Well, you can use one of the methods from [2] to force the queryset to > evaluate before caching it.  But you'll still run a new query in order > to filter, unless you aftually filter the data in your Python code. Very clear, thanks! -- You

installing django

2011-07-15 Thread Charles
I have a windows account on Hostgator.com and would like to install and django. Hostagator is a little lacking in documentations, so does anyone have any idea of how to get things going? Charles -- You received this message because you are subscribed to the Google Groups "Django users"

Re: Setting up Django with fastCGI on centos with apache

2011-07-15 Thread ionic drive
Hello Rick, Address already in use, tells you that on 127.0.0.1 specific port 8000 already a process is running. I guess you have your Apache already running their, right!? you have to listen with your Apache to the proper port where fastcgi is serving the data for Apache. I think you have to

Setting up Django with fastCGI on centos with apache

2011-07-15 Thread Rick Beacham
I'm having alot of trouble with setting up django with fastCGI. I was able to use the default test server made with django no problem. But I'm having trouble setting it up with httpd and fastCGI in scientific linux(centos).. Here is the error message after running this command ./manage.py

Re: custom method in models.py

2011-07-15 Thread nicolas HERSOG
Oh crap i m feel ashame... Thanx for your help ! On Fri, Jul 15, 2011 at 8:46 PM, Shawn Milochik wrote: > On 07/15/2011 02:14 PM, Suprnaturall wrote: > >> def get_short_name(): >>return name[0,20] >> > > Try this: > def get_short_name(self): > >return

Re: filter cache output

2011-07-15 Thread Nan
Well, you can use one of the methods from [2] to force the queryset to evaluate before caching it. But you'll still run a new query in order to filter, unless you aftually filter the data in your Python code. On Jul 15, 2:46 pm, Rob wrote: > On Jul 15, 8:34 pm, Nan

Re: custom method in models.py

2011-07-15 Thread Shawn Milochik
On 07/15/2011 02:14 PM, Suprnaturall wrote: def get_short_name(): return name[0,20] Try this: def get_short_name(self): return self.name[0:20] You need 'self' in two places, and I assume you want a string of the first 20 characters rather than a list of the first and

Re: filter cache output

2011-07-15 Thread Rob
On Jul 15, 8:34 pm, Nan wrote: > Querysets are evaluated lazily.[1][2]  You may have better success > using template fragment caching[3] to cache the menu output. > Thanks for the reply. I read the part about the "lazy" querysets and therefore I suspected the database not to

Re: Add attributes (css-class) to formfield

2011-07-15 Thread Andreas Pfrengle
Tom, it's really so easy, thank you! Seems now I've learned the hard way how forms and fields are working ;-) Andreas -- 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

Re: filter cache output

2011-07-15 Thread Nan
Querysets are evaluated lazily.[1][2] You may have better success using template fragment caching[3] to cache the menu output. [1] https://docs.djangoproject.com/en/dev/topics/db/queries/#querysets-are-lazy [3]

filter cache output

2011-07-15 Thread Rob
I have setup caching with memcached for my site. This works well except from this part of my view. My idea was to store all menu items in the cache, and apply a filter later on to decide if they belong to the left or top menu. menu = cache.get(menu_cache_key) if menu:

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread nicolas HERSOG
Oh sorry, I knew that my sql query was naive, but my question was really about how to use group by and retrieve data throug my template :/ I'm really sorry for waste your time with stupid sql. Nevertheless a great thank you for your help. I'm going to do like you say and in few times, try to

custom method in models.py

2011-07-15 Thread Suprnaturall
Hi, I'm wondering if like in play or symfony you can develop special method for each class/table in the models.py and use them in your template. I'm trying few things but it didn't work. For exemple this is my models.py : class Category(models.Model): name = models.CharField(max_length=250)

Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread Andre Terra
> I'll give a weak vote for C: They can be, and presumabley have been, made > to > work correctly, in a peer reviewed setting, by folks with significant > experience, > so having the less experienced noob implement his own is a little like > saying > that you should implement your own encryption

Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread Bill Freeman
On Fri, Jul 15, 2011 at 12:44 PM, Andre Terra wrote: > Shawn, > > > Chalk one up for option A. > > I never, ever, ever, use them and they can get dropped for all I care, > considering how easy they are to implement "manually". > > They are also my go-to example for teaching

Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread bruno desthuilliers
On 15 juil, 18:22, Shawn Milochik wrote: > A discussion broke out in our office today about using these features, > because there are blog posts[1] bashing them and a comment by JKM > saying they should go away[2]. > > It seems that all of the arguments against are based on

Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread John DeRosa
On Jul 15, 2011, at 9:22 AM, Shawn Milochik wrote: > Considering these facts, I'm wondering what the consensus is in the community: > >A. They're still there because they're too annoying to deprecate > or just not important enough to spend time on. > >B. They're useful shortcuts and

Re: auto_now, auto_now add -- good or bad?

2011-07-15 Thread Andre Terra
Shawn, Chalk one up for option A. I never, ever, ever, use them and they can get dropped for all I care, considering how easy they are to implement "manually". They are also my go-to example for teaching new users how to modify their model's save method and I believe the shortcuts only add

auto_now, auto_now add -- good or bad?

2011-07-15 Thread Shawn Milochik
A discussion broke out in our office today about using these features, because there are blog posts[1] bashing them and a comment by JKM saying they should go away[2]. It seems that all of the arguments against are based on the fact that there were bugs in the past (links in the comments of the

Re: How to configure pgAdminIII

2011-07-15 Thread Simon Riggs
On Fri, Jul 15, 2011 at 4:22 PM, How to configure pgAdminIII wrote: > I recently installed Django, but yet to know how to configure the > pgAdminIII probably which supports DB for Django apps. > http://postimage.org/image/13ynpagx0/ > > This the link which shows I'm

Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread Daniel Roseman
On Friday, July 15, 2011 4:38:08 PM UTC+1, Derick Felsman wrote: > > Well i can install apache and django just fine, but if I download the > wsgi source and use the make command on the makefile generated from > the configure script i ended up getting an error. upon some research > i discovered

Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread Derick Felsman
Well i can install apache and django just fine, but if I download the wsgi source and use the make command on the makefile generated from the configure script i ended up getting an error. upon some research i discovered that xcode 4 removed support for the ppc architecture so you have to manually

Re: How to configure pgAdminIII

2011-07-15 Thread Bill Freeman
The information that you need to fill in this form is the same information that you used to configure the DB connection in setings.py. The "name" is arbitrary, something you can use to identify which DB you want to administer when pgAdmin knows about several. 5432 is the default PostgreSQL port,

How to configure pgAdminIII

2011-07-15 Thread How to configure pgAdminIII
Hi Django users, I recently installed Django, but yet to know how to configure the pgAdminIII probably which supports DB for Django apps. http://postimage.org/image/13ynpagx0/ This the link which shows I'm stuck with. Can anyone guide me what I should do with the form. And anyone tell me how to

Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread i...@webbricks.co.uk
you need xcode to compile stuff like PIL, which most django projects need. then im stuck, for me the dev server is good enough for development on a mac. OP, why not use the dev server and leave apache where its best, in production on a linux server. (IMO?) On Jul 15, 2:54 pm, Javier Guerra

Re: FTP prefic in URL field

2011-07-15 Thread Tim Shaffer
Yeah, it doesn't look like 1.1 allowed for ftp protocol: https://github.com/django/django/blob/1.1.X/django/forms/fields.py#L545 Best bet might be to create your own URLField class and overwrite the __init__ method to use your own regular expression. Kind of a pain. It's a little easier in

Re: FTP prefic in URL field

2011-07-15 Thread ggavy
Hi Tim, I'm getting the 'Enter a valid URL.' error returned. I am however using Django 1.1, and thought that was the issue (I'm not sure where to look for the validator.py in this older version, but I think Iread somewhere that ftp wasn't in the regex at that version). Migrating to 1.2 isn't

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread bruno desthuilliers
On Jul 15, 2:53 pm, nicolas HERSOG wrote: > Of course, and thanks for your help :) > > This is the rows of my first table Video : > id | name | category_id | date > 1 | vids1 | 1 | dd-jj- > 2 | vids2 | 1 | dd-jj- > 3 | vids3 | 1 | dd-jj- > 4 | vids4 | 2 |

Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread Javier Guerra Giraldez
On Thu, Jul 14, 2011 at 5:22 PM, Derick Felsman wrote: > Hi, > > I'm brand new to django and have been having trouble setting it up > with apache and mod_wsgi on my new mac with xcode 4 installed.  All > the resources i've been able to find are either outdated

Re: Django: forms and custom templates

2011-07-15 Thread Javier Guerra Giraldez
On Fri, Jul 15, 2011 at 6:41 AM, samuele.mattiuzzo wrote: > Nope, what i wanted to achieve is just to have django forms spawn my > custom html instead of the default one. note that you can simply not use the form rendering, simply use your HTML (in a template, or even on a

Re: FTP prefic in URL field

2011-07-15 Thread Tim Shaffer
It looks like the URLValidator should in fact accept ftp: https://github.com/django/django/blob/master/django/core/validators.py#L46 What's the specific error you're getting? -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this

FTP prefic in URL field

2011-07-15 Thread ggavy
Hi all, I'm using a URLField in a model and form. However the form validation for this does not accept 'ftp://' type prefixes. What are my options here? Do I need to write a custom field or is it possible to modify the 'validate' method on the field itself so that it includes the default URL

Re: insert an inline to a ModelAdmin at runtime

2011-07-15 Thread Marc Aymerich
On Fri, Jul 15, 2011 at 1:35 PM, Marc Aymerich wrote: > Hi, > I created a method that generates an InlineFormset at runtime and inserts > it to a given ModelAdmin. > > It works perfectly when I call my method directly on admin.py > #admin.py > admin.site.register(MyModel,

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Andre Terra
On Fri, Jul 15, 2011 at 7:37 AM, Kenneth Gonsalves wrote: > > caveat - I have never used generic views, class based or otherwise, but > I was under the impression that if one wants customised forms or views, > generic is not the way to go. > > These views are classes and

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Andre Terra
Paul, Your form logic will go on your Form (or ModelForm) definition, not on the view. As the docs [1] say, CreateView is a combination of ModelFormMixin and ProcessFormView. Please read the docs on those two mixins to understand what methods your CampaignCreate class can override, but do move

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread nicolas HERSOG
Of course, and thanks for your help :) This is the rows of my first table Video : id | name | category_id | date 1 | vids1 | 1 | dd-jj- 2 | vids2 | 1 | dd-jj- 3 | vids3 | 1 | dd-jj- 4 | vids4 | 2 | dd-jj- 5 | vids5 | 2 | dd-jj- 6 | vids6 | 3 | dd-jj- and here the rows of

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread bruno desthuilliers
On Jul 15, 10:13 am, Suprnaturall wrote: > Hi dear django users :) > > I m facing a stupid problem. > Here is my models.py : > > class Video(models.Model): >     (...) >     category = models.ForeignKey('Category') >    (...) > > class Category(models.Model): >     name =

Re: getting django working with apache and mod_wsgi on a brand new mac with xcode 4

2011-07-15 Thread Cal Leeming [Simplicity Media Ltd]
I'm sorry but I don't understand your question. Which resources are you saying are out of date?? Cal On Thu, Jul 14, 2011 at 11:22 PM, Derick Felsman < derick.fels...@cbsinteractive.com> wrote: > Hi, > > I'm brand new to django and have been having trouble setting it up > with apache and

Re: Django: forms and custom templates

2011-07-15 Thread samuele.mattiuzzo
I figured out i have to override the default form classes of django i have to create a CustomCheckboxSelectMultiple(CheckboxSelectMultiple) class and override the "render" method, making it generate the html i want for my particular cases -- You received this message because you are subscribed

Re: Django: forms and custom templates

2011-07-15 Thread samuele.mattiuzzo
Actually, i figured it out. Nope, what i wanted to achieve is just to have django forms spawn my custom html instead of the default one. I just have to subclass the main class (ex CheckboxSelectMultiple) and override the render method, then in my custom form, i add formfield_override On 15 Lug,

insert an inline to a ModelAdmin at runtime

2011-07-15 Thread Marc Aymerich
Hi, I created a method that generates an InlineFormset at runtime and inserts it to a given ModelAdmin. It works perfectly when I call my method directly on admin.py #admin.py admin.site.register(MyModel, MyModelAdmin) insert_generic_plugin_inlines(MyOtherModelAdmin) but it doesn't work when

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Michał Sawicz
Dnia 2011-07-15, pią o godzinie 16:07 +0530, Kenneth Gonsalves pisze: > caveat - I have never used generic views, class based or otherwise, > but > I was under the impression that if one wants customised forms or > views, > generic is not the way to go. Why not? The model edit views use the

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Venkatraman S
Class based views reduce the amount of code written, but i am yet to get a grasp of it(need more experimentation). Somehow, i prefer plain 'old' way of methods in views.py which respond to different urls - it gives me better control and is easily to maintain. -V -- You received this message

Re: Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Kenneth Gonsalves
On Fri, 2011-07-15 at 02:18 -0700, Paul Walsh wrote: > I am pretty new to Django - new enough to be developing my first > Django app > on 1.3. So, I am basing all my work on class-based generic views, and > have > never used the older generic view functions. caveat - I have never used generic

Class-Based Generic Views (CreateView) - field exclusions and defaults

2011-07-15 Thread Paul Walsh
I am pretty new to Django - new enough to be developing my first Django app on 1.3. So, I am basing all my work on class-based generic views, and have never used the older generic view functions. A problem I have is the lack of examples and documentation on the new class-based generic views.

Aw: Django: forms and custom templates

2011-07-15 Thread Juergen Schackmann
I am also not sure, what exactly you are looking for, but what about this: https://docs.djangoproject.com/en/1.3/topics/forms/#customizing-the-form-template so you will have complete control of your html code??? -- You received this message because you are subscribed to the Google Groups

AW: creating a simple mailbox

2011-07-15 Thread Szabo, Patrick (LNG-VIE)
Maybe one of those is something for you http://djangopackages.com/grids/g/email/ . . . . . . . . . . . . . . . . . . . . . . . . . . Patrick Szabo XSLT Developer LexisNexis Marxergasse 25, 1030 Wien mailto:patrick.sz...@lexisnexis.at Tel.: 00431 534521573 Fax: +43 (1) 534 52 - 146

Re: creating a simple mailbox

2011-07-15 Thread bh.hoseini
yes i've recently done that (to make project easier i'm covering "inbox" part first), what should i do next? that's very kind of you, thanks On Jul 14, 1:35 pm, ikatanda wrote: > have you created your views and added the url to point to the app > mailbox page? > > On Jul 14,

Re: group by and retrieve to template date from foreinKey

2011-07-15 Thread Venkatraman S
concise reply : I would strongly suggest you to have a look at django-taggit. OTOH, use django-debug-toolbar to diagnose the sql that is being fired. -V -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Re: something about django mysql database long connection

2011-07-15 Thread Kejun He
hi, I found a method to make a persistent connection to database. from django.core import signals from django.db import close_connection signals.request_finished.disconnect(close_connection) <== I have tested, it work normally! regards, he On Fri, Jul 15, 2011 at 9:44 AM, Kejun He

group by and retrieve to template date from foreinKey

2011-07-15 Thread Suprnaturall
Hi dear django users :) I m facing a stupid problem. Here is my models.py : class Video(models.Model): (...) category = models.ForeignKey('Category') (...) class Category(models.Model): name = models.CharField(max_length=250) I'm trying in a tags to make a group by on the

AW: Django: forms and custom templates

2011-07-15 Thread Szabo, Patrick (LNG-VIE)
I'm not sure if i understood your problem a 100 percent so i'll just write what i think you want ^^ >From what i understand i think you can use the code that has already been >written. Of course you might want to edit it a little bit for it to comply >with the other templates. If you want to

Django: forms and custom templates

2011-07-15 Thread samuele.mattiuzzo
basic problem: i need to create real customized templates for my django forms. That's it. I'm used to style the forms based on django's output. This time is different, the html/css template is already done (months before i was hired) and i cannot modify it, so i need django to output exactly that

AW: admin_media_prefix in page source is wrong

2011-07-15 Thread Szabo, Patrick (LNG-VIE)
I'm sorry maybe this is a dumb question but what do you mean when you say " Inside static-folder I made a link to ../../lib/python2.7/site-packages/django/contrib/admin/static/admin for the admin-media files." ?! . . . . . . . . . . . . . . . . . . . . . . . . . . Patrick Szabo XSLT

admin_media_prefix in page source is wrong

2011-07-15 Thread Bram Deprettere
I'm having the following situation; django project named inventory Made a folder static for media-files. Inside static-folder I made a link to ../../lib/python2.7/site-packages/django/contrib/admin/static/admin for the admin-media files. When I go to http://inventory/admin, the static/admin