Re: int argument required error in HttpResponseRedirect

2010-01-16 Thread Cummins Group
It worked as follows:


return HttpResponseRedirect('/userans/%s/%s/' % (uno,qno))

Thank you for helping..

On Sat, Jan 16, 2010 at 3:36 PM, Daniel Roseman wrote:

> On Jan 16, 8:38 am, grp25  wrote:
> > The code which we have written is
> >   return HttpResponseRedirect ('/userans/%d/%d'  %
> > uno,qno)
> >
> > And the error given is int argument required error..
> >
> > Can anyone tell syntax for this..
>
> Nothing to do with HttpResponseRedirect, it's the string interpolation
> syntax that is giving a problem. Presumably one of uno and qno are not
> integers, and %d only works with ints. Use %s instead.
> --
> DR.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>
-- 

You received this message because you are subscribed to the Google Groups "Django users" group.

To post to this group, send email to django-us...@googlegroups.com.

To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



Re: NoReverseMatch:

2010-01-16 Thread Ian Lewis
Bhaskar,

The error means that there is either no defined URL called
'tellfriend' or it requires some kind of argument, like a user id, to
generate the URL.

Having two separate forms with different actions is no problem. Fixing
the URL reversing should clear up your issue.

Ian



On Sunday, January 17, 2010, Bhaskar Gara  wrote:
> Caught an exception while rendering: Reverse for 'tellfriend' with
> arguments '()' and keyword arguments '{}' not found.
>
> 
>
>
> I have a html template which has two form
>
> My form1  action is empty  and form 2 action is as above. I am
> getting error @ that line.
>
>
> 1)   What is the meaning of the error ?
> 2)   How can I call two different fucntion in views.py  from the same
> HTML form action.
>
>
> Thank you
> Bhaskar
>

-- 
===
株式会社ビープラウド  イアン・ルイス
〒150-0012
東京都渋谷区広尾1-11-2アイオス広尾ビル604
email: ianmle...@beproud.jp
TEL:03-5795-2707
FAX:03-5795-2708
http://www.beproud.jp/
===
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: myModel.Meta.abstract is unexpectedly False

2010-01-16 Thread pkghost
RTFM fail. Two times sorry for the spam.

cb

On Jan 16, 9:03 pm, pkghost  wrote:
> I've defined some abstract classes in my models.py, and yet, iterating
> over them and inspecting the property always reports a False value. I
> must admit to being a little befuddled. Any guidance will be
> appreciated.
>
> Cheers,
>
> cb
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




NoReverseMatch:

2010-01-16 Thread Bhaskar Gara
Caught an exception while rendering: Reverse for 'tellfriend' with
arguments '()' and keyword arguments '{}' not found.




I have a html template which has two form

My form1  action is empty  and form 2 action is as above. I am
getting error @ that line.


1)   What is the meaning of the error ?
2)   How can I call two different fucntion in views.py  from the same
HTML form action.


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




myModel.Meta.abstract is unexpectedly False

2010-01-16 Thread pkghost
I've defined some abstract classes in my models.py, and yet, iterating
over them and inspecting the property always reports a False value. I
must admit to being a little befuddled. Any guidance will be
appreciated.

Cheers,

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




Permission denied

2010-01-16 Thread Bhaskar Gara
Request Method:

POST
Request URL:
Exception Type:IOError
Exception Value:[Errno 13] Permission denied: u'Bhaskar_dsa.xml'
Exception Location:/home/erp/webappserp_dev/erp/apps/erp_site/views.py
in testimonials, line 238
Python Executable:/usr/local/bin/python
Python Version:2.5.4

This is the above error I am getting when I am trying to write an xml
file in
TESTIMONIAL_DIR  /home/erp/webapps/erp_dev/erp/xml/testimonial'

It something related to permission stuff.   I  did  chmod 777 on both
xml and testimonial folder which I created. Still getting the same
issue.  Can you please help me there.

Scenerio is  I need to generate xml file from the form field and put
it in to that TESTIMONIAL folder.

my code in views.py

filename = fname + "_" + lname + ".xml"
filepath = settings.TESTIMONIAL_DIR + "/" + filename;
logging.debug('filepath = %s' % filepath)

FILE = open(filename,"w")-This is the line its giving the
error.
doc.writexml(FILE)
FILE.close()


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




