Re: accessing pk of an existing object in ModelForm

2009-11-23 Thread Daniel Roseman
On Nov 23, 2:57 pm, hg7581 wrote: > Hello there, > For doing some sanity checks, I need the primary key (pk) of an > (already existing) object in a ModelForm. > > What works for me in the meantime, ist the following (admin interface): > > class NF(ModelForm): > def __init__(self,*args,**kwargs): >

Re: Can't get form to update, rather than insert

2009-11-24 Thread Daniel Roseman
On Nov 24, 4:42 am, Nick Arnett wrote: > I have a form that I've tried creating a couple of ways, including as a > ModelForm, which doesn't seem to want to perform an UPDATE operation.  I'm > hoping for some help here... If I create it as a ModelForm, it doesn't > validate, I'm guessing because th

Re: Is there any way of model cross reference placed in different files but in one app?

2009-11-26 Thread Daniel Roseman
On Nov 26, 10:01 am, Denis Cheremisov wrote: > I have models directory with several files in it (models/__init__.py, > models/main.py, ...) > I have basic "Article" model and many models derived from it. So, I > would like to place them into separate file: models/article.py > But I also have sever

Re: Request POST String

2009-11-26 Thread Daniel Roseman
On Nov 26, 3:55 pm, Chris wrote: > Hi all, > > Sorry for bothering you with something that is probably fairly > straight forward but I cant seem to find the solution myself. > > I am using Google Checkout on my site. It calls one of my pages after > processing an order. It posts XML. Django seems

Re: View returns no queryset

