Re: Current user in model.save() context

2009-07-21 Thread Bartłomiej Górny
Matthias Kestenholz wrote: > On Mon, Jul 20, 2009 at 9:26 AM, Bartłomiej Górny wrote: >> [...] >>> there is a cookbook recipe for achieving this sort of thing: >>> >>> http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser >> Yep, that's exactly what I did :) >> >>> That's deep in the cate

Re: Windows development server problem

2009-07-21 Thread Sam Lai
Did you forget any imports? Maybe your code snippet's identifiers clashed with the default django ones? Are there any errors in stdout? 2009/7/21 cwurld : > > Hi, > > I have a snippet of code that runs fine as a standalone program. But > when I incorporate it into a view and access that view w

Re: Current user in model.save() context

2009-07-21 Thread Bartłomiej Górny
Joshua Russo wrote: > On Mon, Jul 20, 2009 at 9:23 AM, Matthias Kestenholz > mailto:matthias.kestenh...@gmail.com>> > wrote: > > thread locals have all the problems which are generally associated > with global variables. They might be overwritten by other code, they > make testing e

Search Field Problem

2009-07-21 Thread Harish
Hi Friends, Just refer the sample code below. My problem is I am referring a Dependant models field in 'search_field' it is working correctly but when i delete a record from 'Dept' name from Dept Model the Search for the firstname is not working.. For example The following data is displayed in

Re: Windows development server problem

2009-07-21 Thread Daniel Roseman
On Jul 21, 12:13 am, cwurld wrote: > Hi, > > I have a snippet of code that runs fine as a standalone program. But > when I incorporate it into a view and access that view w the > development server, the snippet no longer works. > > What is the difference between the python interpreter and the > d

Re: combining valueslistqueryset with a simple list

