RE: How to Auto fill fields on Save in Django Admin?

2011-02-16 Thread Chris Matthews
Hi Matteius, You must set blank=True in the model so that the form can be returned to you with those fields empty and then you fill it in the save(). pub_date = models.DateTimeField(blank=True) author = models.ForeignKey(User, blank=True, verbose_name='Author') Also read up on editable=

How to Auto fill fields on Save in Django Admin?

2011-02-16 Thread Matteius
I have an Announcement model that has two fields I want to auto-fill in when they are left blank (they are required fields with normal defaults). I have the following Code (simplified data listing for this post) THe Problem is that when I go to save an Announement in the admin with either of

Re: Importing modules in code

2011-02-16 Thread Kenneth Gonsalves
On Wed, 2011-02-16 at 02:12 -0800, Daniel Roseman wrote: > Your question betrays a misconception that I often see. Django - at > least > when served other than via CGI - does not reload everything for each > request. The Django process is long-running, and is managed by the > server, > but usual

Re: App engine serving static files?

2011-02-16 Thread Eric Chamberlain
On Feb 15, 2011, at 11:44 PM, Praveen Krishna R wrote: > Hey Guys, > > Does Anyone has experience, serving static content with google app engine? > Does it make a big difference, than serving it with nginx on the same server > as django? > I currently use a shared hosting, and was just thinking

RE: how can I filter related (foreign key) objects?

2011-02-16 Thread Chris Matthews
Hi Serek, Try this def doMagic(self): date = '2010-05-04' #//here I need to take 10 conencted Bbb objects whcich data is less then date previous10days = Bbb.objects.filter(date__lt=date).order_by('data') Also read up about managers http://docs.djangoproject.c

Re: Having trouble synchronizing the database, can someone help?

2011-02-16 Thread Chen Xu
Sorry, I dont really understand how python manage.py sqlcustom command works, can anyone give an example, I am trying to flush a database for one of my two apps. Thanks On Tue, Feb 15, 2011 at 12:33 AM, Szabo, Patrick (LNG-VIE) < patrick.sz...@lexisnexis.at> wrote: > I think i rember reading

RE: form select box how to (help needed)

2011-02-16 Thread Chris Matthews
Hi Bobby, See http://adil.2scomplement.com/2008/05/django-add-choices-to-form-fields-on-runtime/ Try something like the following: # Define your choices LOCATION_CHOICES = ((1,'location1'), (2,'location2'), (3,'location3'), (4,'locatio

Slammed Hard on Django Admin Queries with Tabular Inlines

2011-02-16 Thread Matteius
So I've been implementing the new Django 1.2 and 1.3 methods such as queryset in my admin.py for my Classcomm student models. All is going well, in the case of an Add/Edit DDO page I went from having 82/87 to 6/10 queries which makes things now much more tolerable. However I still have a concern

Re: thummer and django

2011-02-16 Thread Graham Dumpleton
Add the 500.html template like it tells you to, then you can see what the real error is. Otherwise enable DEBUG, as is also suggests. http://docs.djangoproject.com/en/dev/topics/http/views/#the-500-server-error-view On Thursday, February 17, 2011 7:31:04 AM UTC+8, mickarea wrote: > > Hi, > > >

thummer and django

2011-02-16 Thread mickarea
Hi, I'm trying to test thummer on my ubuntu 10.04 server machine, but i got this error : ProcessId: 3635 Interpreter:'test.test.com' ServerName: 'test.test.com' DocumentRoot: '/var/www/thummer/thummer' URI:'/300/300/1/http://news.bbc.co.uk/' Location: None Dir

ManyToMany problem

