Conditional view processing: *one* function for timestamp and ETag?

2010-07-21 Thread Torsten Bronger
Hallöchen!

For timestamp and ETag in conditional view processing, I have to
pass two function to the @conditional decorator.  However, I've used
this twice so far, and both times I needed common DB access in both
methods.  Thus, I embedded the common data in a custom attribute of
the "request" object.  Not beautiful.

Wouldn't it make sense to have an etag_last_modified_func parameter
for @conditional?  Before I create a ticket, I'd like to see whether
others have run into the same problem, or whether there is a
solution that I've missed.

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How can view tweak response object to go to a specific *anchor* on the template?

2010-07-21 Thread Chris Seberino


On Jul 17, 11:16 am, Justin Myers  wrote:

> or just put that one line (with a semicolon at the end, since it's
> missing one) in a 

Re: URL to specify when accessing subdomains using Django

2010-07-21 Thread nandu
Dear jaymzcd,

I understand what the sites framework is used for and I have read
through the Sites Frameworks documentation at least ten times. After a
lot of experimentation I have found that my main problem is how i
should specify my URL as I am working on my local machine.

I have set up my sub domain as:
subdomain1.example.com

Now if I wish to navigate to the index page of the above subdomain and
specify my URL as subdomain1.example.com the URL takes the shape of
http://127.0.0.1/subdomain1.example.com which is not what I want.
Hence, my problem is creating a URL that will be recognised by urls.py
and give me the domain name "subdomain1.example.com" in my views when
the view executes the command Site.objects.get_current().domain.

I have set up the view in question like this:
--
# Create your views here.
from django.contrib.sites.models import Site
from django.conf import settings
from django.template import Context, loader
from django.shortcuts import render_to_response
from django.http import HttpResponse

def index(request):
current_site = Site.objects.get_current()
print current_site
# do some stuff based on the current_site
return render_to_response("main/index.html", {})
--

I think I first need to solve this before I start thinking about where
to put my multiple settings.py files and so on.

Thank you.

Yours sincerely,
Nanda


On Jul 20, 11:52 pm, jaymzcd  wrote:
> Have you been through everything 
> here:http://docs.djangoproject.com/en/dev/ref/contrib/sites/
> ? It goes through the whole process of working with thesitesframework, its 
> even encouraged to be used when running just a single
> site. It sounds like you are making it more complicated that needs be.
> If you just want to do one separate action for a certain subdomain you
> can check the contents of request.META['SERVER_NAME'] and switch on
> that in your view, but it sounds like you want to do separate things
> per subdomain. The django docs really go go through it all.
>
> The purpose of thesitesframeworkis to have different domains that
> may or may not have a completely different look and feel share the
> same common core code. Thats why they have they're own settings.py
> files, they're essentially separatesiteswith a common underbelly.
>
> jaymz
>
> On Jul 20, 5:55 am, nandu  wrote:
>
> > Could someone please help me and answer my question in the last email?
>
> > Thank you.
> > Nanda
>
> > On Jul 19, 9:52 pm, nandu  wrote:
>
> > > Dear All,
>
> > > I have now set up my subdomains as separatesitesusing thesites
> > >frameworkbut I have a few queries:
>
> > > 1. Does each site really require a separate django instance or can I
> > > run all the subdomains on one instance? I have seven subdomains and
> > > running seven django instances seems wasteful.
>
> > > 2. Currently I have a Django app corresponding to each subdomain since
> > > each subdomain now needs a unique settings.py file is it ok to have
> > > the settings file within the app or is it necessary for the app to
> > > become a project in this case a project within a project?
>
> > > 3. Is it OK for me to put all my urls in the one single urls.py file
> > > or would it be best to separate them on a per app basis.
>
> > > I just need a pointer in the right direction since I have never used
> > > thesitesframeworkbefore, and as far as I know I could not find too
> > > many tutorials or howtos on how touseit either.
>
> > > Thank you for all the help all of you have given me so far.
>
> > > Yours sincerely,
> > > Nanda
>
> > > On Jul 19, 3:00 pm,nandu wrote:
>
> > > > Thank you to all whohave replied.
>
> > > > I will give thesitesframeworkan honest effort and solve my problem.
>
> > > > Thank you very much for your time and effort. :-)
>
> > > > Nanda
>
> > > > On Jul 19, 2:42 pm, jaymzcd  wrote:
>
> > > > > Like Daniel & Steve have said already, urls.py only deals with the
> > > > > path component of the URL, not the domain. Thesitesframeworkis what
> > > > > you need touse, its pretty simple. All you really need to do is
> > > > > something like:
>
> > > > > 1. in urls.py match the URL you want that is common for both
> > > > > subdomains
> > > > > 2. in your view for that pattern get the current site id
> > > > > 3. based on what subdomain (site) is returned execute the appropriate
> > > > > function
>
> > > > > urls.py *cant* know about the subdomain.  If you have an aversion to
> > > > > using thesitesframeworkyou could maybe hack it to work by looking
> > > > > at the contents of request.META['SERVER_NAME'] in your view but i
> > > > > wouldnt do that. Check thesitesframework...
>
> > > > > jaymz
>
> > > > > On Jul 19, 7:05 am,nandu wrote:
>
> > > > > > Thank 

Re: values() returning more than values

2010-07-21 Thread Nick
It looks like its returning every organization instance in the table,

There are about 190 organizations and 900 totals entries, each of
which are assigned an organization.

The count on the query is correct, but when I output the actual values
it returns every entry in the table, so I'm seeing multiple duplicate
organizations.

On Jul 21, 10:47 pm, Kenneth Gonsalves  wrote:
> On Thursday, July 22, 2010 09:10:31 am Nick wrote:
>
> > Readers = Readers.objects.values_list('organization').distinct()
>
> > The count returns 189 results but when I send it to output to a csv it
> > returns all of the values, with duplicates which is something like 900
> > entries.
>
> by duplicates do you mean the whole row is duplicate or it is duplicate with
> the exception of the id of the row?
> --
> Regards
> Kenneth Gonsalves
> Senior Associate
> NRC-FOSS at AU-KBC

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: values() returning more than values

2010-07-21 Thread Kenneth Gonsalves
On Thursday, July 22, 2010 09:10:31 am Nick wrote:
> Readers = Readers.objects.values_list('organization').distinct()
> 
> The count returns 189 results but when I send it to output to a csv it
> returns all of the values, with duplicates which is something like 900
> entries.

by duplicates do you mean the whole row is duplicate or it is duplicate with 
the exception of the id of the row?
-- 
Regards
Kenneth Gonsalves
Senior Associate
NRC-FOSS at AU-KBC

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



values() returning more than values

2010-07-21 Thread Nick
I may be misunderstanding the values method but it is returning
duplicate results when I use the distinct method. I have a query that
pulls the values of a column:

Readers = Readers.objects.values_list('organization').distinct()

The count returns 189 results but when I send it to output to a csv it
returns all of the values, with duplicates which is something like 900
entries.

Any help is appreciated.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Template tag does not like parameters with filters ({% with foo as bar %} question)

2010-07-21 Thread Micky Hulse
Hi,

> Is my above assumption correct? If so, is there an easy fix?

Someone else asked the same question a few hours after I posted my question:



They were much more to the point. :)

I need to train myself to look at the django source before asking for help here.

Thanks,
Micky

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



filebrowser not uploading

2010-07-21 Thread Bobby Roberts
Django 1.2.1 (mod_wsgi 3.2/Python 2.5)
django-tinymce 1.5
filebrowser (trunk)

i am getting no errors but filebrowser will not upload images.  I can
create directories through filebrowser fine.  Can you think of any
reason images would not be loading?


-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Help and Training

2010-07-21 Thread zero00
Well Fred the enviorment where I live theres almost no programmers and
the ones that I do know that are experienced are Java developers.
Theres really no Programming community at all.
Much less a language that is new and also not studied on the
universities here. So I have that disadvantage.

