Re: hi [django-users] How to do something after "return HttpResponse(html)"?

2013-06-26 Thread Michael Anckaert
On 25/06/13 12:35, lx wrote:
> hi all:
>   I want to do someing after "return HttpResponse(html)".
> for example
> """"""""""""""
> from django.http import HttpResponse
> import datetime
> def current_datetime(request):
>   now = datetime.datetime.now()
>   html = "It is now %s." % now
>   return HttpResponse(html)
> """""""""""""""""""""""""""""
>
> Actually, I have a question that I need first give a response to the
> client, second I do something else.
> How to solve this?
>
> Thank you
>
>
You can't do anything after your view (= python function) returns.
If you need to perform a task but don't want to keep the user waiting,
you should look into Celery. This is a Distributed Task Queue: you can
start a task that a worker will execute in the backend. Your view can
return immediately, being very responsive to the user. In the meanwhile
the worker will perform the extra work in the background.

--
Kind regards
Michael Anckaert




signature.asc
Description: OpenPGP digital signature


Re: Problem setting up django server

2013-06-18 Thread Michael Anckaert
On 18/06/13 17:46, smy28 wrote:
> No, I haven't edited anything yet. Okay, I attached a models.py file
> from django/contrib/auth
>
> On Tuesday, June 18, 2013 11:39:09 AM UTC-4, Michael Anckaert wrote:
>
> On 18/06/13 17:37, smy28 wrote:
>> Yes, I have attached the base.py file (which seems to be the one
>> with the error, correct?)
>>
>>     On Tuesday, June 18, 2013 11:11:52 AM UTC-4, Michael Anckaert wrote:
>>
>> On 18/06/13 17:00, smy28 wrote:
>> > I just installed Django and I'm trying to initially set up
>> the server,
>> > as detailed in the 'Part 1' Tutorial. I haven't configured any
>> > settings yet. Whenever I run the command "python manage.py
>> runserver",
>> > I get the following message:
>> >
>> >
>> >
>> > Validating models...
>> >
>> > Unhandled exception in thread started by > > Command.inner_run of
>> >
>> >
>> > object at 0x100592e90>>
>> > Traceback (most recent call last):
>> >   File
>> >
>> 
>> "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py",
>>
>> > line 92, in inner_run
>> > self.validate(display_num_errors=True)
>> >   File
>> >
>> "/Library/Python/2.6/site-packages/django/core/management/base.py",
>>
>> > line 280, in validate
>> > num_errors = get_validation_errors(s, app)
>> >   File
>> >
>> 
>> "/Library/Python/2.6/site-packages/django/core/management/validation.py",
>>
>> > line 35, in get_validation_errors
>> > for (app_name, error) in get_app_errors().items():
>> >   File
>> >
>> "/Library/Python/2.6/site-packages/django/db/models/loading.py",
>> line
>> > 166, in get_app_errors
>> > self._populate()
>> >   File
>> >
>> "/Library/Python/2.6/site-packages/django/db/models/loading.py",
>> line
>> > 72, in _populate
>> > self.load_app(app_name, True)
>> >   File
>> >
>> "/Library/Python/2.6/site-packages/django/db/models/loading.py",
>> line
>> > 96, in load_app
>> > models = import_module('.models', app_name)
>> >   File
>> "/Library/Python/2.6/site-packages/django/utils/importlib.py",
>> > line 35, in import_module
>> > __import__(name)
>> >   File
>> >
>> "/Library/Python/2.6/site-packages/django/contrib/auth/models.py",
>>
>> > line 21, in 
>> > from django.contrib.contenttypes.models import ContentType
>> >   File
>> >
>> 
>> "/Library/Python/2.6/site-packages/django/contrib/contenttypes/models.py",
>>
>> > line 127, in 
>> > class ContentType(models.Model):
>> >   File
>> "/Library/Python/2.6/site-packages/django/db/models/base.py",
>> > line 97, in __new__
>> > new_class.add_to_class('_meta', Options(meta, **kwargs))
>> > TypeError: Error when calling the metaclass bases
>> > __init__() keywords must be strings
>>
>> Can you show us your models.py? There is an error in one of
>> your models.
>>
>> -- 
>> Kind regards
>> Michael
>>
>> Sinax Platform - Scalable Django hosting
>> http://www.sinaxplatform.com
>>
>>
> Did you already edit a models.py file in your application?
> According to the traceback you provided I think there is an error
> in one of your models. So you should send a models.py file.
>
> -- 
> Kind regards
> Michael
>
> Sinax Platform - Scalable Django hosting
> http://www.sinaxplatform.com
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  
It seems that I was too quick with my reply and the solution lies in
what Roberto posted in his reply.
Could you give us the result of the command:

  python --version

-- 
Kind regards
Michael

Sinax Platform - Scalable Django hosting
http://www.sinaxplatform.com



signature.asc
Description: OpenPGP digital signature


Re: Problem setting up django server

2013-06-18 Thread Michael Anckaert
On 18/06/13 17:37, smy28 wrote:
> Yes, I have attached the base.py file (which seems to be the one with
> the error, correct?)
>
> On Tuesday, June 18, 2013 11:11:52 AM UTC-4, Michael Anckaert wrote:
>
> On 18/06/13 17:00, smy28 wrote:
> > I just installed Django and I'm trying to initially set up the
> server,
> > as detailed in the 'Part 1' Tutorial. I haven't configured any
> > settings yet. Whenever I run the command "python manage.py
> runserver",
> > I get the following message:
> >
> >
> >
> > Validating models...
> >
> > Unhandled exception in thread started by  > Command.inner_run of
> >  > object at 0x100592e90>>
> > Traceback (most recent call last):
> >   File
> >
> 
> "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py",
>
> > line 92, in inner_run
> > self.validate(display_num_errors=True)
> >   File
> > "/Library/Python/2.6/site-packages/django/core/management/base.py",
> > line 280, in validate
> > num_errors = get_validation_errors(s, app)
> >   File
> >
> "/Library/Python/2.6/site-packages/django/core/management/validation.py",
>
> > line 35, in get_validation_errors
> > for (app_name, error) in get_app_errors().items():
> >   File
> > "/Library/Python/2.6/site-packages/django/db/models/loading.py",
> line
> > 166, in get_app_errors
> > self._populate()
> >   File
> > "/Library/Python/2.6/site-packages/django/db/models/loading.py",
> line
> > 72, in _populate
> > self.load_app(app_name, True)
> >   File
> > "/Library/Python/2.6/site-packages/django/db/models/loading.py",
> line
> > 96, in load_app
> > models = import_module('.models', app_name)
> >   File
> "/Library/Python/2.6/site-packages/django/utils/importlib.py",
> > line 35, in import_module
> > __import__(name)
> >   File
> > "/Library/Python/2.6/site-packages/django/contrib/auth/models.py",
> > line 21, in 
> > from django.contrib.contenttypes.models import ContentType
> >   File
> >
> "/Library/Python/2.6/site-packages/django/contrib/contenttypes/models.py",
>
> > line 127, in 
> > class ContentType(models.Model):
> >   File
> "/Library/Python/2.6/site-packages/django/db/models/base.py",
> > line 97, in __new__
> > new_class.add_to_class('_meta', Options(meta, **kwargs))
> > TypeError: Error when calling the metaclass bases
> > __init__() keywords must be strings
>
> Can you show us your models.py? There is an error in one of your
> models.
>
> -- 
> Kind regards
> Michael
>
> Sinax Platform - Scalable Django hosting
> http://www.sinaxplatform.com
>
>
Did you already edit a models.py file in your application?
According to the traceback you provided I think there is an error in one
of your models. So you should send a models.py file.

-- 
Kind regards
Michael

Sinax Platform - Scalable Django hosting
http://www.sinaxplatform.com



signature.asc
Description: OpenPGP digital signature


Re: Problem setting up django server

2013-06-18 Thread Michael Anckaert
On 18/06/13 17:00, smy28 wrote:
> I just installed Django and I'm trying to initially set up the server,
> as detailed in the 'Part 1' Tutorial. I haven't configured any
> settings yet. Whenever I run the command "python manage.py runserver",
> I get the following message:
>
>
>
> Validating models...
>
> Unhandled exception in thread started by  Command.inner_run of
>  object at 0x100592e90>>
> Traceback (most recent call last):
>   File
> "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py",
> line 92, in inner_run
> self.validate(display_num_errors=True)
>   File
> "/Library/Python/2.6/site-packages/django/core/management/base.py",
> line 280, in validate
> num_errors = get_validation_errors(s, app)
>   File
> "/Library/Python/2.6/site-packages/django/core/management/validation.py",
> line 35, in get_validation_errors
> for (app_name, error) in get_app_errors().items():
>   File
> "/Library/Python/2.6/site-packages/django/db/models/loading.py", line
> 166, in get_app_errors
> self._populate()
>   File
> "/Library/Python/2.6/site-packages/django/db/models/loading.py", line
> 72, in _populate
> self.load_app(app_name, True)
>   File
> "/Library/Python/2.6/site-packages/django/db/models/loading.py", line
> 96, in load_app
> models = import_module('.models', app_name)
>   File "/Library/Python/2.6/site-packages/django/utils/importlib.py",
> line 35, in import_module
> __import__(name)
>   File
> "/Library/Python/2.6/site-packages/django/contrib/auth/models.py",
> line 21, in 
> from django.contrib.contenttypes.models import ContentType
>   File
> "/Library/Python/2.6/site-packages/django/contrib/contenttypes/models.py",
> line 127, in 
> class ContentType(models.Model):
>   File "/Library/Python/2.6/site-packages/django/db/models/base.py",
> line 97, in __new__
> new_class.add_to_class('_meta', Options(meta, **kwargs))
> TypeError: Error when calling the metaclass bases
> __init__() keywords must be strings

Can you show us your models.py? There is an error in one of your models.

-- 
Kind regards
Michael

Sinax Platform - Scalable Django hosting
http://www.sinaxplatform.com




signature.asc
Description: OpenPGP digital signature


Looking for beta testers for new Django hosting

2013-05-23 Thread Michael Anckaert
Hello everyone

We are developing a new Python/wsgi hosting solution and are looking for
beta testers.
The solution we are developing will focus on ease of deployment (git
integration, management of application versions, ...)

Beta testers will receive a free instance on our platform. Don't expect a
stable or production ready environment. Your (testing) projects will live a
bleeding edge fast changing environment!

We would very much appreciate you help in developing this new product. You
can expect to work closely with our developers and your input will be used
in further defining our roadmap.
If you would like to help us out, please send an email to
platform@sinax.bewith some info about you. Ideas about what a good
hosting solution should
have are also very much appreciated.

*Kind regards*

Michael Anckaert
michael.ancka...@sinax.be
http://www.sinax.be

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




Re: General Apache Deploy Strategy

2013-04-03 Thread Michael Anckaert
The fact that you have to copy over the entire project directory (including 
docs) shouldn't be an issue. If your application deployment is correctly 
the user won't be able to access anything that isn't in your root 
urlconfig. 
If the issue is upload size you should be able to find benefit using rsync 
(or a similar tool) to copy over only changed files. 

Op dinsdag 2 april 2013 16:04:14 UTC+2 schreef fred het volgende:
>
>  We use django for intranet applications.  There is minimal coupling 
> between applications and we generally dedicate a virtual server for each 
> application.  Perhaps not the most efficient, but it works for our 
> environment.
>
>  
>
> In django 1.3 I just copied the “site” directory to the deploy location 
> and since the app directory was below that, it was a simple deploy.
>
>  
>
> With the revised directory structure of 1.4/1.5  I would need to copy the 
> project root directory to the production server when deploying.  That’s 
> acceptable, except that I prefer to create a “docs” directory under the 
> project to hold any specifications, critical instructions, etc and there is 
> no need to deploy this, nor would I want to make it accessible to our user 
> base.  Also I frequently work remotely on a wireless connection and copying 
> unnecessary files is a pain.
>
>  
>
> It’s not that I can’t live with copying the project in its entirety, but 
> is there a better, more django-esque way?
>
>  
>
> Thanks,
>
>  
>
> Fred.
>  

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




Authentication backends

2012-12-16 Thread Michael Anckaert
Hello everyone

On my current project I need a mix of builtin Django authentication and
oAuth2 sources. But when writing a custom authentication backend, when does
it get used? The docs say:

"""Once a user has authenticated, Django stores which backend was used to
authenticate the user in the user's session, and re-uses the same backend
for the duration of that session whenever access to the currently
authenticated user is needed."""

The code of ModelBackend only seems to deal with permissions. Assuming an
oAuth2 source deals with authentication my backend should only handle
permission checks?

Thanks for taking the time to answer this.

Kind regards
Michael

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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.



Prefix primary key

2009-09-22 Thread Michael Anckaert

Hello everyone,

I'm sure this is something that has been done before, I just can't
figure out (or google) how to do it.

I want to create PK's on a model that are in the form of 2009001,
2009002, 2009003, etc. Simple creating a model method that appends the
year is not an option because I need models from 2010 to start with
2010001, 2010002, etc.

Is there an elegant automatic solution or am I stuck with manually
creating the PK?

Kind regards,
Michael
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-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: Subclassing CharField

2009-07-30 Thread Michael Anckaert

Just a simple

class MyCharField(forms.CharField):
 pass

to start out

On Jul 30, 11:12 pm, Xiong Chiamiov  wrote:
> On Jul 30, 7:27 am, Michael Anckaert 
> wrote:
>
> > Hello everyone,
>
> > I subclassed the CharField but have run into this problem:
>
> How did you subclass CharField?  It's difficult to say what the
> problem is without seeing what you've done.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Subclassing CharField

2009-07-30 Thread Michael Anckaert
Hello everyone,

I subclassed the CharField but have run into this problem:

In the form HTML output, the label is ok (it used the verbose_name of the
model field as expected), but the form validation error message uses 'None'
as the field name/label. Appearantly it doesn't know the fields verbose
name. When using the standard Django CharField everything is fine.

When I set the field label explicitly in my code (label='Name'), both label
and form validation use the correct label.

I don't think this expected behaviour?

Kind regards,
Michael Anckaert

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