"Legal" way to have foreign key field in the custom form

2008-12-09 Thread Eugene Mirotin
Hello. I'm working on the custom admin page that will serve batch items creation based on the uploaded file. All these items should be linked to the single foreign key item. This item should be selected on the form. Of course, I can investigate the inner structure of the rendered admin pages and

Re: "Legal" way to have foreign key field in the custom form

2008-12-09 Thread Eugene Mirotin
Well, looks that the ModelChoiceField solves the problem except of the plus icon On Dec 9, 12:34 pm, Eugene Mirotin <[EMAIL PROTECTED]> wrote: > Hello. I'm working on the custom admin page  that will serve batch > items creation based on the uploaded file. > All these items

Re: "Legal" way to have foreign key field in the custom form

2008-12-12 Thread Eugene Mirotin
categories=models.Category.objects.order_by('parent', > 'list_order')), >             models.Category._meta.get_field('parent').rel, >             admin.site, >         ) > > -Jeff > > On Dec 9, 6:50 am, Eugene Mirotin wrote: > > > Well, looks that the ModelCho

Re: "Legal" way to have foreign key field in the custom form

2008-12-12 Thread Eugene Mirotin
t using a Select() directly, you'd want to pass the > choices in there.  Here's a simple list comprehension that you may > have to adapt a little to do that: > > [(t.id, unicode(t)) for t in queryset.all()] > > That assumes that you add "queryset" as an argument t

Re: "Legal" way to have foreign key field in the custom form

2008-12-13 Thread Eugene Mirotin
ock > "extrahead", make sure to put a {{ block.super }} in there, so it > includes anything that's been defined by parent templates. > > -Jeff > > On Dec 12, 2:32 pm, Eugene Mirotin wrote: > > > Thank you very much for the help. It have finally solved the problem. &g

Re: stupid question

2008-12-14 Thread Eugene Mirotin
Not necessary manually, 'cause you can use "reset App" On Dec 14, 12:13 am, "Huseyin Berberoglu" wrote: > On Sat, Dec 13, 2008 at 11:08 PM, volk23 wrote: > > > i've made a modification in a App i created. run syncdb, it dont show > > changes made. what could be wrong? thanks in advance > > You

SQLite iexact problem with non-latin symbols

2008-12-18 Thread Eugene Mirotin
Hello. Consider I have a simple model class Team(models.Model): name = models.CharField(max_length=200) Then I create some team and try to look for it with iexact match: tt = Team(name='English') tt.save() Team.objects.filter(name__iexact=tt.name.lower()) # this returns the list containing m

Re: SQLite iexact problem with non-latin symbols

2008-12-19 Thread Eugene Mirotin
from several different computers and do not still have hosted SQL. On Dec 19, 3:28 am, "Karen Tracey" wrote: > On Thu, Dec 18, 2008 at 4:53 PM, Eugene Mirotin wrote: > > > Hello. > > Consider I have a simple model > > > class Team(models.Model): > >    name

Re: django-admin.py not working on Vista

2009-01-10 Thread Eugene Mirotin
You can simply append django's bin directory to your _system_ PATH variable (still the same way as on the earlier versions - through the computer properties - advanced) I do not have my Vista laptop on hand, but I believe, this it what I have done to make it work On Jan 10, 5:55 am, Rex wrote: >

Re: Validating imported data

2009-01-13 Thread Eugene Mirotin
My favourite solution for this task is the following: 1) you create the "simple" form with the file upload and submit it 2) in submit handler you parse the file and create the "preview" formset (is inline formset, form example) filling it with the parsed data. If the file cannot be parsed, you can

Re: Content blocks editable in Admin