On Jul 21, 5:50 pm, "Sells, Fred" 
wrote:
> FWIW I'm an old time Pythonista who was also forced into a Java world,
> but the pendulum has now swung back to Python.  I would agree with the
> advice of others, but also offer the following:
>
> It is very hard to debug program logic in a web environment.  I have my
> Django view convert anything I need from the request into a form that
> does not use the request object.  I can then debug using the Django
> shell that's part of the Eclipse/PyDev IDE.  
>
> FWIW I'm using Django <-->XML<-->Flex and love it.
>
> -Original Message-
> From: django-users@googlegroups.com
>
> [mailto:django-us...@googlegroups.com] On Behalf Of zero00
> Sent: Wednesday, July 21, 2010 5:39 PM
> To: Django users
> Subject: Help and Training
>
> I'm a web developer and I would like to adopt Django as my primary web
> framework. But where I live there is no Python programmers at all. "I
> live in a Java Island :( " . So I'm in need of a mentor/trainer to get
> around some question that books either are too outdated right now and
> dont cover and some more advance questions that they dont cover. A fee
> may be avaliable if your an actual django trainer. 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/django-users?hl=en.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



manage.py hangs near (or at) the end

2010-07-21 Thread psgou...@gmail.com
I've seen a few references to something like this happening, but
nothing quite right.

somewhere along the line, I have become unable to run manage.py and
have it exit cleanly. it will appear to do everything that it is
supposed to do. (with exceptions,) and then hang.

for example,
in mysql, create the database needed,
in the app folder, execute 'python manage.py syncdb --noinput -v 2'

according to the verbose output, all the tables are created, there is
a section looking for fixtures, ending with the line:
No fixtures found.

which would seem to indicate that it's getting through almost
everything and dying right at the end of it all.

however, it will not return. and I am forced to kill the python
process manually.  after restarting apache, the app will operate as
expected, indicating (it would seem) that the problem is largely
cosmetic.

now, at one point this was working. and the command output ended with
the same line, but it would return.

nothing obvious in the actual app code seems like it would cause this
problem. can anyone suggest anything likely? when syncdb executes is
there anything known that would trip it up based on the contents of
the app being synced?

cheers

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



javascript in template

2010-07-21 Thread T.L
ok, so I have a very simple test template I have made.  What I want it
to do is use javascript to run another view inside of this template.
I have a view called javaScriptTest and this view returns
HttpResponse('javaTest.html).  In javaTest.html, I call a small piece
of script:   In
"anotherView" I have a few operations I want to do, anotherView never
gets called and run.   What do I need to write instead in the
javascript to get the other view to run when I go to the first view,
"javaScriptTest"?  If anyone can help I would appreciate it.  This
problem has been bugging me for a while.  Please tell me if theres
something not clear about my explanation so I clarify for you.
Thanks,
Tony

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ModelForm: setting widget to HiddenInput does not make field hidden

2010-07-21 Thread Jacob Fenwick
I'm building a form for the user model that creates a User, but I only want
it to make the creator enter an email address.

To do this I want to make the username field be hidden.

I'm trying to do this by making the widget be a HiddenInput.

Here is my form:

class FooCreationForm(forms.ModelForm):
username = forms.RegexField(label=_("Username"), max_length=30,
regex=r'^[...@+-]+$')
email = forms.EmailField(label=_("E-mail address"))

class Meta:
model = User
fields = ("email",)
widgets = {
'username': forms.HiddenInput
}

I was expecting the username to turn into an input with the attribute
type set to hidden, but instead it's still a regular input.

What am I doing wrong here?

Jacob

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Composite Primary Keys Status?

2010-07-21 Thread Russell Keith-Magee
On Wed, Jul 21, 2010 at 9:18 PM, Rory Hart  wrote:
> Hey Folks,
> Just wondering if anyone had been squirreling away on the composite primary
> key support that David Cramer and others were working on. It doesn't appear
> any commits have been made on the git for almost a year and a half so I'm
> wondering if anyone is still working on it. I'm happy to put my shoulder to
> the wheel myself but just trying to get a lay of the land first. I've been
> working on a project for the past 6 months that integrates with a legacy
> database which contains loads of composite (foreign) primary keys. I have a
> monster I keep in the basement that has allowed us to integrate
> successfully, with some major annoyances (no admin for a lot of the project,
> hand written create table SQL and no automatic south migrations for a
> start). I'd love to be able to work towards putting the monster down as it
> would make life easier for the team (and I'm sure there are others that
> would love to see support for this too).

I can't speak for everybody who might be working on this in private,
but I'm not aware of anyone who has made a public statement that
they're working on this feature.

Support for composite keys is certainly something I'd like to see in
trunk. It's just waiting on someone to attack the problem and provide
a complete solution -- including admin integration, serialization, and
everything else.

Yours,
Russ Magee %-)

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: using the update() method

2010-07-21 Thread Santiago Perez
I think that what you want can be accomplished by:

from django.db.models import F

readers = Readers.objects.filter(status=active)
readers.update(sorter=(F('library') + F('book'))


On Wed, Jul 21, 2010 at 19:40, Nick  wrote:
>
> I am trying to loop through a queryset and assign values to a field
> based on other values in that entry.
>
> So something like this
>
> readers = Readers.objects.filter(status=active)
>
> for reader in readers:
>library = reader.library
>book = reader.book
>
> readers.update(sorter="%s%s" % (lirbary, book))
>
> however, when I run the update it assigns the same value to all of the
> readers.  I would like this to assign the value to sorter based on
> what their individual library and book choices are.
>
> reader.update return and error "reader has no attribute 'update'"
>
> --
> 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 email to
django-users+unsubscr...@googlegroups.com
.
> For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Inspect a Model in Django

2010-07-21 Thread Santiago Perez
from looking at the fields_for_model(...) method in django.forms.model, it
doas

opts = model._meta

for f in opts.fields + opts.many_to_many:

# 


for each field it ends up calling f.formfield() which in CharField is
implemented as:


def formfield(self, **kwargs):

defaults = {'max_length': self.max_length}

defaults.update(kwargs)

return super(CharField, self).formfield(**defaults)

So, in conclusion, you can use the _meta attribute to inspect the model
fields, and CharField have a public attribute called max_length you can use
when creating your form.



On Wed, Jul 21, 2010 at 17:53, Rex  wrote:

> Hi All,
> I am using Django 1.1, say I have a model like:
> class MyModel(Model):
>someField = CharField(max_length=32)
>
> if I have another class that receives an instance of the model, can I
> read the max_length there?
>
> class Hypothetical_form (forms.Form):
>def __init__(self, model_instance):
>self.someField = forms.CharField(label = u'Some Label', widget
> = forms.TextInput(attrs={'size':
> this.magicalGetSize(model_instance,'someField')}))
>
>def magicalGetSize(instance, fieldname):
> return some_how_find_the_max_length(instance, fieldname)
>
> this will give me the ability to keep my db and forms sync.
> Thank you for any help
> Rex
> disclaimer: I know about ModelForm and all that, but I want to see if
> there is a way to inspect a Model's meta data and field options. I
> found functions like get_field_by_name() but they are not in the
> django documentation.
>
> --
> 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 email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



using the update() method

2010-07-21 Thread Nick
I am trying to loop through a queryset and assign values to a field
based on other values in that entry.

So something like this

readers = Readers.objects.filter(status=active)

for reader in readers:
library = reader.library
book = reader.book

readers.update(sorter="%s%s" % (lirbary, book))

however, when I run the update it assigns the same value to all of the
readers.  I would like this to assign the value to sorter based on
what their individual library and book choices are.

reader.update return and error "reader has no attribute 'update'"

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: formatting values list

2010-07-21 Thread Nick
Perfect, thanks

On Jul 21, 4:50 pm, n3ph  wrote:
>  Definitely the better way..
>
> On 07/21/10 23:42, Franklin Einspruch wrote:
>
> > Nick,
>
> > I think you're looking for this:
>
> >http://docs.djangoproject.com/en/dev/howto/outputting-csv/
>
> > Franklin
>
> > On Wed, Jul 21, 2010 at 5:38 PM, Nick  wrote:
> >> I would like to format the output of a values_list into something a
> >> little more usable for a CSV.
>
> >> My view is really simple
>
> >> def values_view(request)
> >>    list = MyModel.objects.values_list('id', 'name', 'type')
> >>    template = loader.get_template('mytemp.html')
> >>    c = Context({'list': list})
> >>    html = t.render(c)
> >>    HttpResponse(html)
>
> >> my template looks like this
>
> >> {% for item in list %}
> >> {{item}}
> >> {% endfor %}
>
> >> it spits out a list of things like this:
>
> >> (u'id', u'name', u'type), (u'id2', u'name2', u'type2)
>
> >> etc. etc.
>
> >> How can I format a values_list so I could return something like a
> >> table or csv?
>
> >> so:
>
> >> id, name, type
> >> id2, name, type
>
> >> etc. etc.
>
> >> Thanks for the help
> >> Nick
>
> >> --
> >> 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 email to 
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group 
> >> athttp://groups.google.com/group/django-users?hl=en.
>
>
>
>  signature.asc
> < 1KViewDownload

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



how to concatenate 2 columns in query

2010-07-21 Thread Sells, Fred
My queries return XML similar 2 this


 . . .


I would like to return name="Jones, Mary" instead.

The template that I use to convert the list of dictionaries to xml is
used for many different "datagrid" types of queries so I don't really
want to change it. 

I suppose I could use list comprehension and change each dictionary
(row), there's not that much data in each query; but Django seems so
elegant and that seems so clunky.  Up to now, I have not had to resort
to using raw sql and would like to keep it that way as well.

I am using .values(*args) in my query, if that matters?

Is there a Djangonic way of doing this?

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ModelForm subclass of UserCreationForm fails to exclude fields

2010-07-21 Thread Jacob Fenwick
Actually, I just came across this ticket:

http://code.djangoproject.com/ticket/13971

Seems to describe my problem exactly. Sounds like a new bug.

Jacob

On Wed, Jul 21, 2010 at 6:00 PM, Jacob Fenwick wrote:

> class FooCreationForm(UserCreationForm):
> email = forms.EmailField(label=_("E-mail address"))
> class Meta(UserCreationForm.Meta):
> fields = ('email', 'username')
> exclude = ('password1', 'password2')
>
>
>
> I would think that this form would show me only the email and password in
> that order and exclude the two password.
>
> Instead it puts the fields in the correct order but it does not exclude the
> two passwords.
>
> So it's half working.
>
> Why does exclude not work?
>
> Jacob
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ModelForm subclass of UserCreationForm fails to exclude fields

2010-07-21 Thread Jacob Fenwick
class FooCreationForm(UserCreationForm):
email = forms.EmailField(label=_("E-mail address"))
class Meta(UserCreationForm.Meta):
fields = ('email', 'username')
exclude = ('password1', 'password2')



I would think that this form would show me only the email and password in
that order and exclude the two password.

Instead it puts the fields in the correct order but it does not exclude the
two passwords.

So it's half working.

Why does exclude not work?

Jacob

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Inspect a Model in Django

2010-07-21 Thread Rex
Hi All,
I am using Django 1.1, say I have a model like:
class MyModel(Model):
someField = CharField(max_length=32)

if I have another class that receives an instance of the model, can I
read the max_length there?

class Hypothetical_form (forms.Form):
def __init__(self, model_instance):
self.someField = forms.CharField(label = u'Some Label', widget
= forms.TextInput(attrs={'size':
this.magicalGetSize(model_instance,'someField')}))

def magicalGetSize(instance, fieldname):
 return some_how_find_the_max_length(instance, fieldname)

this will give me the ability to keep my db and forms sync.
Thank you for any help
Rex
disclaimer: I know about ModelForm and all that, but I want to see if
there is a way to inspect a Model's meta data and field options. I
found functions like get_field_by_name() but they are not in the
django documentation.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



RE: Help and Training

2010-07-21 Thread Sells, Fred
FWIW I'm an old time Pythonista who was also forced into a Java world,
but the pendulum has now swung back to Python.  I would agree with the
advice of others, but also offer the following:

It is very hard to debug program logic in a web environment.  I have my
Django view convert anything I need from the request into a form that
does not use the request object.  I can then debug using the Django
shell that's part of the Eclipse/PyDev IDE.  

FWIW I'm using Django <-->XML<-->Flex and love it.

-Original Message-
From: django-users@googlegroups.com
[mailto:django-us...@googlegroups.com] On Behalf Of zero00
Sent: Wednesday, July 21, 2010 5:39 PM
To: Django users
Subject: Help and Training

I'm a web developer and I would like to adopt Django as my primary web
framework. But where I live there is no Python programmers at all. "I
live in a Java Island :( " . So I'm in need of a mentor/trainer to get
around some question that books either are too outdated right now and
dont cover and some more advance questions that they dont cover. A fee
may be avaliable if your an actual django trainer. 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-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.


-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: formatting values list

2010-07-21 Thread n3ph
 Definitely the better way..

On 07/21/10 23:42, Franklin Einspruch wrote:
> Nick,
>
> I think you're looking for this:
>
> http://docs.djangoproject.com/en/dev/howto/outputting-csv/
>
> Franklin
>
>
> On Wed, Jul 21, 2010 at 5:38 PM, Nick  wrote:
>> I would like to format the output of a values_list into something a
>> little more usable for a CSV.
>>
>> My view is really simple
>>
>> def values_view(request)
>>list = MyModel.objects.values_list('id', 'name', 'type')
>>template = loader.get_template('mytemp.html')
>>c = Context({'list': list})
>>html = t.render(c)
>>HttpResponse(html)
>>
>> my template looks like this
>>
>> {% for item in list %}
>> {{item}}
>> {% endfor %}
>>
>> it spits out a list of things like this:
>>
>> (u'id', u'name', u'type), (u'id2', u'name2', u'type2)
>>
>> etc. etc.
>>
>> How can I format a values_list so I could return something like a
>> table or csv?
>>
>> so:
>>
>> id, name, type
>> id2, name, type
>>
>> etc. etc.
>>
>> Thanks for the help
>> Nick
>>
>> --
>> 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 email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
>




signature.asc
Description: OpenPGP digital signature


Re: formatting values list

2010-07-21 Thread n3ph
 maybe this way:

from django.shortcuts import get_list_or_404
from MY_APP.models *

def values_view(request)
list = get_list_or_404(MyModel)
template = loader.get_template('mytemp.html')
c = Context({'list': list})
html = t.render(c)
HttpResponse(html)


Template:

{% for item in list %}
{{item.id}}, {{item.name}}, {{item.type}}
{% endfor %}


On 07/21/10 23:38, Nick wrote:
> I would like to format the output of a values_list into something a
> little more usable for a CSV.
>
> My view is really simple
>
> def values_view(request)
> list = MyModel.objects.values_list('id', 'name', 'type')
> template = loader.get_template('mytemp.html')
> c = Context({'list': list})
> html = t.render(c)
> HttpResponse(html)
>
> my template looks like this
>
> {% for item in list %}
> {{item}}
> {% endfor %}
>
> it spits out a list of things like this:
>
> (u'id', u'name', u'type), (u'id2', u'name2', u'type2)
>
> etc. etc.
>
> How can I format a values_list so I could return something like a
> table or csv?
>
> so:
>
> id, name, type
> id2, name, type
>
> etc. etc.
>
> Thanks for the help
> Nick
>




signature.asc
Description: OpenPGP digital signature


Re: Help and Training

2010-07-21 Thread Shawn Milochik
This list and the Python mailing list[1] are both great for that. Of course,
both are forums where you get the best assistance by showing that you've
tried and failed before you asked others for their time.

Shawn

1. http://mail.python.org/mailman/listinfo/python-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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: formatting values list

2010-07-21 Thread Franklin Einspruch
Nick,

I think you're looking for this:

http://docs.djangoproject.com/en/dev/howto/outputting-csv/

Franklin


On Wed, Jul 21, 2010 at 5:38 PM, Nick  wrote:
> I would like to format the output of a values_list into something a
> little more usable for a CSV.
>
> My view is really simple
>
> def values_view(request)
>    list = MyModel.objects.values_list('id', 'name', 'type')
>    template = loader.get_template('mytemp.html')
>    c = Context({'list': list})
>    html = t.render(c)
>    HttpResponse(html)
>
> my template looks like this
>
> {% for item in list %}
> {{item}}
> {% endfor %}
>
> it spits out a list of things like this:
>
> (u'id', u'name', u'type), (u'id2', u'name2', u'type2)
>
> etc. etc.
>
> How can I format a values_list so I could return something like a
> table or csv?
>
> so:
>
> id, name, type
> id2, name, type
>
> etc. etc.
>
> Thanks for the help
> Nick
>
> --
> 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 email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>



-- 
Art, writing, journal: http://einspruch.com
Comics: http://themoonfellonme.com

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Help and Training

2010-07-21 Thread zero00
I'm a web developer and I would like to adopt Django as my primary web
framework. But where I live there is no Python programmers at all. "I
live in a Java Island :( " . So I'm in need of a mentor/trainer to get
around some question that books either are too outdated right now and
dont cover and some more advance questions that they dont cover. A fee
may be avaliable if your an actual django trainer. 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



formatting values list

2010-07-21 Thread Nick
I would like to format the output of a values_list into something a
little more usable for a CSV.

My view is really simple

def values_view(request)
list = MyModel.objects.values_list('id', 'name', 'type')
template = loader.get_template('mytemp.html')
c = Context({'list': list})
html = t.render(c)
HttpResponse(html)

my template looks like this

{% for item in list %}
{{item}}
{% endfor %}

it spits out a list of things like this:

(u'id', u'name', u'type), (u'id2', u'name2', u'type2)

etc. etc.

How can I format a values_list so I could return something like a
table or csv?

so:

id, name, type
id2, name, type

etc. etc.

Thanks for the help
Nick

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: about some ideas for our very largest project

2010-07-21 Thread Antoni Aloy
2010/7/21 RNGLAB :
> hi django peoples
>
> i m rıdvan from turkey and working in a web based big project for now
> this project about web based healthcare and hospital systems.
> and the project is realty big.. we have a team for this.
>
> we are searching a different tech. from .net or java. than we find and
> develop some ideas about pyton and django.
> i wanna ask you about that.. first i must say, i m not enough in
> django and pyton. so i m asking in this level :)
>
> how is django and pyton about this project? this subjects? it can do
> very institutional applications?
> django tech. can support very big web based applications realty ? if
> it supports what can we do with django and pyton?  what is djangos
> differents from .net or java?
>
> if you can share information about this very works for us..
>

The main problem you'll have with instaitutional application with
Django, Python, PHP, Ruby, etc. is the deployment. Some IT departments
does not allow nothing but the technologies they know, and they can be
as old as cobol or j2ee 1.4 + EJB, so ask first your potential
institution clients what they have.

Django and Python can support really big projects. In fact one of the
thinks I like best in Django and Python is that they are scalable in
hardware but also in people, compared with PL/SQL or other languages
where the layer separation is not as clear than the Django one.

It's really difficult to say if Django is the right technology for
your project, but at least you can do your first prototype rally fast
and test for yourself.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: about some ideas for our very largest project

2010-07-21 Thread Javier Guerra Giraldez
On Wed, Jul 21, 2010 at 2:24 PM, RNGLAB  wrote:
> thanks for your ideas
>
> yes django is amazing framework for daily web applications. not for
> core programming. this project's is needs very powerful cores
> programming.

it's usually accepted that most web frameworks have a 'ceiling', and
when reached you have to start tearing it apart and replacing with
custom code that better handles extreme loads.

in Django case it's somewhat easier than on most frameworks because of
the loose coupling between components.  you can replace the ORM with
another one if you want, or the templates, or the wsgi server...

that said, Django's 'ceiling' is much higher than immediately obvious.
 clever use of cache alone can get you a huge boost in efficiency at
very low complexity cost.  also knowing when to denormalize your data,
or apply some preprocessing (like google loves to do) lets you grow by
orders of magnitude.

i don't think any "institutional applications" would outgrow a really
appropriate design on Django (heck, even Rails could do it on the
right hands!).  the usual counterexample to the "my framework is
better than yours!" argument is how yahoo still uses PHP on heavily
accessed sites.


-- 
Javier

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: about some ideas for our very largest project

2010-07-21 Thread CLIFFORD ILKAY

On 07/21/2010 03:24 PM, RNGLAB wrote:

thanks for your ideas

yes django is amazing framework for daily web applications. not for
core programming. this project's is needs very powerful cores
programming.


Perhaps you ought to talk to the creators of the Turkish Linux 
distribution, Pardus, which relies heavily on Python to get a better 
understanding of the capabilities of Python. There is no reason that 
Django can't be used for "core programming". Not to minimize what Django 
is but Django is nothing more than a bunch (very good) Python libraries. 
You have the full power of Python available to you and as such, you can 
build virtually any type of application you want, web, embedded, GUI, 
server, system, web service, etc.

--
Regards,

Clifford Ilkay
Dinamis
1419-3266 Yonge St.
Toronto, ON
Canada  M4N 3P6


+1 416-410-3326

--
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: about some ideas for our very largest project

2010-07-21 Thread RNGLAB
thanks for your ideas

yes django is amazing framework for daily web applications. not for
core programming. this project's is needs very powerful cores
programming.

thanks again.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django-tinymce no links allowed

2010-07-21 Thread Bobby Roberts
hi all.

I'm using:
Django 1.2.1 (mod_wsgi 3.2/Python 2.5)
django-tinymce 1.5

i'm having an issue where the ahref link button is not working
properly.  Although I am getting the popup windows, i complete the
data and hit the button but no link information is inserted.  The only
way to get a href to stick is to view source, edit, and then save.
Anyone else ever experience this?  How'd you fix it?

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: request.is_ajax() good practices

2010-07-21 Thread DrBloodmoney
On Wed, Jul 21, 2010 at 1:37 PM, Juan Hernandez  wrote:
> Hey there,
> I have been working a lot with request.is_ajax() to handle forms and the
> results have been great so fat yet, I have a question about good practices
> and best uses for this function.
> Lets say that I executed a function that returned True and instead of
> sending the boolean to the template, I do something like this:
> def ajaxblue(request):
> if request.is_ajax():
> message = "alert('Hello AJAX');"
> else:
> message = "Hello"
> return HttpResponse(message)
> this is a very simple function but it shows what I'm trying to say. The js
> alert renders itself directly to the template. It works perfectly but
> somehow I thing that I'm violating DRY or at least, good practices
> What do you guys think?
> Thanks a lot
> Juan
>

You should be leaving the js on the client side and instead pass
around json (or equivalent). So test request.is_ajax() and then handle
your ajax requests by passing HttpResponse(json,
mimetype="application/json")

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread rmschne
statuscodes=Member.objects.values('status').order_by('status').distinct()

It gives me the expected results.  Three items in the dictionary from
a database table of about 10,000 records:
[{'status': u'ACTIVE'}, {'status': u'RESIGNED'}, {'status':
u'TRANSFER'}]

it's what i both expected and want.

On Jul 21, 7:33 pm, Subhranath Chunder  wrote:
> I thought you were trying to get:
>
> I'm expecting only the four distinct records.
>
> You'll get a ValuesQuerySet or list of dictionaries with redundant keys this
> way.
>
> Thanks,
> Subhranath Chunder.
>
>
>
> On Wed, Jul 21, 2010 at 11:40 PM, rmschne  wrote:
> > Member.objects.values('status').order_by('status').distinct()  from
> > jaymzcd works perfectly. 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Dangerous "If-Modified-Since"

2010-07-21 Thread Torsten Bronger
Hallöchen!

We've programmed a Django app with mandatory login.  Under somewhat
obscure circumstances, the browser (Firefox and Chrome) sends
spurious If-Modified-Since header fields and may take the page of
another user from the browser cache.  It is like this:

1. User A logs in.

2. User A retrieves ressource (=URL) X.

3. User A logs out.

4. User B logs in in the same browser window.

5. User B retrieved ressource X.

6. User B sees the *same* page as user A!  It was taken from the
   browser's cache.

(6) is disastrous because it may even be that B was not allowed to
see X in the first place.  As far as I can see, "Vary: Cookie" is
properly set.  We added an "@last_modified" decorator to "/X" that
always returns "2001/01/01 00:00".

We sniffed the HTTP headers with the "Live HTTP headers" of Firefox:

--8<---cut here---start->8---
http://127.0.0.1:8000/X

GET /X HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.9) Gecko/20100402 
Ubuntu/9.10 (karmic) Firefox/3.5.9
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://127.0.0.1:8000/
Cookie: csrftoken=ee7e82e6131a46aef229221e1e351987; 
sessionid=8c61c7f10b17435bd7b044222f1e9eb7
If-Modified-Since: Mon, 01 Jan 2001 00:00:00 GMT
Cache-Control: max-age=0

HTTP/1.0 304 NOT MODIFIED
Date: Wed, 21 Jul 2010 19:02:52 GMT
Server: WSGIServer/0.1 Python/2.6.4
Last-Modified: Mon, 01 Jan 2001 00:00:00 GMT
Content-Length: 0
Content-Type: text/html; charset=utf-8
Content-Language: de
Vary: Accept-Language, Cookie
--
[logout]
--
http://127.0.0.1:8000/login

POST /login HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.9) Gecko/20100402 
Ubuntu/9.10 (karmic) Firefox/3.5.9
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://127.0.0.1:8000/login
Cookie: csrftoken=ee7e82e6131a46aef229221e1e351987; 
sessionid=6c784d57f4b6f31e8b9a870afb1dec33
Content-Type: application/x-www-form-urlencoded
Content-Length: 90
username=b.bunny=12345==ee7e82e6131a46aef229221e1e351987

HTTP/1.0 302 FOUND
Date: Wed, 21 Jul 2010 19:03:20 GMT
Server: WSGIServer/0.1 Python/2.6.4
Content-Language: de
Expires: Wed, 21 Jul 2010 19:03:20 GMT
Vary: Accept-Language, Cookie
Last-Modified: Wed, 21 Jul 2010 19:03:20 GMT
Etag: "d41d8cd98f00b204e9800998ecf8427e"
Location: http://127.0.0.1:8000/
Cache-Control: max-age=0
Content-Type: text/html; charset=utf-8
Set-Cookie: sessionid=da1117b2a19755a53fbfc644d3a0e77a; expires=Wed, 
04-Aug-2010 19:03:20 GMT; Max-Age=1209600; Path=/
--
http://127.0.0.1:8000/X

GET /X HTTP/1.1
Host: 127.0.0.1:8000
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.9) Gecko/20100402 
Ubuntu/9.10 (karmic) Firefox/3.5.9
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: de-de,de;q=0.8,en-us;q=0.5,en;q=0.3
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://127.0.0.1:8000/
Cookie: csrftoken=ee7e82e6131a46aef229221e1e351987; 
sessionid=da1117b2a19755a53fbfc644d3a0e77a
If-Modified-Since: Mon, 01 Jan 2001 00:00:00 GMT (*)

