problems with get_or_create

2010-03-24 Thread Kenneth Gonsalves
hi, I have a model like this: name - unique slno - not null mode - not null If the instance does not exist and I give all three values to get_or_create, it works if the instance exists, and I give values for slno and mode which are different from the existing ones - I get a programming error

Re: modify db records without changing html

2010-03-24 Thread johnwlockwood
DG, what you describe is the AJAX approach. I'd use jQuery to help with this sort of thing. use jQuery.post() you would have to define a url to handle the post request and a view function to pass it to. from the view function, you could return an HttpResponse() with the confirmation bit of html or

Job opportunity - Newcastle, NSW, Australia

2010-03-24 Thread Peter Williams
Hi all Please see: http://tinyurl.com/rdnjob2 for a job being advertised by NSW Rural Doctors Network in Newcastle, NSW, Australia. Employment is open to Australian citizens, permanent residents and other applicants with the appropriate visa authorisation to work in Australia. The person

Re: modify db records without changing html

2010-03-24 Thread Django Grappelli
Put another way, how do execute a django function that simply does something with the data in my database? It seems that views are the only way to do this but perhaps I'm missing something. Thanks in advance for all the help. Best, DG On Wed, Mar 24, 2010 at 6:26 PM, Django Grappelli <

Initial data in a many to many field

2010-03-24 Thread mjlissner
I've been struggling with this literally for hours. I'm trying to use a ModelForm with initial values being set as those that are already in the DB for a user. This works marvelously for every field that I have EXCEPT for the one manytomany field I have in my model. For that one, I can submit the

Possible Bug: filter_horizontal not working when formfield_for_manytomany used

2010-03-24 Thread Korey Peters
Hello. When I use formfield_for_manytomany in my admin, those fields do not render with the filter_horizontal JS picker. For example: # admin.py class ProjectAdmin( admin.ModelAdmin ): def formfield_for_manytomany( self, db_field, request, **kwargs ): if db_field.name ==

Re: More PYTHONPATH issues

2010-03-24 Thread Riley
Yup that was it Thanks Riley On Mar 24, 7:12 am, Paulo Almeida wrote: > Ok, that makes more sense. You probably can't import django from anywhere > else because the django folder cannot be read. Try going to > /Library/Python/2.6/site-packages and type 'ls -l' to

Re: modify db records without changing html

2010-03-24 Thread Django Grappelli
Hi Guys, Thanks for your help. I was thinking of taking an AJAX approach, but wondered if there were a simpler way. Basically, I'd like to have the user click, e.g. a delete button. It would delete the selected record and display a small confirmation popup but I don't want to redirect to

Re: High, ongoing CPU consumption

