Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Ken Chida
I tried my best to search for an answer but my efforts yielded nothing. Allow me to give you a simple example to illustrate my problem. Let's pretend that I want to have a login form on every single page on my website. Obviously, the login form will have a corresponding view function. What

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Marc Aymerich
On Sat, Feb 5, 2011 at 9:21 AM, Ken Chida wrote: > I tried my best to search for an answer but my efforts yielded nothing. > Allow me to give you a simple example to illustrate my problem.  Let's > pretend that I want to have a login form on every single page on my > website.  Obviously, the login

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Ronghui Yu
To create a separate decorator, then all other view functions are decorated by this decorator. For implement this decorator, you don't need to include the login function, just redirect to login URL. Is that what you are asking for? On Sat, Feb 5, 2011 at 6:48 PM, Marc Aymerich wrote: > On Sat, F

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread a.esmail
On Feb 5, 3:21 am, Ken Chida wrote: > I tried my best to search for an answer but my efforts yielded nothing.   > Allow me to give you a simple example to illustrate my problem.  Let's > pretend that I want to have a login form on every single page on my > website.  Obviously, the login form will

Re: Help on adding CSS to django project

2011-02-05 Thread Ronghui Yu
It seems that you need to setup your web server to support static contents, django has a middleware to do the job, but it is not recommended to use it in product environment. I had this similar problem when I started to learn django. On Sat, Feb 5, 2011 at 6:15 AM, Chris Hannam wrote: > Apologie

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread James Bennett
On Sat, Feb 5, 2011 at 2:21 AM, Ken Chida wrote: > Is there a better way to do this?  Maybe I can use a custom template tag? The only thing you need is some HTML that spits out the form elements and does a POST to whatever your login URL is. So, you know, do that. Whether you do it with an inclu

Re: Having trouble creating instances of another model in the __init__ of one model

2011-02-05 Thread Ronghui Yu
The error in save, not in constructor, seems you need to set dome default value to Team instances, not quite sure On Sat, Feb 5, 2011 at 2:29 PM, Daniel Klein wrote: > I'm teaching myself django by idling poking at a project in the hope that > it may become a playable browser game some day. It's

Date internationalizaation

2011-02-05 Thread Simon W
Hey, I have a datetime field in my models. When I format the date into letters it appears in english and I'd like it in another langue. How to? Thank you! // Simon -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send emai

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Ken Chida
Hey - Thanks for replying. So I'm thinking that the method that I originally described would amount to only a few lines of code. A decorator would look nicer, but i'd have to remember to add it for future views, which is kinda annoying. Also, I wouldn't have a login URL because all pages will

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Kenneth Gonsalves
On Sat, 2011-02-05 at 00:21 -0800, Ken Chida wrote: > Is there a better way to do this? Maybe I can use a custom template > tag? put it in your base.html - since all your templates extend that (at least I hope they do), you get it on all pages -- regards KG http://lawgon.livejournal.com Coimbato

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread James Bennett
On Sat, Feb 5, 2011 at 6:01 AM, Ken Chida wrote: > Hey - Thanks for replying.  So I'm thinking that the method that I > originally described would amount to only a few lines of code.  A decorator > would look nicer, but i'd have to remember to add it for future views, which > is kinda annoying.  A

Re: Having trouble creating instances of another model in the __init__ of one model

2011-02-05 Thread Tom Evans
On Sat, Feb 5, 2011 at 6:29 AM, Daniel Klein wrote: > I'm teaching myself django by idling poking at a project in the hope that it > may become a playable browser game some day. It's early days. > So I have a model "Game", which is one game session. Each game is supposed > to have two teams. I dou

Desktop Application for Django

2011-02-05 Thread Izz ad-Din Ruhulessin
Hi all, I've been theorizing about a Django Desktop Application built a GUI framework (eg. PyGTK, Tkinter). It basically comes down with this: 1. Login using an SSL POST request and create a user object. 2. Download certain tables from the DB to the local machine, perhaps specified by a "downlo

Use development server database with production server

2011-02-05 Thread Amit
Hello, First of all one should go through with below link; http://stackoverflow.com/questions/4887851/django-database-settings-for-production-server Now, let come up with my hurdle. I am using a database lay out in filesystem(windows) say; C:/miami/data.db I have to use same database with prod

how to make a datatime filed model without timestamp?

