Login over HTTPS

2009-10-26 Thread Jani Tiainen

I'm trying to get Django to make authentication (namely username + 
password) to be transferred over HTTPS. But rest of the site is still on 
plain old HTTP.

How this can be done? I've very little success and google didn't gave 
much of help either.

I'm using Apache 2.2 with mod_wsgi and I've total control over my 
webserver config.

-- 
Jani Tiainen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Putting django based site on HTTPS

2009-10-26 Thread Graham Dumpleton



On Oct 27, 2:20 pm, zweb  wrote:
> I want to serve whole of my site on HTTPS.
> But HttpResponseRedirect  is sending to http by default.
>
> Any way to tell django that it should use https and not http
>
> I am using mod_python on one site and mod_wsgi on another. Both need
> to go to HTTPS

For mod_wsgi, you first need to verify whether it is saying you are
running under HTTPS in the first place. To do this you need to know
the value of wsgi.url_scheme as passed in WSGI request environment.

One way of doing that is to use a WSGI middleware wrapper to capture
request details. See first example in:

  
http://code.google.com/p/modwsgi/wiki/DebuggingTechniques#Tracking_Request_and_Response

If wsgi.url_scheme isn't 'https', then your Apache configuration is
wrong, or you are using another front end web server which is actually
handling HTTPS and you aren't conveying that fact through to backend
Apache and doing appropriate configuration changes to reflect that.

If 'wsgi.url_scheme' is correct, then it is a Django issue, or more
likely how you are using Django or how you have configured it for
location of media resources etc.

Post output or request details from that first code example in
referenced document.

Graham
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Putting django based site on HTTPS

2009-10-26 Thread zweb

I want to serve whole of my site on HTTPS.
But HttpResponseRedirect  is sending to http by default.

Any way to tell django that it should use https and not http

I am using mod_python on one site and mod_wsgi on another. Both need
to go to HTTPS



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: View count ignore auto_now

2009-10-26 Thread TheIvIaxx

yeah i think thats what i will have to do, but you end up treating the
view count as a separate object.  Or i can just take the auto_now off
and just do my own date updates on the save method.  just thought
there may have been a built in way to do it :)