Re: Translation sprint in Montréal

2010-01-16 Thread Yannick Gingras
On January 16, 2010, Alex_Gaynor wrote:
> Could you please make a page for this on the Django wiki, and add it
> to the list here: http://code.djangoproject.com/wiki/Sprints

Done.

-- 
Yannick Gingras
http://ygingras.net
http://confoo.ca -- track coordinator
http://montrealpython.org -- lead organizer


signature.asc
Description: This is a digitally signed message part.


Re: Translation sprint in Montréal

2010-01-16 Thread Alex_Gaynor


On Jan 16, 7:21 pm, Yannick Gingras  wrote:
> Hello guys,
>   this is just a quick note to let you know that we're going to do a
> sprint for French translation of the Django doc here in Montréal next
> Monday:
>
> http://montrealpython.org/2010/01/15/django-translation-sprint-on-201...
>
> If you are in the area, feel free to drop by.
>
> --
> Yannick Gingrashttp://ygingras.nethttp://confoo.ca-- track 
> coordinatorhttp://montrealpython.org-- lead organizer
>
>  signature.asc
> < 1KViewDownload

Could you please make a page for this on the Django wiki, and add it
to the list here: http://code.djangoproject.com/wiki/Sprints

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




Translation sprint in Montréal

2010-01-16 Thread Yannick Gingras

Hello guys, 
  this is just a quick note to let you know that we're going to do a
sprint for French translation of the Django doc here in Montréal next
Monday:

http://montrealpython.org/2010/01/15/django-translation-sprint-on-2010-01-18/

If you are in the area, feel free to drop by.

-- 
Yannick Gingras
http://ygingras.net
http://confoo.ca -- track coordinator
http://montrealpython.org -- lead organizer


signature.asc
Description: This is a digitally signed message part.


Re: form.save() fails with no data, form.is_valid() is True

2010-01-16 Thread Alessandro Pasotti
2010/1/16 tom :
> Hi,
>
> I have a form where I have added on clean method for a field and a
> general clean method for the form. In generall I see a problem, when
> trying to save the form. Here is a very simple test case, where I have
> commented out the "clean" method of the form:


Maybe related with this ticket ?

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


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




Re: Custom filters and partial mark_safe?

2010-01-16 Thread pjrhar...@gmail.com
> Just as I feared. Thanks for the reply.

It's not as bad as you fear! Just escape it, then apply your filter,
then mark it all safe.

You'll find the escape function in django.utils.html

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




MediaCore: An Open Source video and podcast CMS platform built on python & turbogears

