Re: reuse of contrib.admin code for normal users

2006-06-17 Thread Ian Holsman
on each poll add something like user = models.ForeignKey(User, null=True, blank=True) in the update/create views add something like if request.user.is_anonymous(): return redirect_to_login(request.path) try: poll = Poll.objects.get( id= id ) except

reuse of contrib.admin code for normal users

2006-06-17 Thread djx
Hi, wishing to confirm if anyone has managed to do something similar. Using terms from the tutorial at www.djangoproject.com, i wish to - allow users (possibly upto 70 users) to create their own Polls/choices - but not (at least not easily) alter the Polls/choices that other users have created

Re: POST to view loses POST data

2006-06-17 Thread Adrian Holovaty
On 6/17/06, James Bennett <[EMAIL PROTECTED]> wrote: > I'm not convinced that it'd be a good thing to have request.POST > evaluate to True in these cases, but the reasoning is somewhat > pedantic. > > First and foremost, there's a logical difference between the request > method and the request

Free Comments Documented

2006-06-17 Thread Tyson Tate
I'm a strong believer is good documentation and there's a lot of places Django could use better documentation. I encourage everyone to add documentation to the wiki for things that aren't documented or have sparse documentation. I started with Django's free comments. Check it out and help

Re: POST to view loses POST data

2006-06-17 Thread Jeremy Dunck
On 6/17/06, James Bennett <[EMAIL PROTECTED]> wrote: > I'm not convinced that it'd be a good thing to have request.POST > evaluate to True in these cases, but the reasoning is somewhat > pedantic. I put the comment on the ticket. The use of request.POST seems overloaded to mean both "is it a

Re: Automatic create form construction?

2006-06-17 Thread Malcolm Tredinnick
On Sat, 2006-06-17 at 17:59 -0700, [EMAIL PROTECTED] wrote: > I'd like to have a non-admin interface for adding objects, but would > like to use the form that the admin interface generates. Where do I > snag it from? django/contrib/admin/templates/admin/* Start with change_form.html in that

Re: POST to view loses POST data

2006-06-17 Thread James Bennett
On 6/17/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > There is already a way to test for posts via the request object: > request.META['REQUEST_METHOD']. But your suggestion is not unreasonable, > so best to file a ticket so that it can be considered without being > forgotten. I'm not

Re: POST to view loses POST data

2006-06-17 Thread Jeremy Dunck
On 6/17/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > There is already a way to test for posts via the request object: > request.META['REQUEST_METHOD']. But your suggestion is not unreasonable, > so best to file a ticket so that it can be considered without being > forgotten. Filed:

Re: POST to view loses POST data

2006-06-17 Thread Jeremy Dunck
On 6/17/06, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > The implementation side is easy, if we decided to go this route: make > sure that __nonzero__() on the MultiValueDict class returns the right > thing in these cases. Sorry, I dug around in python introspection docs a bit trying to find

Re: POST to view loses POST data

2006-06-17 Thread Max Battcher
Jeremy Dunck wrote: > On 6/17/06, Luke Plant <[EMAIL PROTECTED]> wrote: >> Long version: >> request.POST is (essentially) a dictionary of post variables. As such, >> if it is empty, it evaluates to False, even if the request method is >> 'POST'. In your form, you don't have a single

Automatic create form construction?

2006-06-17 Thread [EMAIL PROTECTED]
I'd like to have a non-admin interface for adding objects, but would like to use the form that the admin interface generates. Where do I snag it from? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users"

Re: POST to view loses POST data

2006-06-17 Thread Malcolm Tredinnick
On Sat, 2006-06-17 at 19:44 -0500, Jeremy Dunck wrote: > On 6/17/06, Luke Plant <[EMAIL PROTECTED]> wrote: > > Long version: > > request.POST is (essentially) a dictionary of post variables. As such, > > if it is empty, it evaluates to False, even if the request method is > > 'POST'. In your

Re: POST to view loses POST data

2006-06-17 Thread Jeremy Dunck
On 6/17/06, Luke Plant <[EMAIL PROTECTED]> wrote: > Long version: > request.POST is (essentially) a dictionary of post variables. As such, > if it is empty, it evaluates to False, even if the request method is > 'POST'. In your form, you don't have a single 'successful' field -- > the only

POST to view loses POST data

2006-06-17 Thread jacob
Yes, I've read http://code.djangoproject.com/wiki/NewbieMistakes This is my URL list: urlpatterns = patterns('', (r'^admin/', include('django.contrib.admin.urls')), (r'^settings/$','file.app.views.settings'), (r'^inbox/$','file.app.views.inbox'),

Re: Custom manager filter by logged in user.

2006-06-17 Thread Adam Hoscilo
Not that way anymore. I will just check (in the middleware) if the requested entry's author is the logged in user (for edit action) if not throw exception. -- Adam Hoscilo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: Custom manager filter by logged in user.