2011-02-05 Thread Nima Gaemi
hello, i am using Djano 1.3 rev.15387 and i made a field 'last_updated=models.DateTimeField(auto_now=True)' when i wanted to get the data out of the database i wanted to get a delta with datetime module of python but i was warned that my datetime.datetime.now() object was not timezone aware.so i th

Database synchronization with sometimes-connected mobile client

2011-02-05 Thread Greg Humphreys
Hi everyone. I've developed a django website of medium complexity (about 50,000 lines of python), and the company I work for is now asking for a subset of the functionality to be available on an iPad. I'm familiar with iPad development, so I'm not worried about that, but all the research I've done

Pythonish approach to widgets

2011-02-05 Thread Alex Polovjan
Hi list, Django.forms have a great system of widgets. But customizing them can be a pain. Writing complex html in the python code is write-only and error-prone approach. I know that js files can be included in admin: class ModelAdmin(admin.ModelAdmin): class Media: css = {

Re: Having trouble creating instances of another model in the __init__ of one model

2011-02-05 Thread Daniel Klein
So I need to create the two teams for a new game instance when I create the game instance? That just feels so clumsy. 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

Re: Amazing work

2011-02-05 Thread Jon J
Well I was unfortunate enough to look up the official zope website, and as I'm typing this it's STILL loading. Haha, I can see what a POS it is and definitely won't be using it for any projects anytime soon. On Fri, Feb 4, 2011 at 10:24 PM, Kenneth Gonsalves wrote: > On Fri, 2011-02-04 at 01:02

Comments app confuses class_prepared signal

2011-02-05 Thread +shaun
I'm trying to create models dynamically for the django.contrib.auth User model using the class_prepared signal. My code works properly except when django.contrib.comments is installed. Seems like class_prepared signals for auth models no longer fire when the comments app is installed. Here's a b

model form validation

2011-02-05 Thread Axel Bock
hi all, really, I don't get this model form validation stuff. And currently, right now, I am immensely p*** off, because either the documentation is horribly bad (at least for me) or I am simply way too stupid. okay, enough rant, let's get practical - on to my little problem. I want to do model f

Re: Amazing work

2011-02-05 Thread kojiro
It would be a mistake to compare Zope to Django. Django is a lightweight, easy-to-learn, something-like-MVC framework with a built- in ORM. Zope is a complex, rich, unabashedly pythonistic metaframework with a built-in ACID compliant key-value store. Zope is neither a POS nor unusually slow. Its hi

Re: model form validation

2011-02-05 Thread Shawn Milochik
What exactly are you trying to accomplish? I'm not sure overriding is_valid is a good idea; it's not a part of the validation -- it's how a model knows that the validation was successful. In your sample view, you're calling is_valid on the formset, not the forms in the formset. That would expl

Re: model form validation

2011-02-05 Thread Axel Bock
let's make an example: in the datetime fields of the forms there will only be a time, which is ok for the user. the date will be added later by some background logic, for convenience. practically: - the user enters "0300" in the datetime field. - I make "0300" into date=0, time=03:00, valid field.

Re: Amazing work

2011-02-05 Thread Jon J
Yeah, I guess I'll have to redact my comment about Zope. I must say though, I've never been much of a fan of bloated frameworks like this. I spent enough time being forced to maintain Cold Fusion, thank you. On Sat, Feb 5, 2011 at 11:56 AM, kojiro wrote: > It would be a mistake to compare Zope t

Re: model form validation

2011-02-05 Thread Shawn Milochik
On 02/05/2011 01:08 PM, Axel Bock wrote: practically: - the user enters "0300" in the datetime field. - I make "0300" into date=0, time=03:00, valid field. Axel, In your example, you're wanting to populate a DateTime field in a model, but you want to allow the user to enter a string which wou

Re: jquery grid and django

2011-02-05 Thread Javier Guerra Giraldez
On Thu, Feb 3, 2011 at 7:50 PM, Tony wrote: > Is there any viable, > simple way to use the jquery grid plugin with django fairly quickly? I made my own, which i find very usable and intend to eventually share; but there's still no documentation, and very few examples. if you can wait a week or t

Re: model form validation

2011-02-05 Thread Axel Bock
Shawn, thanks for hint, I'll give that a try. Also I have some questions, for my own clarification of things: 1) using your method - would is_valid() retur true then? 2) in my form display I should hide the "takeoff" field then, correct? 3) I alredy tried to override clean_takeoff() - it didn't g

Re: model form validation

2011-02-05 Thread Shawn Milochik
On 02/05/2011 01:38 PM, Axel Bock wrote: Shawn, thanks for hint, I'll give that a try. Also I have some questions, for my own clarification of things: 1) using your method - would is_valid() retur true then? Yes, is_valid should end up true. 2) in my form display I should hide the "takeof

Re: Amazing work

2011-02-05 Thread Chris Hannam
Hi, Plone (which runs on Zope) is not that unusual a CMS system for business. It suffers from a lack of documentation like Zope but there is a pretty thriving community behind Plone currently. Certainly worth a look if nothing else. CH -- You received this message because you are subscribed to

Re: Amazing work

2011-02-05 Thread Cal Leeming [Simplicity Media Ltd]
To be honest, I've *never* been a fan of frameworks that try to merge every language into one, like Ext JS, or HTML builders in PHP. Hell I don't particularly like the 'widgets' in Django either :S I even once saw a PHP project that builds HTML and JavaScript from PHP objects, it was absolutely awf

Re: Get request object in class based generic view and form

2011-02-05 Thread roman
Hello Simon, > But I can't figure out how I can retrieve the request object in the class > based generic view. As far as I understand just get it from self.request. > I want to re-verify the user once again to > make sure his authenticated. > I always do it the way it's recommended in the docs,

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Ken Chida
Because I will have the login form on each page, I will not have a separate login URL. That's why I'm having difficulties with organizing the business logic code (i.e. view). It's almost as if I need to have two view functions -- one for login and another for the current page -- for the URL for

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Ken Chida
A global context processor would probably work, but is it kosher to put business logic in a context processor? To me it seems that the whole point of a context processor is to simply take a piece of data and extract/format information from it to form a context dictionary. -- You received this

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Ken Chida
Hi James - I want to point out that I will not have a dedicated login URL, as the functionality will be available on each page (not just a link to the login page, but the actual form). Previously, I had a dedicated login URL and link to the login page, but my frontend guy made a slick jQuery d

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Andre Terra
You don't need a "dedicated" login page with a form like the default login for django admin. All you need is a urlpattern (i.e. domain.com/login) that would allow for forms in other pages to POST to it. You would obviously need a view to handle that POST, but you don't need to link to it anywhere i

Re: Django-filebrowser path problems

2011-02-05 Thread gerram
I decided my problem! If you use dynamic method for getting you path, example: import os SITE_ROOT = os.path.realpath(os.path.dirname(__file__)) MEDIA_ROOT = os.path.join(SITE_ROOT, 'media') you can dismiss path of you real folder especially when project lies outside of the site root. I check it

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Pete Corsaro
Your last paragraph here indicates to me you don't under HTML forms. I think you need to go read about them and you'll understand why people keep telling you don't need to do anything funny with decorating your views or whatever just because your form is now on every page. In short, your form need

Re: Pythonish approach to widgets

2011-02-05 Thread Mike Ramirez
On Saturday, February 05, 2011 07:02:17 am Alex Polovjan wrote: > Hi list, > > > Django.forms have a great system of widgets. But customizing them can > be a pain. Writing complex html in the python code is write-only and > error-prone approach. > > I know that js files can be included in admin:

Re: Use development server database with production server

2011-02-05 Thread Mike Ramirez
On Saturday, February 05, 2011 01:52:43 am Amit wrote: > Hello, > First of all one should go through with below link; > > http://stackoverflow.com/questions/4887851/django-database-settings-for-pro > duction-server > > > Now, let come up with my hurdle. I am using a database lay out in > filesys

Re: Best DRY practices for a view function that will be used by all other views.

2011-02-05 Thread Ken Chida
Yes, I think I have it figured out now. Sorry for asking such a newb question. If I understand correctly, all I need to do is change the form action to the login URL. Then, url.py will direct the request to my existing login view function. I bet you guys were all bashing your heads against t

Re: Desktop Application for Django

2011-02-05 Thread Mike Ramirez
On Saturday, February 05, 2011 01:10:56 am Izz ad-Din Ruhulessin wrote: > Hi all, > > I've been theorizing about a Django Desktop Application built a GUI > framework (eg. PyGTK, Tkinter). > > It basically comes down with this: > > 1. Login using an SSL POST request and create a user object. > >