2010-01-16 Thread Stuart Bowness
My company (http://simplestation.com) has just finished building our
first big Open Source app, and thought we would share it with the
Django community since we are using Python and the TG2 framework to
power the whole web app, and there may be Django users who might find
the web app useful. We actually did start writing the app in Django,
but then switched to TurboGears as we really fell in love with
SQLAlchemy.

MediaCore (http://getmediacore.org) is a open source video, audio, and
podcast publishing platform. It is built for organizations who wish to
distribute media in a variety of formats on their website while still
maintaining the ability to control the user experience.

The purpose behind MediaCore was to make a central media library that
could pull media from any source, track statistics, enable commenting,
and provide a high degree of control over the presentation and
administration.

You can view a demo here:
http://getmediacore.com/demo

Documentation:
http://getmediacore.com/docs/

Download it:
http://getmediacore.com/download

We are also looking for feedback on both the application and the open
source project.
http://getmediacore.com/community/

If anyone has any comments please feel free to send me a message. You
can find us on twitter as well @simplestation.

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




Re: Load template tags if installed?

2010-01-16 Thread Tomasz Zieliński
On 16 Sty, 20:31, "Aaron C. de Bruyn"  wrote:
> Am I missing an easy way to check if an application is installed
> so I can make decisions in a template?
>
> I have an application that currently requires the comments framework
> and django-attachments.
>
> I would rather make them optional depending on the functionality needed
> by the user/hoster of my app.
>
> I don't see a way in the templates to say something like:
> {% if installed django.contrib.comments %}
>   display the comment form
> {% endif %}
>
> I would rather not have 5 different templates for the same page, each
> one with a different combination of possible installed applications along
> with views to figure out which of the templates to load.
>

AFAIK there is no such feature, but I think you could
write template context processor exposing necessary flags to
templates.

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




form.save() fails with no data, form.is_valid() is True

2010-01-16 Thread tom
Hi,

I have a form where I have added on clean method for a field and a
general clean method for the form. In generall I see a problem, when
trying to save the form. Here is a very simple test case, where I have
commented out the "clean" method of the form:

>>> from scrums.forms import SprintForm
>>> import datetime
>>> form = SprintForm(data = {'name': 'foo','description': 'bar','start_date': 
>>> datetime.date(2108,12,23), 'end_date': datetime.date(2109,01,11)})
>>> print form.is_valid()
True
>>> new_sprint = form.save()
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Python/2.6/site-packages/django/forms/models.py",
line 313, in save
fail_message, commit, construct=False)
  File "/Library/Python/2.6/site-packages/django/forms/models.py",
line 95, in save_instance
instance.save()
  File "/Library/Python/2.6/site-packages/django/db/models/base.py",
line 430, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
  File "/Library/Python/2.6/site-packages/django/db/models/base.py",
line 519, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
  File "/Library/Python/2.6/site-packages/django/db/models/
manager.py", line 197, in _insert
return insert_query(self.model, values, **kwargs)
  File "/Library/Python/2.6/site-packages/django/db/models/query.py",
line 1345, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/
compiler.py", line 730, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/
compiler.py", line 674, in execute_sql
cursor.execute(sql, params)
  File "/Library/Python/2.6/site-packages/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
  File "/Library/Python/2.6/site-packages/django/db/backends/sqlite3/
base.py", line 189, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: scrums_sprint.creator_id may not be NULL
>>> new_sprint = form.save(commit = False)
>>> print new_sprint
foo <## notice this
>>>

When I add back the clean method, I see this:
>>> from scrums.forms import SprintForm
>>> import datetime
>>> form = SprintForm(data = {'name': 'foo','description': 'bar','start_date': 
>>> datetime.date(2108,12,23), 'end_date': datetime.date(2109,01,11)})
>>> print form.is_valid()
True
>>> new_sprint = form.save()
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Python/2.6/site-packages/django/forms/models.py",
line 313, in save
fail_message, commit, construct=False)
  File "/Library/Python/2.6/site-packages/django/forms/models.py",
line 95, in save_instance
instance.save()
  File "/Library/Python/2.6/site-packages/django/db/models/base.py",
line 430, in save
self.save_base(using=using, force_insert=force_insert,
force_update=force_update)
  File "/Library/Python/2.6/site-packages/django/db/models/base.py",
line 519, in save_base
result = manager._insert(values, return_id=update_pk, using=using)
  File "/Library/Python/2.6/site-packages/django/db/models/
manager.py", line 197, in _insert
return insert_query(self.model, values, **kwargs)
  File "/Library/Python/2.6/site-packages/django/db/models/query.py",
line 1345, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/
compiler.py", line 730, in execute_sql
cursor = super(SQLInsertCompiler, self).execute_sql(None)
  File "/Library/Python/2.6/site-packages/django/db/models/sql/
compiler.py", line 674, in execute_sql
cursor.execute(sql, params)
  File "/Library/Python/2.6/site-packages/django/db/backends/util.py",
line 19, in execute
return self.cursor.execute(sql, params)
  File "/Library/Python/2.6/site-packages/django/db/backends/sqlite3/
base.py", line 189, in execute
return Database.Cursor.execute(self, query, params)
IntegrityError: scrums_sprint.start_date may not be NULL
>>> new_sprint = form.save(commit = False)
>>> print new_sprint
<### no name, no dates, nothing
>>>

