Django 1.1 returns 500 instead of 404 in non-debug mode

2009-07-30 Thread prabhu S

Hi All,

I am not noticing a weird issue in django 1.1. When DEBUG is true in
settings and if I try a non-existent url, django shows me a friendly
404 page. Now I create 404.html and 500.html and place this in
templates directory. Then If I turn off debug and try a non-existent
url, I expect to see my 404 html. Instead django shows me 500.html.

Infact, even in development I see 500 error codes for missing css,
images and js.

Is anyone else noticing the same issue? Am I missing something?

Regards,
Prabhu

--~--~-~--~~~---~--~~
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: Long Poll in Django

2009-07-30 Thread prabhu S

long poll, push ajax, comet wow too many names for this!!! It will be
interesting to study http://code.google.com/p/pygowave-server/ and
find out how they implement this.

Regards,
Prabhu

On Jul 30, 10:52 am, aleph  wrote:
> Hi!
>
> Is it possible to use Django with longpoll technique? What I mean is a
> client (probably Flex client) which sends a request to server and
> start recieving data 'forever' - until timeout or something. The
> django application on server has polling loop or some producer/
> customer threads inside -  it is receiving data from some side source
> and transmits it to client over HTTP.
>
> Is it possible are there any guidelines about it?
>
> Thank you very much,
> Ilya
--~--~-~--~~~---~--~~
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 1.1 returns 500 instead of 404 in non-debug mode

2009-07-30 Thread prabhu S

Hi Karen,

Thanks for replying. I have put my 404.html in the same place as that
of 500.html. To make sure, I even copy pasted 500.html and changed the
error message text alone.

Here is an output from the django development server, when I tried to
access "sdfsa" (Invalid url)

[30/Jul/2009 18:25:45] "GET /admin/clienty/sdfsa HTTP/1.1" 500 1387
[30/Jul/2009 18:25:45] "GET /scripts/jquery-1.3.2.min.js HTTP/1.1" 500
1387
[30/Jul/2009 18:25:46] "GET /css/style.css HTTP/1.1" 500 1387

I have the sources online at http://github.com/prabhu/invoicy. I would
appreciate if you can take a look at settings.py and let me know if
something is obvious.

Thanks & Regards,
Prabhu

On Jul 30, 2:25 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Jul 30, 2009 at 8:40 AM, prabhu S <prabhu...@gmail.com> wrote:
>
> > Hi All,
>
> > I am not noticing a weird issue in django 1.1. When DEBUG is true in
> > settings and if I try a non-existent url, django shows me a friendly
> > 404 page. Now I create 404.html and 500.html and place this in
> > templates directory. Then If I turn off debug and try a non-existent
> > url, I expect to see my 404 html. Instead django shows me 500.html.
>
> > Infact, even in development I see 500 error codes for missing css,
> > images and js.
>
> > Is anyone else noticing the same issue? Am I missing something?
>
> I cannot recreate this.  Are you absolutely sure everything is set so that
> your 404.html is being found by the server?
>
> 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
-~--~~~~--~~--~--~---



Re: Django 1.1 returns 500 instead of 404 in non-debug mode

2009-07-30 Thread prabhu S

Hi Luke,

Thanks for your email. The particular source is already fine with
no /. I also tried adding slash assuming you swapped the particular
line in your email.

Can you give another shot and let me know if you can spot something?

Regards,
Prabhu