2009-07-09 Thread Eugene Mirotin
Define the model that includes: * (some) Foreign key to the page the block belongs to (so, most probably you'll have to define the model for the site page) * the text field for the block contents Register this model in the admin, which will generate the form with 2 fields - drop-down select (for t

Some post_related_objects_save signal or workaround?

2009-07-09 Thread Eugene Mirotin
Hello! I have a tricky (as seems to me :) problem. Consider I have 2 simply related models - a Game and a Round (with FK to Game). Each has some generic fields like name and description. Also, the Round has the ordering field (called number) (oh, I can imagine your sighs =) They are edited on th

Re: Some post_related_objects_save signal or workaround?

2009-07-10 Thread Eugene Mirotin
rote: > Is there any reason you can't create your own signal and put it in the > rounds save() method and then just call the parents save? > > http://docs.djangoproject.com/en/dev/topics/signals/#defining-and-sen... > > Cheers, > Ryan > > On Jul 9, 6:12 am, Eugene Mirotin

Re: Sending JSON response from views

2009-07-12 Thread Eugene Mirotin
I could suggest you creating the json manually (this is bad if you plan to scale you app) or make the dictionary with the necessary data and then serialize it. i.e users = [{'user': l.user.name, 'status': l.status} for l in ActiveList.objects.all()] Also it would be probably better idea to add the

Re: Ajax call send me the same page

2009-07-13 Thread Eugene Mirotin
There are 3 possible layers of caching that return you the previous page: browser Django Apache The 1st is solved by appending the timestamp or random number as additional fictional GET parameter (jQuery does it automatically when you pass the cache: false to the ajax call) The 2nd is solved by u

Re: submit form

2009-07-13 Thread Eugene Mirotin
The other option is to have the hidden "action" field and fill it with different values on buttons click events. The other option is to change the form action dynamically with JS so you can have separate POST handler views for different actions (like On Jul 12, 3:22 pm, alecs wrote: > Thanks, D

Re: parsing urls with dot

2009-07-14 Thread Eugene Mirotin
The idea is probably in the following. when somebody (may be not Django, but your browser) sees that the last part of the URL does not have dots, it understands that it's the "directory", so the trailing slash should be added (like in the ancient times when URLs really represented files and direct

Re: Question regarding post_save signal and ManyToMany field objects

2009-07-14 Thread Eugene Mirotin
If I understand right, the problem is that you want the signal after all related fields are already saved. If so, this is exactly the problem I have too. You see, when you have such a relation (and, for example, edit the parent object with inlined related objects from the admin page, Django _has t

Re: url as folder path possible?

2009-07-14 Thread Eugene Mirotin
The problem is still unclear. Do you want to handle the path example.com/some/path/ and route it to some view that would get the 'some/path' as argument? If so, * write the url conf like r'^([\w_\/]+)/$', handle_path * write the handle_path(request, path) view * in view split the pass by slashes *

Re: html file (UTF-8) generated from template does not displayed correctly using MS internet explorer 6.0

2009-07-14 Thread Eugene Mirotin
Most probably your html is incorrect, but FF is smart enough to handle it. Try the following: * switch to the Strict XHTML instead of Transitional (as the latter is not recommended) * create a static HTML file (replace the remplate logic with some dummy values) with the desired layout * validate i

Re: url as folder path possible?

2009-07-15 Thread Eugene Mirotin
Never mind. If you wish to understand the regex stuff (and you really have to :), read this tutorial: http://www.regular-expressions.info/tutorial.html On Jul 15, 2:50 am, theiviaxx wrote: > awesome, thats exactly what i needed.  im still trying to figure out > regex stuff. > > Thank you! > --

Re: never_cache doesn't work for login page

2009-07-18 Thread Eugene Mirotin
Isn't adding a timestamp to the url a workaround? I mean making all links to /login/ look like /login/?_=timestamp This can be easily done on the client side with some JS library, or, on the server side. Not nice, but it should help, I guess. On Jul 17, 5:24 pm, Ronghui Yu wrote: > Hi, All, > >

Re: building directory path with user table

2009-07-18 Thread Eugene Mirotin
What you have written (this join for user_dir_path) is evaluated only once on model class creation, but what you need is evaluating it for each specific object. I recommend you overloading the model save method to alter the image save path. On Jul 17, 10:44 am, "neri...@gmail.com" wrote: > Hell

Re: Getting a dynamic model form

2009-07-18 Thread Eugene Mirotin
So, the value is a string, but the widget you want to display to the user should be changed according to the key value? Probably you have to create your custom tag (e.g. render_value_widget) and then use something like {% render_value_widget key value %} in your view. If you provide the same name

Re: Howto add button to certain field

2009-07-18 Thread Eugene Mirotin
The button you want is client-specific. So you really have to write the loop and make the check if the rendered field corresponds to the user name. And if so, render your button with onclick making ajax call next to the rendered field. On Jul 17, 8:19 pm, zayatzz wrote: > Hello > > I have this f

Re: never_cache doesn't work for login page

2009-07-20 Thread Eugene Mirotin
gt; It works fine after removing this middleware. > I believe this middleware cannot work with never_cache. > > Eugene Mirotin ??: > > > > > Isn't adding a timestamp to the url a workaround? > > I mean making all links to /login/ look like /login/?_=timestamp > >

Re: How to create this filter

2009-07-25 Thread Eugene Mirotin
Have you tried making manual formatting, i.e. val1 = 'col1' val2 = 'col2' op = '>' # Python 2.6+ string formatting .extra(where=["{0} {1} {2}".format(val1, op, val2)]) On Jul 25, 2:28 am, David wrote: > anybody likes to give me help? thanks so much. > > On Jul 24, 4:23 pm, David wrote: > > >

Re: Model Formsets Have an Extra Blank Form?

2009-07-25 Thread Eugene Mirotin
set the extra parameter to 0 On Jul 24, 9:44 pm, derek wrote: > I'm following the instructions here: > > http://docs.djangoproject.com/en/dev/topics/forms/modelforms/ > > But when I do this kind of thing: > > formset = AuthorFormSet(queryset=Author.objects.filter > (name__startswith='O')) > > I

Re: Editing model based forms.

2009-07-28 Thread Eugene Mirotin
AKK, the previous response from Daniel Roseman completely answers your question - the user field is HIDDEN on the form and AUTOMATICALLY filled in the form handling action. You should read the Django 'topics', I think. On Jul 27, 10:52 pm, AKK wrote: > Thanks, that will work for time. > > I want

Re: How to send form via email

2009-07-30 Thread Eugene Mirotin
So put join's arguments in a list or tuple On Jul 29, 5:47 pm, el_k...@interia.pl wrote: > Thank you for your answer but there is error > "join() takes exactly one argument (3 given)" > > "Jeremy Boyd" pisze: > > > > > > > Kolo, > > > I'm not positive this is what you're asking, but it seems to

Models mixins/inheritance

2009-10-06 Thread Eugene Mirotin
We have an existing app written in perl with Postgre as DB. I want to add the django admin as the interface to this existing DB. The main app is in constant development, so the DB scheme may change in the future. I have checked the inspectdb output and it is quite good (I do also do some automatic

Re: Models mixins/inheritance

2009-10-07 Thread Eugene Mirotin
import models in admin file and try print Company.__module__ And this gives me the dbadm.models_auto output On Oct 6, 4:10 pm, Eugene Mirotin wrote: > We have an existing app written in perl with Postgre as DB. > I want to add the django admin as the interface to this existing DB. > The

Re: Models mixins/inheritance

2009-10-07 Thread Eugene Mirotin
any.__unicode__ = CompanyUnicode > > __ > > G > > On Oct 7, 12:07 pm, Eugene Mirotin wrote: > > > Let me provide more details. > > > When I make simple python project with the same idea, everything works > > fine. > > > # file test2.py >

Re: Models mixins/inheritance

2009-10-07 Thread Eugene Mirotin
> > > import Company > > > def CompanyUnicode(self): > >     return '%s [%s]' % (self.nick, self.legal_name) > > > Company.__unicode__ = CompanyUnicode > > > __ > > > G > > > On Oct 7, 12:07 pm, Eugene Mirotin wrote: > > &g

Underscores in PKs

2009-10-23 Thread Eugene Mirotin
I have an application working with legacy DB. Some tables have humen-redable PKs, and some of them contain underscores. Django admin escapes them (for what reason?) and seems not unescaping. So these objects are unavailable for editing. The relevant bug (2 years old!) is here: http://code.djangopr

Strange bug when admin list-editing

2010-06-08 Thread Eugene Mirotin
We have Django as DB editor for our customers. We have 2 installations on different servers - one talking to dev DB and used for testing new features (we do some customizations to admin), another used on production. It's convenient for customer to use list editing mode for batch updating one field

Filtering by the intermediary table using the GET parameters

2010-02-02 Thread Eugene Mirotin
I have 3 models - Standard, Product, and ProductStandard. Standards represents some standardization document. Product represents some product. ProductStandard is the intermediary table having 2 FKs (Standard and Product) as well as some extra fields (like comments about the Standard for the specif

Re: Filtering by the intermediary table using the GET parameters

2010-02-03 Thread Eugene Mirotin
th specific standard by: > > Product.objects.filter(has_standard='specific_standard_id') > > Hope it helps. > > wy > > > > On Tue, Feb 2, 2010 at 2:50 PM, Eugene Mirotin wrote: > > I have 3 models - Standard, Product, and ProductStandard. > > > Standards