and this is the clean method:
def clean(self):
cleaned_data = self.cleaned_data
start_date = cleaned_data.get('start_date')
end_date = cleaned_data.get('end_date')
if start_date and end_date:
if start_date > end_date:
raise forms.ValidationError(u'Start date must be
before end date.')
return cleaned_data

There must be an error I have introduced, but I can't see it.

I use this version of django:
Path: .
URL: http://code.djangoproject.com/svn/django/trunk
Repository Root: http://code.djangoproject.com/svn
Repository UUID: bcc190cf-cafb-0310-a4f2-bffc1f526a37
Revision: 12231
Node Kind: directory
Schedule: normal
Last Changed Author: lukeplant
Last 

Re: Filter on forms.ModelChoiceField(queryset=Image.objects.filter())

2010-01-16 Thread GoSantoni

Hi

I'd like to use it in a forms.py to retrieve users own photos to
attach to a blogpost. So actually this would do the job

def __init__(self, *args, **kwargs):
self.user = kwargs.pop('user')
super(forms.Form, self).__init__(*args, **kwargs)
self.fields['url'].queryset = Image.objects.filter(member=self.user)

But I run into a a keyerror because of the pop() function 
http://dpaste.com/146191/
Where can i find more information about the pop() function because
it's not really clear to me. Found so far 
http://docs.python.org/tutorial/datastructures.html
but it still remains unclear to me.

This is the queryset which works in the view Image.objects.filter
(member=request.user)

Thanks guys

On Jan 14, 8:38 pm, Tom Evans  wrote:
> On Thu, Jan 14, 2010 at 6:39 PM, GoSantoni  wrote:
> > Hi
>
> > Is it possible to use extra filter on a ModelChoiceField?
>
> > Tried several strategies:
>
> > if photo.member == user:
> >    url = forms.ModelChoiceField(queryset=Image.objects.filter())
>
> > or
> >    url = forms.ModelChoiceField(queryset=Image.objects.filter
> > (member__id=1))
>
> > or
>
> > if Image.objects.filter(member__id=1):
> >     url = forms.ModelChoiceField(queryset=Image.objects.filter
> > (member__id=1))
>
> > All fail to filter on the member / user
>
> > Thanks
>
> The technique I use to do forms like this is to add the queryset in
> the constructor, passing in whatever I need to filter it.
>
> Eg:
>
> class AttachmentForm(forms.Form):
>   name = forms.CharField(max_length=32)
>   url = forms.ModelChoiceField(queryset=Image.objects.none())
>   def __init__(self, *args, **kwargs):
>     self.user = kwargs.pop('user')
>     super(forms.Form, self).__init__(*args, **kwargs)
>     self.fields['url'].queryset = Image.objects.filter(user=self.user)
>
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Custom filters and partial mark_safe?

2010-01-16 Thread Andrew Turner
On 15 Jan, 12:57, Tomasz Zieliński 
wrote:
> I'm not 100% sure, but after doing quick review of django/utils/
> safestring.py,
> I would say that string is either safe or unsafe, it cannot be only
> half-safe.

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




Enter a valid value while saving fullname during registration

2010-01-16 Thread Praveen
   urls.py

   url(r'^accounts/register/$',register,
{'form_class':RegForm},name='registration_register'),

  form.py
  ---
  from registration.forms import *
  class RegForm(RegistrationForm):
  """
  """
  fullname = forms.RegexField(regex=r'^\w+$',
  max_length=30,
  widget=forms.TextInput
(attrs=attrs_dict),
  label=_(u'fullname'))
  def clean_fullname(self):
  "This function is required to overwrite an inherited
username clean"
  return self.cleaned_data['fullname']'''

 def clean(self):
if not self.errors:
  self.cleaned_data['first_name'] = '%s%s' %
(self.cleaned_data['fullname'].split(' ',1)[0])
  self.cleaned_data['last_name'] = '%s%s' %
(self.cleaned_data['fullname'].split(' ',1)[1])
  super(RegForm, self).clean()
  return self.cleaned_data'''
  views.py
  
  def register(request, success_url=None,
   form_class=RegForm, profile_callback=None,
   template_name='registration/
registration_form.html',
   extra_context=None):
  #pform_class = utils.get_profile_form()
  if request.method == 'POST':
  #profileform = pform_class(data=request.POST,
files=request.FILES)
  form = form_class(data=request.POST,
files=request.FILES)
  if form.is_valid():
  new_user = form.save