On Oct 26, 5:35 pm, Matt Schinckel  wrote:
> On Oct 27, 8:56 am, TheIvIaxx  wrote:
>
> > Hello, I have a simple page model that has created and modified fields
> > with auto_add and auto_now set to True.  I'd like to keep track of the
> > number of views per page so i added a views field to the model.
> > However if i increment the views and save, then the modified gets
> > changed.  This trivializes the modified field as it will be updated
> > every time someone views the page.  Is there a way to update a single
> > field only with the ORM or will i have to do a SQL query?
>
> You /may/ be able to do it with a OneToOne relation instead of a
> field.
>
> (Just an idea, I haven't tested it).
>
> Matt.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: View count ignore auto_now

2009-10-26 Thread Matt Schinckel

On Oct 27, 8:56 am, TheIvIaxx  wrote:
> Hello, I have a simple page model that has created and modified fields
> with auto_add and auto_now set to True.  I'd like to keep track of the
> number of views per page so i added a views field to the model.
> However if i increment the views and save, then the modified gets
> changed.  This trivializes the modified field as it will be updated
> every time someone views the page.  Is there a way to update a single
> field only with the ORM or will i have to do a SQL query?

You /may/ be able to do it with a OneToOne relation instead of a
field.

(Just an idea, I haven't tested it).

Matt.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Discovering the ip/port in use by runserver

2009-10-26 Thread tow

Other than something like this, obviously, which works, but is a bit
fragile & certainly not very nice:

def get_server_address_by_stack_inspection():
import inspect
for s in inspect.stack():
if (s[0].f_code.co_filename.endswith("django/core/
servers/basehttp.py")
and s[0].f_code.co_name == "run" and s
[0].f_code.co_argcount == 3):
return s[0].f_locals['server_address']


On Oct 26, 11:34 pm, tow  wrote:
> If you're running your django server through ./manage.py runserver, is
> there a way, from within the django process, to discover which  IP
> address and port are in use?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



session question

2009-10-26 Thread webbo

Hi all,

It's great to join this great Django place !!

I am trying to make session work, but it doesn't work as I think.

I want my 2 pages able to share the same variables that I stored in
session.

Thanks first for paying attention on this post.



Please give me some suggestion as bellow:

I want to use anonymous sessions for my 2 functions:  list_user and
list_device

1. I have a dropdown box called "group" for both functions.

2. Once I changed group value in either one page, the group value will
be stored in session.

3. For example:
If people click on group dropdown box and change value to "GROUP1"
in list_device or list_user page, then
the value of group drop-down box of both list_user and list_device
should be changed to 'GROUP1'

4. It works on Firefox if I press F5 to refresh the page.  Sometimes
the value is updated by clicking refresh button many times.  Is any
problem relate to my browser setting?

5. It never works on IE, and IE generate so many session_keys in
django_session.

#
setting.py
#

MIDDLEWARE_CLASSES = (
'django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware', )

SESSION_ENGINE= ('django.contrib.sessions.backends.cached_db')

INSTALLED_APPS = (
#start session
'django.contrib.sessions',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sites',
'myTest.FrontEnd',
#admin
'django.contrib.admin',

)

#
view.py
#

def list_users(request, group_from_url ='' ):
   #Variables
   group_is_clicked = ''
   group = ''

   if (group_from_url):  #READ group from URL

 group = group_from_url
 user = user.objects.filter(group=group).distinct().order_by
('name') # generate user table
 form = userForm(initial={'group': group} )

   elif 'group' in request.session: # if group is stored in session

 group = request.session['group']
 user = user.objects.filter(group=group).distinct().order_by
('name')
 form = userForm(initial={'group': group} )

   elif group_is_clicked == 'ON':  #when user clicking on
group_dropdown_box

 group = request.POST.get('group','')
 user = user.objects.filter(group=group).distinct().order_by
('name')
 form = userForm(initial={'group': group} )

   else:# DEFAULT LOOK

  user = user.objects.all()
  form = userForm()

  #update session values
  request.session['group'] = group


  return render_to_response("User/user.html",{'group':group,
'user':user, 'form':form})


def list_device(request, group_from_url ='' ):
   #Variables
   group_is_clicked = ''
   group = ''

   if (group_from_url):  #READ group from URL

 group = group_from_url
 device = device.objects.filter(group=group).distinct().order_by
('name') # generate user table
 form = deviceForm(initial={'group': group} )

   elif 'group' in request.session: # if group is stored in session

 group = request.session['group']
 device = device.objects.filter(group=group).distinct().order_by
('name')
 form = deviceForm(initial={'group': group} )

   elif group_is_clicked == 'ON':  #when user clicking on
group_dropdown_box

 group = request.POST.get('group','')
 device = device.objects.filter(group=group).distinct().order_by
('name')
 form = deviceForm(initial={'group': group} )

   else:# DEFAULT LOOK

  device = device.objects.all()
  form = deviceForm()

  #update session values
  request.session['group'] = group


  return render_to_response("device/device.html",{'group':group,
'device':device, 'form':form})

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Discovering the ip/port in use by runserver

2009-10-26 Thread tow

If you're running your django server through ./manage.py runserver, is
there a way, from within the django process, to discover which  IP
address and port are in use?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



RE: syntax error what am i doing wrong???

2009-10-26 Thread Vincent Jones

Thanks...it worked.

-Original Message-
From: django-users@googlegroups.com [mailto:django-us...@googlegroups.com]
On Behalf Of Daniel Roseman
Sent: Monday, October 26, 2009 7:01 PM
To: Django users
Subject: Re: syntax error what am i doing wrong???


On Oct 26, 10:35 pm, "jon...@cox.net"  wrote:
> SyntaxError at /
>
> ('invalid syntax', ('c:\\Users\\Vincent\\Documents\\django_bookmarks\
> \..\\django_bookmarks\\bookmarks\\views.py', 15, 20, 'return Http
> Response(output)\n'))
>
> SCRIPT FROM VIEWS.PY
>
> from django.http import HttpResponse
> def main_page(request) :
>    output = '''
>   
>      %s
>      
>         %s%s
>      
>   
> ''' % (
>       'Django Bookmarks',
>       'Welcome to Django Bookmarks',
>       'Where you can store and share bookmarks!'
> )
> return HttpResponse(output)

Looks like your final line is not properly indented - should be lined
up with 'output', not 'def'.
--
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-users@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: syntax error what am i doing wrong???

2009-10-26 Thread Daniel Roseman

On Oct 26, 10:35 pm, "jon...@cox.net"  wrote:
> SyntaxError at /
>
> ('invalid syntax', ('c:\\Users\\Vincent\\Documents\\django_bookmarks\
> \..\\django_bookmarks\\bookmarks\\views.py', 15, 20, 'return Http
> Response(output)\n'))
>
> SCRIPT FROM VIEWS.PY
>
> from django.http import HttpResponse
> def main_page(request) :
>    output = '''
>   
>      %s
>      
>         %s%s
>      
>   
> ''' % (
>       'Django Bookmarks',
>       'Welcome to Django Bookmarks',
>       'Where you can store and share bookmarks!'
> )
> return HttpResponse(output)

Looks like your final line is not properly indented - should be lined
up with 'output', not 'def'.
--
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-users@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: syntax error what am i doing wrong???

2009-10-26 Thread Antoni Aloy

2009/10/26 jon...@cox.net :
>
> SyntaxError at /
>
> ('invalid syntax', ('c:\\Users\\Vincent\\Documents\\django_bookmarks\
> \..\\django_bookmarks\\bookmarks\\views.py', 15, 20, 'return Http
> Response(output)\n'))
>
> SCRIPT FROM VIEWS.PY
>
> from django.http import HttpResponse
> def main_page(request) :
>   output = '''
>  
>     %s
>     
>        %s%s
>     
>  
> ''' % (
>      'Django Bookmarks',
>      'Welcome to Django Bookmarks',
>      'Where you can store and share bookmarks!'
> )
> return HttpResponse(output)
>
> >
>

At first sight: you need triple quote string not single.

-- 
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-users@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
-~--~~~~--~~--~--~---



View count ignore auto_now

2009-10-26 Thread TheIvIaxx

Hello, I have a simple page model that has created and modified fields
with auto_add and auto_now set to True.  I'd like to keep track of the
number of views per page so i added a views field to the model.
However if i increment the views and save, then the modified gets
changed.  This trivializes the modified field as it will be updated
every time someone views the page.  Is there a way to update a single
field only with the ORM or will i have to do a SQL query?

Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



syntax error what am i doing wrong???

2009-10-26 Thread jon...@cox.net

SyntaxError at /

('invalid syntax', ('c:\\Users\\Vincent\\Documents\\django_bookmarks\
\..\\django_bookmarks\\bookmarks\\views.py', 15, 20, 'return Http
Response(output)\n'))

SCRIPT FROM VIEWS.PY

from django.http import HttpResponse
def main_page(request) :
   output = '''
  
 %s
 
%s%s
 
  
''' % (
  'Django Bookmarks',
  'Welcome to Django Bookmarks',
  'Where you can store and share bookmarks!'
)
return HttpResponse(output)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Unit testing form validation issue

2009-10-26 Thread Karen Tracey
On Mon, Oct 26, 2009 at 4:12 PM, Chris Allen  wrote:

>
> Anyone have any experience with forms (ModelMultipleChoice fields and
> foreignkey'd choice fields) not validating properly in a unit test but
> just fine in the runserver?
>
> Passing the same request.POST data to the unit test as I am in the
> runserver and live instance, which I verified via the debugger.
>
>
Runserver uses your development database, test uses an initially empty test
database.  You've got primary key id values hardcoded in your test data. You
don't say anything about how you are ensuring that the test database has
exactly the same data, including primary key values, as your development
one.  Are you doing something that would make this assumption that the
development and test databases are identical valid?  Because it's not, in
general.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Unit testing form validation issue

2009-10-26 Thread Chris Allen

Anyone have any experience with forms (ModelMultipleChoice fields and
foreignkey'd choice fields) not validating properly in a unit test but
just fine in the runserver?

Passing the same request.POST data to the unit test as I am in the
runserver and live instance, which I verified via the debugger.

Using a data dict instead of the actual request object.

the is_valid() fails for two different forms on three fields (1 for
one, 2 for the other). All three fields are choice fields.

Dump of various relevant info is below.

I appreciate any help anyone can offer.

Thanks for your time,
Chris

FAIL: test discount, transaction, subscription
--
Traceback (most recent call last):
  File "/Users/callen/Code/sellingstock/account/tests.py", line 170,
in test_transact
self.assertTrue(payment_form.is_valid())
AssertionError

self.assertTrue(address_form.is_valid()) fails as well.

Debugger info:

AccountTest.data
{
" snipped data dict to only the fields that fail validation. "
 u'address-country': 226,
 u'address-state': 35,
 u'payment-type': 2
}

payment_form._get_errors()
Out[0]: {'type': [u'Select a valid choice. That choice is not one of
the available choices.']}

payment_form.is_valid() and address_form.is_valid()
fail in the Unit Test.

Relevant code is pasted below:

type = forms.ModelChoiceField(
queryset=CreditCardType.objects.filter(public=1)
)

class AddressForm(ModelForm):
"""
What it says on the tin.
"""
class Meta:
model = Address
exclude = ('user', 'default', 'phone2', 'fax2',)

class Address(models.Model):
user = models.OneToOneField(User)
street = models.CharField(max_length=150, blank=False, null=False,
verbose_name = "Street Address")
street2 = models.CharField(max_length=150, blank=True, null=False,
verbose_name = "Street Address 2")
city = models.CharField(max_length=150, blank=False, null=False)
state = models.ForeignKey(State)
zip = models.CharField(max_length=150, blank=False, null=False)
country = models.ForeignKey(Country)
phone = models.CharField(max_length=60, blank=True, null=True)
phone2 = models.CharField(max_length=60, blank=True, null=True)
fax = models.CharField(max_length=60, blank=True, null=True)
fax2 = models.CharField(max_length=60, blank=True, null=True)

def __unicode__(self):
return self.street

class Meta:
ordering = ['-id']
verbose_name_plural = "Addresses"

class State(models.Model):
name = models.CharField(max_length=50)
code = models.CharField(max_length=2)

def __unicode__(self):
return self.name

class Country(models.Model):
name = models.CharField(max_length=80)
iso = models.CharField(max_length=2)
iso3 = models.CharField(max_length=3)

def __unicode__(self):
return self.name

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin interface is doing nothing

2009-10-26 Thread M.

Yes, you were right. I copied some of the code from my other project,
which was writen with Django 1.0 and my URL contained .* in the end.
Thank you for your help.


On Oct 26, 10:02 pm, Mikhail Korobov  wrote:
> It is very likely that your urls.py is wrong. Re-check if admin urls
> are included exactly as in documentation example: "(r'^admin/', include
> (admin.site.urls))", without any wildcards.
>
> On 27 окт, 00:12, "M."  wrote:
>
> > Hi,
>
> > I've installed the Admin interface, but the interface is unresponsive.
> > If click on USERS, the page refreshes itself and appends auth/user/ to
> > the URL. If I click it again, it appends it again, but I still remain
> > on the same page. I am using Python 2.6 and Ubuntu.
>
> > Thanks,
> > Martynas

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Definitive solution for foreignkey filtering in Admin

2009-10-26 Thread Tim Valenta

> forms.ModelForm.__init__(self, *args, **kwargs)
> location = kwargs.get('instance', None)
> if location:
> self.fields['contract'].queryset = Contract.objects.filter
> (company=location.company)

It seems that editing the values in self.fields yields rendering
errors:

Caught an exception while rendering: 'QuerySet' object has no
attribute 'label'

It appears that the values are not vanilla QuerySets... I've been
browsing the code again, and I really don't know what the values are.
It's fairly convoluted with that __metaclass__ business in there.  Do
we know what kind of datatype is in self.fields?  When the template
iterates the Form object, it's wrapping it as a BoundField, but
clearly something's messing up during that iteration.  I'm afraid I
don't know much about how the mechanics of this area work in the
Python code.

Any more pointers would be great.  Other than this speedbump, I think
this will do nicely.

Tim

On Oct 26, 8:53 am, Tim Valenta  wrote:
> Many many thanks for the response.
>
> I had tried that approach, but had no idea what was coming through in
> kwargs.  I feel like 'kwargs' on most class objects needs more
> thorough documentation for the general users who refer primarily to
> the on-site docs.  Even digging through some code, I simply had no
> idea.
>
> This should provide a working fix for the sort of filtering I need to
> do.  I hope that maybe I or some other person can provide some code to
> help simplify this amazingly common dilemma.  Any models that group in
> logical relationships of 3 seem to always have this problem, and I'd
> love to have a simpler fix to write off in the docs.
>
> Tim
>
> On Oct 25, 8:28 pm, Matt Schinckel  wrote:
>
>
>
> > On Oct 24, 5:14 am, Tim Valenta  wrote:
>
> > > I've been searching for a while on how to intercept querysets in
> > > forms, to apply a custom filter to the choices on both foreignkey and
> > > m2m widgets.  I'm surprised at how there are so many similar questions
> > > out there, dating back to 2006.
>
> > [snip]
>
> > > The only solution I've seen has dealt with filtering by User foreign
> > > key (being that User is available in the request object in views), and
> > > that's primarily for non-Admin views.
>
> > [snip]
>
> > > I've been looking at the code for the above noted API method,
> > > formfield_for_foreignkey, and I really can't see a way to get
> > > references to an instance of the object being edited.  I would need
> > > such a reference to successfully override that method and filter my
> > > queryset on this relationship.
>
> > I too spent some time looking at formfield_for_foreignkey, and had no
> > luck.
>
> > You can subclass ModelAdmin, and then limit the objects in the field's
> > queryset.
>
> > ** admin.py **
>
> > class LocationAdminForm(forms.ModelForm):
> >     def __init__(self, *args, **kwargs):
> >         forms.ModelForm.__init__(self, *args, **kwargs)
> >         location = kwargs.get('instance', None)
> >         if location:
> >             self.fields['contract'].queryset = Contract.objects.filter
> > (company=location.company)
>
> > class LocationAdmin(admin.ModelAdmin):
> >     model = Location
> >     form = LocationAdminForm
>
> > I also had to do something similar with Inlines, when I did the same
> > type of thing.  This is not my exact code, but it is very close, and
> > suited toward your use case.
>
> > Matt.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Download Free Softwares,Games,Music,Wallpapers,Movies,Dvd movies,bluray movies, hd wallpapers

2009-10-26 Thread Usman Haider

Visit http://www.ReDown.Com for Cracked
Softwares,Games,Wallpapers,Music,Movies,Seasons,Bluray Movies,HD
wallpapers.

www.ReDown.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-users@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: Adding button to admin change form

2009-10-26 Thread Mikhail Korobov

You should override change_form.html template and save it as

/your_project/templates/admin/your_app/change_form.html

or

/your_project/templates/admin/your_app/your_model/change_form.html

On 26 окт, 21:45, Aaron  wrote:
> I need to add a button to the admin change form of certain models,
> which would be placed among the save buttons. I've tried overriding
> the template submit_line.html, but I am coming under the impression
> that this is not possible unless I override the template for my entire
> project.
>
> I need this button so that I can write a view or some other kind of
> handler that is able to access the model form contained in the admin
> change form page. If using the button, I'd override the add_view and
> change_view methods of the appropriate ModelAdmin, and do something
> special if "_mybutton" is in the POST data. If adding a button to the
> change form is not possible, is it possible to add some other link to
> the page that would allow me to access the form object?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Admin interface is doing nothing

2009-10-26 Thread Mikhail Korobov

It is very likely that your urls.py is wrong. Re-check if admin urls
are included exactly as in documentation example: "(r'^admin/', include
(admin.site.urls))", without any wildcards.

On 27 окт, 00:12, "M."  wrote:
> Hi,
>
> I've installed the Admin interface, but the interface is unresponsive.
> If click on USERS, the page refreshes itself and appends auth/user/ to
> the URL. If I click it again, it appends it again, but I still remain
> on the same page. I am using Python 2.6 and Ubuntu.
>
> Thanks,
> Martynas
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Admin interface is doing nothing

2009-10-26 Thread M.

Hi,

I've installed the Admin interface, but the interface is unresponsive.
If click on USERS, the page refreshes itself and appends auth/user/ to
the URL. If I click it again, it appends it again, but I still remain
on the same page. I am using Python 2.6 and Ubuntu.

Thanks,
Martynas

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



DATE_FORMAT

2009-10-26 Thread Sumanth

Hi all,

Currently the DATE_FORMAT is used only for admin pages.

Can I use similar setting where all my date objects are displayed in
the same way in templates , without having to apply humanize on
templates not using date function in templates?

Thanks
Sumanth



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm - how to post primary key to update existing record?

2009-10-26 Thread robinne

I pass Member to the template with something like this...(I don't have
my code here with me)

VIEW
...
if not post
  member = MemberModel(pk=1)
  return render_to_response('mytemplate.html', {'Member':member})

Basically, I am providing a Member (ModelForm) to the template.

What you gave me here should help, I was not familiar with additional
parameters, I will
look more into that.  I just thought I needed the posted data and it
would include the primary key
and then I could load that member again and pass to the save routine.

Thank you!

On Oct 26, 4:07 am, Daniel Roseman  wrote:
> On Oct 26, 5:19 am, robinne  wrote:
>
>
>
> > I am noticing that when I load an existing ModelForm into a template,
> > and I save (POST), I can't seem to get the primary key back in order
> > to update that specific record. I am starting to head down the path of
> > formsets...but that is not what I need. I am updating one record only.
> > Any help is appreciated!
>
> > VIEW
> > def UpdateMember(request):
> >   if request.method == "POST":
> >    # I don't seem to have access to primary key...
> >    # I do have the posted data, and can save to database here.
>
> > TEMPLATE (as you can see, I've tried to explicitly include primary
> > key, both inside and outside the for loop)
> >  {{ Member.MemberID }}
> >  {% for field in Member %}
> >  {{ field.label_tag }}
> >  {{ field }}
> >  {% endfor %}
> > 
>
> You haven't posted the code that shows how you instantiate the form.
> Clearly your UpdateMember view must be taking more than just the
> request parameter - it must include a parameter that gets the object
> you want to update in the first place. And when you instantiate the
> form for editing, you must be passing the 'instance' parameter, so you
> get the data for the form to update. So all you need to do on POST is
> to use that parameter again.
>
> def update_member(request, pk):
>     member = get_object_or_404(member, pk=pk)
>     if request.POST:
>         form = MyForm(instance=member, data=request.POST)
>         if form.is_valid():
>             form.save()
>             return HttpResponseRedirect('/wherever/')
>     else:
>         form = MyForm(instance=member)
>
>     return render_to_response('mytemplate.html', {'form':form})
>
> --
> 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-users@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: static models methods

2009-10-26 Thread Daniel Roseman

On Oct 26, 4:22 pm, Alessandro Ronchi 
wrote:
> I need to create a static method for a model class like this. The line
> Settore.objects.all()[0].id gives error  (
> psycopg2.InternalError: current transaction is aborted) when creating
> the tables at first syncdb. What's the correct way to do that?
>
> ~
> class Settore(models.Model):
>     nome = models.CharField(max_length=200, blank=False, null=False)
>     email = models.EmailField()
>
>     class Meta:
>
>         verbose_name_plural = 'settori'
>         ordering = ('nome',)
>         get_latest_by = "nome"
>
>     def __unicode__(self):
>         return self.nome
>
>     @staticmethod
>     def get_default():
>         try:
>             return Settore.objects.all()[0].id
>         except:
>             return None
> ~
> --
> Alessandro Ronchi

Are you by any chance using that get_default method as the default for
a model field somewhere else? If so, have you perhaps done it like
this:

myfield = models.ForeignKey(Settore, default=Settore.get_default
())

This would call the get_default() staticmethod when the model is
defined, rather than when a new instance is defined. You need to pass
the callable itself:

myfield = models.ForeignKey(Settore, default=Settore.get_default)

- notice the lack of calling () brackets.

All this said, I agree with Ethan that you should be doing this in a
Manager, although I suspect the error might still occur as long as you
call the method in the default, rather than passing the callable.
--
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-users@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: static models methods

2009-10-26 Thread Bill Freeman

I have to wonder whether "get_default" is a name that already means
something to Django.

On Mon, Oct 26, 2009 at 12:22 PM, Alessandro Ronchi
 wrote:
>
> I need to create a static method for a model class like this. The line
> Settore.objects.all()[0].id gives error  (
> psycopg2.InternalError: current transaction is aborted) when creating
> the tables at first syncdb. What's the correct way to do that?
>
> ~
> class Settore(models.Model):
>    nome = models.CharField(max_length=200, blank=False, null=False)
>    email = models.EmailField()
>
>    class Meta:
>
>        verbose_name_plural = 'settori'
>        ordering = ('nome',)
>        get_latest_by = "nome"
>
>    def __unicode__(self):
>        return self.nome
>
>   �...@staticmethod
>    def get_default():
>        try:
>            return Settore.objects.all()[0].id
>        except:
>            return None
> ~
> --
> Alessandro Ronchi
>
> SOASI
> Sviluppo Software e Sistemi Open Source
> http://www.soasi.com
> http://www.linkedin.com/in/ronchialessandro
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Url params with space

2009-10-26 Thread Sumanth

Thanks

That works neat

On Oct 23, 9:53 am, Andrius A  wrote:
> Hi Sumanth,
>
> Yes we do. Use urlib.unquote_plus()
>
> Regards,
> Andrius
>
> On 23 Oct 2009 17:14, "Sumanth"  wrote:
>
> Hi All,
>
> I have url as show below
>
> http://localhost:8000/view/1/1/?scenario=Base,%20Credit
>
> now when I do a request.REQUEST['scenario']
>
> I see a value of 'Base,+Credit'  I get char + instead of space
>
> How do I retain space char ? Do we have a any functions or module
> which will return correct url encoding ?
>
> Thanks
> Sumanth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Adding button to admin change form

2009-10-26 Thread Aaron

I need to add a button to the admin change form of certain models,
which would be placed among the save buttons. I've tried overriding
the template submit_line.html, but I am coming under the impression
that this is not possible unless I override the template for my entire
project.

I need this button so that I can write a view or some other kind of
handler that is able to access the model form contained in the admin
change form page. If using the button, I'd override the add_view and
change_view methods of the appropriate ModelAdmin, and do something
special if "_mybutton" is in the POST data. If adding a button to the
change form is not possible, is it possible to add some other link to
the page that would allow me to access the form object?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: static models methods

2009-10-26 Thread Ethan Jucovy

I don't know what the error means, but this looks like the sort of
thing you might want to put on a custom Manager instead -- then you
could say `Settore.objects.get_default()`.

http://docs.djangoproject.com/en/dev/topics/db/managers/#topics-db-managers

(I have a feeling the error wouldn't happen if it was on a manager class.)

On Mon, Oct 26, 2009 at 12:22 PM, Alessandro Ronchi
 wrote:
>
> I need to create a static method for a model class like this. The line
> Settore.objects.all()[0].id gives error  (
> psycopg2.InternalError: current transaction is aborted) when creating
> the tables at first syncdb. What's the correct way to do that?
>
> ~
> class Settore(models.Model):
>    nome = models.CharField(max_length=200, blank=False, null=False)
>    email = models.EmailField()
>
>    class Meta:
>
>        verbose_name_plural = 'settori'
>        ordering = ('nome',)
>        get_latest_by = "nome"
>
>    def __unicode__(self):
>        return self.nome
>
>   �...@staticmethod
>    def get_default():
>        try:
>            return Settore.objects.all()[0].id
>        except:
>            return None
> ~
> --
> Alessandro Ronchi
>
> SOASI
> Sviluppo Software e Sistemi Open Source
> http://www.soasi.com
> http://www.linkedin.com/in/ronchialessandro
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



static models methods

2009-10-26 Thread Alessandro Ronchi

I need to create a static method for a model class like this. The line
Settore.objects.all()[0].id gives error  (
psycopg2.InternalError: current transaction is aborted) when creating
the tables at first syncdb. What's the correct way to do that?

~
class Settore(models.Model):
nome = models.CharField(max_length=200, blank=False, null=False)
email = models.EmailField()

class Meta:

verbose_name_plural = 'settori'
ordering = ('nome',)
get_latest_by = "nome"

def __unicode__(self):
return self.nome

@staticmethod
def get_default():
try:
return Settore.objects.all()[0].id
except:
return None
~
-- 
Alessandro Ronchi

SOASI
Sviluppo Software e Sistemi Open Source
http://www.soasi.com
http://www.linkedin.com/in/ronchialessandro

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Design decision

2009-10-26 Thread Léon Dignòn

*bump*

On 23 Okt., 11:03, Léon Dignòn  wrote:
> callerlist will MAYBE use a database of another program (not django),
> or it uses a database of another django application. This is optional
> and I want callerlist to work with or without. For that i decided to
> create an application customerlist and develop a model Customer and an
> optional interface for any existing crms. customerlist will either use
> an own model for the crm, or a database of a completely different
> software. To have the callerlist coherent I included a customer-field
> in the PhoneCall model wich should ot throw an error if the
> customerlist application is not installed.
>
> Now I have the following model in the app callerlist with a foreign
> key customer_crm to the optional crm application.
>
> class PhoneCall(models.Model):
>     user = models.ForeignKey(auth.models.User)
>     caller_name = models.CharField(...)
>     customer_crm = models.ForeignKey(customerlist.models.Customer)
>
> If I don't want install the customerlist, model PhoneCall throws an
> error, of course! How would I best change the application callerlist
> to recognize whether customerlist is installed or not, and use the
> customer_crm field or not. Both applications have to be coherent and
> work properly alone.
>
> Any ideas?
>
> On 16 Okt., 21:11, Chip Grandits  wrote:
>
>
>
> > I'm not sure if there is an exact technical defintion of the term
> > 'bind' here. I am assuming you will need the two applications to
> > share a common database? And I am assuming that other application has
> > already been developed and
> > deployed and so you are inclined to work around it?
>
> > So this becomes more of a database question, and might be
> > particular to the particular database engine in use.  I hope it is
> > clear that you do NOT have to use a database that is created
> > with the manage.py syncdb command; although you must have
> > a database that is compatible with one that is created by that
> > command - but it can be a 'superset' of that database.
>
> > My guess is that you might need to know a little bit about the
> > command line interface of the database engine (I doubt you
> > need to be a "power user")  And then brush up on the
> > manage.py database subcommands (dumpdata, inspectdb,
> > and various sql*) and that will help clarify a solution path.
>
> > -Chip
> > On Oct 16, 10:10 am, Léon Dignòn  wrote:
>
> > > I have a project. Within that project I have the app callerlist.
> > > Callerlist is a list of either inbound or outbound phone calls. To
> > > each phone call the following information should be written down: own
> > > name, name of the caller, subject, message and time. This app has to
> > > be coherent.
>
> > > Now, for example, I want to bind the above app to an crm system or
> > > another application with customer data. I am not sure which is the
> > > best way to provide that interface. Should I provide an additional
> > > field as a foreign key to the customer table? The table could be
> > > defined via a variable in the settings.py.
>
> > > Or are there better solutions?
>
> > > ld- Zitierten Text ausblenden -
>
> > - Zitierten Text anzeigen -- Zitierten Text ausblenden -
>
> - Zitierten Text anzeigen -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Definitive solution for foreignkey filtering in Admin

2009-10-26 Thread Tim Valenta

Many many thanks for the response.

I had tried that approach, but had no idea what was coming through in
kwargs.  I feel like 'kwargs' on most class objects needs more
thorough documentation for the general users who refer primarily to
the on-site docs.  Even digging through some code, I simply had no
idea.

This should provide a working fix for the sort of filtering I need to
do.  I hope that maybe I or some other person can provide some code to
help simplify this amazingly common dilemma.  Any models that group in
logical relationships of 3 seem to always have this problem, and I'd
love to have a simpler fix to write off in the docs.

Tim

On Oct 25, 8:28 pm, Matt Schinckel  wrote:
> On Oct 24, 5:14 am, Tim Valenta  wrote:
>
> > I've been searching for a while on how to intercept querysets in
> > forms, to apply a custom filter to the choices on both foreignkey and
> > m2m widgets.  I'm surprised at how there are so many similar questions
> > out there, dating back to 2006.
>
> [snip]
>
> > The only solution I've seen has dealt with filtering by User foreign
> > key (being that User is available in the request object in views), and
> > that's primarily for non-Admin views.
>
> [snip]
>
> > I've been looking at the code for the above noted API method,
> > formfield_for_foreignkey, and I really can't see a way to get
> > references to an instance of the object being edited.  I would need
> > such a reference to successfully override that method and filter my
> > queryset on this relationship.
>
> I too spent some time looking at formfield_for_foreignkey, and had no
> luck.
>
> You can subclass ModelAdmin, and then limit the objects in the field's
> queryset.
>
> ** admin.py **
>
> class LocationAdminForm(forms.ModelForm):
>     def __init__(self, *args, **kwargs):
>         forms.ModelForm.__init__(self, *args, **kwargs)
>         location = kwargs.get('instance', None)
>         if location:
>             self.fields['contract'].queryset = Contract.objects.filter
> (company=location.company)
>
> class LocationAdmin(admin.ModelAdmin):
>     model = Location
>     form = LocationAdminForm
>
> I also had to do something similar with Inlines, when I did the same
> type of thing.  This is not my exact code, but it is very close, and
> suited toward your use case.
>
> Matt.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ajax problem

2009-10-26 Thread elminio

Hello,

The situation is that I have a div to which I want to dynamically load
forms for update create etc of my models.

I use generic forms.

And the problem is that when I use javascript with jQuery :
key is already defined:


$("#div_nontetn").load("/model/"+ key + "/update/", {object_id: key},
function(){ });

It doesnt render the site in which is form to fill but automaticaly
submits empty form and redirect to object_detal.

What am I doing wrong ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Truth values for current database type for custom queries.

2009-10-26 Thread Bill Freeman

I have a query that is complex enough that, even if it can be done
with filter, exclude, and Qs, I find more maintainable as custom SQL.
That all works fine.

But I want to add the test of a boolean field in my WHERE clause, and
different databases represent true and false differently.
Specifically, during development, and probably for later bug fix
testing, I find it convenient to use sqlite, where true and false are
1 and 0, but we will likely deploy on PostgreSQL, where they (at least
as returned
by the command line tool) be t and f, and the documentation implies
that true and false will also work.

I can clearly check settings from django.conf to see which DB I'm
using, and adjust my queries, but it occurs to me that the ORM already
knows how to represent true and false for the current DB.

Is there a reasonable and unlikely to change way of programatically
asking the ORM for the representations?

Thanks, Bill

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Resizing and renaming images in 'save' method

2009-10-26 Thread virhilo

How to correctly resize and rename upladed image in 'save' method?

# Here is our model:
class Product(models.Model):
# some fields
photo = models.ImageField(upload_to='images',
verbose_name=u'zdjęcie', null=True, blank=True)

# and here we are our save method:
def save(self, *args, **kwargs):
if self.photo:
image = Image.open(self.photo)
if image.mode not in ('L', 'RGB'):
image = image.convert('RGB')
image.thumbnail(settings.UPLOADED_IMAGES_SIZE,
Image.ANTIALIAS)
self.photo.open()
image.save(self.photo, 'PNG')
self.photo.name = '%s.png' % os.path.splitext
(self.photo.name)[0]
super(Product, self).save(*args, **kwargs)

everything working but self.photo size(in bytes not width and height)
is wrong(it no changed after resizing), and if we download that image
it have previous size, so i try do it this way:

def save(self, *args, **kwargs):
if self.photo:
image = Image.open(self.photo)
if image.mode not in ('L', 'RGB'):
image = image.convert('RGB')
image.thumbnail(settings.UPLOADED_IMAGES_SIZE,
Image.ANTIALIAS)
tmp_file = StringIO()
image.save(tmp_file, 'PNG')
self.photo.open()
tmp_file.seek(0)
self.photo.write(tmp_file.read())
del image
self.photo.name = '%s.png' % os.path.splitext
(self.photo.name)[0]
# now we have correct image size but i don't know how to
assign it to our image:
# i can't asign it that:
self.photo.size = tmp_file.len
super(Product, self).save(*args, **kwargs)

Anybody know how to solve it?

Łukasz Fidosz
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Troubleshoot import errors

2009-10-26 Thread Hector Garcia

Check out all your template calls to {% url view_picture %}, you are
probably passing wrong arguments to the reverse URL.


Hector Garcia - Web developer, musician
http://nomadblue.com/



On Mon, Oct 26, 2009 at 12:37 PM, Dave  wrote:
>
> Hi All, I admit I must totally be missing something. My problem is
> that IF I screw up an import somewhere tracking down the problem is a
> complete nightmare. The traceback just tells me:
>
> "NoReverseMatch: Reverse for 'view_picture' with arguments '()' and
> keyword arguments '{'picture_id': '', 'size': u'small'}' not found"
>
> This is the case no matter which of the 30/40 apps is causing the
> problem.
>
> I've tried to use the command line switch to debug imports, however it
> just spews out tons of info which so far has proven useless to find
> the problem. In most cases when I track down the problem, the
> offending import is not even mentioned in the log! I don't understand
> why there is not a debug or exception message that simply says where
> the problem is.
>
> Any advice help is greatly appreciated. We are just about at our wits
> end because tracking down what should be simple issues is consuming
> far too much time.
>
> Thanks
>
> Dave
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django templates, break a for after an if

2009-10-26 Thread Tom Evans

On Mon, 2009-10-26 at 15:54 +0200, Jani Tiainen wrote:
> NMarcu kirjoitti:
> > Hello all,
> > 
> >I want to do something like this:
> > 
> > {% for u in users %}
> > {% for su in superu %}
> > {% ifequal u su %}
> >//do something end exit
> > from this for
> > {% endifequal %}
> > {% endfor %}
> > {% endfor %}
> > 
> > How can I do this?
> 
> You can't and shouldn't. It's template language, not progamming 
> language. It's function to define _how_ to show data.
> 
> You need to make that decision in a view which is meant for extracting 
> and preparing _what_ to show.
> 

Now that someone has got the "you shouldn't do that" speech out the way,
here's how you can actually achieve it. Install the 'smart if' tag[1]
from djangosnippets, and alter your template code like so:

{% for u in users %}
  {% if u in superu %}
{{ some_content }}
  {% endif %}
{% endfor %}

The smart if tag is allegedly slated for inclusion in django 1.2.

Cheers

Tom

[1] http://www.djangosnippets.org/snippets/1350/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: inspectdb Oracle

2009-10-26 Thread Mark (Nosrednakram)

On Oct 26, 4:43 am, gillengam  wrote:
> Hi, I must develop an application that use Oracle database. The Oracle
> connection user is the owner of some tables, but he can only read two
> views (he is not the owner). I used command "python manage.py
> inspectdb > models.py", but I got only user's tables and  I need
> also the two views. How can I do? Is it possible?
>
> Thanks

I usually create a table using something similar to:

create table temp_member_view as select * from member_view where
rownum < 2;

Where member_view would be the original view name.  I then use the
inspectdb to create the model for the new table and then drop the
table it should create a better model than I do usually when I try to
do it manually.If your view doesn't have an obvious single column
primary key you may want to look at my notes on this subject:

http://projects.django-development.info/trac/dd_dd/wiki/Creating_Django_Views_of_Tables

Great call on overriding save/delete I'll add to my notes and start
doing that as well since I wasn't.

Mark
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django templates, break a for after an if

2009-10-26 Thread Jani Tiainen

NMarcu kirjoitti:
> Hello all,
> 
>I want to do something like this:
> 
> {% for u in users %}
> {% for su in superu %}
> {% ifequal u su %}
>//do something end exit
> from this for
> {% endifequal %}
> {% endfor %}
> {% endfor %}
> 
> How can I do this?

You can't and shouldn't. It's template language, not progamming 
language. It's function to define _how_ to show data.

You need to make that decision in a view which is meant for extracting 
and preparing _what_ to show.

-- 
Jani Tiainen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django templates, break a for after an if

2009-10-26 Thread NMarcu

Hello all,

   I want to do something like this:

{% for u in users %}
{% for su in superu %}
{% ifequal u su %}
   //do something end exit
from this for
{% endifequal %}
{% endfor %}
{% endfor %}

How can I do 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-users@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: Do reverse relations eventually kill performance?

2009-10-26 Thread Manfre

Subclass Manager and make this the default manager for all owner
restricted models. Override filter() and get() to check for the
"owner" arg. Raise an error if it is not specified. Also set
use_for_related_fields = True for the manager to cover the reverse
relations.

Regards,
Michael


On Oct 25, 7:28 am, Gerard  wrote:
> Hiya Tim,
>
> Thanx for the response. Thing is I already have queries running like this:
>
> Customer.objects.filter(user=request.user).order_by('company_name')
>
> The problem however is that I dont trust myself enough to never make a
> msitake to show the wrong data to the wrong user. All my models have a
> "owner" field, but if the queries are not using that there's unwanted data
> disclosure.
>
> I'm trying to figure out if it's possible to write a tiny piece of
> middleware that alarms me when a query is invoked without filtering on the
> owner field.
>
> And at least have it running during development. Would that be afeasible 
> option?
>
> Thanx,
>
> Regards,
>
> Gerard.
>
>
>
> Tim Chase wrote:
> > Gerard wrote:
> >> Hi all,
>
> >> I'm working on a safe way to get users to only see there own records. I've
> >> been working on subclassing model.Manager and requiring a 'owner' parm for
> >> filter() or otherwise returning an emtpy query set .. just to failsafe my
> >> own view coding.
>
> >> Then I figured I could get records in my view via the user.whatever_objects
> >> like this:
>
> >>      user = User.objects.get(username=request.user)
> >>      customer_list = user.customers.all().order_by('company_name')
>
> >> But that would make two db connects. When growing in scale, could this
> >> eventually be a performance bottleneck?
>
> > This might be rewritable as
>
> > Customer.objects.filter(user=request.user).order_by('company_name')
>
> > or
>
> > request.user.customers.all().order_by('company_name')
>
> > Test each to see how many queries (not connections) are sent in
> > each case.
>
> > -tim
>
> --
> self.url =www.gerardjp.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-users@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
-~--~~~~--~~--~--~---



Redirects on HTTPS

2009-10-26 Thread Tim Sawyer

I still can't get this to work (original thread at
http://groups.google.com/group/django-users/browse_thread/thread/cdece5ef2e7fd280).
 I'm looking to get a HttpResponseRedirect in my django app to redirect to
HTTPS not HTTP.

I've tried:

* proxy server Apache (the one doing the SSL) does:
SetEnv X-Forwarded-Proto=https
* Apache running django/mod_wsgi does this:
SetEnvIf X-Forwarded-Proto https HTTPS=on

I've also tried:
* Hard coding HttpRequest.is_secure() in django to True

I've tried changing my wsgi file to do this:
_application = django.core.handlers.wsgi.WSGIHandler()

def application(environ, start_response):
environ['HTTPS'] = 'on'
return _application(environ, start_response)


but no luck.

With everything I've tried, it still redirects back to HTTP on a
HttpResponseRedirect.

Any clues anyone?

thanks,

Tim.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: inspectdb Oracle

2009-10-26 Thread Jani Tiainen

gillengam kirjoitti:
> Hi, I must develop an application that use Oracle database. The Oracle
> connection user is the owner of some tables, but he can only read two
> views (he is not the owner). I used command "python manage.py
> inspectdb > models.py", but I got only user's tables and  I need
> also the two views. How can I do? Is it possible?

Handcrafing. So you need to construct those two views by hand. Also I 
suggest that you override save() method to raise exception if someone 
tries to save something in views accidentally.

-- 
Jani Tiainen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Troubleshoot import errors

2009-10-26 Thread Dave

Hi All, I admit I must totally be missing something. My problem is
that IF I screw up an import somewhere tracking down the problem is a
complete nightmare. The traceback just tells me:

"NoReverseMatch: Reverse for 'view_picture' with arguments '()' and
keyword arguments '{'picture_id': '', 'size': u'small'}' not found"

This is the case no matter which of the 30/40 apps is causing the
problem.

I've tried to use the command line switch to debug imports, however it
just spews out tons of info which so far has proven useless to find
the problem. In most cases when I track down the problem, the
offending import is not even mentioned in the log! I don't understand
why there is not a debug or exception message that simply says where
the problem is.

Any advice help is greatly appreciated. We are just about at our wits
end because tracking down what should be simple issues is consuming
far too much time.

Thanks

Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



inspectdb Oracle

2009-10-26 Thread gillengam

Hi, I must develop an application that use Oracle database. The Oracle
connection user is the owner of some tables, but he can only read two
views (he is not the owner). I used command "python manage.py
inspectdb > models.py", but I got only user's tables and  I need
also the two views. How can I do? Is it possible?

Thanks

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Starting a daemon thread from Django view

2009-10-26 Thread dim

I am writing a service that should handle HTTP requests according to
following scenario:

- register a job
- make an "ok" response
- do the job
- report the job is complete by making HTTP request to other service

The jobs are often lightweight and will be executed very quickly so I
don't want to use cron-based solutions or queue services - both that
ways are adding too much overhead for such a task.

As far as I know, there is no way (at least no right and easy way) to
use the thread after response was sent. (or maybe I'm wrong here?)
So I'm going to start a new daemon thread to do the job. And my
scenario will look like:

- register a job
- start a new daemon thread for job processing
- make an "ok" response
-- daemon thread will (somewhen) report the job is complete by making
HTTP request to other service

I'm going to do it using a regular threading.Thread with setDaemon
(True)

Is it a reasonable solution?
Are there any hidden dangers in it?
Will it work perfectly with any deployment way? (mod_python, mod_wsgi,
FastCGI)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model design

2009-10-26 Thread Daniel Roseman

On Oct 25, 11:47 pm, Caisys  wrote:
> Thanks but I am not very familiar with forms yet I barely managed to
> override the default form.
> However, I thought that its ok for the time being since places and
> subplaces are not changed frequently so i can live with it for the
> time being and move to more important parts until I am more familiar
> with the forms.
>
> I just need to know how to call the a related field in __unicode__
> (self)

You haven't shown your models. What is the name of the foreign key
field in Subplace that links to Place? That's the name you should use
in the unicode method.
--
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-users@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: Db migration

2009-10-26 Thread Tom Evans

On Mon, 2009-10-26 at 16:09 +0530, aju mathew wrote:
> Hi
> 
> How can I populate values from a python file to database.
> 
> Is it any commands their for db migration from command prompt.
> 
> -- 
> Thanks & Regards,
> Aju P Mathew
> 

http://docs.djangoproject.com/en/dev/howto/initial-data/

Cheers

Tom


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model design

2009-10-26 Thread Vinicius Mendes | meiocodigo.com

def __unicode__(self):
return unicode(self.place)+' - '+self.nome

On Oct 25, 8:47 pm, Caisys  wrote:
> Thanks but I am not very familiar with forms yet I barely managed to
> override the default form.
> However, I thought that its ok for the time being since places and
> subplaces are not changed frequently so i can live with it for the
> time being and move to more important parts until I am more familiar
> with the forms.
>
> I just need to know how to call the a related field in __unicode__
> (self)
>
> On Oct 25, 2:30 pm, "Vinicius Mendes | meiocodigo.com"
>
>  wrote:
> > On Oct 25, 4:53 am, Caisys  wrote:
>
> > > > Just override the form in the inlne admin. All you have to do is set a
> > > > default in the field you want.
>
> > > I managed to do that but now all the extra fields have the default
> > > text not just one.
>
> > What about overriding the formset? You override the __init__ of the
> > formset and before calling super, you add an initial data to the
> > formset adding the default value for the first form.
>
> > > > In this case i prefer the approach of creating a "fake" field called
> > > > places, populated with the places, and when the user select the place,
> > > > you do an ajax request and populate the subplace select with the
> > > > subplaces from the selected place. You will have to override the form
> > > > in the ModelAdmin and add this behaviour to the form. Also you will
> > > > have to create a view to retrieve the subplaces based in the selected
> > > > place.
>
> > > I am not so sure how to do that yet. However, i would like to know how
> > > i could not return the related object name in __unicode__ . Where did
> > > I go wrong?
>
> > > Thanks
>
> > > On Oct 24, 1:38 pm, "Vinicius Mendes | meiocodigo.com"
>
> > >  wrote:
> > > > On Oct 24, 7:14 am, Caisys  wrote:
>
> > > > > Thanks !!! I also felt the second sounds more "right" which leads to
> > > > > two requirements, the first is for convenience but the second is a
> > > > > must:
>
> > > > > 1) On the admin page for add Place I will put 2 or 3 slots for adding
> > > > > Subplace to a place ... is there a way where the first one would be
> > > > > filled with "default" by default? so that each created place would
> > > > > have a default subplace?
>
> > > > Just override the form in the inlne admin. All you have to do is set a
> > > > default in the field you want.
>
> > > > > 2) On the admin page for add event there will be a drop down list for
> > > > > the subplace most of the subplaces will be called "default" is
> > > > > there a way to change the label on drop down list to "place -
> > > > > subplace". i tried to change the __unicode__ of subplace to "return
> > > > > u"% - %" % (self.place, self.name)" but it generated and error that
> > > > > subplace object has no attribute 'place'.
>
> > > > In this case i prefer the approach of creating a "fake" field called
> > > > places, populated with the places, and when the user select the place,
> > > > you do an ajax request and populate the subplace select with the
> > > > subplaces from the selected place. You will have to override the form
> > > > in the ModelAdmin and add this behaviour to the form. Also you will
> > > > have to create a view to retrieve the subplaces based in the selected
> > > > place.
>
> > > > > thanks
>
> > > > > On Oct 24, 2:27 am, Léon Dignòn  wrote:
>
> > > > > > The second sounds more logically.
>
> > > > > > On 23 Okt., 15:41, chefsmart  wrote:
>
> > > > > > > I would go with your second solution.
>
> > > > > > > On Oct 23, 5:17 pm, Caisys  wrote:
>
> > > > > > > > Hi,
> > > > > > > > I have classes for Event, Place and Subplace. Some of the 
> > > > > > > > Places are
> > > > > > > > divided into different Halls (Subplace) and some have only one. 
> > > > > > > > I
> > > > > > > > would like to know how design the relations between the classes.
>
> > > > > > > > 1) Should I put two columns in the Event one FK to Place and 
> > > > > > > > another
> > > > > > > > FK to Hall?
> > > > > > > > 2) Should I create one FK only to Hall and create a record in 
> > > > > > > > Hall for
> > > > > > > > every Place even if the Place has no Halls?
>
> > > > > > > > Thanks- Zitierten Text ausblenden -
>
> > > > > > > - Zitierten Text anzeigen -
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm - how to post primary key to update existing record?

2009-10-26 Thread Daniel Roseman

On Oct 26, 5:19 am, robinne  wrote:
> I am noticing that when I load an existing ModelForm into a template,
> and I save (POST), I can't seem to get the primary key back in order
> to update that specific record. I am starting to head down the path of
> formsets...but that is not what I need. I am updating one record only.
> Any help is appreciated!
>
> VIEW
> def UpdateMember(request):
>   if request.method == "POST":
>    # I don't seem to have access to primary key...
>    # I do have the posted data, and can save to database here.
>
> TEMPLATE (as you can see, I've tried to explicitly include primary
> key, both inside and outside the for loop)
>  {{ Member.MemberID }}
>  {% for field in Member %}
>  {{ field.label_tag }}
>  {{ field }}
>  {% endfor %}
> 

You haven't posted the code that shows how you instantiate the form.
Clearly your UpdateMember view must be taking more than just the
request parameter - it must include a parameter that gets the object
you want to update in the first place. And when you instantiate the
form for editing, you must be passing the 'instance' parameter, so you
get the data for the form to update. So all you need to do on POST is
to use that parameter again.

def update_member(request, pk):
member = get_object_or_404(member, pk=pk)
if request.POST:
form = MyForm(instance=member, data=request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/wherever/')
else:
form = MyForm(instance=member)

return render_to_response('mytemplate.html', {'form':form})

--
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-users@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: Db migration

2009-10-26 Thread Daniel Roseman

On Oct 26, 10:39 am, aju mathew  wrote:
> Hi
>
> How can I populate values from a python file to database.
>
> Is it any commands their for db migration from command prompt.
>
> --
> Thanks & Regards,
> Aju P Mathew

What do you mean a 'Python file'? If it's in a Python file, you can
use ORM commands. What's the issue?
--
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-users@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
-~--~~~~--~~--~--~---



Db migration

2009-10-26 Thread aju mathew
Hi

How can I populate values from a python file to database.

Is it any commands their for db migration from command prompt.

-- 
Thanks & Regards,
Aju P Mathew

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



MultipleForm factory and optional forms

2009-10-26 Thread Norbert Wójtowicz

I've borrowed Alex Gaynor's code for building MultipleForm factories
[0] and updated it to work with optional form fields.

The idea comes from the following situation: you have a profile page
with many services (eg. blip, twitter, etc) that you link to via
ForeignKey.

class MicroBlog(models.Model):
service = models.IntegerField(choices=SOCIAL_MEDIAS)
nick = models.CharField(max_length=50)
# other stuff (eg. verification, update_date, etc)

You would like to build the profile page quickly - so you use a
ModelForm and the MultipleForm factory.

class MicroBlogForm(forms.ModelForm):
class Meta:
model = MicroBlog

BigProfileForm = multiple_form_factory({
'twitter': SocialMicroBlogForm,
'flaker': SocialMicroBlogForm,
# other kinds of forms (so can't really use querysets.. I
think. I could be wrong!)
}, ['twitter', 'flaker'])

The only problem with this is that all submitted forms should validate
BUT not all forms are required. For example, we can't expect everyone
to have a twitter account. One way is to make the fields optional (but
then we need to validate outside of forms), so the only real way to do
it is to mark optional forms.

I've modified Alex's code to support optional fields:

BigProfileForm = multiple_form_factory({
'twitter': SocialMicroBlogForm,
'flaker': SocialMicroBlogForm,
}, ['twitter', 'flaker']
  , ['twitter']) # twitter is optional, flaker
is required

The modified code is posted below. If possible, I'd appreciate some
comments if this is the right way to go about it. Also, there's one
bug I can't figure out - if an empty form is submitted (without any
data), the rendered form shows required field errors on all forms
(even optional). The correct handling is to only show required field
errors on optional fields that had some data submitted. Could someone
point out where my problem is?

Code:

from django.forms.util import ErrorList
from django.utils.datastructures import SortedDict
from django.utils.safestring import mark_safe

def multiple_form_factory(form_classes, form_order=None,
optional_forms=[]):
   if form_order:
   form_classes = SortedDict([(prefix, form_classes[prefix])
  for prefix in form_order])
   else:
   form_classes = SortedDict(form_classes)
   return type('MultipleForm', (MultipleFormBase,),
   {'form_classes': form_classes,
'optional_forms': optional_forms})

class MultipleFormBase(object):
   def __init__(self, data=None, files=None, auto_id='id_%s',
prefix=None, initial=None, error_class=ErrorList,
label_suffix=':', empty_permitted=False):
   initial = initial or {}
   if prefix is None:
   prefix = ''
   self.forms = []
   self.extra_forms_info = []
   for i, (form_prefix, form_class) in enumerate
(self.form_classes.iteritems()):
   self.extra_forms_info.append({
   'prefix': form_prefix,
   'optional': form_prefix in self.optional_forms,
   })
   self.forms.append(form_class(data, files, auto_id, prefix +
form_prefix,
   initial.get(i, None),
   error_class, label_suffix,
empty_permitted))

   def __unicode__(self):
   return self.as_table()

   def __iter__(self):
   for form in self.forms:
   for field in form:
   yield field

   def non_optional_forms(self):
   for i,form in enumerate(self.forms):
   if self.extra_forms_info[i]['optional'] and not
form._get_changed_data():
   continue
   yield form

   def is_valid(self):
   # raise Exception, list(self.non_optional_forms())
   return all(form.is_valid() for form in self.non_optional_forms
())

   def as_table(self):
   return mark_safe('\n'.join(form.as_table() for form in
self.forms))

   def as_ul(self):
   return mark_safe('\n'.join(form.as_ul() for form in
self.forms))

   def as_p(self):
   return mark_safe('\n'.join(form.as_p() for form in self.forms))

   def is_multipart(self):
   return any(form.is_multipart() for form in self.forms)

   def save(self, commit=True):
   return tuple(form.save(commit) for form in
self.non_optional_forms())
   save.alters_data = True


Thanks in advance,
Norbert Wójtowicz

[0] http://en.av5.info/lazypython/2009/05/eurodjangocon-2009.html

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: AttributeError when trying to run syncdb after installing django-friends

2009-10-26 Thread Gezim Hoxha

Actually it was an error with the app itself and it had been corrected
in a newer version.

Thanks :)

On Oct 17, 10:37 pm, Prashanth  wrote:
> Hi Gezim,
>
> On Sun, Oct 18, 2009 at 7:58 AM, Gezim Hoxha  wrote:
> > I also added "friends" to the INSTALLED_APPS.
> > That all went fine. However running syncdb gave me this error:
>
> Is friends django application or your custom application? looks like
> you got the path in the installed_apps wrong can you paste the
> installed apps from the setting file?
>
> --
> regards,
> Prashanth
> twitter: munichlinux
> blog: prashanthblog.appspot.com
> irc: munichlinux, JSLint, munichpython.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django-cms

2009-10-26 Thread David Zhou

On Mon, Oct 26, 2009 at 4:16 AM, aju mathew  wrote
>
> In Django CMS any blog plugin is available.

You should be using the Django-CMS mailing list for this in the future.

That said, use CMS_PLACEHOLDER_CONF to specify which plugins are
available for which placeholders:

http://www.django-cms.org/en/documentation/2.0/configuration/#cms-placeholder-conf


-- dz

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Django-cms

2009-10-26 Thread aju mathew
Hi

In Django CMS any blog plugin is available.



-- 
Thanks & Regards,
Aju P Mathew

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ANN - Satchmo 0.9 Released

2009-10-26 Thread Renato Francisco G. Amaral
Great news! Congrats, Cris.

I intend to use Satchmo in my next project.

Renato Amaral


2009/10/25 Chris Moffitt 

> I am very happy to announce that Satchmo 0.9 is now released.
>
> Satchmo is an ecommerce framework built on the Django framework. It is
> designed to be robust and full featured out of the box but allow developers
> flexibility to modify the store to fit your unique needs.
>
> This release is a major milestone in our path towards 1.0. This release has
> been in active development for over a year and includes many enhancements,
> new features and bug fixes. You can read the full changelog here -
> http://www.satchmoproject.com/docs/svn/release-notes-0-9.html
>
> Some of the highlights:
> - Major reorganization of the Satchmo components to make it more modular
> - New US SST tax module
> - New Canada post shipping module
> - Google checkout v2 integration
> - Migrated to using Sorl Thumbnails
> - Upgraded Authorize.net to ssl v3.0
> - Improved currency display in the admin
> - Many bug fixes and performance improvements
>
> From a project perspective, this is the first release since our migration
> to bitbucket for code hosting and distributed development support. We have
> also made multiple updates and improvements to the documentation system to
> make it more complete and easier to navigate. All of these changes have been
> instrumental in getting Satchmo on a solid foundation for this release.
>
> For more info:
> You can download Satchmo here -
> http://bitbucket.org/chris1610/satchmo/downloads/
> The full documentation is here - http://www.satchmoproject.com/docs/svn/
> Which includes this quickstart tutorial -
> http://www.satchmoproject.com/docs/svn/quickstart.html
>
> Thank you to everyone that has contributed to Satchmo and I look forward to
> finalizing a 1.0 release.
>
> -Chris
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Behaviour of related objects

2009-10-26 Thread Bojan Mihelac



On Oct 26, 5:22 am, Preston Holmes  wrote:
> On Oct 25, 2:55 pm, Bojan Mihelac  wrote:
>
> > Hi all,
>
> > given an many_to_one doctests with Reporter/Article models, the
> > following example would fail with "IntegrityError:
> > many_to_one_article.reporter_id may not be NULL":
>
> > >>> r = Reporter(first_name='John', last_name='Smith', 
> > >>> email='j...@example.com')
> > >>> a = Article(headline="This is a test", pub_date=datetime(2005, 7, 27), 
> > >>> reporter=r)
> > >>> r.save()
> > >>> a.save()
>
> > For me, expected behaviour would be that since article knows it is
> > related to reporter it should check reporter's primary key on save.
>
> > Am I wrong?
>
> But a is being created before r has an id  - just move the r.save()
> line up one.
>
> -Preston
>

Yes it would work but my case is more complicated and include creating
many related objects from session, with saving them optionally in last
step. That's why I tried to present it as simple as I can. I can sure
make workaround in code to reassign related model after it is saved
but I still wandering why is this needed? It's seems like one step
more needed to take care. I would like to know if it was design
decision or if implementation would be too complicated in some cases.

best,
Bojan


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: changing how an admin form field is displayed (float to datetime)

2009-10-26 Thread Paul Smith

Paul Smith  catugmt.com> writes:

> 
> I’ve been trying to a modify an admin form so I have a slightly different
> user interface compared to the database model.
> 
> The main problem is this; in the database model I store a start and end
> time as timestamps (a float holding seconds since 1/1/1970). But when the user
> wants to edit the times I don’t want him to have to deal with big float values
> so I’ve created a new form with DateTimeFields thus;
> 
>   class MyNewForm(forms.ModelForm):
>   start_time = forms.DateTimeField()
>   end_time = forms.DateTimeField()
> 
>   def clean(self):
>   cleaned_data = self.cleaned_data
>   start = cleaned_data.get('start_time')
>   end = cleaned_data.get('end_time')
>   cleaned_data['start_time']=time.mktime(start.timetuple())
> 
>   if end:
>   cleaned_data['end_time']=time.mktime(end.timetuple())
>   return cleaned_data
> 
>   class Meta:
>   model = MyModel
> 
> where MyModel is just;
> 
>   class MyModel(models.Model):
>   start_time = models.FloatField()
>   end_time = models.FloatField(null=True)
> 
> and the admin declaration is;
> 
>   class MyModelAdmin(admin.ModelAdmin):
>   form = MyNewForm
> 
> Now this cleans any new date/time entries and converts them to floats
> before writing to the db just fine, but if the user is editing an existing
> record I can’t get the existing start and end times to display as, for
> example, ‘2009-10-25 12:00’, they always show up as the float
> values. I’ve tried to change this by adding the following __init__ method
> to MyNewForm;
> 
> def __init__(self, *args, **kwargs):
> super(MyNewForm, self).__init__(*args, **kwargs)
> instance=kwargs.get('instance','')
> if instance:
 self.fields['start_time'] = 
forms.DateTimeField(initial=datetime.fromtimestamp(instance.start_time))
 
#
> tried this to set the initial value
> self.fields['start_time'].initial = 
datetime.fromtimestamp(instance.start_time) #
then tried this
> 
> But neither of these seem to override the admin’s rendering of
> the float times and I’m not sure where that gets decided. I haven’t
> seen any examples similar to this but would have thought it was fairly common
> to change the way data is displayed to the user for editing and then convert 
it
> back to another form (via clean) when a change is submitted.
> 
>  
> 
> Paul

Ok, I realised I'd come across this problem elsewhere in my code and forgot
what I did. The __init__ method should look like;

def __init__(self, *args, **kwargs):
super(MyNewForm, self).__init__(*args, **kwargs)
instance=kwargs.get('instance','')
if instance:
self.initial['start_time'] = 
   datetime.fromtimestamp(delay_instance.start_time)
self.initial['end_time'] = 
   datetime.fromtimestamp(delay_instance.end_time)

Then the floats get changed to datetime objects and render properly.



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Open ID & request.user.message_set.create

2009-10-26 Thread cerberos

request.user.message_set.create(message="Your playlist was added
successfully.")

The docs (http://docs.djangoproject.com/en/dev/topics/auth/#messages)
say
"Finally, note that this messages framework only works with users in
the user database. To send messages to anonymous users, use the
session framework."

Can messages be posted for open id users (are they added to the user
database)?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---