Re: nested forms from model with manytomany

2011-09-15 Thread Roald de Vries
On Sep 14, 2011, at 11:32 PM, Visgean wrote: Hello I have these two models: class SubOrder(models.Model): """ This is model for single order it should be used later in complex order """ product = models.ForeignKey(Product) quantity = models.SmallIntegerField() class

Re: Setting a default value for a select widget in a modelformset

2010-09-05 Thread Roald de Vries
On Sep 2, 2010, at 4:41 PM, Steve McConville wrote: What would be the best way to go about this? Is it necessary to create a custom widget to achieve this? I guess the best way would be to use the 'initial' parameter.

Re: passing file from command line startup

2010-08-11 Thread Roald de Vries
On Aug 11, 2010, at 8:47 PM, Bradley Hintze wrote: Hi all, Is there a way that I can startup my script and pass it a file? For example: ~$ python myscript.py mytext.txt and then access mytext.txt in myscript.py? Option 1: use stdin ~$ python myscript.py < mytext.txt >>> import sys >>>

Re: Adding request context to standard login/logout views?

2010-08-11 Thread Roald de Vries
On Aug 11, 2010, at 8:59 PM, Streamweaver wrote: I use the the standard django login and logout views in the usual way url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'accounts/login.xhtml'}, "login-account"), url(r'^logout/$', 'django.contrib.auth.views.logout',

Re: overwrite the save method

2010-08-11 Thread Roald de Vries
On Aug 11, 2010, at 7:25 PM, refreegrata wrote: My code -- class Format(models.Model): name = models.CharField(max_length=5, unique=True) myBoolean = models.BooleanField(default=False) class FormFormat(forms.ModelForm): boolean1 =

Re: add attributes to a field without widgets

2010-08-11 Thread Roald de Vries
Hi refreegrata, On Aug 11, 2010, at 3:31 PM, refreegrata wrote: Hello list. I'm a newbie in django and now i am working with "modelformset_factory". I have something like this

Re: Search Field on All Pages

2010-08-08 Thread Roald de Vries
On Aug 8, 2010, at 2:04 PM, Tim Sawyer wrote: What I do is to setup a search that works at /search/q=search_term, and then create a form on each page that submits to /search. This form is in my top level site template. The /search/ url is part of a search application. There's an

database object initialization versus python object initalization

2010-08-06 Thread Roald de Vries
Hi all, I have two models (Person, PersonUpdate) with a many-to-many field (properties). The properties of a personupdate should be initialized (copied) from that of the corresponding person. But before I can add a list of properties to a new personupdate, it must have an id, and

Re: model inheritance, abtract=True

2010-08-05 Thread Roald de Vries
On Aug 5, 2010, at 3:15 PM, Roald de Vries wrote: On Aug 5, 2010, at 3:00 PM, Emily Rodgers wrote: On Aug 5, 1:50 pm, Roald de Vries <downa...@gmail.com> wrote: Dear all, I have the following error, and don't know what it means: Error: One or more models did not va

Re: model inheritance, abtract=True

2010-08-05 Thread Roald de Vries
On Aug 5, 2010, at 3:00 PM, Emily Rodgers wrote: On Aug 5, 1:50 pm, Roald de Vries <downa...@gmail.com> wrote: Dear all, I have the following error, and don't know what it means: Error: One or more models did not validate: update.personupdate: 'address' has a relation with

model inheritance, abtract=True

2010-08-05 Thread Roald de Vries
Dear all, I have the following error, and don't know what it means: Error: One or more models did not validate: update.personupdate: 'address' has a relation with model Address, which has either not been installed or is abstract. I did a pretty big refactoring, but I think the

Re: Best way to present N items in table row for list

2010-07-29 Thread Roald de Vries
Hi Wadim, On Jul 27, 2010, at 6:51 PM, Wadim wrote: Hello. I have a list that i want to present in a table. Each row should have 5 items. For now i create the function that returns me new grouped list, that i use later in a template. def groupListByRow(list): cnt=0 rows=[]

Re: Django INNER JOIN

2010-07-28 Thread Roald de Vries
On Jul 28, 2010, at 6:02 PM, kostia wrote: Well, I used projects = projects.filter(favourites__user = request.user) And then I tired to order by 'date' field, which is in the Favourite model like here: projects = projects.filter(favourites__user = request.user)#.order_by(filter_field) And it

Re: Django INNER JOIN

2010-07-28 Thread Roald de Vries
On Jul 28, 2010, at 5:19 PM, kostia wrote: Thank you very much Roald, What is faster: projects = Project.objects.filter(favourites__user = request.user) or select_related('project') ? I think it doesn't matter much, but if one is faster, it should be the first one. If you only use

Re: Django INNER JOIN

2010-07-28 Thread Roald de Vries
Dear Kostia On Jul 28, 2010, at 2:29 PM, kostia wrote: I have a model Favourite with fields User, Project, Date, what means that some user put some project as favourite on some date. I take all favourites filtered by this user and I want to INNER JOIN that info with Project model. How can I do

Re: Django IDE

2010-07-18 Thread Roald de Vries
On Jul 18, 2010, at 7:19 PM, Biju Varghese wrote: Eclipse is the best IDE for python and django. On Jul 17, 8:53 pm, Jitendra Joshi wrote: What is the best open source Django IDE ? I would say VIM, too. Emacs should be very good too, but I've never used it.

Re: code repetition in views

2010-04-18 Thread Roald de Vries
On Apr 11, 2010, at 5:58 AM, ydjango wrote: I find all my view method have identical code in start and in end: anyway to avoid repetition...? Example: def typical_view_method(request): Check if user is authenticated. Get user and group Get some session variables try: Method

Re: How can i populate app engine(production environment) database with local sdk database

2010-04-05 Thread Roald de Vries
On Mar 31, 2010, at 9:12 AM, Eximius wrote: Please help me out On Mar 29, 11:04 pm, Eximius wrote: Hi all, I have created a django application using app engine sdk, and have stored data in database using forms. But the problem i am getting when i deploy it, the

Re: Strange difference between runserver and shell

2010-03-12 Thread Roald de Vries
On Mar 11, 2010, at 11:56 AM, pyt...@roalddevries.nl wrote: I have the following model: 1 class MyOrderItem(models.Model): 2 orderitem = models.ForeignKey(OrderItem, null=True, blank=True) 3 # other fields 4 5 def save(self, *args, **kwargs): 6