Re: Why in import statement

2010-01-10 Thread Łukasz Balcerzak
Hi there, Well, it is quite simple but let's break it down: > to me the command "from myproject.myapp.models import Author" should > be > either > >from myapp.models import Author > or >from models import Author # in the same folder as myapp.models. 1) If you use "from myapp.models imp

Re: error in the example

2009-12-30 Thread Łukasz Balcerzak
Hi, Python's parser use indentation to indicate logical blocks. Read more here: http://www.secnetix.de/olli/Python/block_indentation.hawk http://diveintopython.org/getting_to_know_python/indenting_code.html http://docs.python.org/reference/lexical_analysis.html#indentation You have 3 spaces befo

Re: Storing user's IP while using admin site

2009-12-30 Thread Łukasz Balcerzak
de and IMHO > it's pretty clean. > > > Xia Kai(夏恺) > xia...@gmail.com > http://blog.xiaket.org > > ------ > From: "Łukasz Balcerzak" > Sent: Wednesday, December 30, 2009 7:23 PM > T

Storing user's IP while using admin site

2009-12-30 Thread Łukasz Balcerzak
Hi there, I wonder if there is some easy and clean way of achieving this (hooking custom admin views in urls maybe is not that hard but definitely is not clean). Let's assume we have simply model: class Page(models.Model): title = models.CharField(max_length=64) author = models.Foreign

Re: Null constraint violations when saving objects with ForeignKey relationships

2009-12-27 Thread Łukasz Balcerzak
Hi there, Well, just try to make sure you are passing already saved instance (having primary key set) into related model which has foreign key to the first one. Your approach: > from test.models import A,B > instA = A() > instB = B(a=instA) > > Now I'm done with my parsing and am happy to save

Re: Error

2009-12-26 Thread Łukasz Balcerzak
Hi, First argument in ``patterns`` factory method is like the starting point for all views that should be called. Moreover, you may pass function view as a callable object or as a string but in this case your starting point has to be hooked first. So, if for instance, your view method 'firstsite'

Re: django configuration on win/linux

2009-12-24 Thread Łukasz Balcerzak
Hi, For relative paths, os.path module will do the trick - it is platform independent. Use os.path's ``join``/``split`` methods and ``sep`` attribute. If you are depending on absolute paths (which probably for both platforms would just differ) you may simply call platform.system() and write a s

Re: pass to a template many querysets

2009-12-22 Thread Łukasz Balcerzak
ects passed through the "extra_context" parameter are not > updated dinamically. The objects passed in the "queryset" are correctly > updated. > > Thank you very much. > > * martedì 22 dicembre 2009, alle 15:00, Francesco Benincasa scrive: >> * marted

Re: pass to a template many querysets

2009-12-22 Thread Łukasz Balcerzak
way? On Dec 22, 2009, at 1:22 PM, Francesco Benincasa wrote: > * martedì 22 dicembre 2009, alle 12:55, Łukasz Balcerzak scrive: >> At the time queryset is sliced Django actually fire the query and return >> objects as normal python list. >> Thats why your extra_context is &#x

Re: pass to a template many querysets

2009-12-22 Thread Łukasz Balcerzak
At the time queryset is sliced Django actually fire the query and return objects as normal python list. Thats why your extra_context is 'static'. Just slice latest_news / latest_pages at the template. On Dec 22, 2009, at 12:47 PM, Francesco Benincasa wrote: > * lunedì 21 dicembre 2009, alle 12

Re: newbie question: .is_valid seems non-Boolean?

2009-12-20 Thread Łukasz Balcerzak
Well, Form.is_valid calculates the form and returns boolean, thats for sure. Specifically, ">> from django import forms >>> >>> class F(forms.Form): ... name = forms.CharField() ... >>> f = F() >>> f.is_valid > >>> f.is_valid() False >>> f = F({'name': 'Lukasz'}) >>> f.is_valid() True You ge