2011-02-16 Thread Amar
Hi, I have a problem with accessing items using ManyToMany relationship. Here is a sample from shell: >>> parts = Event.objects.all()[0].participants.all() >>> parts [, ] >>> parts[0] >>> parts[1] >>> for p in parts: ... print p ... P1 P2 I cant figure out why accessing parts[0] and parts[1

Re: how can I filter related (foreign key) objects?

2011-02-16 Thread Matias Aguirre
Just refer to the field name, you don't need the class: prev = self.bbb_set.filter(date__lt=date) Take a look to field lookup rules: http://docs.djangoproject.com/en/dev/topics/db/queries/#field-lookups-intro Excerpts from serek's message of Wed Feb 16 20:51:05 -0200 2011: > Hi > > I have not i

how can I filter related (foreign key) objects?

2011-02-16 Thread serek
Hi I have not idea how to describe my problem, so I show pice of code: class Aaa(models.Model): name = models.CharField(max_length=200, unique=True) is_active = models.BooleanField() class Meta: ordering = ('name',) def doMagic(self): date = '2010-05-04'

Re: App engine serving static files?

2011-02-16 Thread rafael.nu...@gmail.com
The 'cold start' could be a problem. But if you pay $9/month to 'AlwaysOn' feature, it's ok. I am using without 'AlwaysOn', with a little 'workaround' and with an agressive cache, it's very good. On Wed, Feb 16, 2011 at 9:32 AM, Brian Bouterse wrote: > I've never used it, but I always wanted to

Re: Class-based views & authentication

2011-02-16 Thread Łukasz Rekucki
On 16 February 2011 19:46, Andre Terra wrote: > I should also add that the functionality described in the docs simply did > not work for me: > http://docs.djangoproject.com/en/dev//topics/class-based-views/#decorating-the-class > > My attempt to follow that approach is registered here: > http://dp

django CMS 2.1.2 released

2011-02-16 Thread Jonas Obrist
We just released django CMS 2.1.2 to fix a CSRF issue occuring in some browser with django CMS 2.1.1. This release fixes the CSRF issues happening on Ajax requests in older Internet Explorers (and according to some reports also other browsers) as well as a CSRF issue when adding embbeded plugi

PDF response using wkhtmltopdf.

2011-02-16 Thread juanefren
I am using wkhtmltopdf to create PDF files, how ever I don't know how to return them properly, docs says using a single dash instead of output file name will write that to stdout. But I don't realize how to return that content. I have been trying using subprocess.Popen this way: r = HttpResponse(

Re: Class-based views & authentication

2011-02-16 Thread Andre Terra
I should also add that the functionality described in the docs simply did not work for me: http://docs.djangoproject.com/en/dev//topics/class-based-views/#decorating-the-class My attempt to follow that approach is registered here: http://dpaste.com/hold/423359/ Sincerely, Andre Terra On Wed, F

Re: Class-based views & authentication

2011-02-16 Thread Andre Terra
Thank you for sharing that, Pascal. I'm already using it on my project! I've modified get_login_url to fallback to settings.LOGIN_URL, though. I'll keep an eye open on the development of this, as CBVs really are great to work with. Sincerely, Andre Terra On Wed, Feb 9, 2011 at 4:06 PM, Pascal

unique_together validation passes on model forms that exclude unique fields

2011-02-16 Thread Lior Sion
Hi, I have a model with a unique_together field set. I also have a form for that model that excludes one field - but I still need the uniqueness to stay. Example: class A(models.Model): name = models.CharField(max_length=30) friend = models.ForeignKey(Friend) and the form: class AForm

Re: django.contrib.auth.views.login customization

2011-02-16 Thread Dean Chester
I would write my own login controller using the Authentication and Login methods. Check out this part of the django docs: http://docs.djangoproject.com/en/1.2/topics/auth/#how-to-log-a-user-in Dean On 16 Feb 2011, at 13:51, galago wrote: > Is it possible, to add some extra validation checks in

Admin - click through to parent / child

2011-02-16 Thread Alec
Hi, I'm wondering if there are any add-ons that show a list of children and give the ability to click through to parent or children records. I'm aware of the InlineAdmin feature, but I'm thinking of a non- editable list of children for all relations that automatically (i.e. no need to edit admin.p

Re: Django + WebDAV

2011-02-16 Thread Michael Ryan
I have looked at wsgiDAV as well as a nice looking WebDAV emulator for Google App Engines, and they will be considered when I go to start this project. A big issue with WebDAV from an HTTP framework perspective is that ideally it should be storage agnostic. When you start to throw in stuff like "

Re: Datefield

2011-02-16 Thread william ratcliff
There is a nice stack overflow question on this: http://stackoverflow.com/questions/38601/using-django-time-date-widgets-in-custom-form On Wed, Feb 16, 2011 at 10:26 AM, Szabo, Patrick (LNG-VIE) < patrick.sz..

Datefield

2011-02-16 Thread Szabo, Patrick (LNG-VIE)
Hi, I built my own view where users can add new DB-entries. I have a DateField and generated the Form for it directly from the model but i don't see this calender-icon like i do in the admin panel. How can I add it ?! Is it enough to just reference to the .js in the template !? (doesn'

Ajax form in django

2011-02-16 Thread mf
Hi, the problem I'm having is that, when I submit the form, the response is placed in a new url(/feedback) instead of placing it in the actual(/results) url. The alert never gets executed. I guess I'm doing something wrong in the template but I can't find views.py: def ajax_feedback(request):

reimport module every n seconds in main process

2011-02-16 Thread Santiago Caracol
Hello, in a Django application I compile certain data into a Python module for efficiency reasons. Each time an admin changes or adds objects, this module also changes. Therefore, I want my main process (the one that is started with "manage.py runserver" or the like) to reimport the data module ev

Re: chrome extension

2011-02-16 Thread Piotr Zalewa
On 02/16/11 05:34, Tony Lambropoulos wrote: > Should I assume that this was a silly question? > > On Mon, Feb 14, 2011 at 10:10 PM, Tony > wrote: > > Hi, > Is there any way to have a chrome extension with a backend in Django, > like for storing data server

Re: chrome extension

2011-02-16 Thread Derek
> On Mon, Feb 14, 2011 at 10:10 PM, Tony wrote: > > Hi, > > Is there any way to have a chrome extension with a backend in Django, > > like for storing data server side and using its views?  Or is this not > > possible? > > thanks > A similar question: http://stackoverflow.com/questions/3411690/ser

Re: How to select a random tuples from a database table and render them?

2011-02-16 Thread balu
Thank you Shawn... On Feb 16, 6:46 pm, Shawn Milochik wrote: > QuestionBank.objects.filter(id__in = id_list) -- 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 fro

Re: Django custom field or widget?

2011-02-16 Thread Shawn Milochik
Sure. In your ModelForm instance's __init__, set that field's ".choices" value. -- 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 d

django.contrib.auth.views.login customization

2011-02-16 Thread galago
Is it possible, to add some extra validation checks into django.contrib.auth.views.login? I need to check some fields from UserProfile to login -- 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@go

Mockup, like Fudge, in unittesting of django when the orm is involved

2011-02-16 Thread MrMuffin
I`m looking into new ways to unittest my django code. The reason for this is that I find it cumbersome to always have to set up a real database, allthough using sqlite and :memory: makes it relatively easy, I was wondering if anybody has done it using mock/fake objects like Fudge? Writing unittests

Re: How to select a random tuples from a database table and render them?

2011-02-16 Thread Shawn Milochik
QuestionBank.objects.filter(id__in = id_list) -- 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+unsubscr...@googlegrou

How to select a random tuples from a database table and render them?

2011-02-16 Thread balu
Respected all I'm currently working on building an Online Examination system. In that there will be a Question Bank which contains hundreds of questions about different questions. I represented them using Django model class. From them I have to select 20 questions and render them as question paper

Re: Importing modules in code

2011-02-16 Thread Aryeh Leib Taurog
On Feb 16, 12:21 pm, galago wrote: > My django runs on FastCGI as I can see. > I have that small part of the code: > > # Generate user register_hash >                 import hashlib >                 reg_hash = hashlib.md5() >                 reg_hash.update(request.POST.get('email') + > str(rando

Re: form select box how to (help needed)

2011-02-16 Thread Bobby Roberts
i have no idea what this means is there an example anywhere? On Feb 16, 12:43 am, Kenneth Gonsalves wrote: > On Tue, 2011-02-15 at 19:05 -0800, Bobby Roberts wrote: > > I can't load it through the "CHOICES" parameter in my forms field... > > how can I do this? > > override __init__ in your fo

Re: unicode options in models...

2011-02-16 Thread galago
At the top of the file pase: # -*- coding: utf-8 -*- In declaration of text that contains utf8 make it in that way: help_text = u"dádá español" of course set file encoding to utf8 :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post

unicode options in models...

2011-02-16 Thread Mario
Hi, total noob here. This is probably me being extremelly stupid at some point, and I haven't found an answer to this question however i phrased it even tho it's probably in the documentation somewhere but I just don't understand it So I'm writing a django site in spanish and the spanish non-asci

Full Archive of Tutorial Code?

2011-02-16 Thread cousin isaac
Aloha, I'd like to see what the final code of the tutorial ought to look like so am wondering if there is an archive somewhere of the completed project? Thanks, Cousin Isaac -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this grou

RE: 'str' object is not callable

2011-02-16 Thread Chris Matthews
Hi Patrick, You can typically get it by: 1)missing the % for a string format: x = "Hello number %d" (5) TypeError: 'str' object is not callable 2) And if you overwrite a function name with a string, e.g." >>> min(5,2,3) 2 >>> hour,min,sec = "14:59:03".split(":") >>> m

Re: Django + WebDAV

2011-02-16 Thread MrMuffin
Have you looked at http://code.google.com/p/wsgidav/ ? Thomas On 15 Feb, 14:25, Thomas Weholt wrote: > Please post any findings on this subject or information about any > projects you might start to solve/provide this to this group. This is > very interesting. :-) > I`ve made a ftpserver which a

'str' object is not callable

2011-02-16 Thread Szabo, Patrick (LNG-VIE)
Hi, Im getting 'str' object is not callable and i have no idea why. What I'm doing is the following: delete buchung is a list and the 6th element oft hat list is an object with an attribute id. In my urls.py i did this: (r'deletion_time/(?P\d+)/$', 'deletion_time'), And the view looks like

Re: App engine serving static files?

2011-02-16 Thread Brian Bouterse
I've never used it, but I always wanted to use DryDropto push all my static media over to GAE. Brian On Wed, Feb 16, 2011 at 2:44 AM, Praveen Krishna R < rpraveenkris...@gmail.com> wrote: > *Hey Guys,* > * > * > *Does Anyone has experience, serving static content w

Re: pymssql: Problem with Unicode string

2011-02-16 Thread Ramiro Morales
On Wed, Feb 16, 2011 at 8:46 AM, Orgil wrote: > Hello. > I can not get unicode string from MSSQL. > I have pymssql-1.0.2, freetds-0.82, ubuntu-10.10. It seems you have sent this message to the wrong mailing list. -- Ramiro Morales -- You received this message because you are subscribed to the

Re: Importing modules in code

2011-02-16 Thread galago
My django runs on FastCGI as I can see. I have that small part of the code: # Generate user register_hash import hashlib reg_hash = hashlib.md5() reg_hash.update(request.POST.get('email') + str(random.random()) + request.POST.get('username'))

Re: Importing modules in code

2011-02-16 Thread Daniel Roseman
On Wednesday, February 16, 2011 8:38:40 AM UTC, galago wrote: > > Is it a good idea to import modules in the middle of the code, and not on > the beginning? > I want to make a hash generation. It's few lines - it's used once in all > application. Should I import hashlib just on the beginning of t

Re: chrome extension

2011-02-16 Thread Daniel Roseman
On Wednesday, February 16, 2011 5:34:42 AM UTC, Tony wrote: > > Should I assume that this was a silly question? > > No, just that no-one who knows the answer has been around since you posted it. I've never written a Chrome extension but I suspect they have no network access and can only store da

Re: how to get attribute of intermediary model?

2011-02-16 Thread Daniel Roseman
On Wednesday, February 16, 2011 12:36:49 AM UTC, Margie Roginski wrote: > > Say I am using an intermediary model like that in the doc: > > class Person(models.Model): > name = models.CharField(max_length=128) > > class Group(models.Model): > name = models.CharField(max_length=128) >

RE: Importing modules in code

2011-02-16 Thread Chris Matthews
Hi Galago, For some conventions see http://docs.djangoproject.com/en/dev/internals/contributing/?from=olddocs#django-conventions and http://www.python.org/dev/peps/pep-0008/ Generally I do imports at the top of the module in this order (with a blank line inbetween): 1. python modules 2.

Re: pymssql: Problem with Unicode string

2011-02-16 Thread Adnan Sadzak
You did not install static libs and headers Try this: aptitude install freetds-bin freetds-common freetds-dev or just freetds-dev. Cheers On Wed, Feb 16, 2011 at 9:46 AM, Orgil wrote: > Hello. > I can not get unicode string from MSSQL. > I have pymssql-1.0.2, freetds-0.82, ubuntu-10.10. > I

Few words about serialization roboustness and django app served via fcgi and nginx connected over unix or tcp socket

2011-02-16 Thread gro...@sq9mev.info
Hi there ;). Yesterday i noticed some strange behaviour of one of my sites - view [1] serving json serialized data (one model, no references, 130 objects) was executed about 20 secs[3] in production environment [2], and less than 1s via development server. Strange thing. What I've found - the view

Django custom field or widget?

2011-02-16 Thread ju
I have an integer fields, but their default widget is TextInput. I want to use Select widget, but I have to explicitly provide possible values. Is it possible they to be automatically generated from 'initial', 'min_value' and 'max_value' validation rules of integer! field? Do I have to make my ow

Re: Django Templates: Form field name as variable?

2011-02-16 Thread ju
> I like it too, but aren't you still stuck with validating it or are you > applying a validator to each field you generate this way? I'm not sure that I understand the question but this is how I create new fields self.fields['ticket_%s' % ticket['id']] = forms.IntegerField(label = '', initial =

UserCreationForm extended fields

2011-02-16 Thread galago
Hi, I'm building register form using UserCreationForm. I have simple form: class RegisterCustomerForm(UserCreationForm): def __init__(self, *args, **kwargs): super(RegisterCustomerForm, self).__init__(*args, **kwargs) self.fields['email'].required = True self.fields['em

pymssql: Problem with Unicode string

2011-02-16 Thread Orgil
Hello. I can not get unicode string from MSSQL. I have pymssql-1.0.2, freetds-0.82, ubuntu-10.10. I have two computers. First is well configured and good working (i did not configured). From that computer, I can read the unicode. Now i am trying to set up connection to mssql and reading unicode str

Re: ID of each request

2011-02-16 Thread Masklinn
On 15 févr. 2011, at 17:58, Bzyczek wrote: >> I am not aware of anything, but you can easily make a piece of middleware >> which generated a UUID then exposed this in the request object :) > > Yes I could, but then I must provide to all parts of my code request > object. I don't know how to build

Importing modules in code

2011-02-16 Thread galago
Is it a good idea to import modules in the middle of the code, and not on the beginning? I want to make a hash generation. It's few lines - it's used once in all application. Should I import hashlib just on the beginning of the file? Now I put it with the rest of the code. Is it bad? I don't wa

Re: Dajaxice Unresolved Import

2011-02-16 Thread Jorge Bastida
> > Does anyone know if it matters what version I install of these > packages? > (I'm using version 2.6.6 of python and 1.2.3-1ubuntu0.2.10.10.1 of > python-django.) Hi, Probably the problem is that you are using an old django-dajaxice version. 0.1.5 had some bugs related to the function registra