(profile_callback=profile_callback)
  #profile_obj = profileform.save(commit=False)
  #profile_obj.user = new_user
  #profile_obj.save()
  return HttpResponseRedirect(success_url or reverse
('registration_complete'))
  else:
  form = form_class()
  #profileform = pform_class()
  if extra_context is None:
  extra_context = {}
  context = RequestContext(request)
  for key, value in extra_context.items():
  context[key] = callable(value) and value() or value
  return render_to_response(template_name,
{ 'form': form},
context_instance=context)

  registration_form.html
  --
  
  Full Name
  
  
  
  {{ form.fullname }}
  {% for error in form.fullname.errors
%}
  {{ error }}
  {% endfor %}
  
  User Name
  
  
  
  {{ form.username }}
  {% for error in form.username.errors
%}
  {{ error }}
  {% endfor %}
  
 Email Address
 
  
  
  {{ form.email }}
  {% for error in form.email.errors %}
  {{ error }}
  {% endfor %}

 Password
  
  
  
  {{ form.password1 }}
  {% for error in
form.password1.errors %}
  {{ error }}
  {% endfor %}

 Confirm Password
 
  
  
  {{ form.password2 }}
  {% for error in
form.password2.errors %}
  {{ error }}
  {% endfor %}
   
  While saving

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




Convert Joomla Template to Django Template

2010-01-16 Thread matt6486
Hi,

I don't know anything about Django and honestly would rather stick
with my current CMS, Joomla, as my current site design works fine with
the Joomla template I have now.  However, the journalism department
will probably end up moving to a CMS based on Django called OchsCMS
from their current CMS Joomla against my wishes.

Since there is not much I can do about them changing the CMS, I really
want to convert my Joomla template to an exact copy template, but just
in Django form that will wor with OchsCMS.  Again, I am neither
familiar with Django at all nor do I know how to code well.  So I ask
you more professional-minded people out there:  Is there an easy way
(or at least a not-so-difficult way) to convert my Joomla files I have
now in a .zip folder to a Django template?

Any help would be greatly be appreciated.  And a short step-by-step
explanation would be amazing!
Thank you,

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




My Own Auth Backend

2010-01-16 Thread Détour Olivier
Hi,
I would create my own auth backend. I tried to understand and trace
source code.
I want to create an internal DB with SHA1 and username.
But I cannot login, Django says me I do not set DB ENGINE. I would not
use something like MySQL or any DB Engine.

Here is my source code:
mybackend.py:


from django.contrib.auth.models import User
from django.contrib.auth.backendsimport RemoteUserBackend


class MyUser (User):
  def save (self):
"""saving to DB disabled"""
pass

  objects = None # we cannot really use this w/o local DB
  username = ""  # and all the other properties likewise.
 # They're defined as model.CharField or similar,
 # and we can't allow that

  def get_group_permissions (self):
"""If you don't make your own permissions module,
   the default also will use the DB. Throw it away"""
return [] # likewise with the other permission defs

  def get_and_delete_messages (self):
"""Messages are stored in the DB. Darn!"""
return []

class WWWBackend (RemoteUserBackend):
  # Create a User object if not already in the database?
  create_unknown_user = False

  def get_user (self, user_id):
user = somehow_create_an_instance_of(MyUser, user_id)
return user

  def authenticate (self, username=None, password=None):
if username == "lol" and password == "lol":
  user = MyUser(username=username, password=password)
  return user
return None

my view.py:

from django import forms
from django.core.context_processors import csrf
from django.template import RequestContext, loader
from django.http import HttpResponse, HttpResponseRedirect
from django.contrib.auth import authenticate, login

#! Form Upload Object
class LoginForm (forms.Form):
  user = forms.CharField(widget = forms.TextInput)
  password = forms.CharField(widget = forms.PasswordInput)

def index(request):
  if request.method == 'POST':
form = LoginForm(request.POST)
if form.is_valid():
  # FIXME: Check if file is good.
  #handle_uploaded_torrent(request.FILES['file'])
  username = request.POST['user']
  password = request.POST['password']
  user = authenticate(username=username, password=password)
  if user is not None:
login(request, user)

  return HttpResponseRedirect('/')
  else:
form = LoginForm()

  t = loader.get_template('template/index.html')
  c = RequestContext(request, {
  'login_form': form,
  })
  return HttpResponse(t.render(c))


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




Load template tags if installed?

2010-01-16 Thread Aaron C. de Bruyn
Am I missing an easy way to check if an application is installed
so I can make decisions in a template?

I have an application that currently requires the comments framework
and django-attachments.

I would rather make them optional depending on the functionality needed
by the user/hoster of my app.

I don't see a way in the templates to say something like:
{% if installed django.contrib.comments %}
  display the comment form
{% endif %}