2006-06-17 Thread ToddG
Just curious -- so now you're going to tie your middleware to the model? ;-) The MV(C|T) police will come after you! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Custom manager filter by logged in user.

2006-06-17 Thread Adam Hoscilo
You're right - my fault. It just isn't the way I would like to handle this problem. But I've forgotten about middleware and I think this will be the best way to solve this _issue_ without breaking MVC(MVT) schema (just check if the requested object was created by user).

Re: Custom manager filter by logged in user.

2006-06-17 Thread ToddG
But Luke *is* proposing to do this in a manager. The middleware just makes the current user available in the model/manager. (if you want it to be) Rather than a hack, the functionality that his middleware module provides seems to me a missing part in a mostly very pragmatic codebase, but I

Re: get_absolute_url + date_based generic views

2006-06-17 Thread Jay Parlar
On 6/17/06, James Bennett <[EMAIL PROTECTED]> wrote: > > On 6/17/06, Jay Parlar <[EMAIL PROTECTED]> wrote: > > def get_absolute_url(self): > > return "/articles/" + self.pub_date.replace("-","/") + "/" + self.slug > > > > But it seems like there'd be a cleaner way (ie. not having to call > >

Re: get_absolute_url + date_based generic views

2006-06-17 Thread James Bennett
On 6/17/06, Jay Parlar <[EMAIL PROTECTED]> wrote: > def get_absolute_url(self): > return "/articles/" + self.pub_date.replace("-","/") + "/" + self.slug > > But it seems like there'd be a cleaner way (ie. not having to call 'replace') def get_absolute_url(self): return "/articles/%s/%s"

get_absolute_url + date_based generic views

2006-06-17 Thread Jay Parlar
Maybe it's too hot, and my mind isn't working straight, but I can't figure out the best way to write my 'get_absolute_url' for objects that will live in date based URLs, ie. class Article(models.Model): title = models.CharField(...) slug = models.SlugField(...) pub_date =

Re: Hosting a Django project in Bluehost

2006-06-17 Thread Eugene Lazutkin
[EMAIL PROTECTED] wrote: > Hi all, > I'm trying to run a project hosted in Bluehost, it only supports fcgi. > I'm an apache guy. > Anyone have a project maded with Django hosted in Bluehost? I don't use Bluehost, but I think the setup will be similar to Django on DreamHost, which supports

French translation of Django documentation

2006-06-17 Thread David Larlet
Hi! I'm glad to announce the french translation of Django tutorials. http://www.biologeek.com/journal/index.php/traduction-francaise-de-la-documentation-de-django-le-framework-web-python I hope it's just the beginning, feel free to add corrections and/or to participate. Cheers, David Larlet

Re: Divide list in a template

2006-06-17 Thread Wilson Miner
I don't know of a way to do this by a calculated fraction of the total items in the list, but you can use the slice filter to break it up into groups of a set number: {% for object in object_list|slice:":5" %} {% for object in object_list|slice:"5:10" %} etc. There's also a handy trick if you

Re: How install mysqldb under CentOS3 (or enable pyvault?)

2006-06-17 Thread Ramiro Morales
On 6/16/06, mamcxyz <[EMAIL PROTECTED]> wrote: > > Sorry, when I say easy_setup I mean easy_install ;) > > (I run it easy_install-2.4 mysql-python) > You need to have the develpment support files (headers, libraries) of the zlib package installed (zlib-devel package in RHL/FC/CentOS?) Anyway,

Re: Custom manager filter by logged in user.

2006-06-17 Thread Luke Plant
On Saturday 17 June 2006 10:50, Adam Hoscilo wrote: > I would like to filter entries from a logged in user and give him/her > the ability to edit them - it would be nice to ensure that scope by > manager. > As far as I know Models don't have access to request and session data > (and I realize

Custom manager filter by logged in user.

2006-06-17 Thread Adam Hoscilo
I would like to filter entries from a logged in user and give him/her the ability to edit them - it would be nice to ensure that scope by manager. As far as I know Models don't have access to request and session data (and I realize it's a MVC/MVT schema violation). Is there any way to manage that

Divide list in a template

2006-06-17 Thread James Stembridge
Hi, Is there a way to split a list using the built-in tags and filters? What I want is to take an object list from a generic view and iterate over the first and second halfs separetely. e.g. {% for object in object_list|firsthalf %} ... {% endfor %} {% for object in object_list|secondhalf %}

Hosting a Django project in Bluehost

2006-06-17 Thread nm
Hi all, I'm trying to run a project hosted in Bluehost, it only supports fcgi. I'm an apache guy. Anyone have a project maded with Django hosted in Bluehost? Thanks, Nuno --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google

Re: How to re-use the admin contrib ?

2006-06-17 Thread william
oggie rob wrote: > > I've thought about an url like "/company1/admin" that will display me only > > the "periodical" and "article" that belongs to company1. > > Just be sure this is what you want. There may be times where you wish > to completely separate each company's data - in which case,