HTTP/1.0 304 NOT MODIFIED
Date: Wed, 21 Jul 2010 19:03:26 GMT
Server: WSGIServer/0.1 Python/2.6.4
Last-Modified: Mon, 01 Jan 2001 00:00:00 GMT
Content-Length: 0
Content-Type: text/html; charset=utf-8
Content-Language: de
Vary: Accept-Language, Cookie

--8<---cut here---end--->8---


That last If-Modified-Since causes my headaches.  The server
responds -- correctly -- with 304, and the browser takes the other
user's page from the cache.

The big question is: Why does the browser send the If-Modified-Since
in (*).

And the even bigger question is: How can be prevent it?

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread Subhranath Chunder
I would have rather done something simple like:

set(Member.objects.values_list('status', flat=True))

Thanks,
Subhranath Chunder.

On Thu, Jul 22, 2010 at 12:03 AM, Subhranath Chunder
wrote:

> I thought you were trying to get:
>
> I'm expecting only the four distinct records.
>
> You'll get a ValuesQuerySet or list of dictionaries with redundant keys
> this way.
>
> Thanks,
> Subhranath Chunder.
>
> On Wed, Jul 21, 2010 at 11:40 PM, rmschne  wrote:
>
>> Member.objects.values('status').order_by('status').distinct()  from
>> jaymzcd works perfectly. 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-us...@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread Subhranath Chunder
I thought you were trying to get:

I'm expecting only the four distinct records.

You'll get a ValuesQuerySet or list of dictionaries with redundant keys this
way.

Thanks,
Subhranath Chunder.

On Wed, Jul 21, 2010 at 11:40 PM, rmschne  wrote:

> Member.objects.values('status').order_by('status').distinct()  from
> jaymzcd works perfectly. 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Inline forms

2010-07-21 Thread Ramesh
Thank you very much!

On Jul 21, 10:02 am, Alex Robbins 
wrote:
> You'll have to write your own javascript to add forms dynamically.
> Django doesn't provide front-end javascript.
> Here are some 
> ideas:http://stackoverflow.com/questions/501719/dynamically-adding-a-form-t...
>
> Hope that helps,
> Alex
>
>
>
> On Wed, Jul 21, 2010 at 9:52 AM, Ramesh  wrote:
> > I had already gone through those tutorial, they are really great.
>
> > Here is my problem:
> > At django tutorial it has two tables defined at models, Poll and
> > Choice, Choice table has a foreign key that refers to Polls table.
>
> > When adding Poll questions, I can add choices at the same time which
> > eventually add records at two tables.
> > I can add as many choices as I want by clicking at "Add another
> > Choice".
> > I would like to have same feature on my form which is outside the
> > admin site. How can do that ?
>
> > Thanks!
> > Ramesh
>
> > On Jul 21, 8:53 am, Alex Robbins 
> > wrote:
> >> The ability to make multiple forms of the same type is a 
> >> formset.http://docs.djangoproject.com/en/1.2/topics/forms/formsets/#topics-fo...
>
> >> If you want those forms to represent models, then you want a model
> >> formset.http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#id1
>
> >> Hope that helps!
> >> Alex
>
> >> On Jul 20, 1:00 pm, Ramesh  wrote:
>
> >> > Hi,
>
> >> > I would like to have inline forms for my project (not admin site) as
> >> > shown in django tutorials "Writing your first Django app, part 
> >> > 2",http://docs.djangoproject.com/en/dev/intro/tutorial02/
>
> >> > Here is the form image 
> >> > url:http://docs.djangoproject.com/en/dev/_images/admin12.png
>
> >> > This works fine on my admin site, obviously I followed the tutorial.
>
> >> > Now I would like to have same kind of inline form which is outside the
> >> > admin site. How can I do that?
> >> > I want to add as many field as I want similar to the example shown for
> >> > poll admin sit.
>
> >> > Can someone please provide me some idea/resource from where I can
> >> > start with ?
>
> >> > Thanks!
> >> > Ramesh
>
> > --
> > 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 email to 
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/django-users?hl=en.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread rmschne
Member.objects.values('status').order_by('status').distinct()  from
jaymzcd works perfectly. 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread Subhranath Chunder
>
>
> Member.objects.values('status').order_by('status').distinct()
>
>
I don't think this will ever work, to achieve what is required by him.

Thanks,
Subhranath

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Facebook

2010-07-21 Thread mtnpaul
Trying to decide on which way to go with facebook
http://github.com/teebes/django-facebookconnect.git or
http://code.google.com/p/django-facebookconnect/ ? Same name, but very
different apps. Does anyone have experience with either one?

Does anyone have any other suggestions?

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: custom tag and filtered value

2010-07-21 Thread Micky Hulse
> The django sources for the standard tags show the method, make
> sure you are calling parser.compile_filter() on the relevant arg.

Thanks David!

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread jaymzcd
"I've solved the problem by passing the returned dictionary through my
own distinct() function which strips out duplicates."

Don't roll your own implementations unless you actually really need
to! It's bad practise and can introduce added complexity to your
solution. The .distinct() call will work fine, you just need to order
correctly.

Also, if you needed to do something in sql that you couldnt get to
work via the django ORM i would use the new raw sql features so that
you at least get back queryset objects that you can use "as is" rather
than converting & flattening it to a dict and whatnot.

On 21 July, 18:29, rmschne  wrote:
> Yep.  (as I slap my forehead).
>
> I read that but erroneously concluded that since I had no sort_by on
> the query, I didn't pursue it.  There is a default ordering in the
> model.
> I've solved the problem by passing the returned dictionary through my
> own distinct() function which strips out duplicates.
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Plese guide to solve this

2010-07-21 Thread jaymzcd
I'm going to guess you have been following along with the 
http://www.djangobook.com/
site. It was great in the day but *do not use that* now-a-days as it
covers 0.96. There have been significant changes, one of which is the
maxlength to max_length on CharFields. Stick with the particular
version you are using from docs.djangoproject.com. Even changes from
1.1 to 1.2 are significant enough that reading the wrong version's
docs can give you headaches.

On 21 July, 18:05, Subhranath Chunder  wrote:
> Must be using very old docs:
>
> Use these instead:http://docs.djangoproject.com/en/dev/
>
> Thanks,
> Subhranath Chunder.
>
>
>
> On Wed, Jul 21, 2010 at 8:47 PM, n3ph  wrote:
> >  Another one who's confused about all the deep API-Changes in Django :-(
>
> > But reading the doc's is very helpful to preventing you from thees traps...
>
> > Am 21.07.2010 17:04, schrieb euan.godd...@googlemail.com:
>
> >  The traceback tells you exactly what the problem is. The correct kwarg
> >> is max_length
>
> >> On Jul 21, 2:00 pm, balu  wrote:
>
> >>> Respected sir
>
> >>> This is balu studying B.Tech third year. I started working on django
> >>> in order to create dynamic website. My Python version is 2.6.5. While
> >>> I'm using creating a app the following error has displayed in the
> >>> command line.
>
> >>> /
>
> >>> ***
> >>>  **/
>
> >>> Microsoft Windows XP [Version 5.1.2600]
> >>> (C) Copyright 1985-2001 Microsoft Corp.
>
> >>> C:\Documents and Settings\Administrator>cd c:\
>
> >>> C:\>cd projects
>
> >>> C:\projects>manage.py startapp books
> >>> 'manage.py' is not recognized as an internal or external command,
> >>> operable program or batch file.
>
> >>> C:\projects>cd mysite
>
> >>> C:\projects\mysite>python manage.py startapp books
>
> >>> C:\projects\mysite>cd books
>
> >>> C:\projects\mysite\books>div
> >>> 'div' is not recognized as an internal or external command,
> >>> operable program or batch file.
>
> >>> C:\projects\mysite\books>dir
> >>>  Volume in drive C has no label.
> >>>  Volume Serial Number is 3474-4CF2
>
> >>>  Directory of C:\projects\mysite\books
>
> >>> 07/21/2010  04:59 PM            .
> >>> 07/21/2010  04:59 PM            ..
> >>> 07/21/2010  04:59 PM                60 models.py
> >>> 07/21/2010  04:59 PM               537 tests.py
> >>> 07/21/2010  04:59 PM                27 views.py
> >>> 07/21/2010  04:59 PM                 0 __init__.py
> >>>                4 File(s)            624 bytes
> >>>                2 Dir(s)  27,813,937,152 bytes free
>
> >>> C:\projects\mysite\books>cd C:\projects\mysite
>
> >>> C:\projects\mysite>python manage.py validate
> >>> Traceback (most recent call last):
> >>>   File "manage.py", line 11, in
> >>>     execute_manager(settings)
> >>>   File "C:\python26\lib\site-packages\django\core\management
> >>> \__init__.py", line
> >>> 438, in execute_manager
> >>>     utility.execute()
> >>>   File "C:\python26\lib\site-packages\django\core\management
> >>> \__init__.py", line
> >>> 379, in execute
> >>>     self.fetch_command(subcommand).run_from_argv(self.argv)
> >>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
> >>> line 191,
> >>>  in run_from_argv
> >>>     self.execute(*args, **options.__dict__)
> >>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
> >>> line 218,
> >>>  in execute
> >>>     output = self.handle(*args, **options)
> >>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
> >>> line 347,
> >>>  in handle
> >>>     return self.handle_noargs(**options)
> >>>   File "C:\python26\lib\site-packages\django\core\management\commands
> >>> \validate.p
> >>> y", line 9, in handle_noargs
> >>>     self.validate(display_num_errors=True)
> >>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
> >>> line 245,
> >>>  in validate
> >>>     num_errors = get_validation_errors(s, app)
> >>>   File "C:\python26\lib\site-packages\django\core\management
> >>> \validation.py", lin
> >>> e 28, in get_validation_errors
> >>>     for (app_name, error) in get_app_errors().items():
> >>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
> >>> line 146, in
> >>>  get_app_errors
> >>>     self._populate()
> >>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
> >>> line 61, in
> >>> _populate
> >>>     self.load_app(app_name, True)
> >>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
> >>> line 78, in
> >>> load_app
> >>>     models = import_module('.models', app_name)
> >>>   File "C:\python26\lib\site-packages\django\utils\importlib.py", line
> >>> 35, in im
> >>> port_module
> >>>     __import__(name)
> >>>   File "C:\projects\mysite\..\mysite\books\models.py", line 5, in
> >>> 
> >>>     class Publisher(models.Model):
> >>>   File "C:\projects\mysite\..\mysite\books\models.py", 