2009-07-21 Thread V
thx On Jul 20, 4:25 pm, Alex Gaynor wrote: > On Mon, Jul 20, 2009 at 6:48 AM, Viktor wrote: > > > Hi, > > > I would like to run something like > > > ["User",].expand(MyObject.objects.all().values_list('myfield', > > flat=True) > > > but expand seemingly can't handle this operation. > > I was try

Re: Retaining POST DATA

2009-07-21 Thread Tim Chase
> I am sending POST data to a view But this view has login_required > decorator enabled, So if i m user is not logged in, he goes to > /accounts/login page and when user login, al the POST data is lost. Is there > any way to maintain the actual POST data sent for view. There was a long discuss

Re: Search Field Problem

2009-07-21 Thread PanFei
may I have your version of django ? On Tue, Jul 21, 2009 at 4:49 PM, Harish wrote: > > Hi Friends, > > Just refer the sample code below. > > My problem is I am referring a Dependant models field in > 'search_field' > it is working correctly but when i delete a record from 'Dept' name > from Dept

Re: Search Field Problem

2009-07-21 Thread Harish
The Django Version I am using is '0.97-pre-SVN-7049' On Jul 21, 2:56 pm, PanFei wrote: > may I have your version of django ? > > On Tue, Jul 21, 2009 at 4:49 PM, Harish wrote: > > > Hi Friends, > > > Just refer the sample code below. > > > My problem is I am referring a Dependant models field

Re: Search Field Problem

2009-07-21 Thread PanFei
oh my god ,I begin studying django by using 1.02 On Tue, Jul 21, 2009 at 6:06 PM, Harish wrote: > > The Django Version I am using is > '0.97-pre-SVN-7049' > > > On Jul 21, 2:56 pm, PanFei wrote: > > may I have your version of django ? > > > > On Tue, Jul 21, 2009 at 4:49 PM, Harish wro

Re: django profiles :: choices form?

2009-07-21 Thread Léon Dignòn
You might take a look at this: http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fields models.py class Foo(models.Model): GENDER_CHOICES = ( ('M', 'Male'), ('F', 'Female'), ) gender = mo

Re: Foreign Keys

2009-07-21 Thread AKK
Do i need to have a one to many or many to many field for this to work? Thanks Andrew On 20 July, 22:24, AKK wrote: > Hello, i currently have two classes in my model: > > class Post(models.Model): >     prepopulated_fields = {"post_slug": ("post_title",)} > >     post_title = models.CharField(

Re: Foreign Keys

2009-07-21 Thread TiNo
On Mon, Jul 20, 2009 at 23:24, AKK wrote: > > Hello, i currently have two classes in my model: > > class Post(models.Model): >prepopulated_fields = {"post_slug": ("post_title",)} > >post_title = models.CharField(max_length=750) >post_slug = models.SlugField() >

Django site on Apache

2009-07-21 Thread Kannan
Hi friends... I have downloaded the source of the http://in.pycon.org/2009/from here http://bitbucket.org/lawgon/fossconf/downloads/. I try to run the site in my Apache server. So i copy the extracted file to my /var/www/ directory named fossconf. My apache2 conf file is here http://d

Re: Django admin doesn’t show translated enumerations in list view under Python 2.3

2009-07-21 Thread Ramiro Morales
On Mon, Jul 20, 2009 at 8:45 PM, Tomas Andrle wrote: > > When using localized list of "choices" for a model field, the admin > doesn't show the translated values in the list view. > > Short example: > > from django.utils.translation import ugettext_lazy as _ > > class OrderStates: >    STATES = (

Re: Search Field Problem

2009-07-21 Thread ankit rai
pls switch to django 1.1 beta version.You can easily download it from django site On Tue, Jul 21, 2009 at 3:47 PM, PanFei wrote: > oh my god ,I begin studying django by using 1.02 > > > > > On Tue, Jul 21, 2009 at 6:06 PM, Harish wrote: > >> >> The Django Version I am using is >> '0.97-pr

Re: Problem sending json objects

2009-07-21 Thread Gustavo Henrique
Thanks, David! I converted to string using: str_obj = '' $.each(obj, function(k, v) { str_cols += '"'+k+'": "'+v+'",'; }); str_obj = '{'+str_obj.slice(0,-1)+'}'; -- Gustavo Henrique Site: http://www.gustavohenrique.net Blog: http://blog.gustavohenrique.net --~--~-~--~~

Re: Template tags as parameter to template tag

2009-07-21 Thread David De La Harpe Golden
phoebebright wrote: > Is there a way to get this to work: > > {% for tag in tags %} > {% tag_link > "{{tag.name}}" %} > {% endfor %} > > > The outer loop is using the standard tagging application and the > tag_link is my custom template tag which has a di

Re: Django site on Apache

2009-07-21 Thread Daniel Roseman
On Jul 21, 12:16 pm, Kannan wrote: > Hi friends... >              I have downloaded the source of > thehttp://in.pycon.org/2009/fromherehttp://bitbucket.org/lawgon/fossconf/downloads/. > I try to run the site in my Apache server. > So i copy the extracted file to my /var/www/ directory named fos

SpatialRefSys

2009-07-21 Thread ckar...@googlemail.com
Hi, i've posted this question already in the geodjango-group (http:// groups.google.com/group/geodjango/browse_thread/thread/ 844c8c601f24cdf9?hl=en) but I think this should be a general django question. I have in my models: class PointClass(...): srid = models.ForeignKey(SpatialRe

Re: Retaining POST DATA

2009-07-21 Thread ckar...@googlemail.com
You should define in your template or view to enable/disable the submit button if the user is logged in/logged out before sending POST Data. But I think there should be a way to this what you want ;-) On Jul 21, 7:57 am, Raashid Malik wrote: > hi all, > >   I am sending POST data to a view But t

UnicodeEncodeError on admin site

2009-07-21 Thread Rodrigo Gomes
Hi, I'm getting the error below when i'm trying to edit a non ascii value on the admin site. I tried to put # -*- coding: utf-8 -*- on my model file, tried to set settings.FILE_CHARSET to 'utf-8' and I tried to put on the admin page "change.form.html", but it didn't work. Is there something that

TransactionMiddleware not working

2009-07-21 Thread Parag Shah
Hello, Hello, I am using TransactionMiddleware to get per request transactions working in my Django project. However, it does not seem to be working. I have a view in which I save an object and when I try to save a related object there is an Exception. However, the first object is still saved. P

Re: Model inheritance problem, inherited instances

2009-07-21 Thread Rodrigue
If you look here http://docs.djangoproject.com/en/dev/topics/db/models/#id7 you'll see that multi-table inheritance is handled at the db level "via an automatically-created OneToOneField". This means that an instance of B has a foreign key to an instance of A. At the model level, there should be

middleware cache problem

2009-07-21 Thread Norman
Hi all, I cache my view that show a list of stories, but I have also small voting button (like digg). Voting is done be middleware class (it reads user IP), so I can ask for view with list of stories and tell that this list shall be cached and I have to ask middleware for vote results. Unfortuna

Re: UnicodeEncodeError on admin site

2009-07-21 Thread Daniel Roseman
On Jul 21, 1:27 pm, Rodrigo Gomes wrote: > Hi, > > I'm getting the error below when i'm trying to edit a non ascii value on the > admin site. > I tried to put # -*- coding: utf-8 -*- on my model file, tried to set > settings.FILE_CHARSET to 'utf-8' and I tried to put > on the > admin page "chang

How I run background processes

2009-07-21 Thread Philippe Josse
Hi there, I would like to have your feedback on the way I am running daemon scripts for my Django/ Python app. I know this is definitely not the "one best way", but this is a solution I came up with that seemed simple to implement. (I am a real newbie!) My constraints: - getting a few processs c

Re: middleware cache problem

2009-07-21 Thread Michael
On Tue, Jul 21, 2009 at 9:02 AM, Norman wrote: > > Hi all, > > I cache my view that show a list of stories, but I have also small > voting button (like digg). Voting is done be middleware class (it > reads user IP), so I can ask for view with list of stories and tell > that this list shall be cac

Re: Django site on Apache

2009-07-21 Thread Kannan
>Only you can help yourself, and you do that by reading the >documentation: >http://docs.djangoproject.com/en/dev/howto/deployment/ I read the documentation of that and configure all the settings. that settings work in Fedora 10 bu

Filtered ManyToMany list in admin?

2009-07-21 Thread kaosbunny
Hello! I'm fairly new to Python and Django and have mostly focused on the admin system so far, but I am a programmer with fairly deep html/css/ javascript knowledge. I was wondering if it's possible to filter the list generated in admin forms for a ManyToMany field in a model. Ideally I would l

Re: How I run background processes

2009-07-21 Thread Andrew Fong
>> I was worried by potential caching issues with the database that >> may prevent my cron script to retrieve the latest boolean value. It sounds as if you're worried about a race condition when scale up -- e.g. let's say you need to run a lot of background processes and decide to split them up a

Re: never_cache doesn't work for login page

2009-07-21 Thread Ronghui Yu
Eugene Mirotin ??: > May be the order of middleware classes does matter here? > > On Jul 19, 4:08 pm, Ronghui Yu wrote: > >> It proves that it is introduced by >> django.middleware.http.ConditionalGetMiddleware. It returns 304 when >> requesting the same login page, so at last the browser uses

Re: Django site on Apache

2009-07-21 Thread Andrew Fong
The documentation is distribution agnostic, so I'm not sure what you're referring to. It sounds as if you just dropped a Django project into /var/www and expected it to work. Unfortunately, Django is not PHP. I'm going to assume you're unfamiliar with how Django works, so apologies if you already

Re: TransactionMiddleware not working

2009-07-21 Thread Andrew Fong
Just double checking, but are you using a DB that supports transactions? On Jul 21, 8:16 am, Parag Shah wrote: > Hello, > > Hello, > > I am using TransactionMiddleware to get per request transactions working in > my Django project. However, it does not seem to be working. > > I have a view in wh

Re: TransactionMiddleware not working

2009-07-21 Thread Parag Shah
Hi Andrew, I am using MySql. I believe it does support transactions. Here is the version line of my instance of MySql $mysql -V mysql Ver 14.12 Distrib 5.0.67, for debian-linux-gnu (x86_64) using readline 5.2 -- Thanks & Regards Parag Shah On Tue, Jul 21, 2009 at 7:16 PM, Andrew Fong wrote:

Re: pre-fetch one-to-many and many-to-many relationships

2009-07-21 Thread Miriam
Hi Russ -- Awesome. I will organize my ideas and start a thread over on django- developers. > I've heard people claim that > this is possible in Rails (also in SQLAlchemy), but I've never had > enough of an itch to go looking and see if this is true, and if so, > how they implement it. This is

Re: TransactionMiddleware not working

2009-07-21 Thread Hank Gay
Not all of the storage engines in MySQL support transactions, e.g., MyISAM doesn't. On Tue, Jul 21, 2009 at 9:54 AM, Parag Shah wrote: > Hi Andrew, > > I am using MySql. I believe it does support transactions. Here is the > version line of my instance of MySql > > $mysql -V > mysql  Ver 14.12 Dis

Re: TransactionMiddleware not working

2009-07-21 Thread Randy Barlow
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Parag Shah declared: > I am using MySql. I believe it does support transactions. MySQL only supports transactions if you are using INNODB tables. This is not the default. - -- Randy Barlow Software Developer The American Research Institute http://a

Re: UnicodeEncodeError on admin site

2009-07-21 Thread Rodrigo Gomes
Hi Daniel, My databse enconding (Mysql) is utf-8, as you can see below: Server characterset:latin1 Db characterset:utf8 Client characterset:latin1 Conn. characterset:latin1 There is something strange, because I'm showing the same information on my page and I'm not getting th

Re: middleware cache problem

2009-07-21 Thread Norman
per-view cache is not a solution because I need only a method to retrieve fresh (not cached) data from middleware. I wanna take cached list of stories and not cached vote results for it. regards, Norman On Jul 21, 3:13 pm, Michael wrote: > On Tue, Jul 21, 2009 at 9:02 AM, Norman wrote: > >

Re: Foreign Keys

2009-07-21 Thread AKK
Thanks, i tried this: blog_posts = Post.objects.filter(post_slug=slug) blog_comments = blog_posts.comment_set.all() but i got this error and i don't know why: Traceback: File "C:\ProgLangs\Python25\lib\site-packages\django\core\handlers \base.py" in get_response 86. response =

Re: Foreign Keys

2009-07-21 Thread Daniel Roseman
On Jul 21, 4:25 pm, AKK wrote: > Thanks, i tried this: > > blog_posts = Post.objects.filter(post_slug=slug) > blog_comments = blog_posts.comment_set.all() > > but i got this error and i don't know why: > > Traceback: > File "C:\ProgLangs\Python25\lib\site-packages\django\core\handlers > \base.py"

Don't understand ModelForm

2009-07-21 Thread mettwoch
Hi, I'd like to implement a simple "create" & "update" form for my "Partner" model using ModelForm. How can I make the difference in a view "save" function whether the POST comes from a "creation" or an "update" form? Unfortunately the primary-key seems never to be included by default in the form

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 12:00 PM, mettwoch wrote: > > Hi, > > I'd like to implement a simple "create" & "update" form for my > "Partner" model using ModelForm. How can I make the difference in a > view "save" function whether the POST comes from a "creation" or an > "update" form? Unfortunately the

Re: UnicodeEncodeError on admin site

2009-07-21 Thread Daniel Roseman
On Jul 21, 3:46 pm, Rodrigo Gomes wrote: > Hi Daniel, > > My databse enconding (Mysql) is utf-8, as you can see below: > > Server characterset:    latin1 > Db     characterset:    utf8 > Client characterset:    latin1 > Conn.  characterset:    latin1 But what about your actual tables? When you d

inclusion_tag -- error

2009-07-21 Thread Buddy
Hi. I learn to inclusion_tag from django documentation. and i take code from here. I try do it code: http://dpaste.com/69553/ but i get error: http://dpaste.com/69555/ Where is my mistake? --~--~-~--~~~---~--~~ You received this message because you are subscribed t

Recommendations for a Django development book?

2009-07-21 Thread Stodge
What is currently the best Django development book? There seem to be quite a few on Amazon.ca, but none are reviewed. I'm familiar with Python and the very basics of Django and I've been developing s/w for 15+ years. So something geared towards advanced users would be good. Much appreciated! Than

Re: Template tags as parameter to template tag

2009-07-21 Thread Reiner
Maybe I'm missing something here, but what is wrong with this? {% tag_link tag.name %} The string "tag.name" gets passed to your template tag, you resolve it against the current context when rendering it, and then you have the value and can do whatever you want with it. See [1] for reference. [

Re: Don't understand ModelForm

2009-07-21 Thread mettwoch
Sorry my old brain doesn't get it. Is there somewhere a complete CRUD example using ModelForm? Thanks Marc On Jul 21, 6:04 pm, Shawn Milochik wrote: > On Jul 21, 2009, at 12:00 PM, mettwoch wrote: > > > > > > > Hi, > > > I'd like to implement a simple "create" & "update" form for my > > "Partne

Re: Recommendations for a Django development book?

2009-07-21 Thread Masklinn
On 21 Jul 2009, at 18:36 , Stodge wrote: > What is currently the best Django development book? There seem to be > quite a few on Amazon.ca, but none are reviewed. I'm familiar with > Python and the very basics of Django and I've been developing s/w for > 15+ years. So something geared towards adva

AnonymousUser and groups attribute

2009-07-21 Thread Frédéric Hébert
Hi there, I've a context_processor to automatically add to each template a object which says to me if a given user is memeber of an admin group. It works fine when user is authenticated (whichever groups he belongs to) but raise an AttributeError when user is not. "Nonetype has no attribute _me

Re: TransactionMiddleware not working

2009-07-21 Thread Parag Shah
Thanks for the help. Transactions work just fine after changing MyISam to InnoDB. -- Thanks & Regards Parag Shah On Tue, Jul 21, 2009 at 7:42 PM, Randy Barlow wrote: > > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > Parag Shah declared: > > I am using MySql. I believe it does support tran

Re: Making Django ldapauth more sophisticated

2009-07-21 Thread Frédéric Hébert
On 21 juil, 00:35, "Daniele Procida" wrote: > I finally have ldapauth working now, and a user who is in our LDAP > database can connect as a Django User. > > But it's not entirely satisfactory. Before the LDAP user becomes a > Django User they have to try logging (which fails of course). Are y

admin add view saves two entries on submit

2009-07-21 Thread JP
Hi! I'm not sure why this happens but when I save a model (that has a foreign key) two identical entries are saved in the database (but diffs in id of course..). As there aren't really any errors I'm stumped on where to actually start looking. Any ideas? The models I made we're really simple test

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 12:49 PM, mettwoch wrote: > > Sorry my old brain doesn't get it. Is there somewhere a complete CRUD > example using ModelForm? > > Thanks > Marc CRUD: If your modelform is called PartnerForm, then. CREATE and UPDATE: #on initial page load (no POST)

Re: Recommendations for a Django development book?

2009-07-21 Thread Shawn Milochik
"The Definitive Guide to Django," second edition. It was just published and was written by Adrian Holovaty and Jacob Kaplan-Moss. In case you don't know who they are, they're the co-creator and a lead developer of Django, respectively. --~--~-~--~~~---~--~~

Re: Don't understand ModelForm

2009-07-21 Thread mettwoch
Hi again, That's exactly what I did and the point is that it doesn't work! See my comments below ... On Jul 21, 8:00 pm, Shawn Milochik wrote: > On Jul 21, 2009, at 12:49 PM, mettwoch wrote: > > > > > Sorry my old brain doesn't get it. Is there somewhere a complete CRUD > > example using ModelF

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
> > This always creates a new partner! In fact, in the ModelForm > documentation is written that the save() method creates a new instance > unless an existing instance is passed to the ModelForm constructor. So > one has to differentiate if the POST comes from an initially empty > form or from a bo

Re: Recommendations for a Django development book?

2009-07-21 Thread Dan Harris
You can always check out the free online Django book at: http://www.djangobook.com/ There is the 1.0 version (outdated) and a free web-preview of the 2nd edition available. In addition to books, the documentation for Django is pretty fantastic to learn from for a beginner. This is located at: h

Show related inlines in the admin on form of model with GenericForeignKey

2009-07-21 Thread ramu...@gmail.com
I have simple models with generic relations from this example at the Django Project: class Image(models.Model): image = models.ImageField(upload_to="images") content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericFor

How to make email field unique in model User from contrib.auth in Django

2009-07-21 Thread ramu...@gmail.com
I need to patch the standard User model of contrib.auth by ensuring the email field entry is unique: User._meta.fields[4].unique = True Where is best place in code to do that? I want to avoid using the number fields[4]. It's better to user fields ['email'], but fields is not dictionary, only li

Re: Don't understand ModelForm

2009-07-21 Thread mettwoch
Sorry to insist, but that's what I don't understand here. How can I know that the partner that is 'posted' is new or not? I really become crazy here. I can't believe after all the good things I've discovered in Django that this can be so hard. Thanks for your time > > You are right, I made a mist

Customizing context by opening up BoundField, is it ok?

2009-07-21 Thread Joshua Russo
I have a complex form that where I generate a grid (for lack of a better term) of fields for data entry. To simplify the template context I have a dictionaries within dictionaries so I can just use FOR loops within FOR loops in the template. My problem was that, unless I wrapped my fields in a Bo

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 3:39 PM, mettwoch wrote: > > Sorry to insist, but that's what I don't understand here. How can I > know that the partner that is 'posted' is new or not? I really become > crazy here. I can't believe after all the good things I've discovered > in Django that this can be so har

Re: Don't understand ModelForm

2009-07-21 Thread Dan Harris
This may not be helpful but here is how I usually go about processing model forms: class Partner(models.Model): # this is your model, DB fields go in here # This is your model form class PartnerForm(forms.ModelForm): class Meta: model = Partner # This is the view that displays a ne

Re: Don't understand ModelForm

2009-07-21 Thread mettwoch
Ok, I come back to what I wrote before. If the partner already exists it has an id (primary-key or whatever). If it doesn't exist it has no id. I'd just like to have the id in the form. Is it a bug, is something missing here or am I completely on the wrong track. That's basic database form handlin

Might have found a bug with manage.py

2009-07-21 Thread Some Guy
I have a model with a proxy subclass. dumpdata saves an entry for each of the superclass' and an additional entry for the proxy class (with no fields) as well. loaddata then chokes on the superclasses constraints. Or is it supposed to do this? i.e. (psuedocode..) assume app = 'bar' class a(

Re: Don't understand ModelForm

2009-07-21 Thread Dan Harris
What do you mean by having the ID "in" the form? I don't quite understand what you are trying to do. On Jul 21, 4:15 pm, mettwoch wrote: > Ok, I come back to what I wrote before. If the partner already exists > it has an id (primary-key or whatever). If it doesn't exist it has no > id. I'd just

Re: Might have found a bug with manage.py

2009-07-21 Thread Some Guy
also... Django version 1.1 beta 1 SVN-11082 On Jul 21, 1:22 pm, Some Guy wrote: > I have a model with a proxy subclass.  dumpdata saves an entry for > each of the superclass' and an additional entry for the proxy class > (with no fields) as well. > >  loaddata then chokes on the superclasses co

Re: Might have found a bug with manage.py

2009-07-21 Thread Some Guy
Nevermind, I should have checked trac first instead of searching this group found http://code.djangoproject.com/ticket/11429 and http://code.djangoproject.com/ticket/11428 I guess I'll have to be explicit with which models to dump On Jul 21, 1:23 pm, Some Guy wrote: > also... > > Django versi

Re: What editor do you use for .po files?

2009-07-21 Thread bittin
i also use PoEdit =) On Fri, Jun 19, 2009 at 11:05 PM, Joshua Russo wrote: > > I started using PoEdit but it seems to thing that the .po files > created by makemessages are malformed, or at least don't have all the > right headers. Is there a better editor for Windows? > > > i --~--~-~--

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 4:22 PM, Dan Harris wrote: > > What do you mean by having the ID "in" the form? I don't quite > understand what you are trying to do. > > On Jul 21, 4:15 pm, mettwoch wrote: >> Ok, I come back to what I wrote before. If the partner already exists >> it has an id (primary-key