On Jul 30, 6:46 pm, Luke Seelenbinder <luke.seelenbin...@gmail.com>
wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> Hey, I think I located your problem.
>
> In file invoicy / guidy / urls.py
>
> You should change the first url pattern to read:
> url(r'^/$', 'guidy_default', name='guidy-default'),
> instead of:
> url(r'^$', 'guidy_default', name='guidy-default'),
>
> That should fix your problem. What is actually happening is you are
> raising 500s on 404s. That's why the 404 error page is not showing.
>
> Luke
> luke.seelenbin...@gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
>
>
>
> prabhu S wrote:
> > Hi Karen,
>
> > Thanks for replying. I have put my 404.html in the same place as that
> > of500.html. To make sure, I even copy pasted500.html and changed the
> > error message text alone.
>
> > Here is an output from the django development server, when I tried to
> > access "sdfsa" (Invalid url)
>
> > [30/Jul/2009 18:25:45] "GET /admin/clienty/sdfsa HTTP/1.1"5001387
> > [30/Jul/2009 18:25:45] "GET /scripts/jquery-1.3.2.min.js HTTP/1.1"500
> > 1387
> > [30/Jul/2009 18:25:46] "GET /css/style.css HTTP/1.1"5001387
>
> > I have the sources online athttp://github.com/prabhu/invoicy. I would
> > appreciate if you can take a look at settings.py and let me know if
> > something is obvious.
>
> > Thanks & Regards,
> > Prabhu
>
> > On Jul 30, 2:25 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> >> On Thu, Jul 30, 2009 at 8:40 AM, prabhu S <prabhu...@gmail.com> wrote:
>
> >>> Hi All,
> >>> I am not noticing a weird issue in django 1.1. When DEBUG is true in
> >>> settings and if I try a non-existent url, django shows me a friendly
> >>> 404 page. Now I create 404.html and500.html and place this in
> >>> templates directory. Then If I turn off debug and try a non-existent
> >>> url, I expect to see my 404 html. Instead django shows me500.html.
> >>> Infact, even in development I see500error codes for missing css,
> >>> images and js.
> >>> Is anyone else noticing the same issue? Am I missing something?
> >> I cannot recreate this.  Are you absolutely sure everything is set so that
> >> your 404.html is being found by the server?
>
> >> Karen
>
> -BEGIN PGP SIGNATURE-
> Version: GnuPG v1.4.9 (GNU/Linux)
>
> iEYEARECAAYFAkpx3HAACgkQXQrGVCncjPyTCACfR6jyWAfXScSgM9STXKN5nksa
> zRYAoJv2zvJnLpI47kuuArFS+tO5X6MW
> =7wa6
> -END PGP SIGNATURE-
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Thoughts on many-to-many relationship

2009-07-31 Thread prabhu S

Hi All,

When I try to create a Group (django.contrib.auth.models.Group)
dynamically, I get the below error.

'Group' instance needs to have a primary key value before a many-to-
many relationship can be used.

This is because I am trying to add permissions to the group object and
trying to save every thing in one shot. As a work around to this
problem, I am doing an intermediate save and reload of Group object,
which seems to work fine.

Is there a logical reason behind this error? Is this something
fixable?

Regards,
Prabhu
P.S: Exact source code here -
http://github.com/prabhu/invoicy/blob/3f32fff86b806bc0b769de6de7dbe049788f0b24/invoicy/common/utils/decorators.py

--~--~-~--~~~---~--~~
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 newbie deployment question

2009-08-01 Thread prabhu S

Your apache server would run as www user. Where as you have saved your
project in /root with root as the owner. To do this properly, do not
save your django project in /root. Have it somewhere like /var/www and
make "www" as the owner. Also fix execute permissions.

chmod -R 700  should do. Or try 744