request.is_ajax() good practices

2010-07-21 Thread Juan Hernandez
Hey there,

I have been working a lot with request.is_ajax() to handle forms and the
results have been great so fat yet, I have a question about good practices
and best uses for this function.

Lets say that I executed a function that returned True and instead of
sending the boolean to the template, I do something like this:

def ajaxblue(request):
if request.is_ajax():
message = "alert('Hello AJAX');"
else:
message = "Hello"
return HttpResponse(message)

this is a very simple function but it shows what I'm trying to say. The js
alert renders itself directly to the template. It works perfectly but
somehow I thing that I'm violating DRY or at least, good practices

What do you guys think?

Thanks a lot
Juan

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread jaymzcd
I'm guessing your Members model is referencing the User model? Check
the ordering as related models will influence your distinct. If your
Members model has its own ordering that will also come into effect
even though your picking your value out explicitly:

"If you order by fields from a related model, those fields will be
added to the selected columns and they may make otherwise duplicate
rows appear to be distinctThe moral here is that if you are using
distinct() be careful about ordering by related models. Similarly,
when using distinct() and values() together, be careful when ordering
by fields not in the values() call."

Member.objects.values('status').order_by('status').distinct()

Should give the correct count.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Iterating over model instances ordered_with_respect_to in templates

2010-07-21 Thread Marek Dudek

Hello

I have two models and 1-to-many relation between them, using ForeignKey 
(gallery with pictures). Additionally instances on 'many' side are 
ordered_with_respect_to owning instance. I need to iterate over them in 
template, respecting imposed order. I can use 
"get_pictureingallery_order" on owner instance but all I get is IDs, not 
instance itself.
Moreover, situation like this repeats itself, each of instances on 
'many' side has (ordered) many instances of a third model, also ordered 
(subtitles for a piture). And these also need to be iterated over with 
respect to imposed order.


How to do it?

Simplified code:

# models.py

class Gallery(models.Model):
...

class PictureInGallery(models.Model):

picture = models.ForeignKey(Picture)
gallery = models.ForeignKey(Gallery)

class Meta:
order_with_respect_to = 'gallery'
...

class PictureSubtitle(models.Model):

picture_in_gallery = models.ForeignKey(PictureInGallery)
subtitle = models.CharField(max_length=50)

class Meta:
order_with_respect_to = 'picture_in_gallery'

# gallery.html
# iteration without respect to order (yields improper order)

{% for picture_in_gallery in gallery.pictureingallery_set.all %}



   {% for subtitle in picture_in_gallery.picturesubtitle_set.all %}
   {{subtitle}}
   {% endfor %}

{% endfor %}

# iteration with respect to order (yields proper order of IDs but 
doesn't yield instances)


{% for picture_in_gallery_id in gallery.get_pictureingallery_order %}
 {{picture_in_gallery_id}}
{% endfor %}


Thanks in advance

Marek

--
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread rmschne
Yep.  (as I slap my forehead).

I read that but erroneously concluded that since I had no sort_by on
the query, I didn't pursue it.  There is a default ordering in the
model.
I've solved the problem by passing the returned dictionary through my
own distinct() function which strips out duplicates.

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: distinct() ?

2010-07-21 Thread Scott Gould
Does your model refer to any other fields for its default ordering?

http://docs.djangoproject.com/en/1.2/ref/models/querysets/#distinct


On Jul 21, 1:06 pm, rmschne  wrote:
> I'm trying to use the distinct() and it's giving me unexpected
> results.  Surely it's something simple, but I can't spot it.
>
> I've referred 
> tohttp://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct
>
> In SQL, it would be:
> select distinct status from members;
>
> in Django I am using:
> statuscodes=Member.objects.values('status').distinct()
>
> With SQL I get the four distinct values of status from the database I
> expect.
>
> In Django, I get back a dictionary with every record.  I'm expecting
> only the four distinct records.
>
> Any thoughts on what i'm doing wrong?
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



distinct() ?

2010-07-21 Thread rmschne
I'm trying to use the distinct() and it's giving me unexpected
results.  Surely it's something simple, but I can't spot it.

I've referred to 
http://docs.djangoproject.com/en/dev/ref/models/querysets/#distinct

In SQL, it would be:
select distinct status from members;

in Django I am using:
statuscodes=Member.objects.values('status').distinct()

With SQL I get the four distinct values of status from the database I
expect.

In Django, I get back a dictionary with every record.  I'm expecting
only the four distinct records.

Any thoughts on what i'm doing wrong?

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Plese guide to solve this

2010-07-21 Thread Subhranath Chunder
Must be using very old docs:

Use these instead: http://docs.djangoproject.com/en/dev/

Thanks,
Subhranath Chunder.

On Wed, Jul 21, 2010 at 8:47 PM, n3ph  wrote:

>  Another one who's confused about all the deep API-Changes in Django :-(
>
> But reading the doc's is very helpful to preventing you from thees traps...
>
>
>
> Am 21.07.2010 17:04, schrieb euan.godd...@googlemail.com:
>
>  The traceback tells you exactly what the problem is. The correct kwarg
>> is max_length
>>
>>
>> On Jul 21, 2:00 pm, balu  wrote:
>>
>>> Respected sir
>>>
>>> This is balu studying B.Tech third year. I started working on django
>>> in order to create dynamic website. My Python version is 2.6.5. While
>>> I'm using creating a app the following error has displayed in the
>>> command line.
>>>
>>> /
>>>
>>> */
>>>
>>> Microsoft Windows XP [Version 5.1.2600]
>>> (C) Copyright 1985-2001 Microsoft Corp.
>>>
>>> C:\Documents and Settings\Administrator>cd c:\
>>>
>>> C:\>cd projects
>>>
>>> C:\projects>manage.py startapp books
>>> 'manage.py' is not recognized as an internal or external command,
>>> operable program or batch file.
>>>
>>> C:\projects>cd mysite
>>>
>>> C:\projects\mysite>python manage.py startapp books
>>>
>>> C:\projects\mysite>cd books
>>>
>>> C:\projects\mysite\books>div
>>> 'div' is not recognized as an internal or external command,
>>> operable program or batch file.
>>>
>>> C:\projects\mysite\books>dir
>>>  Volume in drive C has no label.
>>>  Volume Serial Number is 3474-4CF2
>>>
>>>  Directory of C:\projects\mysite\books
>>>
>>> 07/21/2010  04:59 PM.
>>> 07/21/2010  04:59 PM..
>>> 07/21/2010  04:59 PM60 models.py
>>> 07/21/2010  04:59 PM   537 tests.py
>>> 07/21/2010  04:59 PM27 views.py
>>> 07/21/2010  04:59 PM 0 __init__.py
>>>4 File(s)624 bytes
>>>2 Dir(s)  27,813,937,152 bytes free
>>>
>>> C:\projects\mysite\books>cd C:\projects\mysite
>>>
>>> C:\projects\mysite>python manage.py validate
>>> Traceback (most recent call last):
>>>   File "manage.py", line 11, in
>>> execute_manager(settings)
>>>   File "C:\python26\lib\site-packages\django\core\management
>>> \__init__.py", line
>>> 438, in execute_manager
>>> utility.execute()
>>>   File "C:\python26\lib\site-packages\django\core\management
>>> \__init__.py", line
>>> 379, in execute
>>> self.fetch_command(subcommand).run_from_argv(self.argv)
>>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
>>> line 191,
>>>  in run_from_argv
>>> self.execute(*args, **options.__dict__)
>>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
>>> line 218,
>>>  in execute
>>> output = self.handle(*args, **options)
>>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
>>> line 347,
>>>  in handle
>>> return self.handle_noargs(**options)
>>>   File "C:\python26\lib\site-packages\django\core\management\commands
>>> \validate.p
>>> y", line 9, in handle_noargs
>>> self.validate(display_num_errors=True)
>>>   File "C:\python26\lib\site-packages\django\core\management\base.py",
>>> line 245,
>>>  in validate
>>> num_errors = get_validation_errors(s, app)
>>>   File "C:\python26\lib\site-packages\django\core\management
>>> \validation.py", lin
>>> e 28, in get_validation_errors
>>> for (app_name, error) in get_app_errors().items():
>>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
>>> line 146, in
>>>  get_app_errors
>>> self._populate()
>>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
>>> line 61, in
>>> _populate
>>> self.load_app(app_name, True)
>>>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
>>> line 78, in
>>> load_app
>>> models = import_module('.models', app_name)
>>>   File "C:\python26\lib\site-packages\django\utils\importlib.py", line
>>> 35, in im
>>> port_module
>>> __import__(name)
>>>   File "C:\projects\mysite\..\mysite\books\models.py", line 5, in
>>> 
>>> class Publisher(models.Model):
>>>   File "C:\projects\mysite\..\mysite\books\models.py", line 6, in
>>> Publisher
>>> name = models.CharField(maxlength=30)
>>>   File "C:\python26\lib\site-packages\django\db\models\fields
>>> \__init__.py", line
>>>  542, in __init__
>>> super(CharField, self).__init__(*args, **kwargs)
>>> TypeError: __init__() got an unexpected keyword argument 'maxlength'
>>>
>>> C:\projects\mysite>
>>>
>>> /
>>>
>>> **/
>>>
>>> I'm very thankful to you if anyone could able to direct me to solve
>>> this error.
>>>
>>> Thanking you
>>> balu.
>>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this 

Re: best practice for widget that edits multiple model fields

2010-07-21 Thread Scott Gould
I'd definitely go that route (I think the "serialized data" bit in
your first post made me think you wanted to just wrap it up and be
done with it).

I'd probably even make it a OneToOneField instead of a ForeignKey to
reinforce the concept that an EventDateRange is a dedicated satellite
bit of data to a discrete Event, and just include it in the Event's
form structure as an inline. You also get an in-built interface of
"event.eventdaterange" instead of mucking around with, or aliasing,
"event.eventdaterange_set.all[0]".

On Jul 21, 9:38 am, Brad Buran  wrote:
> <>
>
> Hi Scott:
>
> Thank you for the suggestion.  I reviewed the docs, and it appears like it
> could work but would restrict the functionality.  For example, I would have
> to somehow serialize two datetime types plus a boolean type into a single
> database column.  This would take away a lot of advantages (such as being
> able to filter based on only one of the datetimes).
>
> One other option I am exploring is simply doing:
>
> class DateRange(Model):
>     start = DateTimeField()
>     end = DateTimeField()
>     all_day = BooleanField()
>
> # subclass DateRange so we can reuse it in various models
> class EventDateRange(DateRange):
>     date = ForeignKey(Event)
>
> class Event(Model):
>     #various other fields required for event
>
> Does this seem like it would make more sense?
>
> Thanks,
> Brad
>
>
>
> On Wed, Jul 21, 2010 at 8:03 AM, Scott Gould  wrote:
> > My immediate thought upon reading your post was that you should build
> > an accompanying custom model field. Having said that, I haven't had
> > cause to do one that involved (only extend -- simply -- the stock
> > fields) so can't provide any specifics.
>
> >http://docs.djangoproject.com/en/1.2/howto/custom-model-fields/#howto...
>
> > On Jul 20, 10:00 pm, Brad Buran  wrote:
> > > I have a group of fields (date_start, date_end, all_day) that I would
> > like
> > > to reuse in several models.  I've defined a MultiWidget that displays two
> > > split datetime fields plus a checkbox (for the all_day toggle).  However,
> > > I'm not sure how to get the MultiWidget to set the value of these three
> > > fields in the model.  If I understand correctly, a MultiWidget can only
> > set
> > > the value of a single model field.  Hence, I would need to create some
> > sort
> > > of field (e.g. "combined_date_info") that MultiWidget saves the
> > serialized
> > > data from these three form fields.  Once I have done this, then I would
> > use
> > > model.save() to deserialize the data in the combined_date_info field and
> > > save it to the appropriate model fields.
>
> > > This solution seems a bit hackish and not very DRY.  Are there better
> > > approaches?
>
> > > Brad
>
> > --
> > 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 email to
> > django-users+unsubscr...@googlegroups.com > groups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Django mod_wsgi PicklingError while saving object

2010-07-21 Thread Etam
Do you know any solution to this:

[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162] mod_wsgi
(pid=3072): Exception occurred processing WSGI script '/home/www/shop/
django.wsgi'., referer: http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162] Traceback
(most recent call last):, referer: http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162]   File "/usr/
lib/python2.5/site-packages/django/core/handlers/wsgi.py", line 245,
in __call__, referer: http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162] response
= middleware_method(request, response), referer: 
http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162]   File "/usr/
lib/python2.5/site-packages/django/contrib/sessions/middleware.py",
line 36, in process_response, referer: 
http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162]
request.session.save(), referer: http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162]   File "/usr/
lib/python2.5/site-packages/django/contrib/sessions/backends/db.py",
line 57, in save, referer: http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162]
session_data = self.encode(self._get_session(no_load=must_create)),,
referer: http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162]   File "/usr/
lib/python2.5/site-packages/django/contrib/sessions/backends/base.py",
line 88, in encode, referer: http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162] pickled
= pickle.dumps(session_dict, pickle.HIGHEST_PROTOCOL), referer:
http://shop.domain.com/accounts/checkout/?
[Thu Jul 08 19:15:38 2010] [error] [client 79.162.31.162]
PicklingError: Can't pickle : it's not the
same object as decimal.Decimal, referer: 
http://shop.domain.com/accounts/checkout/?

It occures _sometimes_... Not always :/.

views.py:

def checkout_authenticated(request):
log.info("checkout_authenticated(request)")
try:
order = get_order(request)
user = request.user
if request.method == 'POST':
form = OrderCheckoutForm(request.POST, instance = order)
if form.is_valid():
form.save()
log.debug('Cash on delivery: %s', 
order.shipping.cash_on_delivery)
if order.shipping.cash_on_delivery:
log.info("NOW PICKLINGERROR")
return HttpResponseRedirect('/accounts/
cash_on_delivery')#cash_on_delivery(request)
...

forms.py:

class OrderCheckoutForm(forms.ModelForm):
class Meta:
model = Order
exclude = ('status',
   'user')
models.py:

class Shipping(models.Model):
name = models.CharField(max_length = 256)
price = models.DecimalField(max_digits = 10, decimal_places = 2)
description = models.TextField(blank = True, null = True)
cash_on_delivery = models.BooleanField(default = False)

class Order(models.Model):
date = models.DateField(editable = False, auto_now_add=True)
status = models.CharField(max_length = 1, choices = STATUS,
default = Status.NEW)

shipping = models.ForeignKey(Shipping, related_name = 'orders',
null = True)
address = models.ForeignKey(Address, related_name =
'address_order', null = True)
invoice = models.BooleanField(default = False)
company = models.ForeignKey(Company, related_name =
'company_order', blank = True, null = True)
I think the reason is:

price = models.DecimalField(max_digits = 10, decimal_places = 2)

Thanks in advance,
Etam.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How retrieve a single object rather than a list from DB?

2010-07-21 Thread Michael
On Wed, Jul 21, 2010 at 12:04 PM, Darius Damalakas <
darius.damala...@gmail.com> wrote:

> Hi,
>
> I want to select a single object or get None if my query does not
> return a single object.
>
>
> So far here is what i have found in the docs (http://
> docs.djangoproject.com/en/dev/topics/db/queries/#limiting-querysets):
>
> 
> To retrieve a single object rather than a list (e.g. SELECT foo FROM
> bar  LIMIT 1), use a simple index instead of a slice. For example,
> this returns the first Entry in the database, after ordering entries
> alphabetically by headline:
>
> >>> Entry.objects.order_by('headline')[0]
>
> This is roughly equivalent to:
>
> >>> Entry.objects.order_by('headline')[0:1].get()
>
> Note, however, that the first of these will raise IndexError while the
> second will raise DoesNotExist if no objects match the given criteria.
> See get() for more details.
> 
>
> Unfortunately, both ways generate an exception, which is bad.
>
> Is there some kind of way to either get a single object and evaluate
> the query, or get None instead?
> NHibernate and LINQ has a way to do that, so i wonder does Django have
> that
>
>
> Darius


try:
 obj = Entry.objects.order_by('headline')[0:1].get()
except Entry.DoesNotExist:
 obj = None

This is pretty standard. There has been some discussion on a get_or_none
style function on querysets, but I think we will have to wait a version for
it.

Also look up django.shortcuts.get_object_or_404

Hope that helps,

Michael

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



How retrieve a single object rather than a list from DB?

2010-07-21 Thread Darius Damalakas
Hi,

I want to select a single object or get None if my query does not
return a single object.


So far here is what i have found in the docs (http://
docs.djangoproject.com/en/dev/topics/db/queries/#limiting-querysets):


To retrieve a single object rather than a list (e.g. SELECT foo FROM
bar  LIMIT 1), use a simple index instead of a slice. For example,
this returns the first Entry in the database, after ordering entries
alphabetically by headline:

>>> Entry.objects.order_by('headline')[0]

This is roughly equivalent to:

>>> Entry.objects.order_by('headline')[0:1].get()

Note, however, that the first of these will raise IndexError while the
second will raise DoesNotExist if no objects match the given criteria.
See get() for more details.


Unfortunately, both ways generate an exception, which is bad.

Is there some kind of way to either get a single object and evaluate
the query, or get None instead?
NHibernate and LINQ has a way to do that, so i wonder does Django have
that


Darius



-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



csrf_exempt ==> anonymoususer ??

2010-07-21 Thread Oran
Hi,

I'm using django 1.2 behind Apache 2.2.x, and authenticating with
mod_python PythonAuthenHandler.
My purpose is to call a view function from a non-human authorized HTTP
client.
Hence, I would like to use both the @csrf_exempt and the
@user_passes_test decorators together.

However, there seems to be a problem with obtaining the user identify
when @csrf_exempt is used.
The following scenario works fine without the @csrf_exempt decorator:

1. Use Firefox to access the web application. As expected, Apache
requires a username and password.
2. Enter a valid username and password
3. Have the view function print request.username. The correct username
is printed.

Now I add the @csrf_exempt decorator, clear the Firefox user/password
cache and repeat the same steps.
But this time a wrong user object is received: AnonymousUser.

Is this by design and I'm just missing something? Or is this a bug?
Any suggested workarounds?

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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Free web-hosting sites that support Django ?

2010-07-21 Thread Qwavel
I'm looking at using Google App Engine for Django.

You requested Python > 2.5, but Django doesn't work with Python 3.x,
and 2.7 it just out the door, so the only thing beyond 2.5 is 2.6 and
I don't think the difference is that big.

I can't deny, though, that it would be nice if GAE would add support
for 2.7.  There will always be ways in which using GAE reduces your
flexibility and control.

On the upside, with GAE you won't need to change hosts later.

GAE's built-in Django support is currently at Django 1.1, but you can
bypass this and use whatever version you want (or so I've heard).

It appears to me that the best way to use Django on GAE at this time
is to stick with 1.1 and use the Django-nonrel patch:

http://www.allbuttonspressed.com/
http://www.allbuttonspressed.com/projects/djangoappengine
http://groups.google.com/group/django-non-relational

With Django non-rel you avoid dependencies on GAE and dependencies on
any particular data paradigm (i.e. it will work with SQL or noSQL
backends).

Qw.

On Jul 21, 10:59 am, Shawn Milochik  wrote:
> http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ManyToMany incompatibility between Django 1.1 and 1.2?

2010-07-21 Thread Yngve Nysaeter Pettersen

Hello Russel,

Ticket submitted: http://code.djangoproject.com/ticket/13975

IIRC there has been no identifier length warnings when I have validated or  
synced the tables.


While I was at it, I also filed a ticket about a pet-peeve in the admin  
view: http://code.djangoproject.com/ticket/13976


On Wed, 21 Jul 2010 04:45:06 +0200, Russell Keith-Magee  
 wrote:



Hi Yngve --

I just wanted to let you know that your report has been heard -- I
just haven't got a lot of spare cycles at the moment to dig into this
problem. Hopefully that situation will improve in the near future.

Here's some quick and (possibly) helpful explanatory notes:

Django 1.2 started imposing a 63 character limit on long names. In
Django 1.1, >63 character names were legal, but would raise warnings
under PostgreSQL. Under 1.2, we use a hashing behavior to collapse >63
character names into the PostgreSQL allowed namespace.

So, if you are ignoring the identifier length warnings under Django
1.1, it's possible that the table/column/sequence names may not be
100% compatible with Django 1.2. However, since PostgreSQL is raising
a warning advising that the 1.1 names are bad, this comes under the
category of bug fix, rather than breaking backwards compatibility.

Like I said, I hope to be able to dig into this problem in more depth
in the near future. In the interim, if you could open a ticket logging
this problem (along with all the very helpful debugging details and
test case you have gleaned in your investigation), I'd be much
obliged.

Yours,
Russ Magee %-)

On Wed, Jul 21, 2010 at 9:18 AM, Yngve Nysaeter Pettersen
 wrote:

Hi again,

This seems to have to do with long names on ManyToMany members, when
model_bar_foo_id_seq exceeds 63 characters, there is also a similar  
problem

if the referenced class name is too long.

I have now created a small testcase.

When running the foobar_test.py script after doing syncdb from Django  
1.1.1

all four tests works in Django 1.1.1, while the fourth fails in 1.2.1 as
mentioned below.

Then, when deleting the tables and syncdb-ing from Django 1.2.1 the  
fourth

test still does not work, while the tests still works in 1.1.1.

Therefore, this seems to be a bug in Django 1.2.1.

There is some complaint when doing syncdb, but they seem to be for some
other database operation, not configuring the tables.

It is possible that http://code.djangoproject.com/changeset/13328 may  
have

fixed part of the problem, but when testing the last_insert_id() part of
that fix, it did not work with names that contain upper case  
characters. I

have not tested the full fix.

On Tue, 20 Jul 2010 20:21:33 +0200, Yngve Nysaeter Pettersen
 wrote:


Hello all,

By accident I have ended up with a mixed Django 1.1.1 and Django 1.2.1
environment, on different machines.

I am currently considering whether to downgrade the 1.2 installations,  
or

upgrade the older ones, or keep the current setup, but this depends on
finding a solution to an apparent incompatibility between 1.1 and 1.2,  
and

whether or not the upgrade can cause other problems.

The current applications, including the configuration of the Postgresql
8.3, have all been developed in v1.1.1

While this have not caused problems for one of my applications  
(AFAICT),
I've discovered that v1.2 is apparently not compatible with the  
ManyToMany
relations used in a second application, causing an exception to be  
thrown

when adding to the many to many field:


  File  
"/usr/lib/pymodules/python2.5/django/db/models/fields/related.py",

line 490, in add
self._add_items(self.source_field_name, self.target_field_name,  
*objs)
  File  
"/usr/lib/pymodules/python2.5/django/db/models/fields/related.py",

line 574, in _add_items
'%s_id' % target_field_name: obj_id,
  File "/usr/lib/pymodules/python2.5/django/db/models/query.py", line  
352,

in create
obj.save(force_insert=True, using=self.db)
  File "/usr/lib/pymodules/python2.5/django/db/models/base.py", line  
435,

in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
  File "/usr/lib/pymodules/python2.5/django/db/models/base.py", line  
528,

in save_base
result = manager._insert(values, return_id=update_pk, using=using)
  File "/usr/lib/pymodules/python2.5/django/db/models/manager.py", line
195, in _insert
return insert_query(self.model, values, **kwargs)
  File "/usr/lib/pymodules/python2.5/django/db/models/query.py", line
1479, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
  File "/usr/lib/pymodules/python2.5/django/db/models/sql/compiler.py",
line 789, in execute_sql
self.query.model._meta.db_table, self.query.model._meta.pk.column)
  File
"/usr/lib/pymodules/python2.5/django/db/backends/postgresql/operations.py",
line 57, in last_insert_id
cursor.execute("SELECT CURRVAL('\"%s_%s_seq\"')" % (table_name,
pk_name))
  File

Re: Plese guide to solve this

2010-07-21 Thread n3ph

 Another one who's confused about all the deep API-Changes in Django :-(

But reading the doc's is very helpful to preventing you from thees traps...



Am 21.07.2010 17:04, schrieb euan.godd...@googlemail.com:

The traceback tells you exactly what the problem is. The correct kwarg
is max_length


On Jul 21, 2:00 pm, balu  wrote:

Respected sir

This is balu studying B.Tech third year. I started working on django
in order to create dynamic website. My Python version is 2.6.5. While
I'm using creating a app the following error has displayed in the
command line.

/
*/

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd c:\

C:\>cd projects

C:\projects>manage.py startapp books
'manage.py' is not recognized as an internal or external command,
operable program or batch file.

C:\projects>cd mysite

C:\projects\mysite>python manage.py startapp books

C:\projects\mysite>cd books

C:\projects\mysite\books>div
'div' is not recognized as an internal or external command,
operable program or batch file.

C:\projects\mysite\books>dir
  Volume in drive C has no label.
  Volume Serial Number is 3474-4CF2

  Directory of C:\projects\mysite\books

07/21/2010  04:59 PM.
07/21/2010  04:59 PM..
07/21/2010  04:59 PM60 models.py
07/21/2010  04:59 PM   537 tests.py
07/21/2010  04:59 PM27 views.py
07/21/2010  04:59 PM 0 __init__.py
4 File(s)624 bytes
2 Dir(s)  27,813,937,152 bytes free

C:\projects\mysite\books>cd C:\projects\mysite

C:\projects\mysite>python manage.py validate
Traceback (most recent call last):
   File "manage.py", line 11, in
 execute_manager(settings)
   File "C:\python26\lib\site-packages\django\core\management
\__init__.py", line
438, in execute_manager
 utility.execute()
   File "C:\python26\lib\site-packages\django\core\management
\__init__.py", line
379, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
   File "C:\python26\lib\site-packages\django\core\management\base.py",
line 191,
  in run_from_argv
 self.execute(*args, **options.__dict__)
   File "C:\python26\lib\site-packages\django\core\management\base.py",
line 218,
  in execute
 output = self.handle(*args, **options)
   File "C:\python26\lib\site-packages\django\core\management\base.py",
line 347,
  in handle
 return self.handle_noargs(**options)
   File "C:\python26\lib\site-packages\django\core\management\commands
\validate.p
y", line 9, in handle_noargs
 self.validate(display_num_errors=True)
   File "C:\python26\lib\site-packages\django\core\management\base.py",
line 245,
  in validate
 num_errors = get_validation_errors(s, app)
   File "C:\python26\lib\site-packages\django\core\management
\validation.py", lin
e 28, in get_validation_errors
 for (app_name, error) in get_app_errors().items():
   File "C:\python26\lib\site-packages\django\db\models\loading.py",
line 146, in
  get_app_errors
 self._populate()
   File "C:\python26\lib\site-packages\django\db\models\loading.py",
line 61, in
_populate
 self.load_app(app_name, True)
   File "C:\python26\lib\site-packages\django\db\models\loading.py",
line 78, in
load_app
 models = import_module('.models', app_name)
   File "C:\python26\lib\site-packages\django\utils\importlib.py", line
35, in im
port_module
 __import__(name)
   File "C:\projects\mysite\..\mysite\books\models.py", line 5, in

 class Publisher(models.Model):
   File "C:\projects\mysite\..\mysite\books\models.py", line 6, in
Publisher
 name = models.CharField(maxlength=30)
   File "C:\python26\lib\site-packages\django\db\models\fields
\__init__.py", line
  542, in __init__
 super(CharField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'maxlength'

C:\projects\mysite>

/
**/

I'm very thankful to you if anyone could able to direct me to solve
this error.

Thanking you
balu.


--
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Free web-hosting sites that support Django ?

2010-07-21 Thread Bill Liao
On Wed, Jul 21, 2010 at 9:28 PM, Ron Barak <
google_maps_forum.comve...@9ox.net> wrote:

> Hi,
>
> I'm starting to learn Django, and was wandering if there were any free
> web-hosting sites that would support modern Python (e.g. > 2.5) and
> Django ?
>
> Once the site I have in mind is developed and working in beta on the
> free web-hosting site, I'll get myself a real domain and paid web-
> hosting, but for the intial development time, I'd rather do it on free
> hosting.
>
> My searches didn't turn any sites that definitely support Django.
> Closest I found was http://www.frihost.com/, but I'm still trying to
> determine if Django is supported there.
>
> So, to recap: d'you know of free web-hosting sites that support modern
> Python and Django ?
> Thanks,
> Ron.
>
> --
> 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 email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
Google app engine..

-- 
*If the dream is BIG enough,the facts don't count!*

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: iPython and Django issue

2010-07-21 Thread Shawn Milochik
Are you using the default version of Python that came with Snow Leopard? If
so, try a virtualenv. I did some searching on Google and saw similar errors
reported but it seems that bugs which would cause them have been patched in
current versions.

I do all my development in virtualenvs with official download versions of
Python from python.org and I've never had this problem, and I do use
iPython.

This doesn't answer your question, but it should solve your problem.

Shawn

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: iPython and Django issue

2010-07-21 Thread Dario Ghilardi
2010/7/21 Shawn Milochik 

> Evidently the function you are trying to call has been moved.


I see, but that function is called by iPython, not by me. This is a bit
strange.

2010/7/21 euan.godd...@googlemail.com 

> I think you need to install readline before you compile python.
> iPython doesn't work properly without it, although I've never seen it
> give a traceback - it usually just looks a bit forlorn.
>

I have already installed readline, but it's the same.
Thanks,
Ingo86

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Plese guide to solve this

2010-07-21 Thread euan.godd...@googlemail.com
The traceback tells you exactly what the problem is. The correct kwarg
is max_length


On Jul 21, 2:00 pm, balu  wrote:
> Respected sir
>
> This is balu studying B.Tech third year. I started working on django
> in order to create dynamic website. My Python version is 2.6.5. While
> I'm using creating a app the following error has displayed in the
> command line.
>
> /
> */
>
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> C:\Documents and Settings\Administrator>cd c:\
>
> C:\>cd projects
>
> C:\projects>manage.py startapp books
> 'manage.py' is not recognized as an internal or external command,
> operable program or batch file.
>
> C:\projects>cd mysite
>
> C:\projects\mysite>python manage.py startapp books
>
> C:\projects\mysite>cd books
>
> C:\projects\mysite\books>div
> 'div' is not recognized as an internal or external command,
> operable program or batch file.
>
> C:\projects\mysite\books>dir
>  Volume in drive C has no label.
>  Volume Serial Number is 3474-4CF2
>
>  Directory of C:\projects\mysite\books
>
> 07/21/2010  04:59 PM              .
> 07/21/2010  04:59 PM              ..
> 07/21/2010  04:59 PM                60 models.py
> 07/21/2010  04:59 PM               537 tests.py
> 07/21/2010  04:59 PM                27 views.py
> 07/21/2010  04:59 PM                 0 __init__.py
>                4 File(s)            624 bytes
>                2 Dir(s)  27,813,937,152 bytes free
>
> C:\projects\mysite\books>cd C:\projects\mysite
>
> C:\projects\mysite>python manage.py validate
> Traceback (most recent call last):
>   File "manage.py", line 11, in 
>     execute_manager(settings)
>   File "C:\python26\lib\site-packages\django\core\management
> \__init__.py", line
> 438, in execute_manager
>     utility.execute()
>   File "C:\python26\lib\site-packages\django\core\management
> \__init__.py", line
> 379, in execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "C:\python26\lib\site-packages\django\core\management\base.py",
> line 191,
>  in run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "C:\python26\lib\site-packages\django\core\management\base.py",
> line 218,
>  in execute
>     output = self.handle(*args, **options)
>   File "C:\python26\lib\site-packages\django\core\management\base.py",
> line 347,
>  in handle
>     return self.handle_noargs(**options)
>   File "C:\python26\lib\site-packages\django\core\management\commands
> \validate.p
> y", line 9, in handle_noargs
>     self.validate(display_num_errors=True)
>   File "C:\python26\lib\site-packages\django\core\management\base.py",
> line 245,
>  in validate
>     num_errors = get_validation_errors(s, app)
>   File "C:\python26\lib\site-packages\django\core\management
> \validation.py", lin
> e 28, in get_validation_errors
>     for (app_name, error) in get_app_errors().items():
>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
> line 146, in
>  get_app_errors
>     self._populate()
>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
> line 61, in
> _populate
>     self.load_app(app_name, True)
>   File "C:\python26\lib\site-packages\django\db\models\loading.py",
> line 78, in
> load_app
>     models = import_module('.models', app_name)
>   File "C:\python26\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>     __import__(name)
>   File "C:\projects\mysite\..\mysite\books\models.py", line 5, in
> 
>     class Publisher(models.Model):
>   File "C:\projects\mysite\..\mysite\books\models.py", line 6, in
> Publisher
>     name = models.CharField(maxlength=30)
>   File "C:\python26\lib\site-packages\django\db\models\fields
> \__init__.py", line
>  542, in __init__
>     super(CharField, self).__init__(*args, **kwargs)
> TypeError: __init__() got an unexpected keyword argument 'maxlength'
>
> C:\projects\mysite>
>
> /
> **/
>
> I'm very thankful to you if anyone could able to direct me to solve
> this error.
>
> Thanking you
> balu.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Plese guide to solve this

2010-07-21 Thread Subramanyam
Hi

In your models.py

Change the below to
name = models.CharField(maxlength=30)
this
name = models.CharField(max*_*length=30)
underscore is the diff


Regards
Subramanyam


On Wed, Jul 21, 2010 at 6:30 PM, balu  wrote:

> Respected sir
>
> This is balu studying B.Tech third year. I started working on django
> in order to create dynamic website. My Python version is 2.6.5. While
> I'm using creating a app the following error has displayed in the
> command line.
>
>
> /
>
> */
>
> Microsoft Windows XP [Version 5.1.2600]
> (C) Copyright 1985-2001 Microsoft Corp.
>
> C:\Documents and Settings\Administrator>cd c:\
>
> C:\>cd projects
>
> C:\projects>manage.py startapp books
> 'manage.py' is not recognized as an internal or external command,
> operable program or batch file.
>
> C:\projects>cd mysite
>
> C:\projects\mysite>python manage.py startapp books
>
> C:\projects\mysite>cd books
>
> C:\projects\mysite\books>div
> 'div' is not recognized as an internal or external command,
> operable program or batch file.
>
> C:\projects\mysite\books>dir
>  Volume in drive C has no label.
>  Volume Serial Number is 3474-4CF2
>
>  Directory of C:\projects\mysite\books
>
> 07/21/2010  04:59 PM  .
> 07/21/2010  04:59 PM  ..
> 07/21/2010  04:59 PM60 models.py
> 07/21/2010  04:59 PM   537 tests.py
> 07/21/2010  04:59 PM27 views.py
> 07/21/2010  04:59 PM 0 __init__.py
>   4 File(s)624 bytes
>   2 Dir(s)  27,813,937,152 bytes free
>
> C:\projects\mysite\books>cd C:\projects\mysite
>
> C:\projects\mysite>python manage.py validate
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "C:\python26\lib\site-packages\django\core\management
> \__init__.py", line
> 438, in execute_manager
>utility.execute()
>  File "C:\python26\lib\site-packages\django\core\management
> \__init__.py", line
> 379, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "C:\python26\lib\site-packages\django\core\management\base.py",
> line 191,
>  in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "C:\python26\lib\site-packages\django\core\management\base.py",
> line 218,
>  in execute
>output = self.handle(*args, **options)
>  File "C:\python26\lib\site-packages\django\core\management\base.py",
> line 347,
>  in handle
>return self.handle_noargs(**options)
>  File "C:\python26\lib\site-packages\django\core\management\commands
> \validate.p
> y", line 9, in handle_noargs
>self.validate(display_num_errors=True)
>  File "C:\python26\lib\site-packages\django\core\management\base.py",
> line 245,
>  in validate
>num_errors = get_validation_errors(s, app)
>  File "C:\python26\lib\site-packages\django\core\management
> \validation.py", lin
> e 28, in get_validation_errors
>for (app_name, error) in get_app_errors().items():
>  File "C:\python26\lib\site-packages\django\db\models\loading.py",
> line 146, in
>  get_app_errors
>self._populate()
>  File "C:\python26\lib\site-packages\django\db\models\loading.py",
> line 61, in
> _populate
>self.load_app(app_name, True)
>  File "C:\python26\lib\site-packages\django\db\models\loading.py",
> line 78, in
> load_app
>models = import_module('.models', app_name)
>  File "C:\python26\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>__import__(name)
>  File "C:\projects\mysite\..\mysite\books\models.py", line 5, in
> 
>class Publisher(models.Model):
>  File "C:\projects\mysite\..\mysite\books\models.py", line 6, in
> Publisher
>name = models.CharField(maxlength=30)
>  File "C:\python26\lib\site-packages\django\db\models\fields
> \__init__.py", line
>  542, in __init__
>super(CharField, self).__init__(*args, **kwargs)
> TypeError: __init__() got an unexpected keyword argument 'maxlength'
>
> C:\projects\mysite>
>
> /
>
> **/
>
> I'm very thankful to you if anyone could able to direct me to solve
> this error.
>
> Thanking you
> balu.
>
> --
> 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 email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 

Re: Plese guide to solve this

2010-07-21 Thread Shawn Milochik
>
>
> TypeError: __init__() got an unexpected keyword argument 'maxlength'
>
>
Your error is right there, at the bottom of your stack trace. The keyword
maxlength is not valid. You probably meant max_length.

In the future, please actually read the error message output. It is usually
very helpful.

Shawn

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Inline forms

2010-07-21 Thread Alex Robbins
You'll have to write your own javascript to add forms dynamically.
Django doesn't provide front-end javascript.
Here are some ideas:
http://stackoverflow.com/questions/501719/dynamically-adding-a-form-to-a-django-formset-with-ajax

Hope that helps,
Alex



On Wed, Jul 21, 2010 at 9:52 AM, Ramesh  wrote:
> I had already gone through those tutorial, they are really great.
>
> Here is my problem:
> At django tutorial it has two tables defined at models, Poll and
> Choice, Choice table has a foreign key that refers to Polls table.
>
> When adding Poll questions, I can add choices at the same time which
> eventually add records at two tables.
> I can add as many choices as I want by clicking at "Add another
> Choice".
> I would like to have same feature on my form which is outside the
> admin site. How can do that ?
>
> Thanks!
> Ramesh
>
>
>
> On Jul 21, 8:53 am, Alex Robbins 
> wrote:
>> The ability to make multiple forms of the same type is a 
>> formset.http://docs.djangoproject.com/en/1.2/topics/forms/formsets/#topics-fo...
>>
>> If you want those forms to represent models, then you want a model
>> formset.http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#id1
>>
>> Hope that helps!
>> Alex
>>
>> On Jul 20, 1:00 pm, Ramesh  wrote:
>>
>>
>>
>> > Hi,
>>
>> > I would like to have inline forms for my project (not admin site) as
>> > shown in django tutorials "Writing your first Django app, part 
>> > 2",http://docs.djangoproject.com/en/dev/intro/tutorial02/
>>
>> > Here is the form image 
>> > url:http://docs.djangoproject.com/en/dev/_images/admin12.png
>>
>> > This works fine on my admin site, obviously I followed the tutorial.
>>
>> > Now I would like to have same kind of inline form which is outside the
>> > admin site. How can I do that?
>> > I want to add as many field as I want similar to the example shown for
>> > poll admin sit.
>>
>> > Can someone please provide me some idea/resource from where I can
>> > start with ?
>>
>> > Thanks!
>> > Ramesh
>
> --
> 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 email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: iPython and Django issue

2010-07-21 Thread euan.godd...@googlemail.com
I think you need to install readline before you compile python.
iPython doesn't work properly without it, although I've never seen it
give a traceback - it usually just looks a bit forlorn.

On Jul 21, 2:02 pm, Ingo86  wrote:
> Hello all,
> i'm on MacOSX Snow Leopard and I have an issue with iPython. When i
> launch "python manage.py shell" I get the following error:
>
> Traceback (most recent call last):
>   File "manage.py", line 11, in 
>     execute_manager(settings)
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/django/core/management/__init__.py", line 438, in
> execute_manager
>     utility.execute()
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/django/core/management/__init__.py", line 379, in
> execute
>     self.fetch_command(subcommand).run_from_argv(self.argv)
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/django/core/management/base.py", line 191, in
> run_from_argv
>     self.execute(*args, **options.__dict__)
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/django/core/management/base.py", line 218, in execute
>     output = self.handle(*args, **options)
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/django/core/management/base.py", line 347, in handle
>     return self.handle_noargs(**options)
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/django/core/management/commands/shell.py", line 26, in
> handle_noargs
>     import IPython
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/IPython/__init__.py", line 58, in 
>     __import__(name,glob,loc,[])
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/IPython/ipstruct.py", line 17, in 
>     from IPython.genutils import list2dict2
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/IPython/genutils.py", line 114, in 
>     import IPython.rlineimpl as readline
>   File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
> site-packages/IPython/rlineimpl.py", line 36, in 
>     (status, result) = commands.getstatusoutput( "otool -L %s | grep
> libedit" % _rl.__file__ )
> AttributeError: 'module' object has no attribute 'getstatusoutput'
>
> I can't figure out why is this happening. Anyone could helps?
> Thank you,
> Ingo86

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: iPython and Django issue

2010-07-21 Thread Shawn Milochik
Evidently the function you are trying to call has been moved.

http://docs.python.org/library/commands.html

Try subprocess instead of commands.

Shawn

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Free web-hosting sites that support Django ?

2010-07-21 Thread Shawn Milochik
http://code.djangoproject.com/wiki/DjangoFriendlyWebHosts

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Free web-hosting sites that support Django ?

2010-07-21 Thread Ron Barak
Hi,

I'm starting to learn Django, and was wandering if there were any free
web-hosting sites that would support modern Python (e.g. > 2.5) and
Django ?

Once the site I have in mind is developed and working in beta on the
free web-hosting site, I'll get myself a real domain and paid web-
hosting, but for the intial development time, I'd rather do it on free
hosting.

My searches didn't turn any sites that definitely support Django.
Closest I found was http://www.frihost.com/, but I'm still trying to
determine if Django is supported there.

So, to recap: d'you know of free web-hosting sites that support modern
Python and Django ?
Thanks,
Ron.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



iPython and Django issue

2010-07-21 Thread Ingo86
Hello all,
i'm on MacOSX Snow Leopard and I have an issue with iPython. When i
launch "python manage.py shell" I get the following error:

Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/django/core/management/__init__.py", line 438, in
execute_manager
utility.execute()
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/django/core/management/__init__.py", line 379, in
execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/django/core/management/base.py", line 191, in
run_from_argv
self.execute(*args, **options.__dict__)
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/django/core/management/base.py", line 218, in execute
output = self.handle(*args, **options)
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/django/core/management/base.py", line 347, in handle
return self.handle_noargs(**options)
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/django/core/management/commands/shell.py", line 26, in
handle_noargs
import IPython
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/IPython/__init__.py", line 58, in 
__import__(name,glob,loc,[])
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/IPython/ipstruct.py", line 17, in 
from IPython.genutils import list2dict2
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/IPython/genutils.py", line 114, in 
import IPython.rlineimpl as readline
  File "/Users/ingo/Documents/django_projects/youroad/lib/python2.6/
site-packages/IPython/rlineimpl.py", line 36, in 
(status, result) = commands.getstatusoutput( "otool -L %s | grep
libedit" % _rl.__file__ )
AttributeError: 'module' object has no attribute 'getstatusoutput'

I can't figure out why is this happening. Anyone could helps?
Thank you,
Ingo86

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Plese guide to solve this

2010-07-21 Thread balu
Respected sir

This is balu studying B.Tech third year. I started working on django
in order to create dynamic website. My Python version is 2.6.5. While
I'm using creating a app the following error has displayed in the
command line.


/
*/

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd c:\

C:\>cd projects

C:\projects>manage.py startapp books
'manage.py' is not recognized as an internal or external command,
operable program or batch file.

C:\projects>cd mysite

C:\projects\mysite>python manage.py startapp books

C:\projects\mysite>cd books

C:\projects\mysite\books>div
'div' is not recognized as an internal or external command,
operable program or batch file.

C:\projects\mysite\books>dir
 Volume in drive C has no label.
 Volume Serial Number is 3474-4CF2

 Directory of C:\projects\mysite\books

07/21/2010  04:59 PM  .
07/21/2010  04:59 PM  ..
07/21/2010  04:59 PM60 models.py
07/21/2010  04:59 PM   537 tests.py
07/21/2010  04:59 PM27 views.py
07/21/2010  04:59 PM 0 __init__.py
   4 File(s)624 bytes
   2 Dir(s)  27,813,937,152 bytes free

C:\projects\mysite\books>cd C:\projects\mysite

C:\projects\mysite>python manage.py validate
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "C:\python26\lib\site-packages\django\core\management
\__init__.py", line
438, in execute_manager
utility.execute()
  File "C:\python26\lib\site-packages\django\core\management
\__init__.py", line
379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\python26\lib\site-packages\django\core\management\base.py",
line 191,
 in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\python26\lib\site-packages\django\core\management\base.py",
line 218,
 in execute
output = self.handle(*args, **options)
  File "C:\python26\lib\site-packages\django\core\management\base.py",
line 347,
 in handle
return self.handle_noargs(**options)
  File "C:\python26\lib\site-packages\django\core\management\commands
\validate.p
y", line 9, in handle_noargs
self.validate(display_num_errors=True)
  File "C:\python26\lib\site-packages\django\core\management\base.py",
line 245,
 in validate
num_errors = get_validation_errors(s, app)
  File "C:\python26\lib\site-packages\django\core\management
\validation.py", lin
e 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "C:\python26\lib\site-packages\django\db\models\loading.py",
line 146, in
 get_app_errors
self._populate()
  File "C:\python26\lib\site-packages\django\db\models\loading.py",
line 61, in
_populate
self.load_app(app_name, True)
  File "C:\python26\lib\site-packages\django\db\models\loading.py",
line 78, in
load_app
models = import_module('.models', app_name)
  File "C:\python26\lib\site-packages\django\utils\importlib.py", line
35, in im
port_module
__import__(name)
  File "C:\projects\mysite\..\mysite\books\models.py", line 5, in

class Publisher(models.Model):
  File "C:\projects\mysite\..\mysite\books\models.py", line 6, in
Publisher
name = models.CharField(maxlength=30)
  File "C:\python26\lib\site-packages\django\db\models\fields
\__init__.py", line
 542, in __init__
super(CharField, self).__init__(*args, **kwargs)
TypeError: __init__() got an unexpected keyword argument 'maxlength'

C:\projects\mysite>

/
**/

I'm very thankful to you if anyone could able to direct me to solve
this error.

Thanking you
balu.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Inline forms

2010-07-21 Thread Ramesh
I had already gone through those tutorial, they are really great.

Here is my problem:
At django tutorial it has two tables defined at models, Poll and
Choice, Choice table has a foreign key that refers to Polls table.

When adding Poll questions, I can add choices at the same time which
eventually add records at two tables.
I can add as many choices as I want by clicking at "Add another
Choice".
I would like to have same feature on my form which is outside the
admin site. How can do that ?

Thanks!
Ramesh



On Jul 21, 8:53 am, Alex Robbins 
wrote:
> The ability to make multiple forms of the same type is a 
> formset.http://docs.djangoproject.com/en/1.2/topics/forms/formsets/#topics-fo...
>
> If you want those forms to represent models, then you want a model
> formset.http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#id1
>
> Hope that helps!
> Alex
>
> On Jul 20, 1:00 pm, Ramesh  wrote:
>
>
>
> > Hi,
>
> > I would like to have inline forms for my project (not admin site) as
> > shown in django tutorials "Writing your first Django app, part 
> > 2",http://docs.djangoproject.com/en/dev/intro/tutorial02/
>
> > Here is the form image 
> > url:http://docs.djangoproject.com/en/dev/_images/admin12.png
>
> > This works fine on my admin site, obviously I followed the tutorial.
>
> > Now I would like to have same kind of inline form which is outside the
> > admin site. How can I do that?
> > I want to add as many field as I want similar to the example shown for
> > poll admin sit.
>
> > Can someone please provide me some idea/resource from where I can
> > start with ?
>
> > Thanks!
> > Ramesh

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Register Multiple ModelAdmins for a Table or Create a Admin View for a "Query"

2010-07-21 Thread Michael
Hello,

I have two tables... one contains information about a Family and the
other has all the Financial Records for them. I am trying to figure
out (while staying within the framework/interface of the Admin Model)
to pull the two tables together...

My thoughts were that for the Family model/table I could create a set
of methods such as... Total Paid, Total Due, Last Payment Made, etc...
that would be calculated based on FinancialRecord table/model. Then I
would create a second Family ModelAdmin that would pull these fields
and I could search and filter on them. However, I cannot register the
second admin model to the table.

Is there a better way to do this?

Going further... When one clicked on the family name it would give you
all the FinancialRecord objects editable inline with the Total Paid,
Total Due, Last Payment Made, etc... information at the top of the
page.

Thanks for the help/insight,
Michael

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Searching in Admin View --- Foreign Key

2010-07-21 Thread Michael
Is there a way to search on the Foreign Key's __str__ representation
in admin views? I have the FK listed in the search_fields but it fails
to find it.

Thanks,
Michael

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Searching in Admin View --- Foreign Key

2010-07-21 Thread Michael
Is there a way to search on the Foreign Key's __str__ representation
in admin views? I have the FK listed in the search_fields but it fails
to find it.

Thanks,
Michael

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Is Django right for what I am trying to do

2010-07-21 Thread SteveB.
Hi Bradley,

Just my 2c re feeling comfortable with how django does things:-

A high level walkthrough of which bits of Django are used and how they
fit together.

1. You define the URL's that you want to present via a web server in
urls.py.
2. In the urls.py file you configure url's and map these to views
(python functions) held in views.py
3. The views can take an HTTP request as a parameter along with the
parameters from the context.
4. The views use the parameters to retrieve a model instance, or
multiple model instances.
5. The view 'calls' a template with the model instances received by 4.
6. The template processor parses the template & processes the model
instances.
7. The view returns the processed template to the browser, or can
redirects to another URL.

8. If you want a quick CRUD set of forms for admin use only you can
use the admin functionality to provide this - you don't have to
though.

I think it takes a bit of getting your head around initially but it's
very flexible/powerful when you do.  There are loads of other things
that Django can do, including Form processing but you can code forms
yourself if you prefer.

HIH

On Jul 8, 6:43 pm, Bradley Hintze  wrote:
> Hi all
>
> I did the tutorial and I've spent the last two days in the
> documentation trying, and failing, to figure out how to tie my model
> to a view and ultimately a template that is served. The documentation
> seems to do a lot of things (like write html) automatically which is
> not what I want (seehttp://docs.djangoproject.com/en/dev/topics/forms/).  I 
> am not
> interested in admin sites, they make things easier but I am interested
> in learning the code (i.e. the HTML and how it communicates with
> python) rather than, in my view, just blackbox automation.
>
> I hope this makes sense. Please tell me if it doesn't.  I want to
> simply upload a file and then process the file using code I already
> have. I would like to write the HTML code myself rather then having
> django automatically do it. This is because I want to learn how to
> process forms and not have a black box do everything for me. Are there
> methods to simply get post data from a form that I write rather the
> django automatically creating it (an example maybe)? are models
> necessary for what I'm explaining? Is django right for what I'm
> explaining?
>
> --
> Bradley J. Hintze
> Graduate Student
> Duke University
> School of Medicine
> 801-712-8799

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Sending emails, threads, progress back to user

2010-07-21 Thread Michael Hipp

I've been googling extensively but can't seem to find an real answer for this...

- User clicks a button to send a batch of emails to customers
- Django view kicks off a thread to send the emails using django.core.mail
- The view response sends the user to a page that will monitor progress
  using periodic ajax calls

Questions:
- How does the thread communicate progress back to a place where the ajax 
driven view can pick it up and return it to the user?

- Is there a problem running django.core.mail in a thread?

(I'd prefer not to use some of the heavyweight solutions relying on daemons and 
other stuff running entirely outside Django and cron doesn't make the user feel 
involved. In my wxPython desktop apps this stuff is pretty easy using pubsub. 
But I don't see how to make that work in Django.)


Thanks,
Michael

--
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: about some ideas for our very largest project

2010-07-21 Thread derek
On Jul 21, 11:07 am, RNGLAB  wrote:
> hi django peoples
>
> i m rıdvan from turkey and working in a web based big project for now
> this project about web based healthcare and hospital systems.
> and the project is realty big.. we have a team for this.
>
> we are searching a different tech. from .net or java. than we find and
> develop some ideas about pyton and django.
> i wanna ask you about that.. first i must say, i m not enough in
> django and pyton. so i m asking in this level :)
>
> how is django and pyton about this project? this subjects? it can do
> very institutional applications?
> django tech. can support very big web based applications realty ? if
> it supports what can we do with django and pyton?  what is djangos
> differents from .net or java?
>
> if you can share information about this very works for us..
>
> thanks for your answers..

First off, your limitation is not likely to be Django or Python per
se, both of which are capable of handing any web app development...
but your own (you+team) knowledge about these domains.  Even the best-
of-the-best-of-the-best will take some time to get comfortable with
these tools.

For some discussions as to Django suitability and use in large apps:

http://groups.google.com/group/django-users/browse_thread/thread/12c898ac406b906c/ddf0bc81fe2c117b?lnk=gst=suitable#ddf0bc81fe2c117b

http://groups.google.com/group/django-users/browse_thread/thread/3c8a6b30696565ad/bef1ce2bda1b6fca?lnk=gst=scalable#bef1ce2bda1b6fca

(e.g. see Dave Snider's remarks in the above thread).

Finally, also have a look at: http://www.djangosites.org/

Hope this helps
Derek

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Inline forms

2010-07-21 Thread Alex Robbins
The ability to make multiple forms of the same type is a formset.
http://docs.djangoproject.com/en/1.2/topics/forms/formsets/#topics-forms-formsets

If you want those forms to represent models, then you want a model
formset.
http://docs.djangoproject.com/en/1.2/topics/forms/modelforms/#id1

Hope that helps!
Alex

On Jul 20, 1:00 pm, Ramesh  wrote:
> Hi,
>
> I would like to have inline forms for my project (not admin site) as
> shown in django tutorials "Writing your first Django app, part 
> 2",http://docs.djangoproject.com/en/dev/intro/tutorial02/
>
> Here is the form image 
> url:http://docs.djangoproject.com/en/dev/_images/admin12.png
>
> This works fine on my admin site, obviously I followed the tutorial.
>
> Now I would like to have same kind of inline form which is outside the
> admin site. How can I do that?
> I want to add as many field as I want similar to the example shown for
> poll admin sit.
>
> Can someone please provide me some idea/resource from where I can
> start with ?
>
> Thanks!
> Ramesh

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Send email attachment from memory buffer

2010-07-21 Thread Michael Hipp

On 7/20/2010 9:08 PM, Ale wrote:

On Tue, Jul 20, 2010 at 10:04 PM, Michael Hipp > wrote:
Is it
possible to give it a file-like object instead?

Did you see the documentation regarding creating an EmailMessage and the
attach() method?

"""You can pass it a single argument that is an email.MIMEBase.MIMEBase
instance. This will be inserted directly into the resulting message."""


Yes, I saw that but didn't grasp that therein was the answer to my question. 
Thanks for the hint.



Another idea: In what type of operating environment are you? If you are
in linux you can use /dev/shm [0]


Unfortunately this deployment will be on an old W2k box for a while.

Thanks,
Michael

--
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Problem validating two forms in a view

2010-07-21 Thread Renne Rocha
  That's exactly what I need!!!

  Thank you!

On Wed, Jul 21, 2010 at 12:15 AM, Ivan  wrote:
> http://charlesleifer.com/blog/djangos-inlineformsetfactory-and-you/
> might be the one you're looking for.
>
> Cheers,
> Ivan
>
>
>
> On Wed, Jul 21, 2010 at 7:30 AM, Renne Rocha  wrote:
>>  Hello all,
>>
>>  I want to create a page that the user will be able to include one
>> 'Project', and several 'Ports' (related to this project). But I am
>> having problems saving the Ports form, because the project_id isn't in
>> the form yet.
>>
>>  I have the following models:
>>
>> class Project(models.Model):
>>    name = models.CharField(max_length=100)
>>
>> class Port(models.Model):
>>    description = models.CharField(max_length=20)
>>    project = models.ForeignKey(Project)
>>
>>  And the following forms:
>>
>>  class ProjectForm(ModelForm):
>>      class Meta:
>>        model = Project
>>
>>  class PortForm(ModelForm):
>>    class Meta:
>>        model = Port
>>        widgets = {
>>            'project': HiddenInput() # Hidden because I can't choose
>> the project yet
>>        }
>>
>> And in the view that generate my form I have:
>> def new_project(request):
>>    PortFormSet = formset_factory(PortForm)
>>    if request.method == 'POST':
>>        project_form = ProjectForm(request.POST)
>>        port_formset = PortFormSet(request.POST)
>>        if project_form.is_valid():
>>            new_project = project_form.save() # I have my new
>> 'Project' instance here
>>
>>            for port_form in port_formset.forms:
>>                # Here is my problem
>>                if port_form.is_valid(): # Always return false because
>> I haven't set the project_id
>>                   ? # What should I put here to define the project_id?
>>                   port_form.save()
>>            return HttpResponseRedirect('/projects/')
>>    else:
>>        # Create the form and return to the template
>>
>> Thank you!
>>
>>   Renne Rocha
>>   renne.ro...@gmail.com
>>   http://www.linkedin.com/in/rennerocha
>>   +55 19 8154-9345
>>
>> --
>> 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 email to 
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>
> --
> 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 email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: best practice for widget that edits multiple model fields

2010-07-21 Thread Brad Buran
<>

Hi Scott:

Thank you for the suggestion.  I reviewed the docs, and it appears like it
could work but would restrict the functionality.  For example, I would have
to somehow serialize two datetime types plus a boolean type into a single
database column.  This would take away a lot of advantages (such as being
able to filter based on only one of the datetimes).

One other option I am exploring is simply doing:

class DateRange(Model):
start = DateTimeField()
end = DateTimeField()
all_day = BooleanField()

# subclass DateRange so we can reuse it in various models
class EventDateRange(DateRange):
date = ForeignKey(Event)

class Event(Model):
#various other fields required for event

Does this seem like it would make more sense?

Thanks,
Brad


On Wed, Jul 21, 2010 at 8:03 AM, Scott Gould  wrote:

> My immediate thought upon reading your post was that you should build
> an accompanying custom model field. Having said that, I haven't had
> cause to do one that involved (only extend -- simply -- the stock
> fields) so can't provide any specifics.
>
>
> http://docs.djangoproject.com/en/1.2/howto/custom-model-fields/#howto-custom-model-fields
>
> On Jul 20, 10:00 pm, Brad Buran  wrote:
> > I have a group of fields (date_start, date_end, all_day) that I would
> like
> > to reuse in several models.  I've defined a MultiWidget that displays two
> > split datetime fields plus a checkbox (for the all_day toggle).  However,
> > I'm not sure how to get the MultiWidget to set the value of these three
> > fields in the model.  If I understand correctly, a MultiWidget can only
> set
> > the value of a single model field.  Hence, I would need to create some
> sort
> > of field (e.g. "combined_date_info") that MultiWidget saves the
> serialized
> > data from these three form fields.  Once I have done this, then I would
> use
> > model.save() to deserialize the data in the combined_date_info field and
> > save it to the appropriate model fields.
> >
> > This solution seems a bit hackish and not very DRY.  Are there better
> > approaches?
> >
> > Brad
>
> --
> 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 email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: custom tag and filtered value

2010-07-21 Thread David De La Harpe Golden
On 20/07/10 22:57, owidjaya wrote:
> how can i pass a filtered value to a custom tag?
> 
> ie
> if i do this
> 
> 
> {% somecustomtag template_variable|lower %}
> 


The django sources for the standard tags show the method, make
sure you are calling parser.compile_filter() on the relevant arg.

http://code.djangoproject.com/browser/django/trunk/django/template/defaulttags.py#L709

http://code.djangoproject.com/ticket/5756

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: best practice for widget that edits multiple model fields

2010-07-21 Thread Brad Buran
Hi Scott:

Thank you for the suggestion.  I reviewed the docs, and it appears like it
could work but would restrict the functionality.  For example, I would have
to somehow serialize two datetime types plus a boolean type into a single
database column.  This would take away a lot of advantages (such as being
able to filter based on only one of the datetimes).

One other option I am exploring is simply doing:

class DateRange(Model):
start = DateTimeField()
end = DateTimeField()



On Wed, Jul 21, 2010 at 8:03 AM, Scott Gould  wrote:

> My immediate thought upon reading your post was that you should build
> an accompanying custom model field. Having said that, I haven't had
> cause to do one that involved (only extend -- simply -- the stock
> fields) so can't provide any specifics.
>
>
> http://docs.djangoproject.com/en/1.2/howto/custom-model-fields/#howto-custom-model-fields
>
> On Jul 20, 10:00 pm, Brad Buran  wrote:
> > I have a group of fields (date_start, date_end, all_day) that I would
> like
> > to reuse in several models.  I've defined a MultiWidget that displays two
> > split datetime fields plus a checkbox (for the all_day toggle).  However,
> > I'm not sure how to get the MultiWidget to set the value of these three
> > fields in the model.  If I understand correctly, a MultiWidget can only
> set
> > the value of a single model field.  Hence, I would need to create some
> sort
> > of field (e.g. "combined_date_info") that MultiWidget saves the
> serialized
> > data from these three form fields.  Once I have done this, then I would
> use
> > model.save() to deserialize the data in the combined_date_info field and
> > save it to the appropriate model fields.
> >
> > This solution seems a bit hackish and not very DRY.  Are there better
> > approaches?
> >
> > Brad
>
> --
> 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 email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Possible to create models programatically?

2010-07-21 Thread Daniel Roseman
On Jul 21, 1:56 am, Andy  wrote:
> I have N models that are identical except the model names (i.e. they
> all have the same attributes, methods):
>
> MyModel0, MyModel1, MyModel2, ...
>
> Normally I'd need to type out the model definitions for those N models
> by hand inside models.py.
>
> Is there a way to generate the N model definitions programatically
> instead of manually?

I'm not completely sure what you're trying to do, but I have a blog
entry on creating temporary models programmatically - it might help
you:
http://blog.roseman.org.uk/2010/04/13/temporary-models-django/
--
DR.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Composite Primary Keys Status?

2010-07-21 Thread Rory Hart
Hey Folks,

Just wondering if anyone had been squirreling away on the composite primary
key support that David Cramer and others were working on. It doesn't appear
any commits have been made on the git for almost a year and a half so I'm
wondering if anyone is still working on it. I'm happy to put my shoulder to
the wheel myself but just trying to get a lay of the land first. I've been
working on a project for the past 6 months that integrates with a legacy
database which contains loads of composite (foreign) primary keys. I have a
monster I keep in the basement that has allowed us to integrate
successfully, with some major annoyances (no admin for a lot of the project,
hand written create table SQL and no automatic south migrations for a
start). I'd love to be able to work towards putting the monster down as it
would make life easier for the team (and I'm sure there are others that
would love to see support for this too).

Thanks
-- 
Rory Hart

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



about some ideas for our very largest project

2010-07-21 Thread RNGLAB
hi django peoples

i m rıdvan from turkey and working in a web based big project for now
this project about web based healthcare and hospital systems.
and the project is realty big.. we have a team for this.

we are searching a different tech. from .net or java. than we find and
develop some ideas about pyton and django.
i wanna ask you about that.. first i must say, i m not enough in
django and pyton. so i m asking in this level :)

how is django and pyton about this project? this subjects? it can do
very institutional applications?
django tech. can support very big web based applications realty ? if
it supports what can we do with django and pyton?  what is djangos
differents from .net or java?

if you can share information about this very works for us..

thanks for your answers..

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



session cookie problem in IE

2010-07-21 Thread vamsy krishna
Hi,

I am doing the below in my login form. I am setting the session cookie
expiry to expire on close of browser unless the user chooses the
remember me on this computer option.

My problem is that the cookie expires mid-way and too frequently
between user actions on IE. Is there anything more i should do to keep
IE happy?

def login(self, request):
if self.is_valid():
auth_login(request, self.user)
request.user.message_set.create( message="Successfully
logged in as %(username)s." % { 'username' : self.user.username } )
if self.cleaned_data["remember"]:
request.session.set_expiry(60 * 60 * 24 * 7 * 3)
else:
request.session.set_expiry(0)
return True
return False

Thanks & Regards
Vamsy

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Send email attachment from memory buffer

2010-07-21 Thread Ale
On Tue, Jul 20, 2010 at 10:04 PM, Michael Hipp  wrote:

> I will be sending pdfs generated from django and would like to email them
> but without writing them to the filesystem.
>
> I can generate the pdf to a buffer but django.core.mail seems to only
> handle attachments that are specified as a filename. Is it possible to give
> it a file-like object instead?
>
>
Did you see the documentation regarding creating an EmailMessage and the
attach() method?

It says:

"""You can pass it a single argument that is an
email.MIMEBase.MIMEBaseinstance. This will be inserted directly into
the resulting message."""

Maybe you should create your own message using some of the examples:
http://docs.python.org/library/email-examples.html


Another idea: In what type of operating environment are you? If you are in
linux you can use /dev/shm [0]

In [1]: import tempfile
In [2]: my_file = tempfile.NamedTemporaryFile(dir='/dev/shm/')
In [3]: my_file.name
Out[3]: '/dev/shm/tmpD0tjnI'
In [4]: ls /dev/shm/tmp*
/dev/shm/tmpD0tjnI


[0]
http://superuser.com/questions/45342/when-should-i-use-dev-shm-and-when-should-i-use-tmp

hope it helps,

-- 
Ale.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Possible to create models programatically?

2010-07-21 Thread Ale
On Tue, Jul 20, 2010 at 9:56 PM, Andy  wrote:

> Normally I'd need to type out the model definitions for those N models
> by hand inside models.py.
>
> Is there a way to generate the N model definitions programatically
> instead of manually?
>
>
Did you try creating an abstract model, and have the rest of the N models
inherit form the abstract models, you save yourself some typing
http://docs.djangoproject.com/en/dev/topics/db/models/#id6

Or that's not good enough?

-- 
Ale.

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: best practice for widget that edits multiple model fields

2010-07-21 Thread Scott Gould
My immediate thought upon reading your post was that you should build
an accompanying custom model field. Having said that, I haven't had
cause to do one that involved (only extend -- simply -- the stock
fields) so can't provide any specifics.

http://docs.djangoproject.com/en/1.2/howto/custom-model-fields/#howto-custom-model-fields

On Jul 20, 10:00 pm, Brad Buran  wrote:
> I have a group of fields (date_start, date_end, all_day) that I would like
> to reuse in several models.  I've defined a MultiWidget that displays two
> split datetime fields plus a checkbox (for the all_day toggle).  However,
> I'm not sure how to get the MultiWidget to set the value of these three
> fields in the model.  If I understand correctly, a MultiWidget can only set
> the value of a single model field.  Hence, I would need to create some sort
> of field (e.g. "combined_date_info") that MultiWidget saves the serialized
> data from these three form fields.  Once I have done this, then I would use
> model.save() to deserialize the data in the combined_date_info field and
> save it to the appropriate model fields.
>
> This solution seems a bit hackish and not very DRY.  Are there better
> approaches?
>
> Brad

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: import model from other module

2010-07-21 Thread David De La Harpe Golden
On 20/07/10 20:04, Andreas Pfrengle wrote:
> I've tried it with and without installing in settings.INSTALLED_APPS,
> didn't work, table wasn't created vis syncdb.
> 


> David, nevertheless the link you've posted gave me the clue how to
> solve the problem. I've defined my external module's class as an
> abstract base class:
>  classes>



Well, now I'm worried I led you astray:

Bear in mind that a django "application" can be written to be
_reusable_. (beware django-conventional terminology
here - django says "project" where a lot of people would say "[web]app"
and "app" where some people might say "plugin" or "component")

I don't know what exactly you're doing, but so far I haven't seen stuff
that suggests creating a "django_timer" reusable app and adding it to
the INSTALLED_APPS for any projects you want to use it in isn't what you
really wanted to do, and you've just sorta missed that "app" is a unit
of reusability in django terms.

That's what other responses to you were getting at, but were somewhat
terse (or I'm rather verbose).

So you might make;

django_timer/
__init__.py # empty, probably
models.py
...


with models.py containing a _concrete_ class Tim(models.Model).

Then when you add your "django_timer" to settings.INSTALLED_APPS of a
django project, it will include your Tim model along with other models.


There are large lists of such reusable django "apps" on the web, like
http://djangozen.com/app/


A larger reusable app structure might look like:

django_timer/
__init__.py
admin.py # django admin registration of stuff.
models.py # models you want to be able to use in different projects
views.py  # possibly some associated reusable views.
urls.py # possibly a reusuable url subtree structure.
templates/  # some default/example templates used by views.
django_timer/  # some informal namespace for them
something.html # I prefer .html.djt, but never mind.
templatetags/
django_timer_tags.py # some custom templatetags...
management/
__init__.py
commands/
 __init__.py
 timerfrob.py # custom command "./manage.py timerfrob"


Consider the structure of, say, the django bundled django.contrib apps,
or studying the structure of "pinax", say, might be useful:

http://github.com/pinax/pinax/tree/master/pinax/apps/

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: can foreign key fields be empty?

2010-07-21 Thread rmschne
Em,

Perfect.  Thanks for taking the time on this.  Greatly appreciated!!
I'm going to re-write the code here.

(in all my reading, I missed _isnull field lookup)

-- 
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 email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.