Re: Don't understand ModelForm

2009-07-21 Thread mettwoch
I'd like this to work: class PartnerForm(forms.ModelForm): class Meta: model = Partner # I expect that all fields are included in the form (the 'id' field as well) def partner_new(request): form = PartnerForm() return render_to_response('pos.html', {'form': form}, RequestCo

Re: Don't understand ModelForm

2009-07-21 Thread Daniel Roseman
On Jul 21, 9:34 pm, mettwoch wrote: > I'd like this to work: > > class PartnerForm(forms.ModelForm): >     class Meta: >         model  = Partner  # I expect that all fields are included in > the form (the 'id' field as well) > > def partner_new(request): >     form = PartnerForm() >     return r

Re: Don't understand ModelForm

2009-07-21 Thread mettwoch
Of course! The mistake is that I didn't have the ID in the URL, but I took the partner to be edited somewhere from the session. I'll change the code and it should work as expected. Thanks again for your patience Marc On Jul 21, 10:57 pm, Daniel Roseman wrote: > On Jul 21, 9:34 pm, mettwoch wr

Re: Don't understand ModelForm

2009-07-21 Thread Dan Harris
Oh I gotcha now. Django model forms by default do not represent auto fields (ID's) because it wouldn't make much sense for a user to be able to edit the PK in a form. Having said that, I do understand why you need to be able to see the PK. I shown in my example, I personally prefer to represent

Re: Foreign Keys

2009-07-21 Thread AKK
Thank you, got it working On 21 July, 16:55, Daniel Roseman wrote: > On Jul 21, 4:25 pm, AKK wrote: > > > > > Thanks, i tried this: > > > blog_posts = Post.objects.filter(post_slug=slug) > > blog_comments = blog_posts.comment_set.all() > > > but i got this error and i don't know why: > > > Trac

best approaches with render_to_response and large forms

2009-07-21 Thread Juan Hernandez
Hi there, i have two questions in my mind. 1- Let's say that I have tens of views. Do I always have to use render_to_response? I find it totally against DRY. My solution was creating a wrapper that would take as arguments the template file name and a dictionary with all the parameters for that te

Re: Don't understand ModelForm

2009-07-21 Thread Shawn Milochik
To expand on what Dan said with a full (tested and working) example: In urls.py: (r'^partner/$', 'partner_page'), (r'^partner/(?P\d+)/$', 'partner_page'), In the form tag of your template: The view: @login_required def partner_page(request, partner_id = None): if par

Re: best approaches with render_to_response and large forms

2009-07-21 Thread Shawn Milochik
On Jul 21, 2009, at 5:21 PM, Juan Hernandez wrote: > Hi there, > > i have two questions in my mind. > > 1- Let's say that I have tens of views. Do I always have to use > render_to_response? I find it totally against DRY. My solution was > creating a wrapper that would take as arguments the te

Re: What editor do you use for .po files?

2009-07-21 Thread Jonas Obrist
Haven't started by i18n yet but rosetta looks good: http://code.google.com/p/django-rosetta/ bittin wrote: > i also use PoEdit =) > > On Fri, Jun 19, 2009 at 11:05 PM, Joshua Russo > mailto:joshua.rupp...@gmail.com>> wrote: > > > I started using PoEdit but it seems to thing that the .po fil

OR in query_set

2009-07-21 Thread caliman
How do you use django to use OR instead av AND when you use filter? Let's say I want: SELECT * FROM table WHERE attrib1 IN (1,2,3) OR attrib2 IN (4,5,6) in django: table.objects.filter(attrib1__in=[1,2,3]).filter(attrib2__in=[4,5,6]) this will be like: SELECT * FROM table WHERE attrib1 IN (1,2

Re: OR in query_set

2009-07-21 Thread Alex Gaynor
On Tue, Jul 21, 2009 at 4:48 PM, caliman wrote: > > How do you use django to use OR instead av AND when you use filter? > > Let's say I want: > SELECT * FROM table WHERE attrib1 IN (1,2,3)  OR attrib2 IN (4,5,6) > > in django: > table.objects.filter(attrib1__in=[1,2,3]).filter(attrib2__in=[4,5,6])

Bug when creating Q object from string representation of another Q object?

2009-07-21 Thread Margie
I have a situation where I want to do the following: take a bunch of POST params and from them create a Q object urlencode that Q object and turn it into a GET param, redirect using that param process the GET that contains the urlencoded Q object, create a Q object from it, an

Re: OR in query_set

2009-07-21 Thread Stefan Hjelm
Many 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 unsubscribe from this group, send email to django-users+unsubsc

replicating database changes from one postgres DB to another

2009-07-21 Thread Steve Howell
We have an application where we periodically import data from an external vendor, and the process is mostly automated, but we need to review the data before having it go live. We were considering an option where we would run processes on another database, do the manual validation, and then replic

Re: replicating database changes from one postgres DB to another

2009-07-21 Thread Wayne Koorts
Hi Steve, > We have an application where we periodically import data from an > external vendor, and the process is mostly automated, but we need to > review the data before having it go live. > > We were considering an option where we would run processes on another > database, do the manual valid

How to design a new website? (about apps)

2009-07-21 Thread Léon Dignòn
Ok, I have finished the tutorials and learned a lot about Django. I created a polls application and tuned the admin site, etc. Now I want to continue in a bigger application. After some successful coding I ran into a big problem not covered by any piece of documentation out there: 1. Do I need a

Re: How to design a new website? (about apps)

2009-07-21 Thread Javier Guerra
On Tue, Jul 21, 2009 at 10:19 PM, Léon Dignòn wrote: > These questions I would love to see answered: > - Do I create an app for the additional user information, or do I > create a model.py in the site root because it's a main functionality? > - Do I create an app for the image upload and browser,

Re: MEDIA_ROOT and file uploads

2009-07-21 Thread J
It worked automatically for me. Make sure you put enctype="multipart/form-data" in the form definition http://docs.djangoproject.com/en/dev/topics/http/file-uploads/ Note that request.FILES will only contain data if the request method was POST and the that posted the request has the attribute

Re: How to design a new website? (about apps)

2009-07-21 Thread Léon Dignòn
I found it, it's really really great!! http://www.youtube.com/watch?v=A-S0tqpPga4 On Jul 22, 12:30 am, Javier Guerra wrote: > On Tue, Jul 21, 2009 at 10:19 PM, Léon Dignòn wrote: > > These questions I would love to see answered: > > - Do I create an app for the additional user information, or do

Strange things happening with reverse url lookups

2009-07-21 Thread Vasil Vangelovski
I've posted a question about this a few days ago and I thought I was confused about something, but it was probably some problem with the django revision at the time or I'm even more confused now. So... I have an application called epg with a model named Show and I want to provide a link for editin

Re: Strange things happening with reverse url lookups

2009-07-21 Thread Michael
On Tue, Jul 21, 2009 at 7:53 PM, Vasil Vangelovski wrote: > > I've posted a question about this a few days ago and I thought I was > confused about something, but it was probably some problem with the > django revision at the time or I'm even more confused now. So... I > have an application called

Re: Strange things happening with reverse url lookups

2009-07-21 Thread Karen Tracey
On Tue, Jul 21, 2009 at 7:53 PM, Vasil Vangelovski wrote: > > I've posted a question about this a few days ago and I thought I was > confused about something, but it was probably some problem with the > django revision at the time or I'm even more confused now. So... I > have an application called

Re: UnicodeEncodeError on admin site

2009-07-21 Thread Rodrigo Gomes
Hi Daniel, I just changed my method as you suggested, to def __unicode__(self) and the problem was solved. Thanks so much! Rodrigo On Tue, Jul 21, 2009 at 12:54 PM, Daniel Roseman wrote: > > On Jul 21, 3:46 pm, Rodrigo Gomes wrote: > > Hi Daniel, > > > > My databse enconding (Mysql) is utf-8,

Re: Strange things happening with reverse url lookups

2009-07-21 Thread Vasil Vangelovski
Thanx It was just my luck reading about this new feature in the URL dispatcher and trying to use it in my project moments before it was added to trunk :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users

Django 1.1 release candidate now available

2009-07-21 Thread James Bennett
Hi folks! Tonight we've pushed out the Django 1.1 release candidate, which is hopefully the last stepping-stone to the final 1.1 release. If you'd like to try it out, here's where you'll want to look: * Download instructions: http://www.djangoproject.com/download/ * Release notes: http://docs.dja

Re: Django 1.1 release candidate now available

2009-07-21 Thread Joshua Partogi
Congrats! Thanks to everyone that have put all their effort delivering this beautiful framework. Regards, On Wed, Jul 22, 2009 at 12:35 PM, James Bennett wrote: > > Hi folks! Tonight we've pushed out the Django 1.1 release candidate, > which is hopefully the last stepping-stone to the final 1.1

Re: Windows development server problem

2009-07-21 Thread cwurld
Hi, Sorry for not giving more details. I did not want to get into my code as much as I was hoping to find out more about how the dev server might differ from the command line. I was using the pod module (http://code.google.com/p/pickled-object- database/) in addition to mysql. It turns out that

Re: django profiles :: choices form?

2009-07-21 Thread Saketh
Thanks, Léon -- this was exactly what I was looking for! Sincerely, Saketh On Tue, Jul 21, 2009 at 6:37 AM, Léon Dignòn wrote: > > You might take a look at this: > http://docs.djangoproject.com/en/dev/ref/models/fields/#ref-models-fields > > models.py >

  1   2   >