2010-03-24 Thread Graham Dumpleton
On Mar 25, 3:39 am, David Christiansen wrote: > Dear fellow Django users, > > We're beginning to be at wits end with a particular problem that we're > having that I suspect has to do with server configuration issues, but > might be something else. > > Our Django processes (whether

Re: basic django auth fails on valid user

2010-03-24 Thread Tim Shaffer
I think this could all be simplified a bit if you used a UserProfile model instead of subclassing auth.User. http://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users Was there a specific reason you were subclassing auth.User? -- You received this message

new_records = assert_latest(query_set, lambda)

2010-03-24 Thread Phlip
Djangoists: I often want to assert that a given method call (possibly a client.post() call) creates one or a given number of records. This assertion samples the high-water-mark in the primary keys of a given QuerySet, calls your block, and then asserts that it could find your records:

Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker
On Mar 24, 2:08 pm, Shawn Milochik wrote: > > http://docs.python.org/library/functions.html#staticmethod > > It means that the method is function that, when you run it, doesn't > specifically belong to any particular instance, but to the class itself. > > Shawn Thanks

Re: Literal Brace Symbols in Templates

2010-03-24 Thread Rolando Espinoza La Fuente
On Wed, Mar 24, 2010 at 5:49 PM, saxon75 wrote: > I apologize if this is blindingly obvious, but suppose I want to have > a template actually print the literal string "{{ url }}" in the page. > How would I go about doing that?

Literal Brace Symbols in Templates

2010-03-24 Thread saxon75
I apologize if this is blindingly obvious, but suppose I want to have a template actually print the literal string "{{ url }}" in the page. How would I go about doing that? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: How verbose model name in admin panel

2010-03-24 Thread serek
Yes, you nad Nuno have right. Now it is work wll Thanks for help On 24 Mar, 18:56, Shawn Milochik wrote: > The verbose name options you show should work, but they should be in a meta > class within the main model. > > Example: > > class Category(models.Model): > >        

Re: Altering the auth_user model?

2010-03-24 Thread Thierry Chich
Le mercredi 24 mars 2010 16:53:12, Sandman a écrit : > Hi Derek, > > One way to do this would be to create a proxy model that can be used > throughout your project. > > Check out > http://docs.djangoproject.com/en/dev/topics/db/models/#proxy-models for > more info. Hi, This is what is said in

Re: basic django auth fails on valid user

2010-03-24 Thread Jim N
OK, so it seems what's happening is that the password is being stored in `api_qotduser` plain text. I *believe* Django expects a hashed password? More strangeness: I switched to using check_password and NOW Django is querying `api_qotduser`, where before it was querying `auth_user`. New login

Re: Overriding admin Media class

2010-03-24 Thread Shawn Milochik
> >> The problem is you are defining get_class as >> an instance method and trying to call it is a class method (or static >> method). > > Sorry, I have no idea what you're referring to here, and Googling for > static vs. class methods is not turning up anything I can understand. > Can you show

Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker
On Mar 24, 12:05 pm, Firat Can Basarir wrote: > Scot you need to learm Python. Do you mean learn *more* Python? Great, I'm always game to learn more! I've taken a Python class and read books and run several Django sites. It's not like I don't know enough Python to be

Re: Simple export of CSV

2010-03-24 Thread Shawn Milochik
Have your 'export' button make an AJAX call to a view, which creates the CSV file and prompts the user to 'Save As.' Details: 1. Use the same view you currently have, with an 'if' statement which returns a standard (html) response or a CSV file based on a slug in your URL. 2.

Simple export of CSV

2010-03-24 Thread jlwlynn
I'm trying to simply export CSV, but have failed miserably. First I perform a search and the query set is displayed in a template. I want to have an export button that will export the data on the page, but unfortunately, I lost the query set and even if I were to have it as a parameter, it would

basic django auth fails on valid user

2010-03-24 Thread Jim N
Hi, I am writing a basic login routine using django users. Here is the view: def login_result(request): username = request.POST['u'] password = request.POST['p'] logging.debug("look for user %s / %s" % (username, password)) user = authenticate(username=username,

Re: Retrievecomments for a given model

2010-03-24 Thread Federico Capoano
I made a custom template tag. On Mar 24, 7:45 pm, Federico Capoano wrote: > Hello to all, > > I don't understand how I can retrieve the most recent comments for a > given model, something like: > > {% load comments %} > {% get_comment_list for post as comment_list %}

Re: Overriding admin Media class

2010-03-24 Thread Firat Can Basarir
Scot you need to learm Python. The problem is you are defining get_class as an instance method and trying to call it is a class method (or static method). On Wed, Mar 24, 2010 at 8:00 PM, Scot Hacker wrote: > > On Mar 23, 5:32 pm, Paulo Almeida

Retrievecomments for a given model

2010-03-24 Thread Federico Capoano
Hello to all, I don't understand how I can retrieve the most recent comments for a given model, something like: {% load comments %} {% get_comment_list for post as comment_list %} By using this code I get an empty list.. :-S -- You received this message because you are subscribed to the

Re: Overriding admin Media class

2010-03-24 Thread Scot Hacker
On Mar 23, 5:32 pm, Paulo Almeida wrote: > I don't have a working sample (never did this), but you may be looking for > something like this: > > class Media: >        js = get_path() > > And in the class where you keep use_editor: > > def get_path(self) > if

Re: How verbose model name in admin panel

2010-03-24 Thread Shawn Milochik
The verbose name options you show should work, but they should be in a meta class within the main model. Example: class Category(models.Model): #your stuff here class Meta: verbose_name = "Kategoria" verbose_name_plural = "Kategorie" Shawn

Re: How verbose model name in admin panel

2010-03-24 Thread Nuno Maltez
I think you need toput verbose_name(_plural) in the class Meta http://docs.djangoproject.com/en/dev/topics/db/models/#id3 class Category(models.Model): class Meta: verbose_name = "Kategoria" verbose_name_plural = "Kategorie" Nuno On Wed, Mar 24, 2010 at 5:49 PM, serek

How verbose model name in admin panel

2010-03-24 Thread serek
Hi I use Django 1.1 and I would like to display in admin panel different model name. For example from code: class Category(models.Model): in admin panel I receive 'Categorys' instead of Categories I googled for this and try: class Category(models.Model): verbose_name = "Kategoria"

Re: assert_performant(query_set)

2010-03-24 Thread Phlip
Russell Keith-Magee wrote: > Interesting idea! Thanks for sharing. http://www.oreillynet.com/ruby/blog/2008/01/assert_efficient_sql.html > I've just spent a bunch of time hunting down a performance regression > that was caused by someone tweaking a database index, so I'd love to > see something

Re: Internationalization problem - translations not appearing

2010-03-24 Thread filias
Ok, I managed to fix it with LOCALE_PATHS. Example: LOCALE_PATHS = ('', '/locale') I hope it helps someone :) On Mar 24, 4:22 pm, filias wrote: > Hi, > > I have a project with several applications. The translations to > another language are located in /locale > > I

Re: Templates: Looping, ifs and defaults

2010-03-24 Thread bruno desthuilliers
On 24 mar, 16:50, ALJ wrote: > Hi again Paulo, > > Ok. I'll also have a look at that. > > I agree that the business logic should be in the views. However, it > feels that we need a little more flexibility with the templates when > things are truely just a presentation

Re: Django Admin: Redirecting after save

2010-03-24 Thread Daniel Roseman
On Mar 24, 4:23 pm, mwebs wrote: > Hello, > > I have a more complex dialog within the django admin, which requires a > redirect to an intermediate page, when a certain model is saved. It > seems as the django ModelAdmin does not provide any hooks for this > purpose. > >

Re: Django Admin: Redirecting after save

2010-03-24 Thread David Christiansen
On Mar 24, 5:23 pm, mwebs wrote: > But it this doesnt work for me, as I definitvely need the id of the > object that just has been saved. > So what I need is: > - after model save --> redirect to another view > > Any ideas? > > Thanks > - Toni Take a look at the

High, ongoing CPU consumption

2010-03-24 Thread David Christiansen
Dear fellow Django users, We're beginning to be at wits end with a particular problem that we're having that I suspect has to do with server configuration issues, but might be something else. Our Django processes (whether it be Apache when running mod-python or independent daemons when running

Re: Customized filter for Django Admin

2010-03-24 Thread adam
derek i want to do the same thing. first, the site below mentioned about filtering. http://patrickbeeson.com/blog/2008/aug/11/how-create-user-specific-admin-Django/ in this time, you have to give country_id as a request parameter by changing link url. link url is like this:

Django Admin: Redirecting after save

2010-03-24 Thread mwebs
Hello, I have a more complex dialog within the django admin, which requires a redirect to an intermediate page, when a certain model is saved. It seems as the django ModelAdmin does not provide any hooks for this purpose. I found a workarround here:

Internationalization problem - translations not appearing

2010-03-24 Thread filias
Hi, I have a project with several applications. The translations to another language are located in /locale I used the makemessages command (run from the project directory) to generate the .po file and all the marked strings from code and templates appear in the file. I used the compilemessages

Re: i18n Reverse URL Unit Test Error

2010-03-24 Thread John
These are the additions to urls.py js_info_dict = { 'packages': ('cui.translations',), } urlpatterns += patterns('', (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), ) Cheers, John On Mar 23, 6:10 pm, Rolando Espinoza La Fuente wrote: >

Re: Altering the auth_user model?

2010-03-24 Thread Sandman
Hi Derek, One way to do this would be to create a proxy model that can be used throughout your project. Check out http://docs.djangoproject.com/en/dev/topics/db/models/#proxy-models for more info. Take care, Rajiv. On 3/24/10 7:44 AM, Derek wrote: > I am currently using UserProfile to create

Re: Templates: Looping, ifs and defaults

2010-03-24 Thread ALJ
Hi again Paulo, Ok. I'll also have a look at that. I agree that the business logic should be in the views. However, it feels that we need a little more flexibility with the templates when things are truely just a presentation problem. When you have to start constructing your own dictionaries /

Re: Templates: Looping, ifs and defaults

2010-03-24 Thread Paulo Almeida
Sorry, I hadn't understood your original problem, now I see why the nested ifs wouldn't work. Regarding your last question, I think a list of lists would be easier than dictionaries. You can append the product as the first item in each sublist and then iterate the list to get the rows and columns

Altering the auth_user model?

2010-03-24 Thread Derek
I am currently using UserProfile to create additional fields that are needed for my users. I would like to be able to alter the existing User model to use the same fields, but make some of them "required" (show up as bold on the form) e,g, the first name and last name. How would I do that?

Re: Disabling Messaging

2010-03-24 Thread Russell Keith-Magee
On Wed, Mar 24, 2010 at 9:16 PM, jrs wrote: > I'm using 1.1.1 now.  Any idea when there will be a 1.1.2 release?  Is > the current branch considered stable? 1.1.2 will be released at the same time as 1.2; current estimate is mid April. We only ever backport bugfixes from

lat/long model- and formfield

2010-03-24 Thread Klemens Mantzos
Hi list, I need to save spatial data (latitude and longitude) in 2 fields in the db (float). not that big deal, BUT as representation in the admin, i would like to make kind of a modelfield/formfield/widget with the googlemaps api. my problem is to save it in the end in 2 fields in the db. i

Re: Django ORM

2010-03-24 Thread jrs
> Sorry to have to say the last part is pure nonsense. Preserving data > integrity is of course the only sane default behaviour. How could NOT > preserving data integrity be "dangerous" ??? looonng query ? And ? So > what ? You are supposed to know your data model, don't you ? Bruno, I'm

Re: Templates: Looping, ifs and defaults

2010-03-24 Thread ALJ
Just as a matter of interest ... is there a 'best way' of formatting the data if you do decide to process it all in the view and then pass to the template? I seem to have dictionaries coming out of my ears if I construct the data myself. -- You received this message because you are subscribed to

Re: Templates: Looping, ifs and defaults

2010-03-24 Thread ALJ
Hi Dalore, Thanks for that. I changed it a bit because it was still within that {% for sale in sales %} loop. It works. But it really makes the raw html pretty ugly with loads of spaces in it. Never mind. I suppose no- one is going to see it. {% for rate in rates %} {{

Re: Templates: Looping, ifs and defaults

2010-03-24 Thread dalore
What about something like this? It gets you your text field, empty if no data, but with data if it matches your if clause. {{ rate.cost_item.name }} {% for appointment in appointments %} {% for sale in sales %} {% endfor %} {% endfor

Re: Disabling Messaging

2010-03-24 Thread jrs
I'm using 1.1.1 now. Any idea when there will be a 1.1.2 release? Is the current branch considered stable? Thanks Russ. On Mar 23, 8:12 pm, Russell Keith-Magee wrote: > On Wed, Mar 24, 2010 at 5:01 AM, jrs wrote: > > Thanks Preston. > > > I'm not

Re: Negate querysets

2010-03-24 Thread Vinicius Mendes | meiocodigo.com
Ok. I thought it was more simple. I don't know the ORM in deep and forgot about the extra() method. Thanks for the explanation. On Mar 23, 5:15 pm, James Bennett wrote: > On Tue, Mar 23, 2010 at 10:21 AM, Vinicius Mendes | meiocodigo.com > > wrote: > >

Re: Creating sample users for testing

2010-03-24 Thread Ivan Uemlianin
Dear Dave Thanks, that does look useful. Seeing Ian's solution I was wondering if I could manage.py in some way. Best wishes Ivan On Mar 23, 4:55 pm, Dave Murphy wrote: > On Mon, Mar 22, 2010 at 12:26 PM, Ivan Uemlianin wrote: > > > I'm now thinking a

tests fail for django.contrib.auth

2010-03-24 Thread Filip Gruszczyński
When I run all tests, tests for django.contrib.auth. I tried googling it and found information, that django.contrib.sites is required, but I have this app installed. I was also advised to use TEMPLATE_CONTEXT_LOADERS, but this didn't help. Have anyone encountered this problem and know, how to

Re: Templates: Looping, ifs and defaults

2010-03-24 Thread ALJ
Hi Paulo, The 'if' test has to fall within the "for sale in sales" loop, because it's testing the values of the the sale. However, if there is no match, then the default is triggered. Therefore I will get as many defaults as there are sales (-1 if there is a match). Nesting {% if %} 's won't

Custom field state

2010-03-24 Thread IsakovAN
Hello I have made a custom db.field - WeekdaysField wich allow me to split week days into four groups. Also I create forms.field and widget to display it as seven SELECTs. All works fine, but when I have tried to use it with inlinadmin... When editing object Foo wich have TablularInline with

Re: Templates: Looping, ifs and defaults

2010-03-24 Thread Paulo Almeida
I don't understand why is it obvious that an 'else' won't work. If a single {% else %} is not what you want, you can nest {% if %} clauses. But if you are doing this it can also mean that you should move this logic to the view and just pass the final table to the template. - Paulo On Wed, Mar

Re: Difference between request.POST.get('foo') and request.POST['foo']?

2010-03-24 Thread Mahmoud Abdelkader
In python, dictionaries have a get method that will return None if you call it on a dictionary key that doesn't exist. get() can also take an optional default parameter that returns it's value if the key doesn't exist. If you use the indexing method, i.e. [], it invokes the dictionaries

Templates: Looping, ifs and defaults

2010-03-24 Thread ALJ
I have a template that shows a matrix table of form text input boxes. When the form is new, then it should be just empty text boxes. If data already exists, then the form gets repopulated with data. What I am looking for it this: PRODUCTS | DAY1 | DAY2 | DAY3 POLO | Empty text box | 3 | 3

Re: Dynamic multi-site - running many sites from one Django instance

2010-03-24 Thread Tim Shaffer
You are right. I understand now. I must have misread the original request, because I now see that describes multiple instances in memory wouldn't work properly. On Mar 24, 12:52 am, Graham Dumpleton wrote: > On Mar 24, 12:53 pm, Tim Shaffer

Re: More PYTHONPATH issues

2010-03-24 Thread Paulo Almeida
Ok, that makes more sense. You probably can't import django from anywhere else because the django folder cannot be read. Try going to /Library/Python/2.6/site-packages and type 'ls -l' to see the permissions. I presume you don't have e(x)ecute permission in the django folder. These commands might

Django 1.2b multidatabase + manytomany relationship

2010-03-24 Thread mbdtsmh
Hi All, still trying to get my head around the multi db stuff in 1.2 release. Here is my problem that I have hit upon. I have a model in my default db... class Set1(models.Model): create_date = models.DateTimeField(auto_now_add='True') last_update = models.DateTimeField(auto_now='True',

Re: modify db records without changing html

2010-03-24 Thread Omer Barlas
Daniel Roseman @ 24-03-2010 11:43: But what do you mean, 'without changing the HTML'? In order to run a view, the user must make a page request. That will result in new data I guess he is talking about AJAX. -- Omer Barlas omer.bar...@gmail.com -- You received this message because you are

Re: modify db records without changing html

2010-03-24 Thread Daniel Roseman
On Mar 24, 3:21 am, Django Grappelli wrote: > Hi Everyone, > Django noob here.  How do I write a view function that can modify > database records without changing the html on the screen?  Also, from > a best-practices standpoint, is there any reason I shouldn't be >

Re: Django ORM

2010-03-24 Thread bruno desthuilliers
On 23 mar, 21:57, jrs wrote: > Russ and Javier, > > Just to be clear... the reason for my initial note was due to my > already having a work queue which performs cleanup and maintains data > integrity.  It is precisely due to this that I'm surprised the ORM has > cascading

Re: Question about request.POST.get('subject', ' ')

2010-03-24 Thread bruno desthuilliers
On 24 mar, 06:39, Daniel wrote: > Hi there, > > I'm reading the django book and they say that you can validate a form > like this in one line, checking for missing keys and missing data: > >  if not request.POST.get('subject', ' ') >     errors.append('enter a subject')

Re: Re: possible bug or feature request with extra and where

2010-03-24 Thread Russell Keith-Magee
On Wed, Mar 24, 2010 at 2:57 PM, Henrik Genssen wrote: > Hi, > > thanks for your answer! > Now is there a way to force select_related tables any way in a count? >> >>select_related() is an optimization for data retrieval. It allows you >>to expand a select row to

Re: Making a "Common causes for translation problems"

2010-03-24 Thread derek
On Mar 20, 1:09 pm, cool-RR wrote: > Hey Russ, > > At this point I'll just do a brief list, so I think I'll do it on the wiki. > I don't want to invest too much time into it, but I'll be happy if someone > else will want to expand it and put in in the documentation. (I think

RE: Re: possible bug or feature request with extra and where

2010-03-24 Thread Henrik Genssen
Hi, thanks for your answer! >>>Now is there a way to force select_related tables any way in a count? > >select_related() is an optimization for data retrieval. It allows you >to expand a select row to include related objects in a single query. > >It only follows the "1" side of "1-N" relations.

Re: Difference between request.POST.get('foo') and request.POST['foo']?

2010-03-24 Thread Eric Abrahamsen
On Tue, 2010-03-23 at 23:14 -0700, Daniel wrote: > Hi, > > Are these statements equivalent? I want to say no, but I can't see > why. Nope. If the key 'foo' doesn't exist, request.POST.get('foo') will return None, while request.POST['foo'] will blow up with a KeyError. Using the get() method on

Difference between request.POST.get('foo') and request.POST['foo']?

2010-03-24 Thread Daniel
Hi, Are these statements equivalent? I want to say no, but I can't see why. Thank you -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send

Re: Question about request.POST.get('subject', ' ')

2010-03-24 Thread Shawn Milochik
This is a Python question, not a Django question. The Python dictionary get() function accepts a second, optional value to use as the default for what would otherwise raise a KeyError. Shawn Sent from my iPhone On Mar 24, 2010, at 1:39 AM, Daniel wrote: Hi there,