URL Rewrite problem in lighttpd

2012-01-21 Thread Jon Jenkins
I have a django site deployed on lighttpd running on FreeBSD, using FastCGI.

When I specify a URL, for example, http://www.site.com/blog, the debug
program will say 404 and claim that I passed the URL mysite.fcgi/blog.
However, if I put a trailing slash on the URL, everything works fine.

My URL rewrite looks like so:

url.rewrite-once += (
"^(/.*)$" => "/mysite.fcgi$1",
)

To make matters even more confusing, I have a second site running in
the exact same way which is unaffected by this problem. Any help with
this would be appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

2012-01-21 Thread JohnA
Is your code really that simple - I mean get the queryset and
immediately try to delete something out of it?  If so, maybe it's time
to step through the delete in the debugger.  Querysets are lazy but I
assume that referencing an item in the queryset kike you do will cause
the actual data to get feteched.  Maybe the problem is trying to
delete something directly out of the queryset, or maybe you're somehow
deleting the same record twice, or maybe django is somehow getting
confused while performing the operation.

-- John

On Jan 21, 6:39 pm, Chris Seberino  wrote:
> On Jan 21, 2:43 pm, JohnA  wrote:
>
> > How are you finding these objects?  That might point to the answer.
>
> > Probably the likeliest explanation is that you are creating the
> > objects but not saving them.
>
> In the Django shell I do
>
> quests = Question.objects.all()
> quests[579].delete()
>
> Why does the objects.all() invocation add this id=None crud to quests
> list?
>
> cs

-- 
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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

2012-01-21 Thread Chris Seberino
On Jan 21, 2:43 pm, JohnA  wrote:
> How are you finding these objects?  That might point to the answer.
>
> Probably the likeliest explanation is that you are creating the
> objects but not saving them.

In the Django shell I do

quests = Question.objects.all()
quests[579].delete()

Why does the objects.all() invocation add this id=None crud to quests
list?

cs

-- 
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: Internationalization and localization

2012-01-21 Thread Radek Valachovic
but thats developer edition not released yet

On Fri, Jan 13, 2012 at 3:21 AM, Daniel Gerzo  wrote:

> On Tue, 6 Dec 2011 16:40:42 -0800 (PST), rentgeeen wrote:
>
>  But what I want to achieve is if I give somebody link:
>>
>> it/sample/
>> en/sample/
>>
>> it will show that page in that language, now I have to choose language
>> and then go to the page and see it in that language...
>>
>
> you need django 1.4 and i18n_patterns:
> https://docs.djangoproject.**com/en/dev/topics/i18n/**
> translation/#django.conf.urls.**i18n.i18n_patterns
>
> --
> S pozdravom / Best regards
>  Daniel
>
>
> --
> 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+unsubscribe@**
> 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-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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

2012-01-21 Thread JohnA
How are you finding these objects?  That might point to the answer.

Probably the likeliest explanation is that you are creating the
objects but not saving them.

On Jan 21, 12:31 pm, Chris Seberino  wrote:
> On Jan 21, 6:44 am, Tom Evans  wrote:
>
> > Models are representations of rows in a database.
> > Deleting a model instance implies removing a row from a database.
> > Model instances have an id attribute which denotes their row in the 
> > database.
> > Models whose id is None don't exist in the database, and so it is
> > nonsense to delete them - they don't exist.
>
> That makes perfect sense but then why do these zombie id=None objects
> show up?
> *WHERE* are they living if not in the database?  Does the Django shell
> somehow have a secondary storage area for this zombie id=None object
> stuff I can delete somehow?

-- 
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: Can't make 404.html template to be used. Keep getting Apache 500 Internal Server Error instead.

2012-01-21 Thread Chris Seberino

> Check your apache logs.

Last line below says error is that there is no handler500.  I thought
a missing web page for some URL was a 404 error so I'm not sure why
this error is popping up.

cs