I would rather not have 5 different templates for the same page, each
one with a different combination of possible installed applications along
with views to figure out which of the templates to load.

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




Re: Save, Signals and Models

2010-01-16 Thread Eric Chamberlain

On Jan 15, 2010, at 4:22 PM, Victor Loureiro Lima wrote:

> Here is the deal:
> 
> class MyModel ( models.Model ):
>   title = models.CharField( max_length = 100 )
>   only_me = models.BooleanField( default = False )
> 
>  Question: Whats the proper way to guarantee that no matter how many 
> MyModel's are available in the database, only one of them
> will have the only_me set as True? To further clarify things: In the admin, 
> whenever I check the only_me checkbox, and save my model, all other models of 
> this class will have to have its own only_me field set to false.
> 
>  As far as I know, there is no other way of doing this unless I iterate over 
> all MyModel' s objects and uncheck them if they are checked, save them, then 
> afterwards check the model that I am actually saving setting the only_me 
> field to True.
> 
>  I tried doing this on the actual save() of the model, no success. Everytime 
> I called save on iterated objects, I, of course, got the maximum recursive 
> depth error thrown at me. 
>  Fair enough, I quickly thought about signals, hooking my function to 
> post_save(), however I inevitabilly stumbled upon the same
> problem: When I called save() on the iterated objects the post_save signal 
> got sent, I would step again in the same function, thus
> no cookie for me.
>  I jumped over to overriding AdminForm' s save() method, so that I would 
> iterate there on the models unchecking them if necessary, and them returning 
> the proper object, but I stopped that and I said to myself that I must be 
> doing something really stupid, so Im coming to you guys: What would the 
> propper way of doing this?
> 

def save(self, force_insert=False, force_update=False):
if self.only_me is True:
# if this is the new default, set others to False
MyModel.objects.exclude(pk=self.pk).update(only_me=False)

super(MyModel, self).save(force_insert, force_update) # Call the "real" 
save() method.


--
Eric Chamberlain, Founder
RF.com - http://RF.com/







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




Re: Only Email + Password ( without username )

2010-01-16 Thread Eric Chamberlain


On Jan 14, 2010, at 2:44 AM, nameless wrote:

> I want to use "id" as identifier for each user. So every user will
> have an url like this:
> 
> http://www.example.com/827362
> 
> I don't want username for my project.
> So, if I can't delete it, I think to insert email in username field
> and I don't want another identifier in username field as random
> strings :P
> In this case I don't have to create a custom backend.
> Is a good idea in your opinion ?
> 

It's not a good idea, unless you want to do a lot of customization.

Username is unique, 30 characters, and only allows A-Za-z0-9_, no @ or -.

You are better off generating a random unique value for username and 
authenticating on email address.-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: Error message has the wrong file path

2010-01-16 Thread Andrew Bialecki
Cool thanks, that was it.

On Sat, Jan 16, 2010 at 11:55 AM, Karen Tracey  wrote:

> On Sat, Jan 16, 2010 at 11:49 AM, Andrew Bialecki <
> andrew.biale...@gmail.com> wrote:
>
>> I'm in debug mode and the error message I'm getting sounds right but
>> the file paths are wrong.  For instance, I know the module that's
>> failing is in /foo/bar/module.py, but it says the error occurred in
>> the module /baz/module.py which definitely no longer exists.  The
>> module used to located in the directory /baz/, but isn't any more.
>> Any idea what's going on?  This is on Snow Leopard if that makes any
>> difference.  Trying to debug things is difficult when the paths don't
>> make sense.
>>
>>
> Sounds like you have stray .pyc files left over.  Try deleting all .pyc
> files and run again.
>
> 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-us...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
-- 

You received this message because you are subscribed to the Google Groups "Django users" group.

To post to this group, send email to django-us...@googlegroups.com.

To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



Re: Error message has the wrong file path

2010-01-16 Thread Karen Tracey
On Sat, Jan 16, 2010 at 11:49 AM, Andrew Bialecki  wrote:

> I'm in debug mode and the error message I'm getting sounds right but
> the file paths are wrong.  For instance, I know the module that's
> failing is in /foo/bar/module.py, but it says the error occurred in
> the module /baz/module.py which definitely no longer exists.  The
> module used to located in the directory /baz/, but isn't any more.
> Any idea what's going on?  This is on Snow Leopard if that makes any
> difference.  Trying to debug things is difficult when the paths don't
> make sense.
>
>
Sounds like you have stray .pyc files left over.  Try deleting all .pyc
files and run again.

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-us...@googlegroups.com.