On Aug 1, 11:36 am, Ankur Gupta  wrote:
> Hello folks,
>
> I have facing the same problem mentioned in the stackoverflow question
> here (http://stackoverflow.com/questions/962533/django-modpython-error-impo...
> ). The solution doesn't seem to work
>
> Problem description The app runs fine using django internal server
> however when I use apache + mod_python I get the below error
>
> File "/usr/local/lib/python2.6/dist-packages/django/conf/init.py",
> line 75, in init raise ImportError, "Could not import settings
> '%s' (Is it on sys.path? Does it have syntax errors?): %s" %
> (self.SETTINGS_MODULE, e)
>
> ImportError: Could not import settings 'settings' (Is it on sys.path?
> Does it have syntax errors?): No module named settings
>
> Here is the needed information
>
> 1) Project directory: /root/djangoprojects/mysite
>
> 2) directory listing of /root/djangoprojects/mysite ls -ltr total 28 -
> rw-r--r-- 1 root root 546 Aug 1 08:34 manage.py -rw-r--r-- 1 root root
> 0 Aug 1 08:34 init.py -rw-r--r-- 1 root root 136 Aug 1 08:35 init.pyc -
> rw-r--r-- 1 root root 2773 Aug 1 08:39 settings.py -rw-r--r-- 1 root
> root 1660 Aug 1 08:53 settings.pyc drwxr-xr-x 2 root root 4096 Aug 1
> 09:04 polls -rw-r--r-- 1 root root 581 Aug 1 10:06 urls.py -rw-r--r--
> 1 root root 314 Aug 1 10:07 urls.pyc
>
> 3) App directory : /root/djangoprojects/mysite/polls
>
> 4) directory listing of /root/djangoprojects/mysite/polls ls -ltr
> total 20 -rw-r--r-- 1 root root 514 Aug 1 08:53 tests.py -rw-r--r-- 1
> root root 57 Aug 1 08:53 models.py -rw-r--r-- 1 root root 0 Aug 1
> 08:53 init.py -rw-r--r-- 1 root root 128 Aug 1 09:02 views.py -rw-r--
> r-- 1 root root 375 Aug 1 09:04 views.pyc -rw-r--r-- 1 root root 132
> Aug 1 09:04 init.pyc
>
> 5) Anywhere in the filesystem running import django in python
> interpreter works fine
>
> 6) content of httpd.conf
>
> SetHandler python-program PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE settings PythonOption django.root /
> mysite PythonPath "['/root/djangoprojects/', '/root/djangoprojects/
> mysite','/root/djangoprojects/mysite/polls', '/var/www'] + sys.path"
> PythonDebug On
>
> 7) PYTHONPATH variable is set to
>
> echo $PYTHONPATH /root/djangoprojects/mysite
>
> 8) DJANGO_SETTINGS_MODULE is set to echo $DJANGO_SETTINGS_MODULE
> mysite.settings
>
> 9) content of sys.path is
>
> import sys
>
>             sys.path ['', '/root/djangoprojects/mysite', '/usr/lib/
> python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-
> tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/
> usr/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-
> packages']
>
> How do I add settings location to sys.path such that it persistent
> across sessions ?
>
> I have read umpteen no of post with people having the same issue it
> and I have tried a lot completely beats me as to what I need to do.
>
> Looking for some help.
>
> Thanks in advance Ankur Gupta
--~--~-~--~~~---~--~~
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 validation errors

2009-08-01 Thread prabhu S

The method create_profile returns profile after saving. But this
object will not contain primary keys etc generated in the db. To work
around this common issue with django

profile.save()
# Get the data again from db.
profile = Profile.objects.get(user=username)
return profile

Let me know if this helps.

On Aug 1, 8:59 pm, zayatzz  wrote:
> I figured ill add the code i have so far:
>
> The models:
> class ProfileManager(models.Manager):
>         def create_profile(self, username):
>                 "Creates and saves a User with the given username, e-mail and
> password."
>                 now = datetime.datetime.now()
>                 profile = self.model(user=username)
>                 profile.save()
>                 return profile
>
> class Profile(models.Model):
>         """ Profile model """
>         user = models.ForeignKey(User, unique=True)
>         birth_date = models.DateField(help_text="birth date",
> verbose_name="Birth date", blank=True, null=True, )
>         gender = models.PositiveSmallIntegerField(help_text="gender",
> choices=GENDER_CHOICES, blank=True, null=True)
>         about = tinymce_models.HTMLField(blank=True, null=True,
> help_text="Write something about yourself here",
> verbose_name="Something about yourself")
>         # contacts - email, phone nr, website, image
>         img = models.ImageField(upload_to=upload_location, blank=True,
> null=True, verbose_name="Your mugshot")
>         website = models.CharField(max_length=200, blank=True, null=True,
> help_text="Do you have personal website or blog? Promote it by
> entering it here", verbose_name="Your Website address")
>         phonenr = models.CharField(max_length=30, blank=True, null=True,
> help_text="Your office or home phone number", verbose_name="Your home
> or office number")
>         mobilenr = models.CharField(max_length=30, blank=True, null=True,
> help_text="Your mobile phone number", verbose_name="Your mobile phone
> nr")
>         #Full profile - adress will be visible too
>         country = models.PositiveIntegerField(choices=COUNTRY_CHOICES,
> blank=True, null=True)
>         address1 = models.CharField(max_length=200, blank=True, null=True,
> help_text="Address info - street and house/apartment number")
>         address2 = models.CharField(max_length=200, blank=True, null=True,
> help_text="Address info - town and areacode")
>         address3 = models.CharField(max_length=200, blank=True, null=True,
> help_text="Address info - county")
>         publicprofile = models.PositiveSmallIntegerField(help_text="Profile
> type", choices=PROFILE_CHOICES, blank=True, null=True)
>         newsletter = models.BooleanField(help_text="Do you want to recieve
> our newsletter?", verbose_name="Do you want our newsletter",
> blank=True, null=True)
>         objects = ProfileManager()
>
> The Form:
> class ProfileForm(ModelForm):
>         about = forms.CharField(widget=TinyMCE(attrs={'cols': 40, 'rows': 15,
> 'theme':"simple"}), label = "Something about yourself")
>         class Meta:
>                 model = Profile
>                 fields = ('gender', 'birth_date', 'about', 'img', 'website',
> 'phonenr', 'mobilenr', 'country', 'address1', 'address2', 'address3',
> 'publicprofile', 'newsletter', )
>
> The view:
> def profile_edit(request):
>         if request.user.is_authenticated():
>                 message = "default"
>                 try:
>                         profile = Profile.objects.get(user=request.user)
>                 except:
>                         profile = Profile.objects.create_profile(request.user)
>                 if request.method == 'POST':
>                         pform = ProfileForm(request.POST, instance=profile)
>                         if pform.is_valid():
>                                 pform.save()
>                                 message = "form vas saved"
>                         else:
>                                 message = "form not valid"
>                 else:
>                         #dict vaja saata uue formiga
>                         message = "new form"
>                         pform = ProfileForm(instance=profile)
>                 context = { 'message':message, 'pform':pform, }
>                 return render_to_response('profile/profile_detail.html', 
> context,
> context_instance=RequestContext(request))
>         else:
>                 return HttpResponseRedirect("/accounts/login/")
>
> What i see in view after posting is - form not valid
>
> I really could use help figuring out, why it is not valid.
>
> Alan
--~--~-~--~~~---~--~~
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: Log in problem

2009-08-01 Thread prabhu S

I think this should fix. Additionally if you are using
render_to_response for some reason, it passes Context instead of
RequestContext.

To solve this do render_to_response('view', {},
context_instance=RequestContext(request))

On Aug 1, 9:10 pm, OIM  wrote:
> You should use:
>
> {% block user_info %}
>         
>                 {% if user.is_authenticated %}
>                         User {{ user.username }} ( href="/accounts/logout">logout |
> profile)
>                 {% endif %}
>         
> {% endblock %}
>
> It works.
--~--~-~--~~~---~--~~
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: Python Conditional help

2009-08-01 Thread prabhu S

change student_id_validate to student_id_check

Invalid variable dude.

On Aug 2, 12:46 am, cprsystems  wrote:
> I'm trying to redirect users of an html page to another page depending
> on the user id entered. I'm using if else statements and declaring ids
> within views.py named htmlp2. I keep getting syntax errors, any
> insight as to why would be much appreciated. My code is below
>
> Thank you
>
> from django.shortcuts import render_to_response
> import datetime
>
> def htmlp1(request):
>     now = datetime.datetime.now()
>     return render_to_response('page-one.html', locals())
>
> def htmlp2(request):
>     dan_id = 1234567
>     stu_id = 7654321
>     student_id_check = request.GET['student_id']
>     if student_id_validate == dan_id:
>         return render_to_response('page-two', locals())
>     elif: student_id_validate == stu_id:
>         return render_to_response('page-three', locals())
>     else:
>         return render_to_response('page-one', locals())
>
> ERROR INFO
>
> SyntaxError at /htmlp1/
>
> ('invalid syntax', ('C:\\dantest\\..\\dantest\\views.py', 14, 9, '
> elif: student_id_validate == stu_id:\n'))
>
> Request Method:         GET
> Request URL:    http://127.0.0.1:8000/htmlp1/
> Exception Type:         SyntaxError
> Exception Value:
>
> ('invalid syntax', ('C:\\dantest\\..\\dantest\\views.py', 14, 9, '
> elif: student_id_validate == stu_id:\n'))
>
> Exception Location:     C:\dantest\..\dantest\urls.py in , line 3
> Python Executable:      C:\Python26\python.exe
> Python Version:         2.6.2
> Python Path:    ['C:\\dantest', 'C:\\Python26\\python26.zip', 'C:\
> \Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win',
> 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26', 'C:\\Python26\\lib\\site-
> packages']
> Server time:    Sat, 1 Aug 2009 18:39:31 -0500
--~--~-~--~~~---~--~~
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: Python Conditional help

2009-08-01 Thread prabhu S

Also declare dan_id and stu_id as string. Unless request.GET can
magically return you number, which I am not sure.

Looks we are doing compilers job here :)

On Aug 2, 1:17 am, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Sat, Aug 1, 2009 at 6:59 PM, prabhu S<prabhu...@gmail.com> wrote:
>
> > change student_id_validate to student_id_check
>
> > Invalid variable dude.
>
> > On Aug 2, 12:46 am, cprsystems <cprsyst...@gmail.com> wrote:
> >> I'm trying to redirect users of an html page to another page depending
> >> on the user id entered. I'm using if else statements and declaring ids
> >> within views.py named htmlp2. I keep getting syntax errors, any
> >> insight as to why would be much appreciated. My code is below
>
> >> Thank you
>
> >> from django.shortcuts import render_to_response
> >> import datetime
>
> >> def htmlp1(request):
> >>     now = datetime.datetime.now()
> >>     return render_to_response('page-one.html', locals())
>
> >> def htmlp2(request):
> >>     dan_id = 1234567
> >>     stu_id = 7654321
> >>     student_id_check = request.GET['student_id']
> >>     if student_id_validate == dan_id:
> >>         return render_to_response('page-two', locals())
> >>     elif: student_id_validate == stu_id:
> >>         return render_to_response('page-three', locals())
> >>     else:
> >>         return render_to_response('page-one', locals())
>
> >> ERROR INFO
>
> >> SyntaxError at /htmlp1/
>
> >> ('invalid syntax', ('C:\\dantest\\..\\dantest\\views.py', 14, 9, '
> >> elif: student_id_validate == stu_id:\n'))
>
> >> Request Method:         GET
> >> Request URL:    http://127.0.0.1:8000/htmlp1/
> >> Exception Type:         SyntaxError
> >> Exception Value:
>
> >> ('invalid syntax', ('C:\\dantest\\..\\dantest\\views.py', 14, 9, '
> >> elif: student_id_validate == stu_id:\n'))
>
> >> Exception Location:     C:\dantest\..\dantest\urls.py in , line 3
> >> Python Executable:      C:\Python26\python.exe
> >> Python Version:         2.6.2
> >> Python Path:    ['C:\\dantest', 'C:\\Python26\\python26.zip', 'C:\
> >> \Python26\\DLLs', 'C:\\Python26\\lib', 'C:\\Python26\\lib\\plat-win',
> >> 'C:\\Python26\\lib\\lib-tk', 'C:\\Python26', 'C:\\Python26\\lib\\site-
> >> packages']
> >> Server time:    Sat, 1 Aug 2009 18:39:31 -0500
>
> You have a colon after elif that shouldn't be there, you just need the
> one at the end of the line.
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
> "The people's good is the highest law." -- Cicero
> "Code can always be simpler than you think, but never as simple as you
> want" -- Me
--~--~-~--~~~---~--~~
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: cab snippet add gives error

2009-08-03 Thread prabhu S

Appears like a data type mismatch. Are you entering some string value
in a integer field or something of that sort?

On Aug 3, 12:45 pm, andreas schmid  wrote:
> hi,
>
> im trying to build the cab code sharing app with the practical django
> projects book, at the moment i have a problem adding snippets bc i get
> this error:http://dpaste.com/74671/
>
> solutions?
> thx
--~--~-~--~~~---~--~~
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: Receiving email, similar to Rails

2009-08-03 Thread prabhu S

Not sure whether this is possible out of the box yet. But here is some
starter. 
http://code.google.com/p/jutda-helpdesk/source/browse/trunk/management/commands/get_email.py

jutda-helpdesk project as a whole should be a good reference.

On Aug 3, 4:14 pm, Brandon Taylor  wrote:
> Hi everyone,
>
> Does anyone know of a way to mimic the functionality Rails has to set
> up a URL pattern to receive emails and handle attachments, such as
> photos?
>
> TIA,
> Brandon
--~--~-~--~~~---~--~~
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: how to, complex filters in admin

2009-08-03 Thread prabhu S

Right. If you are looking for more complex queries take a look at Q

http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects

On Aug 3, 6:40 pm, selcukcihan  wrote:
> I need to get the filtering criteria from the request, is that right?
>
> On Aug 3, 2:24 pm, Peter Bengtsson  wrote:
>
>
>
> > Untested but should work (in admin.py):
>
> > class ThingAdmin(admin.ModelAdmin):
> >     def queryset(self, request):
> >         qs = super(ThingAdmin, self).queryset(request)
> >         qs = qs.filter(some_integer_field__gt=10)
> >         return qs
>
> > admin.site.register(Thing, ThingAdmin)
>
> > On 3 Aug, 10:52, selcukcihan  wrote:
>
> > > Hi, is there a ready to go solution within django for providing
> > > complex filters(besides the date filters and others) on models within
> > > the admin? For instance, there is a model with an integer field, i
> > > would like to be able to apply filters of the form "greater than or
> > > equal to" or "between this and that"
--~--~-~--~~~---~--~~
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 on Hostmonster shared hosting

2009-08-03 Thread prabhu S

in mysite.fcgi fix the settings file name.

os.environ['DJANGO_SETTINGS_MODULE'] = "mysite.settings"

Your settings file is inside a directory called "mysite". It will help
if you quickly take a look at modules documentation in python.

Also your fcgi complains about several missing parameters. It may not
work correctly without them.

WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!


On Aug 3, 10:17 pm, uxp  wrote:
> On Aug 2, 4:21 pm, Daniel Roseman  wrote:
>
>
>
>
>
> > On Aug 2, 8:10 pm, Tim  wrote:
>
> > > Hello
>
> > > I have been trying to get Django working with Hostmonster.com shared
> > > webhosting with FCGI.
>
> > > From what I gather from the HM forums, this is possible, but I've been
> > > hitting some issues.
>
> > > I've installed Python 2.6.2 in my home directory, and by all accounts,
> > > its working.
>
> > > I've downloaded Django from SVN (revision 11375)
>
> > > If I create a project, and an app, I can run it by
>
> > > >> ~/local/bin/python manage.py runserver
>
> > > This gives me a server running at 127.0.0.1:8000 ..  which I can get
> > > to if I telnet locally (lynx is b0rked, dunno why, not really part of
> > > this problem here).
>
> > > Configure the FCGI app, and .htaccess, as described 
> > > athttp://docs.djangoproject.com/en/dev/howto/deployment/fastcgi/#runnin...
> > > and elaborated on 
> > > athttp://www.hostmonsterforum.com/showpost.php?p=15030=4,
> > > I can get it to generate an internal exception.
>
> > > Run the fgci script at a shell, and I get:
> > > timat...@host280:~/public_html/django$ ./mysite.fcgi
> > > WSGIServer: missing FastCGI param REQUEST_METHOD required by WSGI!
> > > WSGIServer: missing FastCGI param SERVER_NAME required by WSGI!
> > > WSGIServer: missing FastCGI param SERVER_PORT required by WSGI!
> > > WSGIServer: missing FastCGI param SERVER_PROTOCOL required by WSGI!
> > > Traceback (most recent call last):
> > >   File "/home2/timatlee/local/lib/python2.6/site-packages/
> > > flup-1.0.3.dev_20090716-py2.6.egg/flup/server/fcgi_base.py", line 558,
> > > in run
> > >     protocolStatus, appStatus = self.server.handler(self)
> > >   File "/home2/timatlee/local/lib/python2.6/site-packages/
> > > flup-1.0.3.dev_20090716-py2.6.egg/flup/server/fcgi_base.py", line
> > > 1118, in handler
> > >     result = self.application(environ, start_response)
> > >   File "/home2/timatlee/djtrunk/django/core/handlers/wsgi.py", line
> > > 230, in __call__
> > >     self.load_middleware()
> > >   File "/home2/timatlee/djtrunk/django/core/handlers/base.py", line
> > > 33, in load_middleware
> > >     for middleware_path in settings.MIDDLEWARE_CLASSES:
> > >   File "/home2/timatlee/djtrunk/django/utils/functional.py", line 269,
> > > in __getattr__
> > >     self._setup()
> > >   File "/home2/timatlee/djtrunk/django/conf/__init__.py", line 40, in
> > > _setup
> > >     self._wrapped = Settings(settings_module)
> > >   File "/home2/timatlee/djtrunk/django/conf/__init__.py", line 75, in
> > > __init__
> > >     raise ImportError, "Could not import settings '%s' (Is it on
> > > sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE,
> > > e)
> > > ImportError: Could not import settings 'myproject.settings' (Is it on
> > > sys.path? Does it have syntax errors?): No module named
> > > myproject.settings
>
> > > ..  which is to say, it fails just the same as if I went to the
> > > website.
>
> > > mysite.fcgi looks like:
> > > #!/home2/timatlee/local/bin/python
> > > import sys, os
>
> > > # Add a custom Python path.
> > > # sys.path.insert(0, "/home/user/python")
> > > sys.path.insert(0, "/home2/timatlee/local/bin/python")
> > > sys.path.insert(0, "/home2/timatlee/local/lib/python2.6/site-packages/
> > > flup-1.0.3.dev_20090716-py2.6.egg")
> > > sys.path.insert(0, "/home2/timatlee/local/lib/python2.6")
> > > sys.path.insert(0, "/home2/timatlee/djcode")
> > > sys.path.insert(0, "/home2/timatlee/djcode/mysite")
> > > sys.path.insert(0, "/home2/timatlee/djtrunk")
>
> > > # Switch to the directory of your project. (Optional.)
> > > os.chdir("/home2/timatlee/djcode/mysite")
>
> > > # Set the DJANGO_SETTINGS_MODULE environment variable.
> > > os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
>
> > > from django.core.servers.fastcgi import runfastcgi
> > > runfastcgi(method="threaded", daemonize="false")
>
> > > myproject.settings exists in /home2/timatlee/djcode/mysite, which from
> > > what I can tell is on the path.
>
> > > If I set os.environ['DJANGO_SETTINGS_MODULE'] = "myproject.settings"
> > > to be the absolute path of the file, I get the following as an error:
> > > ImportError: Could not import settings '/home2/timatlee/djcode/mysite/
> > > myproject.settings' (Is it on 

Re: Using email instead of username in extended "User" model?

2009-08-03 Thread prabhu S

Going a step backward, why cant you make username same as email. Have
a custom login_required decorator that uses email and password to
authenticate, override registeration pages and not show username
field?

It seems to work for me.

On Aug 2, 4:38 pm, Dana  wrote:
> Hello All,
>
> I am looking to create a user model that extends the Auth "User"
> model, like how James Bennett outlines in his article "Extending the
> User Model" [1] by creating a FK to the "User" model and everything is
> going fine other than one issue.
>
> I would like to make "email" become the unique field and not need
> "username" when creating user accounts. Now, I don't mind using
> username for the Django admin, but for my own user section on the
> front end I want people creating accounts/logging in using an email. I
> am wondering if there is any clear way of doing this without having to
> roll my own auth app?
>
> I played with the idea of having my "save()" function create a random
> username when saving but that is obviously an ugly solution. Is there
> an easier way to do this that I am overlooking?
>
> Thanks for all your time!
> Dana W
>
> [1]http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-m...
--~--~-~--~~~---~--~~
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: Recursive request and page layout

2009-08-09 Thread prabhu S

It will be awesome if you can make and open source such a tag.
Shouldn't be hard since templates can be evaluated independent of
http. If you want something simpler, use iframe and point it to the
correct url.

Regards,
Prabhu

On Aug 8, 12:11 pm, SardarNL  wrote:
> I've checked the custom tags and the middleware that automatically
> registers request object inside the template context, this is all I
> need to get the recursive call working. However I wonder why such
> functionality isn't there. Probably there is another way to put
> content from totally independent components/apps on the same page.
> Could someone point me in the right direction?
>
> The overhead of recursive requests is negligible and I will make
> custom render tag for it Monday if no other "django way" solution
> bubbles up here.
>
> On Aug 7, 8:11 pm, Daniel Roseman  wrote:
>
>
>
> > On Aug 7, 5:24 pm, SardarNL  wrote:
>
> > > Hi Folks
>
> > > Here is the problem, we have some pages that don't contain any
> > > content, but rather layout the blocks which are served by other views.
> > > Extending the template and overriding some blocks is not a solution,
> > > because there are many unrelated blocks, that can not be rendered by a
> > > single view.
>
> > > Naturally I would expect some {% dispatch "/some/path/here" %} tag,
> > > such that when template is being processed, the tag will issue
> > > recursive request and will be replaced by obtained content. The tag
> > > should be able to replace the base template of called view, so the
> > > header/footer and other markup will not be rendered if view is called
> > > as a block.
>
> > > Unfortunately there is no such tag. So my question is: how to give the
> > > control to independent blocks. The idea is:
>
> > >   - current request is being processed by some view, which knows how
> > > to fetch only its own content
> > >   - the designer may want to add other content/block, totally
> > > unrelated to current request, for example a poll/banner/menu etc.
> > >   - the block needs to be served by some view because there database
> > > fetch is needed along other processing. So simple include of a
> > > template is not a solution. Fetching all the content within the top-
> > > most view isn't a solution because the block can be used on many
> > > places.
>
> > > That is the reason why this should be implemented as recursive call,
> > > such that the block-view will not even know it is being called as a
> > > block and will simply render the content. Of course in real situation
> > > the view still needs to know it is being called as a block, such that
> > > more simplistic templates may be used.
>
> > > Please explain what is the django way and how would you solve this,
> > > maybe I'm digging in totally wrong direction.
>
> > Including blocks on a page is what custom template tags are for. See
> > here:http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
> > particularly the section on 'inclusion tags'.
>
> > That's not exactly what you asked for in terms of recursive views, but
> > is probably better as it has less overhead - calling a view
> > recursively would involve instantiating an HttpResponse object each
> > time, then extracting the content and throwing the object away.
> > --
> > 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: weirdist situation I have faced in 4 years of (ab)using django

2009-08-09 Thread prabhu S

Hi KG,

Nice to meet you! How are you confirming if the data is from Meeting?
Are you looking at the final rendered html? What does a print after
the statement

p = Event.objects.get(pk=id)

tell you? Also check if you have just one view for the particular url
mapping.

Regards,
Prabhu

On Aug 9, 8:33 am, Kenneth Gonsalves  wrote:
> hi
> latest svn, apache and mod_python on fedora 11 (same problem with runserver)
>
> I have three models: Event, Report and Meeting.
> Outside admin I have addevent which adds and event, event, which gives a list
> of events and eventfull which details one event.. And the same for Report and
> Meeting.
>
> addevent works fine and so does listing of events - and so does Meeting and
> Report. I have done this so many times in the last 4 years that I can do it in
> my sleep. But this time eventfull does not work. It does not throw errors. The
> template is displayed, but the data is from Meeting. The same thing happens
> with reportfull. What django is doing is calling eventfull, getting data from
> meetingfull and displaying that in eventfull.html. I have another app with the
> same three models which works perfectly on the same machine with the same
> configuration. Obviously I am doing something stupid. But what? Here is my
> urls.py (relevant extracts):
>
> urlpatterns = patterns('ilugc.web.views',
>     url(r'^$', 'report', name='report'),
>     #meeting
>     url(r'^meeting/$', 'meeting', name='meeting'),
>     url(r'^meetingfull/(?P\d+)/$', 'meetingfull', name='meeting_by_id'),
>     #report
>     url(r'^report/$', 'report', name='report'),
>     url(r'^report/(?P\d+)/$', 'report', name='report_by_tag'),
>     url(r'^addreport/$', 'addreport', name='addreport'),
>     url(r'^addreport/(?P\d+)/$', 'addreport', name='add_report'),
>     url(r'^reportfull/(?P\d+)/$', 'reportfull', name='report_by_id'),
>     #event
>     url(r'^event/$', 'event', name='event'),
>     url(r'^addevent/$', 'addevent', name='addevent'),
>     url(r'^addevent/(?P\d+)/$', 'addevent', name='add_event'),
>     url(r'^eventfull/(?P\d+)/$', 'eventfull', name='event_by_id'),
>
> and the relevant extract from views.py:
>
> def event(request):
>     """
>     list of events by topic
>     """
>
>     lst=Event.objects.all()
>     t = loader.get_template('web/event.html')
>     c = RequestContext(request,
>                 {'lst':lst,
>                  })
>     return HttpResponse(t.render(c))
>
> def eventfull(request,id):
>     """
>     Details of specific Events
>     """
>     canedit = False
>     p = Event.objects.get(pk=id)
>     if p.author_id == request.user.id:
>         canedit=True
>     t = loader.get_template('web/eventfull.html')
>     c = RequestContext(request,
>                 {'p':p,
>                 'canedit': canedit,
>                  })
>     return HttpResponse(t.render(c))
>
> --
> regards
> kghttp://lawgon.livejournal.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: Standalone script with django's ORM and multiprocessing

2009-08-11 Thread prabhu S

Solution appears like a hack to me. Why do you close the connection in
every process? Can you not just close once in parent? Execute commits
alone in each process.

On Aug 11, 10:50 am, Spajderix  wrote:
> Malcolm Tredinnick pisze:
>
>
>
> > On Tue, 2009-08-11 at 11:06 +0200, Spajderix wrote:
>
> >> Hi!
>
> >> I've written a standalone script, which looks throught a table in db for
> >> tasks to perform. It then starts subprocesses for each task it founds
> >> using multiprocessing.Process class from python. Everything's fine when
> >> there is one task, but when i try to start more subprocesses at once i get:
>
> >> OperationalError: (2013, 'Lost connection to MySQL server during query')
> >>     raise errorclass, errorvalue
> >> OperationalError: (2006, 'MySQL server has gone away')
>
> >> I guess that this happens because all subprocesses share one connection,
> >> and when one of them closes this connection, rest of subprocesses raises
> >> an error.
>
> > That certainly sounds believable. We call close() explicitly, too, so
> > that is why ongoing operations are interrupted in the middle.
>
> >> Do you know a way to go round this problem?
>
> > If you close the database connection, Django will open a new one the
> > next time it needs it. So I suspect you can work around this by
> > explicitly closing the connection immediately after you start a new
> > process (in the new process). Then the process will get its own
> > connection when you try to do something.
>
> > Regards,
> > Malcolm
>
> Thank you! That solved the problem:)
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---