[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48] mod_wsgi
(pid=19346): Exception occurred processing WSGI script '/etc/apache2/
wsgi/phil4.com.wsgi'.
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48] Traceback
(most recent call last):
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48]   File "/usr/
lib/pymodules/python2.6/django/core/handlers/wsgi.py", line 241, in
__call__
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48] response
= self.get_response(request)
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48]   File "/usr/
lib/pymodules/python2.6/django/core/handlers/base.py", line 130, in
get_response
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48] return
self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48]   File "/usr/
lib/pymodules/python2.6/django/core/handlers/base.py", line 179, in
handle_uncaught_exception
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48]
callback, param_dict = resolver.resolve500()
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48]   File "/usr/
lib/pymodules/python2.6/django/core/urlresolvers.py", line 263, in
resolve500
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48] return
self._resolve_special('500')
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48]   File "/usr/
lib/pymodules/python2.6/django/core/urlresolvers.py", line 253, in
_resolve_special
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48] callback
= getattr(self.urlconf_module, 'handler%s' % view_type)
[Sat Jan 21 13:24:44 2012] [error] [client 75.108.243.48]
AttributeError: 'module' object has no attribute 'handler500'

-- 
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: Can't make 404.html template to be used. Keep getting Apache 500 Internal Server Error instead.

2012-01-21 Thread Gabriel [SGT]
On Sat, Jan 21, 2012 at 2:28 PM, Chris Seberino  wrote:
> I am proxying my Django app behind Apache.  I created a 404.html in my
> template directory but when I try to test it I get the following error
> that appears to come from Apache...
>
> Internal Server Error
>

Check your apache logs.

-- 
Kind 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-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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

2012-01-21 Thread Chris Seberino

On Jan 21, 6:44 am, Tom Evans  wrote:
> Models are representations of rows in a database.
> Deleting a model instance implies removing a row from a database.
> Model instances have an id attribute which denotes their row in the database.
> Models whose id is None don't exist in the database, and so it is
> nonsense to delete them - they don't exist.

That makes perfect sense but then why do these zombie id=None objects
show up?
*WHERE* are they living if not in the database?  Does the Django shell
somehow have a secondary storage area for this zombie id=None object
stuff I can delete somehow?

-- 
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.



Can't make 404.html template to be used. Keep getting Apache 500 Internal Server Error instead.

2012-01-21 Thread Chris Seberino
I am proxying my Django app behind Apache.  I created a 404.html in my
template directory but when I try to test it I get the following error
that appears to come from Apache...

Internal Server Error

The server encountered an internal error or misconfiguration and was
unable to complete your request.

Please contact the server administrator, [no address given] and inform
them of the time the error occurred, and anything you might have done
that may have caused the error.

More information about this error may be available in the server error
log.
Apache/2.2.16 (Ubuntu) Server at phil4.com Port 80

Here is the relevant Apache settings...

NameVirtualHost  72.14.188.15:80
NameVirtualHost  72.14.188.15:443
WSGIRestrictEmbedded On


#
=
ServerName  phil4.com
ServerAlias www.phil4.com
DocumentRoot/var/www
Options Indexes FollowSymLinks
#
=
WSGIProcessGroupphil4.com
WSGIScriptAlias / /etc/apache2/wsgi/phil4.com.wsgi
WSGIDaemonProcess   phil4.com user=seb group=seb threads=25
#
=

Order Allow,Deny
Allow from All

#
=
Alias /favicon.ico /var/www/static/images/favicon.ico
Alias /base.css/var/www/static/base.css
Alias /static  /var/www/static
Alias /public  /var/www/static/public
Alias /misc/var/www/static/misc
Alias /images  /var/www/static/images
Alias /books/  /var/www/static/books/
Alias /homework/   /var/www/static/homework/
Alias /exams/  /var/www/static/exams/
#
=
Redirect /sign_in  https://phil4.com/sign_in
Redirect /register https://phil4.com/register
#
=


-- 
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: what is the best IDE to use for Python / Django

2012-01-21 Thread goosfancito

El 21/01/12 08:52, kenneth gonsalves escribió:

On Sat, 2012-01-21 at 03:34 -0800, John Yeukhon Wong wrote:

While it has been asked a trillion times already, let me say TRY UT
YOURSELF.

you were requested not to feed this thread. If the OP cannot search,
here it is:

http://duckduckgo.com/?q=site%3Agroups.google.com%2Fgroup%2Fdjango-users
+python+IDE

i used gedit only.

--
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: Having Headache With LoginForm

2012-01-21 Thread coded kid