To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/django-users?hl=en.



Django site behind an Apache reverse proxy

2010-01-16 Thread AlK
Hi !

I developed a small Website querying some other sites in background
like a "cron". The queries are handled in a separate thread that I can
start and stop when I want from a simple web-interface. It works great
on my development environment, when I launch the website using the
"python manage.py runserver" command.

But when I put the site on a production environment, using mod_wsgi
(or mod_python) following the steps described on Django's website, it
appears that the website is launched each time a user is querying it,
so the thread does not persist between them.

So I managed to run the site with a reverse proxy handled by Apache
with mod_proxy ( here is my config file if you are interested
http://dpaste.com/hold/146080/ ). I simply run the django's integrated
server on the port 8000 and it works as expected.

I need your point of view of that approach of the problem : is it good
enough for a production website ? (fast, stable etc...) My website is
not intended to a large public, but I am curious about that, and - if
this is a viable solution -, why not document it as an alternative of
the other deployment solutions ?

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




Error message has the wrong file path

2010-01-16 Thread Andrew Bialecki
I'm in debug mode and the error message I'm getting sounds right but
the file paths are wrong.  For instance, I know the module that's
failing is in /foo/bar/module.py, but it says the error occurred in
the module /baz/module.py which definitely no longer exists.  The
module used to located in the directory /baz/, but isn't any more.
Any idea what's going on?  This is on Snow Leopard if that makes any
difference.  Trying to debug things is difficult when the paths don't
make sense.
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Serving static files from subdomain.

2010-01-16 Thread nameless
I have a site developed with django at www.example.com

I want that django insert/serve static files ( images, css, js, ect )
in/from media.example.com.

I have edited settings.py:

MEDIA_ROOT = 'http://media.miosito.it'

MEDIA_URL =  'http://media.miosito.it'

ADMIN_MEDIA_PREFIX =  'http://media.miosito.it'


And now ? What do I do ?
.

I am using Apache but I could switch to lightpd or ngix ( if there is
a valid reason ).


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




Re: #django :You need to be identified to join that channel

2010-01-16 Thread nek4life
You probably have to register your Nickname with nickserv.

http://oreillynet.com/pub/h/1940

On Jan 16, 7:59 am, NMarcu  wrote:
> Hello,
>
>     Somebody know why i get this message when I try to join django
> channel from freenode irc:
> #django :You need to be identified to join that channel
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: django production server upgrade now not serving images, scripts or css...

2010-01-16 Thread Daniel Roseman
On Jan 16, 9:32 am, Sam Walters  wrote:
> Hi,
> The production server running centos was just upgraded and in apache
> 1.3 the old httpd.conf file was moved to httpd.conf.bak.
> I had to move my mod_wsgi + virtualhost entry over to the new
> httpd.conf and recompiled mod_wsgi.
>
> Everything works except that when i load my pages none of the .css .js
> .png .gif etc files are being loaded.
>
> when presented with this problem I initially recompiled+installed
> mod_wsgi, then installed python 2.5.4 in /opt/ and looked at paths:
>
> *The project files are in exactly the same place.
> *The virtualhosts entry points to the same locations for these files
> *The settings.py file points to the same template dirs
> *Of course the urls file still points to the same static resources and
> the templates html files still refer to the files form the same
> relative url.
>
> in settings.py:
>
> TEMPLATE_DIRS = ("/home/aero00/aeroclub-beta/Aeroclub/templates",
>                  "/home/aero00/aeroclub-beta/Aeroclub/templates/css",
>                  "/home/aero00/aeroclub-beta/Aeroclub/templates/css/admincss",
>     # Put strings here, like "/home/html/django_templates" or
> "C:/www/django/templates".
>     # Always use forward slashes, even on Windows.
>     # Don't forget to use absolute paths, not relative paths.
> )

Why are the CSS paths in TEMPLATE_DIRS? And what are the values of the
actual MEDIA_URL, MEDIA_ROOT and ADMIN_MEDIA settings?
--
DR.
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Re: django production server upgrade now not serving images, scripts or css...

2010-01-16 Thread Mike Ramirez
On Saturday 16 January 2010 01:32:21 Sam Walters wrote:
> Hi,
> The production server running centos was just upgraded and in apache
> 1.3 the old httpd.conf file was moved to httpd.conf.bak.
> I had to move my mod_wsgi + virtualhost entry over to the new
> httpd.conf and recompiled mod_wsgi.
> 
> 
> Everything works except that when i load my pages none of the .css .js
> .png .gif etc files are being loaded.
> 
> when presented with this problem I initially recompiled+installed
> mod_wsgi, then installed python 2.5.4 in /opt/ and looked at paths:
> 
> *The project files are in exactly the same place.
> *The virtualhosts entry points to the same locations for these files
> *The settings.py file points to the same template dirs
> *Of course the urls file still points to the same static resources and
> the templates html files still refer to the files form the same
> relative url.
> 
> in settings.py:
> 
> TEMPLATE_DIRS = ("/home/aero00/aeroclub-beta/Aeroclub/templates",
>  "/home/aero00/aeroclub-beta/Aeroclub/templates/css",
> 
>  "/home/aero00/aeroclub-beta/Aeroclub/templates/css/admincss", # Put
>  strings here, like "/home/html/django_templates" or
> "C:/www/django/templates".
> # Always use forward slashes, even on Windows.
> # Don't forget to use absolute paths, not relative paths.
> )
> 
> in httpd.conf:
> 
> AliasMatch /([^/]*\.css)
>  /home/aero00/aeroclub-beta/Aeroclub/templates/css/$1 AliasMatch
>  /([^/]*\.html) /home/aero00/aeroclub-beta/Aeroclub/templates/$1 AliasMatch
>  /([^/]*\.js) /home/aero00/aeroclub-beta/Aeroclub/scripts/$1 AliasMatch
>  /([^/]*\.gif)
> /home/aero00/aeroclub-beta/Aeroclub/templates/images/$1
> AliasMatch /([^/]*\.png)
> /home/aero00/aeroclub-beta/Aeroclub/templates/images/$1
> 
> DocumentRoot /home/aero00/aeroclub-beta
> 
> 
> Order deny,allow
> Allow from all
> 
> 
> Im not sure where this problem is, any pointers on where to look would
> be greatly appreciated.
> 
> Cheers
> 
> Sam_w
> 

Apache error logs?
-- 
Heaven, n.:
A place where the wicked cease from troubling you with talk of
their personal affairs, and the good listen with attention while you
expound your own.
-- Ambrose Bierce, "The Devil's Dictionary"


signature.asc
Description: This is a digitally signed message part.


Re: OS X 10.6 Snow Leopard Setup Tutorial

2010-01-16 Thread dk
Thanks for posting this.  You are right -- OSX is not an easy platform
for development, because apple has nothing akin to apt-get.  (Why they
have not done this, I cannot guess.  Surely it cannot be because
people find macports and fink to be reliable and useful.)

A couple of points:

1. I found that:

sudo easy_install mysql-python

worked well, which saves a bit of editing and compiling.

2. Using this (at least with fastcgi) is problematic, because the
webserver user ("_www" on OSX) tries to write eggs to locations in
which it lacks permissions.  I guess the solution is to add the
following:

os.environ['PYTHON_EGG_CACHE'] = "..."

to the fastcgi script, in which the ... is replaced with something
that is sensible and safe.  But I'm not too sure what is sensible
(e.g. things in /tmp get erased by cron jobs) and I certainly have no
idea what is safe, so I punted and switched to sqlite3, which seems to
work well.

3. A DMG would be terrific.

Thanks much for posting this.

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




#django :You need to be identified to join that channel

2010-01-16 Thread NMarcu
Hello,

Somebody know why i get this message when I try to join django
channel from freenode irc:
#django :You need to be identified to join that channel
-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.




Sorting multi-level categories

2010-01-16 Thread Nianbig
Hi,

I´m using this code todo a multi-level category Django-app:
http://code.djangoproject.com/wiki/CookBookCategoryDataModelPostMagic

However, I would like to sort these in alphabetical order on the
parents first and then the childs... how can I do this?
I have tried various settings for 'ordering' variable in admin.py but
I can´t figure this one out... can I do some help method in the model?

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