2009-11-29 Thread Daniel Roseman
On Nov 28, 11:15 pm, "R. Gorman" wrote: > I've got a real stumper. Well, a stumper for me; I'm hoping someone > has some insight. Here's the view I'm calling: > > >     games = Game.objects.all() >     return render_to_response('season_schedule.html', > {games:"object_list"},context_instance = Re

Re: How to call this function

2009-12-01 Thread Daniel Roseman
On Dec 1, 5:42 am, David wrote: > Hello, > > In my template file I have > >   {% for value in data %} >                                {% ifequal all_domain 1 %} >                           class="odd" id="{{value.publisher}}"   > "showDomain('{{value.publisher}}', '{{value.country}}');" >  

Re: Got error when update object

2009-12-01 Thread Daniel Roseman
On Dec 1, 3:24 pm, 邓超 wrote: > Hi all, >   I'm writing a small app, and get an error when trying to update the > object, the error message is > > 'QuerySet' object has no attribute '_meta'. and It shows that I made > some mistake on this line: > form = ProjectForm(instance = projectInstance). But

Re: redundant SQL's in Django tutorial

2009-12-01 Thread Daniel Roseman
On Dec 1, 1:57 pm, stargazer wrote: > Hi all, > > I'm trying the famous Django > tutorial:http://docs.djangoproject.com/en/1.1/intro/ > > Playing with "polls" and "choices" I see lot of SQL queries this > application creates. Actually, I just selected a list of polls > than selected the poll with

Re: How to call this function

2009-12-01 Thread Daniel Roseman
On Dec 1, 3:53 pm, David wrote: > Hello John and Daniel, thanks for your replies. Let me tell what I > need in more details. > > {% for value in data %} >                                {% ifequal all_domain 1 %} >                           class="odd" id="{{value.publisher}}"   > "showDomain

Re: Help with installing MySQLdb package for Django on OS X Snow Leopard

2009-12-02 Thread Daniel Roseman
On Dec 1, 11:23 pm, James Dekker wrote: > My problem, however, is that I can't seem to figure out how to install the > MySQLdb package for Python / Django? > > Downloaded the tar.gz from: > > http://sourceforge.net/projects/mysql-python/ The main 'Download Now' link from this page for some reas

Re: Help with installing MySQLdb package for Django on OS X Snow Leopard

2009-12-02 Thread Daniel Roseman
On Dec 2, 12:18 pm, James Dekker wrote: > Daniel, > > Under the Files tab, the only ones that are available are for Linux > not OS X Snow Leopard... > > -James No, they're not 'for' anything. They're source code, which you compile on your platform. Here's the link to the page: http://sourceforge

Re: Sick of defining urls

2009-12-03 Thread Daniel Roseman
On Dec 3, 7:37 am, Todd Blanchard wrote: > I think you've kind of missed my point as there's not a view that can render > any object - but rather the name of the view is in the url. > > This is the url conf for a typical rails app. > >   map.connect '', :controller => "public" >   # Install the d

Re: Using a form to UPDATE a record?

2009-12-03 Thread Daniel Roseman
On Dec 3, 8:53 am, Todd Blanchard wrote: > Thanks, that makes the form show up populated. > But saving it creates a new record, despite making sure I have id in a hidden > field on the form.  :-/ It does work, so you'll need to show us some code so we can see where you're going wrong. -- DR. --

Re: Using a form to UPDATE a record?

2009-12-03 Thread Daniel Roseman
On Dec 3, 9:53 am, Todd Blanchard wrote: > K > > def edit(request): >     form = None >     if request.method == 'GET': >         try: >             form = IncidentForm(instance = Incident.objects.get(id = > request.GET['id'])) >         except ObjectDoesNotExist: >             raise Http404 >  

Re: Invalid block tag: 'reverse'

2009-12-03 Thread Daniel Roseman
On Dec 3, 2:14 pm, kelvan.mailingl...@gmail.com wrote: > Hi, > > Due the fact that the url tag fails accepting variable I installed the > reversetag fromhttp://github.com/ulope/django-reversetag > Putting it in INSTALLED_APPS works (django seems to found it) > > But django means that reverse is a

Re: reading iptc info

2009-12-03 Thread Daniel Roseman
On Dec 3, 3:30 pm, "bax...@gretschpages.com" wrote: > Any suggestions on django/python code to read iptc info from images? A quick Google shows this, which uses PIL to parse the image and extract the IPTC data: http://mail.python.org/pipermail/image-sig/2001-November/001675.html -- DR. -- You

Re: Need help on jquery Ajax load(use load two times)

2009-12-04 Thread Daniel Roseman
On Dec 4, 9:52 am, NMarcu wrote: > Hello all, > >     I have a strange problem with jquery load. I have this two loads > on a click event: > > action='first'; > $( '#operators_list_div' ).html( ' ' ).load( '{% url > add_save_view %}',{'action':action, }); > action='second'; > $( '#address_list' ).

Re: render_to_response and HTTP status codes other than 200

2009-12-04 Thread Daniel Roseman
On Dec 4, 8:37 am, chefsmart wrote: > According to the docs > athttp://docs.djangoproject.com/en/dev/topics/http/shortcuts/#render-to... > the render_to_response shortcut "Renders a given template with a given > context dictionary and returns an HttpResponse object with that > rendered text." > >

Re: delete every record in a table?

2009-12-04 Thread Daniel Roseman
On Dec 4, 8:37 pm, Phlip wrote: > Django users: > > I only ask the question to help improve my esthetics, but others might > need a performance boost here. > > How to delete every record in a table? > > A related question - how to delete every record matching a filter, out > of one internal SQL co

Re: Porting issu 0.96 > 1.0

2009-12-05 Thread Daniel Roseman
On Dec 5, 4:14 pm, Robert wrote: > Hi, > > I try to run an app that ran successfully on 0.96 but doesn't run on > version 1.1.1. > > I have validated my models.py with the command python manage.py > validate. > > It output a syntax error in this line: > > if not force_update and self.next_update a

Re: How to create a form to edit an existing object without knowing the object's id?

2009-12-07 Thread Daniel Roseman
On Dec 7, 12:22 am, Continuation wrote: > I have: > > class MyModel(models.Model): >     fk                    = models.ForeignKey(AnotherModel) >     field               = models.PositiveIntegerField() > > class MyForm((forms.ModelForm): >     class Meta: >         model   = MyModel > > Now I wan

Re: browser input and strings

2009-12-07 Thread Daniel Roseman
On Dec 7, 3:11 pm, rvandam wrote: > Hi Shawn thanks for your reply. > > I have some categories, with multiple items per category. If a user > entershttp://mysite.com/items-from-100-to-1000I want a short > description of all items in that category listed. > > I have done this so far with: >    {% f

Re: browser input and strings

2009-12-07 Thread Daniel Roseman
On Dec 7, 4:35 pm, rvandam wrote: > Sorry for the confusion. Here are both complete models: > > class Nl(models.Model): >         lijst = models.ForeignKey('Menu_nl') >         type = models.ForeignKey('Type_nl') >         perceel = models.ForeignKey('Perceel_nl') >         plaatshuur = model

Re: Has form.errors been deprecated?

2009-12-07 Thread Daniel Roseman
On Dec 8, 4:23 am, Continuation wrote: > I want a way to tell if the form submitted contains errors or not. > > There're django snippets that use the field form.errors to test for > errors (like this one:http://www.djangosnippets.org/snippets/1094/) > > And when I looked at my own form.errors, it

Re: Model and Model Manager override-able methods

2009-12-07 Thread Daniel Roseman
On Dec 8, 4:11 am, Waqqas Jabbar wrote: > Hi, > > Where can i get the list of ALL the methods that a derive class can override > for Model and Model Manager classes > > goto >From the source code. It's just Python. You can override what you like. -- DR. -- You received this message because you

Re: Queryset filter on foreign key

2009-12-08 Thread Daniel Roseman
On Dec 8, 2:47 am, GoSantoni wrote: > Guys, i'm struggling with this problem for more than a week now. My > goal is to use a queryset filter with a foreign key. > Issues are > 1) column generates a list, what is the right way to get the blog id > for a post? So whether the post belongs to blog  1

Re: Styling widgets with django.forms

2009-12-08 Thread Daniel Roseman
On Dec 8, 9:28 am, playfire wrote: > I am using django.forms for my forms and I want to style my > tags using css. I know I can customize the form template, but how do i > customize the widget itself? Normally I would do > and then put the style in my css file but all I have is > {{ form.fieldna

Re: settings caching?

2009-12-08 Thread Daniel Roseman
On Dec 8, 1:54 pm, Benjamin Wolf wrote: > Hi there, > > I've just put my first little django app online (at webfaction) and I > have the problem that when I change my database connection in the > settings.py, > the application always tries to connect with my old connection data. > I just got no id

Re: Help me with django templates

2009-12-09 Thread Daniel Roseman
On Dec 9, 2:18 pm, Biju Varghese wrote: > >                 {%for jobsp in jobspecs%} >                         {%ifequal jobsp.id jobtitle.jobspec_id %} >                                 {{jobsp.id}} >                         {%endifequal%} >                 {%endfor%} >                        

Re: Expiry Date

2009-12-09 Thread Daniel Roseman
On Dec 9, 12:07 pm, Djangobot wrote: > Hi all > > I am very new to Django and Python and I was wondering if anyone could > help me on here as I am desperate for help. > > I am designing a mobi. site and I need to somehow set an expiry date > on the competitions that will be run on the site. > > I

Re: Question about forms in templates

2009-12-09 Thread Daniel Roseman
On Dec 9, 5:14 pm, jul wrote: > Hi, > > I'm not very clear on how forms work. > In the form below, both fields are required. When not filling anything > and clicking submit, I got the error messages. > Since I didn't specified any action, how can the form know that the > form is not valid and get

Re: Tricky Django tables setup

2009-12-10 Thread Daniel Roseman
On Dec 10, 3:19 pm, Superman wrote: > Hi guys, I can't wrap my head around this problem I have... someone > please help. > > The Problem: I have a list of various projects, in a Project Model. > Each of them has a foreign Key to a Category model. Each Category has > a Many to Many Relationship to

Re: return a dynamically generated image to the user?

2009-12-10 Thread Daniel Roseman
On Dec 10, 4:45 pm, Mark Freeman wrote: > I have recently created a python module which parses an input string > and invokes the program lilypond to generate a music score image. All > of this works fine as a standalone python app. I'm now looking to add > this to my django site so users can enter

Re: Queryset filter on foreign key

2009-12-11 Thread Daniel Roseman
On Dec 11, 3:33 am, Mark Schuuring wrote: > Hey Daniel, > First of all thanks a lot for your response. You understood it right > that i just want to split up the columns by the blog id so the > defintion of blogs_one and blogs_two was really helpful, thanks. So in > the shell i found out the blogs

Re: speed of calculations - combining query improves speed?

2009-12-11 Thread Daniel Roseman
On Dec 11, 2:22 pm, mbdtsmh wrote: > Hi all - can someone put me out of my misery on this one please? > > I have a piece of code that uses the request.GET keys in the url to > produce the following in my views.py > > objects = Issue.objects.all() > objects = objects.filter > (designset__project__R

Re: How to choose one row of data

2009-12-11 Thread Daniel Roseman
On Dec 11, 3:13 pm, Andy wrote: > Thanks for the response Shawn.  I have done what you suggested, > assigning a variable named order_info and can use it if I use > render_to_response in my order view.  But I want to use > HttpResponseRedirect after the form is saved.  I'm thinking I need to > get

Re: How to avoid listing all objects initially until searching

2009-12-11 Thread Daniel Roseman
On Dec 11, 2:51 pm, Jean Stebens wrote: > Hi there, > > I have a rather large set of objects in my database, around 200k, using > the django admin interface and listing them is always terrible slow as > it always fetches all entries (paginated). I usually just run a few > searches or add some filt

Re: can't create a project

2009-12-13 Thread Daniel Roseman
On Dec 13, 5:55 pm, surender wrote: > I want to create a project using the command line by running the > command "django-admin.py startproject mysite". > But every time I run this I get an error. > import django is working fine > I am new to this and don't know what should I do to create project?

Re: request and email templates

2009-12-13 Thread Daniel Roseman
On Dec 13, 5:06 pm, Tim Miller wrote: > I'm using django.contrib.auth.views.password_reset and trying to pass > the ip address of the user requesting a password reset into the > confirmation email. > > I've enabled django.core.context_processors.request in settings and can > successfully display r

Re: How to implement GROUP BY in Django object models?

2009-12-14 Thread Daniel Roseman
On Dec 15, 4:51 am, "thai.pham" wrote: > Hello, I don't know if it is suitable to post such a question right > here. Anyway, I have a simple model as below: > > def acct_data(models.Model): >     timestamp = models.DateTimeField(); >     msg_type = models.IntegerField(); >     username = models.Ch

Re: How to set attribute to the items in a QuerySet.

2009-12-15 Thread Daniel Roseman
On Dec 15, 7:02 am, Xuqing Kuang wrote: > Hi, all. > > Are there any way could keep a attribute new set to a item in QuerySet > object ? > > For example: > > >>> tcs = TestCase.objects.filter(case_id__in = [1123, 1124, 1125]) > >>> tcs > > [, , MigrateOneWayDisk>]>>> tc = tcs[1] > >>> setattr(tc,

Re: how to get the list_display properly?

2009-12-15 Thread Daniel Roseman
On Dec 15, 12:48 pm, Viktor wrote: > hi, > > I've just noticed that even the contrib apps' admin interface is bogus > in django 1.1 > > namely, the first column name should be the "check all" checkbox, > instead that column receives a the first header of list_display, and > finally the last column

Re: variable {% url %} parameter

2009-12-15 Thread Daniel Roseman
On Dec 15, 3:36 pm, Baurzhan Ismagulov wrote: > On Mon, Dec 14, 2009 at 02:12:00AM -0800, bruno desthuilliers wrote: > > > (r'^app/(?P\d+)/$', create_update.update_object, > > > {'model': App}, 'app-edit'), > > > > Now, using {% url 'app-edit' object.pk %} in a form throws > > > TemplateSyntaxErro

Re: Forms Delay

2009-12-16 Thread Daniel Roseman
On Dec 16, 3:09 pm, Limpy wrote: > I am using forms in a pretty standard way, however I am running into > some problems which I can't find a solution to involving forms not > updating appropriately. > > I have the following form code: > > class AllStatsForm(forms.Form): >         game = forms.Choi

Re: Need help: customise a multi-key dictionary sort to put None objects at the end.

2009-12-17 Thread Daniel Roseman
On Dec 17, 6:23 am, Sam Walters wrote: > Hi I have been reading stuff like: > > http://wiki.python.org/moin/SortingListsOfDictionaries > > I want to sort a list of dictionaries (alphanumeric values) by > multiple keys (achieved with code below). However I would like to > customise the comparator t

Re: comparing datefield

2009-12-17 Thread Daniel Roseman
On Dec 17, 10:10 am, gganesh wrote: > hi group, >  How to compare date field types in a template ,a have field due_on > taking DateField type .I have to compare to present date .I have tried > the following in vain ,please help > In a template > {% if enquiry.due_on >= datetime.datetime.today %} .

Re: How to deal with NULL value in template

2009-12-18 Thread Daniel Roseman
On Dec 18, 7:12 am, Continuation wrote: > I have a field with the null=True option > > How do I test for the Null value in template? > > I did something like: > > {% ifequal field Null %} >     do something > {% else %} >     do something else > > I tested it and it worked. But I want to make sure

Re: choice model with objects.values_list options

2009-12-20 Thread Daniel Roseman
On Dec 20, 4:26 am, GoSantoni wrote: > Found this (old) > posthttp://oebfare.com/blog/2008/feb/23/changing-modelchoicefield-queryset/ > > So i tried > > class Post(models.Model): >     blog = models.ForeignKey(blog) >     . >     url             = models.ModelChoiceField > (queryset=Image.obj

Re: Is this right: Modifying the admin changelist?

2009-12-21 Thread Daniel Roseman
On Dec 21, 4:40 pm, yummy_droid wrote: > Anyone have advice on this? Not really. Your solution is probably the best that can be done - it does involve instantiating the ChangeList twice, but that's pretty much unavoidable. One of the main criticisms a lot of people have of the (otherwise wonderfu

Re: Generic Inlines in Admin - Causes Parent model to disappear in Admin

2009-12-23 Thread Daniel Roseman
On Dec 23, 5:41 am, Victor Hooi wrote: >     class AddressInline(generic.GenericTabularInline): >         models = Address Is that just a typo here, or do you actually have it as 'models' in your code? It should be 'model'. Change that and see if it fixes your problem. -- DR. -- You received t

Re: Safety Properties and Consistency Issues

2009-12-23 Thread Daniel Roseman
On Dec 23, 6:56 pm, Pamela Bhattacharya wrote: > Hi, > > I wanted to know where I can get information about how Django > guarantees consistency and details about local safety properties. > > Thanks Er, what? Consistency in what? Safety where? -- You received this message because you are subscri

Re: copied change_form load problems

2009-12-23 Thread Daniel Roseman
On Dec 23, 11:14 pm, maxweld wrote: > I am pretty sure that it is not loading the custom template tags > {{ load i18n admin_modify adminmedia %} If that's a cut and paste, you have the opening tag wrong: it should be {% -- DR. -- You received this message because you are subscribed to the Googl

Re: outputting two lists in a table with two columns

2009-12-24 Thread Daniel Roseman
On Dec 24, 6:37 am, dhruvg wrote: > hey.. > > i have two lists - lets call them A and B, both of which have the same > number of elements. > > i want to output a table with two columns (one column which will have > rows containing elements of A and one column which will have rows > contains elemen

Re: Problem with letters like ÄÖÕÜ in django adm in

2010-04-15 Thread Daniel Roseman
On Apr 15, 4:54 pm, zayatzz wrote: > Hello > > I recieve this kind of error message when in admin: > > Caught an exception while rendering: ('ascii', 'Madalal temperatuuril k > \xc3\xbcpsetatud stressivaba sea parim t\xc3\xbckk', 23, 24, 'ordinal > not in range(128)') > > The text should actually

Re: Problem with letters like ÄÖÕÜ in django adm in

2010-04-15 Thread Daniel Roseman
On Apr 15, 7:52 pm, Bill Freeman wrote: > I don't find it on > http://docs.djangoproject.com/en/1.1/ref/templates/builtins/. No, it's not a builtin, it's part of the default admin - it renders the changelist. -- DR. -- You received this message because you are subscribed to the Google Groups

Re: a simple question concerning dots in template values

2010-04-15 Thread Daniel Roseman
On Apr 15, 8:26 pm, xpanta wrote: > I have this template problem. > > Although {{ myDictionary.1 }} works, if I write > {{ myDictionary.user.id }} it does not. It prints nothing, actually. > (user comes from a {% for user in Users %} loop. > > user.id is 1 at the first iteration (I have checked it

Re: can't display my the data in my form

2010-04-16 Thread Daniel Roseman
On Apr 16, 3:08 pm, JoJo wrote: > Hi all, i am new to django, i was following an example online of how > to use forms, the one i am on at the min is a user page, where the > form accepts the submitted data, i have the html page displaying but > when i click submit i get this error > > Environment:

Re: can't display my the data in my form

2010-04-16 Thread Daniel Roseman
On Apr 16, 3:24 pm, JoJo wrote: > Snippet must be a class, see i'm not sure because i am following an > example from a book online and some of the pages aren't displayed, so > i don't no what is in snippet. You need to learn some Python. You can't use any names that have not either been defined o

Re: modelmultiplechoicefield show as null on the template -2

2010-04-16 Thread Daniel Roseman
On Apr 16, 3:22 pm, Daxal wrote: > Hey guys, > > I am trying to render a modelmultiplechoicefield on my template and i > cannot seem to figure out how. any help would be appreciated. > > Thanks. > > Here is model: > class cvdb(models.Model): >   user = models.ForeignKey(User) >   Language = models

Re: select_related() and primary-keys

2010-04-18 Thread Daniel Roseman
On Apr 18, 5:32 pm, Daishy wrote: > Hi together, > > I'm trying to use select_related in a query, but it seems i'm doing > something wrong. I have googled, but not really found anything (Maybee > used the wrong keywords :/) > > I've got a model that is related to another model, roughly like that:

Re: get_next_by title?

2010-04-19 Thread Daniel Roseman
On Apr 19, 5:55 am, ChrisR wrote: > I still haven't found anything useful to help on this. > > Anyone have any thoughts, suggestions, pointers? > The basic algorithm for get_next_by_FOO is just: MyModel.objects.order_by('FOO').filter(FOO__gt=myobject.FOO)[0] In other words, order by the relevan

Re: multiple projects are getting url's confused

2010-04-19 Thread Daniel Roseman
On Apr 19, 7:38 pm, mh...@yahoo.com wrote: > I'm fairly new to django so hopefully its something simple I'm missing > - I've tried setting up 2 separate projects(both are fairly simple) > > The problem I'm having is, after restarting apache2 > I can point my browser to:http://98.232.251.252/stockda

Re: Getting a Blog included in the Django community aggregator

2010-04-21 Thread Daniel Roseman
On Apr 20, 3:36 pm, Russell Keith-Magee wrote: > Obviously this isn't an isolated problem - I'll see what I can do > about changing the advice on the community page so that Jacob's inbox > doesn't become a bottleneck. > > Yours, > Russ Magee %-) Without wishing to pile on, I'm in exactly the same

Re: Why doesn't my isinstance() work?

2010-04-21 Thread Daniel Roseman
On Apr 21, 7:08 am, Lachlan Musicman wrote: > Hola, > > I'm having trouble getting a subclass to trigger an isinstance(). Code below: > > model.py excerpt: > > from django.db import models > from django.forms import ModelForm > > class Author(models.Model): >   first = models.CharFiel

Re: Setting list_display for InlineModelAdmin

2010-04-21 Thread Daniel Roseman
On Apr 21, 3:20 pm, Brad Pitcher wrote: > Hi guys, > This is driving me a little crazy, so I hope someone can offer good > advice.  I've specified an inline class in my admin.py file, and in it > I have specified a subset of the classes attributes with > list_display.  However, what I set in list

Re: How to set the sucess message after inserting values to db in django admin site

2010-04-22 Thread Daniel Roseman
On Apr 22, 7:09 am, Radhikavk wrote: > And i tried to enable the messaging module in django but in django.contrib > messages folder is missing > my django version is 1.1 > > Thaks > Radhika If you're using 1.1, you really should use the 1.1 documentation. http://docs.djangoproject.com/en/1.1/top

Re: django bitwise operator

2010-04-22 Thread Daniel Roseman
On Apr 22, 6:10 am, CCC wrote: > In django's modelManager > I use oracle do bitwise operator,like: > > select * from MultiRoom m where bitand(m.groupidx,tem ) <> 0 > > and Now I want to change it to  use django's orm ? > anyone know how to write? > Thanks Use 'extra' : MultiRoom.objects.extr

Re: unable to create en-gb for localisation

2010-04-22 Thread Daniel Roseman
On Apr 22, 7:48 pm, Aaron Lee wrote: > Hi, > > I am trying to create a UK version of my site and ran into some problems. > I am manually setting my LANGUAGE_CODE to 'en-gb' and use > django-admin.py makemessages -l en-gb and then run compilemessages > > For some reason it's not picking up the loca

Re: Any way to do select_related() moving backward?

2010-04-23 Thread Daniel Roseman
On Apr 23, 12:03 am, Continuation wrote: > Is there any way to do something similar to select_related() when > following a foreign key relationship backward? > > For example, > b = Blog.objects.get(id=1) > e = b.entry_set.all() > > Any way to retrieve both b and e in one single DB query? No, not

Re: form class

2010-04-23 Thread Daniel Roseman
On Apr 23, 8:52 am, xpanta wrote: > Hi, > > I wanted to ask if I am somehow "obliged" to use the form class > provided by Django framework. I can see its use on "static" forms (eg. > registration forms or account forms) but most of the forms I write are > "dynamic" (forms that are dynamically crea

Re: error with forms

2010-04-24 Thread Daniel Roseman
On Apr 17, 1:14 am, JoJo wrote: > Hi all, i have an error here im not sure what it means can anyone help > me > > here is my models.py file## > class AddStuffForm(forms.Form): > >         title = forms.CharField(max_length=100) >         body = forms.CharField(widget = forms.Textarea()) > >      

Re: form class

2010-04-24 Thread Daniel Roseman
On Apr 23, 9:03 pm, xpanta wrote: > Thank you for the answers. > > The link provided by George is an excellent resource and I should > thank him for that. > > However my task is a bit simpler. Let's say I own a car company and I > have dealers in various cities. By clicking on each city name I get

Re: admin not playing nicely with sqlite

2010-04-25 Thread Daniel Roseman
On Apr 25, 6:07 pm, Sheena wrote: > I've been experiencing some strange problems with my admin site. I > defined a few simple models and got Django to talk to an sqlite db > sucessfully, I have no problem adding and removing table entries > through the shell. I then activated the admin site and ad

Re: Template tag to understand if a request if from a spider

2010-04-27 Thread Daniel Roseman
On Apr 27, 9:42 am, Alessandro Ronchi wrote: > Is it possible to check in a django template if a request is from a spider/ > bot or not? > > -- > Alessandro Ronchi > As long as you use a RequestContext to render your template, and the tag itself has access to the `request` object - either passed

Re: Template tag to display boolean values?

2010-04-28 Thread Daniel Roseman
On Apr 28, 9:08 am, derek wrote: > On Apr 25, 6:55 pm, Dmitry Dzhus wrote:> Derek wrote: > > > I am looking for a way to display a boolean value, with the "on" / "off" > > >http://docs.djangoproject.com/en/1.1/ref/templates/builtins/#yesno > > -- > > Thanks - but that outputs strings, not URL lin

Re: Template tag to display boolean values?

2010-04-28 Thread Daniel Roseman
On Apr 28, 10:25 am, derek wrote: > On Apr 28, 11:12 am, Daniel Roseman wrote: > > > On Apr 28, 9:08 am, derek wrote: > > > > On Apr 25, 6:55 pm, Dmitry Dzhus wrote:> Derek wrote: > > > > > I am looking for a way to display a boolean value, with

Re: Admin Inline empty extra - how to access parent form model ID?

2010-04-28 Thread Daniel Roseman
On Apr 28, 10:48 am, mixit wrote: > Using an Inline in an Admin form: > The main Form model has various text fields, and one Inline, using a > custom little form of its own. > The Inline model has an parentFK pointing to the parent Form model and > has an different FK to a large table, which is di

Re: "dynamically" setting ModelAdmin properties?

2010-04-29 Thread Daniel Roseman
On Apr 29, 6:10 am, akonsu wrote: > hello, > > in my custom admin class that inherits ModelAdmin i need to set > ModelAdmin.exclude, ModelAdmin.list_display, etc based on whether the > logged in user is a superuser or not. > > is this possible? > > thanks > konstantin > ModelAdmin provides a get_

Re: Setting readonly_fields dynamically

2010-04-29 Thread Daniel Roseman
On Apr 29, 3:43 pm, Nick wrote: > Hi, > > I would like to set some fields to be readonly in the Admin app based > on some logic, and would like to use the new readonly_fields attribute > of ModelAdmin if possible (rather than some other sort of hack). > > I'm trying to access readonly_fields, but

Re: django-admin tab completion not working

2010-04-30 Thread Daniel Roseman
On Apr 30, 7:55 am, Martin Lundberg wrote: > Thanks, at least I know that it should work. Could it be that I don't have > bash-completion installed on osx? I've tried to install it with brew and it > seemed to work but I'm not sure if it is in fact installed and working and > I'm not sure how to t

Re: How to filter a query set based on a calculated date value?

2010-04-30 Thread Daniel Roseman
On Apr 30, 11:26 am, Derek wrote: > I would like to be able to filter a query set based on a calculated date > value.  Googling did not bring up anything obvious. > > As close as I can express it in "pseudo syntax", I'd like to do something > along these lines: > > import datetime > from dateutil.

Re: Problems with Admin CSS

2010-05-01 Thread Daniel Roseman
On May 1, 10:15 am, maxweld wrote: > Hi > I have set up a basic project and am trying to get it running under > Apache in a shared virtual hosting environment. The aim is to get it > working here first, and then work with my hosting company so that they > can support Django for their customers. >

Re: Problems with Admin CSS

2010-05-01 Thread Daniel Roseman
On May 1, 2:16 pm, maxweld wrote: > On May 1, 12:17 pm, Daniel Roseman wrote: > > > On May 1, 10:15 am, maxweld wrote: > > > You haven't got anything in here to actually serve the files from www. > > Surely you should have an Alias directive to point to the m

Re: add button to admin change list at row level.

2010-05-02 Thread Daniel Roseman
On May 2, 4:29 am, Wayne wrote: > Hi, > > We are trying to customize Django admin change list displaying model > objects. We want to add two buttons (Change, delete) to each row of > the record, something very similar to "Add" and "Change" buttons on > application list beside the model name. Could

Re: error in urls.py

2010-05-03 Thread Daniel Roseman
On May 3, 8:27 am, andy saksena wrote: > Hi > > my urls.py is > > from django.conf.urls.defaults import * > > # Uncomment the next two lines to enable the admin: > from django.contrib import admin > admin.autodiscover() > > urlpatterns = patterns(”, > # Example: > # (r’^/’, include(‘.foo.u

Re: Multiple Django versions on one server?

2010-05-03 Thread Daniel Roseman
On May 3, 1:03 pm, Stodge wrote: > We're about to deploy our Django app on our production Redhat cluster > using mod_wsgi, earlier than expected. We developed the app using > Django 1.2b1 because we wanted the multiple database support. > Unfortunately, the cluster uses Django 1.1.x. What are th

Re: Q objects subquery

2010-05-04 Thread Daniel Roseman
On May 4, 9:53 am, danfis wrote: > Hi guys, > > i ran into a problem today which i'm not sure if it's a bug (or a > feature?!) so you might can help me: > > when i call a model manager method to manipulate the queryset and > using Q objects for filtering, it seems like the query of the method > (=

Re: HttpResponseRedirect and user message

2010-05-04 Thread Daniel Roseman
On May 4, 9:43 am, xpanta wrote: > Thank you. One more thing: how to save info in the session? Read the fine documentation: http://docs.djangoproject.com/en/1.1/topics/http/sessions/ -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To po

Re: TypeError with a Decimal Field

2010-05-04 Thread Daniel Roseman
On May 4, 1:15 pm, JonathanB wrote: > I'm working on a Grade Book program for my personal use. Here is the > relevant class from my models.py file: > > class Grade(models.Model): >         student = models.ForeignKey(Student) >         assignment = models.ForeignKey(Assignment) >         grade = m

Re: Working out some custom API stuff

2010-05-05 Thread Daniel Roseman
On May 5, 4:46 am, Nick wrote: > Here's the deal. I'm working on a custom API for moving information > about. I am stuck at a point in creating my view. > It might be best just to get into the details. > > Here is the model: > > class entry(models.Model): >     question = models.CharField('Questio

Re: How to adapt some code provided by friend

2010-05-05 Thread Daniel Roseman
On May 5, 11:06 am, Etienne Python wrote: > Hey all, > > I'm a real beginner at both Django and Python, so excuse me if my > question looks silly to you. > > A friend of mine did me a huge favour by coding a form for me. > However, I would like to modify a couple of details in the page. > > I have

Re: How to adapt some code provided by friend

2010-05-05 Thread Daniel Roseman
On May 5, 12:23 pm, Etienne Python wrote: > > File "c:\python26\lib\site-packages\django\db\backends\mysql\base.py", > line 13, in >    raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e) > django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb > module: No module named

Re: How to adapt some code provided by friend

2010-05-05 Thread Daniel Roseman
On May 5, 1:05 pm, Etienne Python wrote: > Well actually, I copied all of the data (including the database), not only > the code. But indeed, like you say, the problem is not solved yet just by > installing mysql. > > So I followed the alternative solution you suggested. Now I get another > error

Re: Syntax for displaying field values from parent model(s) in a template?

2010-05-05 Thread Daniel Roseman
On May 5, 6:27 pm, Derek wrote: > I  have set of models, with relationships D -> C -> B -> A, where the > "->" indicates a "many to one" relationship. > > I have been able to create a filtered queryset on child model D, based > on a value in a parent model A, using the following syntax: > > my_que

Re: Getting object representing the current user

2010-05-05 Thread Daniel Roseman
On May 5, 9:30 pm, Paul wrote: > I have the following model (stripped of comments and __unicode__ for > brevity) which defines  a comment in my Django app (I'm not using the > comment module provided with Django for various reasons): > > class Comment(models.Model): >   comment = models.TextField(

Re: Errors while attempting to enable admin

2010-05-07 Thread Daniel Roseman
On May 7, 4:37 am, Andrew Burns wrote: > Django newbie here.  I am learning by following the Django book.  All > is good until I try to enable the admin interface (on v1.1.1) and I > get the following error: >         TemplateDoesNotExist at /admin/ >         admin/login.html > > So I did some pok

Re: Error with passing 'form_class' arg with Django Contact Form

2010-05-07 Thread Daniel Roseman
On May 7, 1:48 am, Ricko wrote: > Hi All, > > Bashing my head against a wall trying to understand this issue. > Playing around with Django-Contact-Form app, and trying to use my own > subclassed Form in the views. From the code in views, it looks like it > just takes an optional arg, form_class, w

Re: values() and GenericRelation

2010-05-07 Thread Daniel Roseman
On May 7, 10:53 am, caio wrote: > I have in my model something like this: > > class Person(models.Model): >     field1 = ForeignKey(City) >     field2 = models.TextField() >     field3 = ForeignKey(Type) >     photos = ImagingField() >     photos_set = generic.GenericRelation(Image) >     > >

Re: Additional Text Form Field within a Models Admin Screen

2010-05-09 Thread Daniel Roseman
On May 9, 12:49 am, Nick Taylor wrote: > Hi all, > > I'm pretty new to Django so bare with me if this is a simple question. > > Basically, I have an Article model which is simply title, body, status > etc. Now, I want to add an additional TextBox to the admin for the > model, but I don't want to a

Re: Models Tutorial Django

2010-05-11 Thread Daniel Roseman
On May 11, 11:15 am, HelloWorld wrote: > Hi Jirka > > Thanks for your answer! > > By structure I mean, I just followed the tutorial and am not sure if > the position and order of these tutorial code is right in my code: > > class Poll(models.Model): >     # ... >     def __unicode__(self): >      

<    5   6   7   8   9   10   11   12   13   14   >