On Jan 21, 2:35 pm, coded kid  wrote:
> Thanks for the help bro.
>
> How can I make the form verify users name and password before login
> in. So that if the user wants to login in with wrong data, the form
> will tell the user to login in with the correct data. Any idea?
>
> Can this code be put in the views.py?
> def get_user(self, user_id):
>     try:
>         return User.objects.get(pk=user_id)
>     except User.DoesNotExist:
>         return None
> So that it can verify users data before they loggin in?
>
> On Jan 19, 6:03 pm, Mark Furbee  wrote:
>
>
>
>
>
>
>
> > No problem. You will likely use the form objects in your template, I just
> > chose to create my own form in HTML.
>
> > Since the 'views.Login' is a string, you don't need to import it. It just
> > tells Django which view to pass the request to when that url pattern is
> > found. The ^ means the beginning of the url after the slash
> > (www.mysite.com/ > here>). The $ means the string ends. I found this useful, because without
> > it, multiple urls will match. For example: with `url(r'^login',
> > 'views.Login')`, the following will all match and go to views.Login: 
> > 1)www.mysite.com/login, 2)www.mysite.com/login_page, 
> > 3)www.mysite.com/login?no_login=1. So I specify the $ to make it more exact,
> > more out of habit than requirement. If you add the slash to the end like
> > `url(r'^login/$', 'views.Login')`, it will require the slash, 
> > sowww.mysite.com/loginwillnot match. If you want to have both urls work, I
> > think this will work (although untested): `url(r'^login/?$',
> > 'views.Login')`, where the /? means that there could be no / or one slash.
> > With this, the following would not match: www,mysite.com/login///. If you
> > wanted to allow multiple slashes, change the ? with *, like
> > `url(r'^login/*', 'views.Login')`. Again, that's not tested, but it should
> > work, I think.
>
> > Happy Coding!
>
> > Mark
>
> > On Wed, Jan 18, 2012 at 6:09 PM, coded kid  wrote:
> > > Thanks bro. Don't you think I should import Login in urls.py? What
> > > about / in before the $ in urls.py? Or I should just place it like
> > > that?
>
> > > Mark Furbee wrote:
> > > > This is my login process.
>
> > > > urls.py:
> > > > url(r'^login$', 'views.Login'),
> > > > url(r'^logout$', 'views.Logout'),
>
> > > > views.py:
> > > > def Login(request, next=None):
> > > >     """
> > > >         Used to log into the application.
> > > >     """
>
> > > >     #  If the user is authenticated pass them through to the homepage.
> > > >     if request.user.is_authenticated():
> > > >         return HttpResponseRedirect('/')
>
> > > >     # If the user is not authenticated, but the method is POST, they 
> > > > have
> > > > posted their username and password.
> > > >     if request.method == "POST":
>
> > > >         # Get Username and Password.
> > > >         username = request.POST['username']
> > > >         password = request.POST['password']
>
> > > >         # Authenticate.
> > > >         user = authenticate(username=username, password=password)
>
> > > >         # If the User is not None, they have a valid account and
> > > password.
> > > >         if user is not None:
>
> > > >             # If the user isactive, we can log them in.
> > > >             if user.is_active:
> > > >                 # Log them in, and redirect to the homepage.
> > > >                 login(request, user)
> > > >                 return HttpResponseRedirect('/')
>
> > > >             # If the user is not active, pass them back to the login
> > > page,
> > > > with a message that the account is inactive.
> > > >             else:
> > > >                 return render_to_response('login.htm', {'error': 
> > > > 'Account
> > > > Disabled - contact I.T. for assistance'},
> > > > context_instance=RequestContext(request))
>
> > > >         # The user with those credentials did not exist, pass them back
> > > to
> > > > the login page, with a message that the account was invalid.
> > > >         else:
> > > >             return render_to_response('login.htm', {'error': 'Invalid
> > > > Username/Password - contact I.T. for assistance'},
> > > > context_instance=RequestContext(request))
>
> > > >     # They have not yet attempted a login, pass them to the login page,
> > > > without any error messages..
> > > >     else:
>
> > > >         return render_to_response('login.htm', {'NoSessionTimeout':
> > > 'True',
> > > > 'next': next}, context_instance=RequestContext(request))
>
> > > > def Logout(request):
> > > >     logout(request)
>
> > > >     # Render the logout.htm page, which will display they are logging 
> > > > out
> > > > and redirect them to the login page.
> > > >     return render_to_response('login.htm', {'notice': 'You have been
> > > logged
> > > > out successfully.'}, context_instance=RequestContext(request))
>
> > > > template login.htm:
>
> > > > .
> > > > .
> > > > .
> > > >  > > > method="post" name="login">
> > > >  {% csrf_token %}
> > > >  
> > > >  

Re: imagefiled don't Work

2012-01-21 Thread Babatunde Akinyanmi
I haven't really read your mail but after you added the imagefield to
your Category model did you drop the category table and then syncdb?

On 1/21/12, cha  wrote:
> Hello I reading this tutorial
> https://pype.its.utexas.edu/docs/tutorial/unit6.html#answers
> it's work OK But When I want improve it and add ImageField in Category
> Model i have problem with ImageField It's Not uploaded
>
> file = models.ImageField(upload_to='img/%Y')
>
>
> see code please :
> _
> views.py
> _
> from django import forms
> class CategoryForm(forms.ModelForm):
> class Meta:
> model = Category
>
> def add_category(request):
> if request.method == "POST":
> form = CategoryForm(request.POST, request.FILES)
> ## Handle AJAX  ##
> if request.is_ajax():
> if form.is_valid():
> form.save()
> # Get a list of Categories to return
> cats = Category.objects.all().order_by('name')
> # Create a dictionary for our response data
> data = {
> 'error': False,
> 'message': 'Category %s Added Successfully' %
> form.cleaned_data['name'],
> # Pass a list of the 'name' attribute from each
> Category.
> # Django model instances are not serializable
> 'categories': [c.name for c in cats],
> }
> else:
> # Form was not valid, get the errors from the form and
> # create a dictionary for our error response.
> data = {
> 'error': True,
> 'message': "Please try again! one",
> 'name_error': str(form.errors.get('name', '')),
> 'slug_error': str(form.errors.get('slug', '')),
> 'file_error': str(form.errors.get('file', '')),
> }
> # encode the data as a json object and return it
> return http.HttpResponse(json.dumps(data))
>
> ## Old Form Handler Logic ##
> if form.is_valid():
> form.save()
> return http.HttpResponseRedirect('/category/')
> else:
> form = CategoryForm()
> cats = Category.objects.all().order_by('name')
> context = Context({'title': 'Add Category', 'form': form,
> 'categories': cats})
> return render_to_response('ajax_form.html',
> context,context_instance=RequestContext(request))
>
> ___
> ajax_form.html
> ___
>
>  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>
> http://www.w3.org/1999/xhtml";>
> 
>{{ title }}
>
>   #message {width:250px; background-color:#aaa;}
>   .hide {display: none;}
>
>http://ajax.googleapis.com/ajax/
> libs/jquery/1.3.2/jquery.js">
> 
> 
>
> 
> // prepare the form when the DOM is ready
> $(document).ready(function() {
> $("#add_cat").ajaxStart(function() {
> // Remove any errors/messages and fade the form.
> $(".form_row").removeClass('errors');
> $(".form_row_errors").html('');
> $("#add_cat").fadeTo('slow', 0.33);
> $("#add_cat_btn").attr('disabled', 'disabled');
> $("#message").addClass('hide');
> });
>
> // Submit the form with ajax.
> $("#add_cat").submit(function(){
> $.post(
> // Grab the action url from the form.
> "#add_cat.getAttribute('action')",
>
> // Serialize the form data to send.
> $("#add_cat").serialize(),
>
> // Callback function to handle the response from view.
> function(resp, testStatus) {
> if (resp.error) {
> // check for field errors
> if (resp.name_error != '') {
> $("#name_row").addClass('errors');
> $("#name_errors").html(resp.name_error);
> }
> if (resp.slug_error != '') {
> $("#slug_row").addClass('errors');
> $("#slug_errors").html(resp.slug_error);
> }
> if (resp.file_error != '') {
> $("#file_row").addClass('errors');
> $("#file_errors").html(resp.file_error);
> }
> } else {
> // No errors. Rewrite the category list.
> $("#categories").fadeTo('fast', 0);
> var text = new String();
> for(i=0; i var m = resp.categories[i]
> text += "
  • " + m + "
  • " > } > $("#categories").html(text); >

    Re: Having Headache With LoginForm

    2012-01-21 Thread coded kid
    Thanks for the help bro.
    
    How can I make the form verify users name and password before login
    in. So that if the user wants to login in with wrong data, the form
    will tell the user to login in with the correct data. Any idea?
    
    Can this code be put in the views.py?
    def get_user(self, user_id):
    try:
    return User.objects.get(pk=user_id)
    except User.DoesNotExist:
    return None
    So that it can verify users data before they loggin in?
    
    On Jan 19, 6:03 pm, Mark Furbee  wrote:
    > No problem. You will likely use the form objects in your template, I just
    > chose to create my own form in HTML.
    >
    > Since the 'views.Login' is a string, you don't need to import it. It just
    > tells Django which view to pass the request to when that url pattern is
    > found. The ^ means the beginning of the url after the slash
    > (www.mysite.com/ here>). The $ means the string ends. I found this useful, because without
    > it, multiple urls will match. For example: with `url(r'^login',
    > 'views.Login')`, the following will all match and go to views.Login: 
    > 1)www.mysite.com/login, 2)www.mysite.com/login_page, 
    > 3)www.mysite.com/login?no_login=1. So I specify the $ to make it more exact,
    > more out of habit than requirement. If you add the slash to the end like
    > `url(r'^login/$', 'views.Login')`, it will require the slash, 
    > sowww.mysite.com/loginwill not match. If you want to have both urls work, I
    > think this will work (although untested): `url(r'^login/?$',
    > 'views.Login')`, where the /? means that there could be no / or one slash.
    > With this, the following would not match: www,mysite.com/login///. If you
    > wanted to allow multiple slashes, change the ? with *, like
    > `url(r'^login/*', 'views.Login')`. Again, that's not tested, but it should
    > work, I think.
    >
    > Happy Coding!
    >
    > Mark
    >
    >
    >
    >
    >
    >
    >
    > On Wed, Jan 18, 2012 at 6:09 PM, coded kid  wrote:
    > > Thanks bro. Don't you think I should import Login in urls.py? What
    > > about / in before the $ in urls.py? Or I should just place it like
    > > that?
    >
    > > Mark Furbee wrote:
    > > > This is my login process.
    >
    > > > urls.py:
    > > > url(r'^login$', 'views.Login'),
    > > > url(r'^logout$', 'views.Logout'),
    >
    > > > views.py:
    > > > def Login(request, next=None):
    > > >     """
    > > >         Used to log into the application.
    > > >     """
    >
    > > >     #  If the user is authenticated pass them through to the homepage.
    > > >     if request.user.is_authenticated():
    > > >         return HttpResponseRedirect('/')
    >
    > > >     # If the user is not authenticated, but the method is POST, they have
    > > > posted their username and password.
    > > >     if request.method == "POST":
    >
    > > >         # Get Username and Password.
    > > >         username = request.POST['username']
    > > >         password = request.POST['password']
    >
    > > >         # Authenticate.
    > > >         user = authenticate(username=username, password=password)
    >
    > > >         # If the User is not None, they have a valid account and
    > > password.
    > > >         if user is not None:
    >
    > > >             # If the user isactive, we can log them in.
    > > >             if user.is_active:
    > > >                 # Log them in, and redirect to the homepage.
    > > >                 login(request, user)
    > > >                 return HttpResponseRedirect('/')
    >
    > > >             # If the user is not active, pass them back to the login
    > > page,
    > > > with a message that the account is inactive.
    > > >             else:
    > > >                 return render_to_response('login.htm', {'error': 'Account
    > > > Disabled - contact I.T. for assistance'},
    > > > context_instance=RequestContext(request))
    >
    > > >         # The user with those credentials did not exist, pass them back
    > > to
    > > > the login page, with a message that the account was invalid.
    > > >         else:
    > > >             return render_to_response('login.htm', {'error': 'Invalid
    > > > Username/Password - contact I.T. for assistance'},
    > > > context_instance=RequestContext(request))
    >
    > > >     # They have not yet attempted a login, pass them to the login page,
    > > > without any error messages..
    > > >     else:
    >
    > > >         return render_to_response('login.htm', {'NoSessionTimeout':
    > > 'True',
    > > > 'next': next}, context_instance=RequestContext(request))
    >
    > > > def Logout(request):
    > > >     logout(request)
    >
    > > >     # Render the logout.htm page, which will display they are logging out
    > > > and redirect them to the login page.
    > > >     return render_to_response('login.htm', {'notice': 'You have been
    > > logged
    > > > out successfully.'}, context_instance=RequestContext(request))
    >
    > > > template login.htm:
    >
    > > > .
    > > > .
    > > > .
    > > >  > > method="post" name="login">
    > > >  {% csrf_token %}
    > > >  
    > > >  
    > > >  Login
    > > >  
    > > > 
    > > >  
    > > > {% if error %}
    > > >  
    > > > 
    > > >  {% FatalImage %}
    > > > {{ error }}
    > > > 
    > > >  
    > > > 
    > > >  {% endif %}
    > > > {% if warning %}
    > > > 
    > > >  
    > > > {% WarnImage %}
    > > >  {{ warning }}
    > > > 
    > > > 
    > > >  
    > > > {% endif %}
    

    Re: How to use a DB table for choices=tuples in ChoiceField?

    2012-01-21 Thread Bill Beal
    It looks like the Pythonic way is to create the list in
    models.py and invoke it from forms.py.
    
    Sorry about the heterogeneous names--some of
    them match the document the requirements were
    extracted from and others are more meaningful
    to me.  The former were picked because we'll
    need a requirements cross-reference and they'll
    be easier to match up with the requirements.
    And the dashes in place of spaces--most of the
    code examples I see here are almost unreadable
    because of leading spaces disappearing.
    I saw one example of replacing all but the last
    leading space with '-', and it was more readable.
    
    Regards
    
    On Fri, Jan 20, 2012 at 11:22 PM, Dennis Lee Bieber
    wrote:
    
    > On Fri, 20 Jan 2012 19:44:16 -0800 (PST), Bill Beal
    >  wrote:
    >
    >Caveat: I've only looked at Django, but not in enough detail to be
    > "expert"; my comments are based upon basic Python syntax/semantics (my
    > apologies to the developers, but I work better with printed
    > documentation and Django is too much of a moving target for the few
    > books that did come out to be relevant four months later)
    >
    > >name 'scac_choicelist' is not defined at the marked
    > >line in my form:
    > >
    > Which is true -- it is not defined at that point. (NOTE: your names
    > don't really help understanding the purpose of the variables )
    >
    > >from django import forms
    > >from django.forms.fields import ChoiceField
    > >from myapp.models import *
    > >
    > >BOL_CODE_QUALIFIERS = (
    > >  ('OB', 'Ocean Bill of Lading (OB)'),
    > >  ('BM', 'House Bill of Lading (BM)'),
    > >)
    > >
    > >class BolForm(forms.Form):
    > >- scac = forms.ChoiceField(
    > >- label=u'Ocean Carrier',
    > >- choices=scac_choicelist()) ##
    > >- bill_of_lading = forms.CharField(
    > >- label=u'Bill of Lading #', max_length=50)
    > >- bol_type = forms.ChoiceField(
    > >- label=u'Type of B/L',
    > >- choices=BOL_CODE_QUALIFIERS)
    > >
    > >Here's my model:
    > >
    > >from django.db import models
    > >
    > >class Scac(models.Model):
    > >- code = models.CharField(max_length=4)
    > >- name = models.CharField(max_length=60)
    > >
    > >- def __unicode__(self):
    > >--- return self.code
    > >
    > >- def scac_choicelist():
    > >--- q = Scac.objects.all()
    > >--- scaclist = []
    > >--- for x in q:
    > >- scaclist.append((x.code, x.name))
    > >- return scaclist
    >
    > Presuming the many "-"s represent indentation, "scac_choicelist" is
    > a method of Scac. That means it should have at least one parameter: self
    >
    >def scac_choicelist(self):
    >scaclist = []
    >for item in self.objects.all():
    >scaclist.append((item.code, item.name))
    >return scaclist
    >
    > NOTE: based on your "-"s, your return statement is inside your loop, so
    > you'd be returning after processing only one element.
    >
    >NOW... In the form module you need to reference an instance of the
    > model! The method itself is not visible.
    >
    > >- scac = forms.ChoiceField(
    > >- label=u'Ocean Carrier',
    > >- choices=scac_choicelist()) ##
    > >
    >
    > Something like:
    >
    >scac = forms.ChoiceField(   label=u"Ocean Carrier",
    >
    >  choices=Scac().scac_choicelist())
    >
    > --
    >Wulfraed Dennis Lee Bieber AF6VN
    >wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.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.
    >
    >
    
    -- 
    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: Why can't erase this model object? "AssertionError: Question object can't be deleted because its id attribute is set to None."

    2012-01-21 Thread Tom Evans
    On Sat, Jan 21, 2012 at 3:49 AM, Chris Seberino  wrote:
    > I get the following error when attempting to delete an object of my
    > model...
    >
    > "AssertionError: Question object can't be deleted because its id
    > attribute is set to None."
    >
    
    Models are representations of rows in a database.
    Deleting a model instance implies removing a row from a database.
    Model instances have an id attribute which denotes their row in the database.
    Models whose id is None don't exist in the database, and so it is
    nonsense to delete them - they don't exist.
    
    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: what is the best IDE to use for Python / Django

    2012-01-21 Thread kenneth gonsalves
    On Sat, 2012-01-21 at 03:34 -0800, John Yeukhon Wong wrote:
    > While it has been asked a trillion times already, let me say TRY UT
    > YOURSELF. 
    
    you were requested not to feed this thread. If the OP cannot search,
    here it is:
    
    http://duckduckgo.com/?q=site%3Agroups.google.com%2Fgroup%2Fdjango-users
    +python+IDE
    -- 
    regards
    Kenneth Gonsalves
    
    -- 
    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: what is the best IDE to use for Python / Django

    2012-01-21 Thread John Yeukhon Wong
    
    While it has been asked a trillion times already, let me say TRY UT
    YOURSELF. Sometimes even doing on console such as vim is not bad.
    However if you are working on a huge project an IDE can help you.
    Pycharm is very good. The problem is still very new but its
    development. Maturity is outstanding. I love its database auto
    complete. But version control is still e
    On Jan 19, 9:14 am, Andre Terra  wrote:
    > *** Everyone, please DO NOT reply to this thread. ***
    >
    > Krondaj, feel free to search the archives for similar threads. This
    > question has been asked an answered at least a dozen times.
    >
    > Cheers,
    > André Terra
    >
    >
    >
    > On Thu, Jan 19, 2012 at 12:08 PM, Krondaj  wrote:
    > > Hi,
    >
    > > I was wondering what the best IDE to use for Python / Django would
    > > be?
    >
    > > I am currently using Geany, but i'm sure there is a better (hopefully
    > > free) one out there!?!
    >
    > > Regards,
    >
    > > 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.
    
    -- 
    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-driven Django development

    2012-01-21 Thread Mike Dewhirst
    
    On 21/01/2012 2:50pm, Alec Taylor wrote:
    
    At University I've learned various techniques for model-driven
    developments, such as:
    - Class diagrams (generate code)
    - ERD Diagrams (generate db code [e.g. SQL])
    
    
    Check out Dia which has a Python script interface and I seem to remember 
    someone doing a script to create Django models from the ER or UML 
    diagrams. It is a while since I looked at it so I might be leading you 
    astray.
    
    
    Good luck
    
    Mike
    
    
    
    Can any of these sorts of—or for that matter, any sort of—model-driven
    development techniques be used for Django?
    
    
    
    --
    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: Does Django provide a function that can get the base_url. Ex: http://127.0.0.1:8000/ if on local, www.example.com if on prod?

    2012-01-21 Thread Russell Keith-Magee
    On Sat, Jan 21, 2012 at 4:32 PM, Chen Xu  wrote:
    > Hi, everyone:
    > Does Django provide a function that can get the base_url. Ex:
    >  http://127.0.0.1:8000/  if on local, www.example.com if on prod?
    
    Yes -- the request object [1] holds that sort of information; in
    particular, you're looking for the HttpRequest.get_host() call [2].
    
    [1] 
    https://docs.djangoproject.com/en/1.3/ref/request-response/#httprequest-objects
    [2] 
    https://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.HttpRequest.get_host
    
    Yours,
    Russ Magee %-)
    
    -- 
    You received this message because you are subscribed to the Google Groups 
    "Django users" group.
    To post to this group, send email to django-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.
    
    
    

    Does Django provide a function that can get the base_url. Ex: http://127.0.0.1:8000/ if on local, www.example.com if on prod?

    2012-01-21 Thread Chen Xu
    Hi, everyone:
    Does Django provide a function that can get the base_url. Ex:
    http://127.0.0.1:8000/  if on local, www.example.com if on prod?
    
    
    Thanks very much
    Best regards
    
    -- 
    ⚡ Chen Xu ⚡
    
    -- 
    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.