Re: Profiling tools?

2012-10-22 Thread Larry Martell
On Sunday, October 21, 2012, zweb wrote:

>
> I am using Django 1.3.1
>
> I want to know in my application how much time is taken by a) database
> access b) creation of XML c) other parts of code. What would be some good
> tools to profile my application?
>
> The code to be profiled is in django view and uses Django ORM and Python
> 2.6 and lxml to generate XML. It is called from AJAX request and returns
> XML.
> 3
> Please recommend both open source and commercial tools.
>
> I don't know of this will meet your needs or not but I used the Navigation
Timing package (html5rocks.com/en/tutorials/webperformance/basics/) to
measure things like network latency and page render time. For database
level timing I did that myself from within my app.

HTH

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



Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-22 Thread Louise OTT

>
> In [10]: run1= Run(project=Project.objects.get(pk=1), 
> sequencing_type=SequencingType.objects.get(pk=1))


> In [11]: run1.save()


> In [12]: Run.objects.all()

Out[12]: []


> In [13]: s1=RunHasSample(run=run1, sample=Sample.objects.get(pk=1), 
> dna_quantification_ng_per_ul=1)


> In [14]: s1.save()

 
In [30]: s1.lines.add(Line.objects.get(id=1), Line.objects.get(id=2))

In [31]: s1.save()


Yes, I added the lines to the wrong table :)
Now it is working in the shell. I'll try to use 
this
 to 
make this work too in the admin.py interface.

I keep you posted, thanks for your help !


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



Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-22 Thread Louise OTT
Ok, it is still not working. 
Django can't find the intermediate table.

And I can't put an "inlines" into an "inlines" ! My RunHasSample are 
already in a field "inlines" in the RunAdmin, so I cannot put the lines in 
an "inlines" field into the class RunHasSamplesInLine


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/c9vDPXyGIMIJ.
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: querying data from Django userena profile.

2012-10-22 Thread Subhodip Biswas
Hi all,

I have done a workaround the initial problem, all i did was add the
custom field into my apps models.py. This led to the data entered in
the custom field of signup form is shown in the edit_details page of
the user profile. However, unlike other data fields in edit_profile,
this custom field is not visible in view profile page.

Can anybody explain why is this happening and any workaround for this?
-
Regards
Subhodip Biswas


GPG key : FAEA34AB
Server : pgp.mit.edu
http://subhodipbiswas.wordpress.com
http:/www.fedoraproject.org/wiki/SubhodipBiswas

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



Struggling with static files

2012-10-22 Thread DJ-Tom
Hi,

I'm fairly new with Django and currently I'm only "playing around" to get a 
better feeling for the framework.

I have read the documentation and almost all of the posts here about 
configuring static files with the development server but can't get it 
working.

I wanted to modify the admin login screen to show a company logo, so I 
copied base_site.html to /templates/admin/ and added this:

   


This is how my directory structure looks like:

el_test
  el_test
static
   logo.gif
settings.py
urls.py
  templates
admin
  base_site.html

- Settings.py:

STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)

I also added the following to urls.py

   urlpatterns += staticfiles_urlpatterns()

The HTML in the admin logon screen looks like this, so basically the URL 
seems to be OK


  
  Test Admin


Calling http://localhost:8000/static/logo.gif directly shows a 404 error.

As far as I have understood this should work with the dev server and 
debug=true without calling collectstatic

I have also tried moving the /static/ folder around various locations below 
the project directory... 

I'm sure there is only some small thing missing...

Any help is highly appreciated :-)

Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/YqVkguDtVwEJ.
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: Struggling with static files

2012-10-22 Thread Pervez Mulla
Give path to your STATIC_ROOT of your static folder.


Pervez

On Mon, Oct 22, 2012 at 2:26 PM, DJ-Tom  wrote:

> Hi,
>
> I'm fairly new with Django and currently I'm only "playing around" to get
> a better feeling for the framework.
>
> I have read the documentation and almost all of the posts here about
> configuring static files with the development server but can't get it
> working.
>
> I wanted to modify the admin login screen to show a company logo, so I
> copied base_site.html to /templates/admin/ and added this:
>
>
>
>
> This is how my directory structure looks like:
>
> el_test
>   el_test
> static
>logo.gif
> settings.py
> urls.py
>   templates
> admin
>   base_site.html
>
> - Settings.py:
>
> STATIC_ROOT = ''
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> )
> STATICFILES_FINDERS = (
> 'django.contrib.staticfiles.finders.FileSystemFinder',
> 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> )
>
> I also added the following to urls.py
>
>urlpatterns += staticfiles_urlpatterns()
>
> The HTML in the admin logon screen looks like this, so basically the URL
> seems to be OK
>
> 
>   
>   Test Admin
> 
>
> Calling http://localhost:8000/static/logo.gif directly shows a 404 error.
>
> As far as I have understood this should work with the dev server and
> debug=true without calling collectstatic
>
> I have also tried moving the /static/ folder around various locations
> below the project directory...
>
> I'm sure there is only some small thing missing...
>
> Any help is highly appreciated :-)
>
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/YqVkguDtVwEJ.
> 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: Struggling with static files

2012-10-22 Thread Xavier Ordoquy
Hi,

Your static folder should be declared in STATICFILES_DIRS if you want him to be 
served (see 
https://docs.djangoproject.com/en/1.4/howto/static-files/#basic-usage about 
that).

Please take care to give another name to STATIC_ROOT for production settings.

Regards,
Xavier Ordoquy,
Linovia.


Le 22 oct. 2012 à 10:56, DJ-Tom  a écrit :

> Hi,
> 
> I'm fairly new with Django and currently I'm only "playing around" to get a 
> better feeling for the framework.
> 
> I have read the documentation and almost all of the posts here about 
> configuring static files with the development server but can't get it working.
> 
> I wanted to modify the admin login screen to show a company logo, so I copied 
> base_site.html to /templates/admin/ and added this:
> 
>
> 
> 
> This is how my directory structure looks like:
> 
> el_test
>   el_test
> static
>logo.gif
> settings.py
> urls.py
>   templates
> admin
>   base_site.html
> 
> - Settings.py:
> 
> STATIC_ROOT = ''
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> )
> STATICFILES_FINDERS = (
> 'django.contrib.staticfiles.finders.FileSystemFinder',
> 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> )
> 
> I also added the following to urls.py
> 
>urlpatterns += staticfiles_urlpatterns()
> 
> The HTML in the admin logon screen looks like this, so basically the URL 
> seems to be OK
> 
> 
>   
>   Test Admin
> 
> 
> Calling http://localhost:8000/static/logo.gif directly shows a 404 error.
> 
> As far as I have understood this should work with the dev server and 
> debug=true without calling collectstatic
> 
> I have also tried moving the /static/ folder around various locations below 
> the project directory... 
> 
> I'm sure there is only some small thing missing...
> 
> Any help is highly appreciated :-)
> 
> Thomas
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/YqVkguDtVwEJ.
> 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: Struggling with static files

2012-10-22 Thread Pervez Mulla
something like this in your setting.py

STATIC_ROOT = ''/home/john/yourprojectdir/yourappdir/staic/"



On Mon, Oct 22, 2012 at 2:48 PM, Xavier Ordoquy wrote:

> Hi,
>
> Your static folder should be declared in STATICFILES_DIRS if you want him
> to be served (see
> https://docs.djangoproject.com/en/1.4/howto/static-files/#basic-usage about
> that).
>
> Please take care to give another name to STATIC_ROOT for production
> settings.
>
> Regards,
> Xavier Ordoquy,
> Linovia.
>
>
> Le 22 oct. 2012 à 10:56, DJ-Tom  a écrit :
>
> Hi,
>
> I'm fairly new with Django and currently I'm only "playing around" to get
> a better feeling for the framework.
>
> I have read the documentation and almost all of the posts here about
> configuring static files with the development server but can't get it
> working.
>
> I wanted to modify the admin login screen to show a company logo, so I
> copied base_site.html to /templates/admin/ and added this:
>
>
>
>
> This is how my directory structure looks like:
>
> el_test
>   el_test
> static
>logo.gif
> settings.py
> urls.py
>   templates
> admin
>   base_site.html
>
> - Settings.py:
>
> STATIC_ROOT = ''
> STATIC_URL = '/static/'
> STATICFILES_DIRS = (
> )
> STATICFILES_FINDERS = (
> 'django.contrib.staticfiles.finders.FileSystemFinder',
> 'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> )
>
> I also added the following to urls.py
>
>urlpatterns += staticfiles_urlpatterns()
>
> The HTML in the admin logon screen looks like this, so basically the URL
> seems to be OK
>
> 
>   
>   Test Admin
> 
>
> Calling http://localhost:8000/static/logo.gif directly shows a 404 error.
>
> As far as I have understood this should work with the dev server and
> debug=true without calling collectstatic
>
> I have also tried moving the /static/ folder around various locations
> below the project directory...
>
> I'm sure there is only some small thing missing...
>
> Any help is highly appreciated :-)
>
> Thomas
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/YqVkguDtVwEJ.
> 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.
>

-- 
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: Struggling with static files

2012-10-22 Thread Xavier Ordoquy

Le 22 oct. 2012 à 11:25, Pervez Mulla  a écrit :

> something like this in your setting.py
> 
> STATIC_ROOT = ''/home/john/yourprojectdir/yourappdir/staic/"

This is precisely what you shouldn't do.
The STATIC_ROOT is where files are copied to for production using the 
collectstatic command.
This is not for development and this is not where you should store your 
project's static files.

Regards,
Xavier Ordoquy,
Linovia.

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

2012-10-22 Thread Jani Tiainen

19.10.2012 7:07, Sun Simon kirjoitti:

https://www.djangoproject.com/download/

I am installing Django for Python on Win XP and came across this problem
during installation:

|tar xzvf Django-1.4.2.tar.gz
cd Django-1.4.2
sudo python setup.py install


What does "cd" mean? DOes it mean that I have to use command line to type it?
|


--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/RmTilhDq4WIJ.
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.


And if you want to go through slightly more complex setup than provided 
here and use virtualenv I wrote short tutorial as well:


http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

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



My page cound not load image, help!

2012-10-22 Thread Dae James
The returned html code by my app is :  
The "image.jpg" file is in "project_dir/photos/" directory. PS: project_dir is 
my django project's root directory.

So why the image could not be loaded. Please help~
Thank you~




Dae James

-- 
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: Struggling with static files

2012-10-22 Thread DJ-Tom


Am Montag, 22. Oktober 2012 11:19:42 UTC+2 schrieb Xavier Ordoquy:
>
> Hi,
>
> Your static folder should be declared in STATICFILES_DIRS if you want him 
> to be served (see 
> https://docs.djangoproject.com/en/1.4/howto/static-files/#basic-usage about 
> that).
>
>  
>

All the documentation refers to  STATICFILES_DIRS as "this is where tu put 
additional paths" with INSTALLED_APPS/static being the default path. 

If I add this to STATICFILES_DIR:

  '/el_test/static'

...the admin page login completely loses any styling because it can't serve 
the admin css files anymore
(the url's are http://localhost:8000/static/admin/css/login.css and 
http://localhost:8000/static/admin/css/base.css)

So either the documentation is wrong or I understand the word "additional" 
in a different way as the author of the documentation... 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/_wR4nh2TKjYJ.
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: Struggling with static files

2012-10-22 Thread DJ-Tom


Am Montag, 22. Oktober 2012 12:06:44 UTC+2 schrieb DJ-Tom:
>
> If I add this to STATICFILES_DIR:
>
>   '/el_test/static'
>
>
AHHH - I was missing the trailing comma after the path name... so 
STATICFILES_DIR was not a valid list.

Everthing's fine now.

Thanks anyways :-)
Thomas

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/XgCWsaAhaqoJ.
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.



Gunicorn vs Chaussette vs Meinheld

2012-10-22 Thread Santiago Basulto
Hello people. Reading about Circus[1] I ran into a couple of different 
"WSGI servers" that I haven't heard before (Chaussette[2] and Meinheld[3]). 
My question is if those are all similar to Gunicorn (and can be used 
instead of the last) or are just complementary servers.


One thing that really confuses me is this:

Meinheld claims that you can use it with Gunicorn. 

>gunicorn --workers=2 --worker-class="egg:meinheld#gunicorn_worker" 
gunicorn_test:app

And Chaussette claims that you can use Meinheld as the backend.

This is really confusing. What's the advantages of one over the other? I'm 
using Gunicorn right now and works pretty well. Have you used any of the 
others?

[1]: http://circus.readthedocs.org/en/0.5.2.1/
[2]: http://chaussette.readthedocs.org/en/0.4/
[3]: http://meinheld.org/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/qp6ch8XpDmAJ.
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: My page cound not load image, help!

2012-10-22 Thread Joel Goldstick
On Mon, Oct 22, 2012 at 6:00 AM, Dae James  wrote:
> The returned html code by my app is : 
> The "image.jpg" file is in "project_dir/photos/" directory. PS: project_dir
> is my django project's root directory.
>
> So why the image could not be loaded. Please help~
> Thank you~
>
Because your image is not in the directory  that your html file shows.
 Go to the django documentation and try to understand static files.

> 
> Dae James

-- 
Joel Goldstick

-- 
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: Gunicorn vs Chaussette vs Meinheld

2012-10-22 Thread Tarek Ziadé
Oh sorry, that was the other way around - I was getting confused too :)

Meinheld can act as a worker in gunicorn, and in this case you don't use 
the meinheld web server but just its nice async features like gevent
Meinheld also provide a built-in wsgi server, that is used in Chaussette 
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/71oiuAYqqtsJ.
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: Gunicorn vs Chaussette vs Meinheld

2012-10-22 Thread Tarek Ziadé
On Monday, October 22, 2012 1:09:56 PM UTC+2, Santiago Basulto wrote:
>
> Hello people. Reading about Circus[1] I ran into a couple of different 
> "WSGI servers" that I haven't heard before (Chaussette[2] and Meinheld[3]). 
> My question is if those are all similar to Gunicorn (and can be used 
> instead of the last) or are just complementary servers.
>
>
> One thing that really confuses me is this:
>
> Meinheld claims that you can use it with Gunicorn. 
>
> >gunicorn --workers=2 --worker-class="egg:meinheld#gunicorn_worker" 
> gunicorn_test:app
>
> And Chaussette claims that you can use Meinheld as the backend.
>
> This is really confusing. What's the advantages of one over the other? I'm 
> using Gunicorn right now and works pretty well. Have you used any of the 
> others?
>
> [1]: http://circus.readthedocs.org/en/0.5.2.1/
> [2]: http://chaussette.readthedocs.org/en/0.4/
> [3]: http://meinheld.org/
>


tl;dr: with Circus and Chaussette you get a nice process management tool 
where you can manage all your processes in a single place (web 
workers,celery, redis, rabbit, elastic search etc..)

long story:  Circus is able to bind the sockets and share them with the 
processes it manages.  The advantage is that you remove one layer of 
process management

In a classical stack, if you have Gunicorn running 5 workers, and let's say 
- one celeryd and one redis running, you end up with 2 layers of process 
managers: the one you use to manage gunicorn, redis and celeryd -- and 
gunicorn that manages its 5 workers.  You end up not being able to interact 
with your web workers the same way you'd do with your other processes in 
your stack.

using Circus, you can have a single layer of processes management.  More 
explanations here: 
http://circus.readthedocs.org/en/0.5.2.1/sockets/#circus-stack-v-s-classical-stack

As for Meinheld, it can act as a standalone wsgi web server, like uWsgi for 
instance - and Chaussette offers it as a backend. And it also happens to 
allow you to bind gunicorn - which in my opinion does not make much sense 
since it's already a wsgi server.

Cheers
Tarek






 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/IYcPGsXy8WYJ.
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.



In future can we expect things like Annotation based urls , validation , manytomany relationships etc in django like in symfony2 and hibernate

2012-10-22 Thread Pasha
I 

Initially i was using Symfony1.4 framework and i didn't liked that much but 
was good. Then when Symfony2 came i never looked back at other php 
framework with things like annotation , service classes , repository 
classes , it almost similar to Spring/Hibernate of java at enterprise level.

Now i am doing Django. But i see that Django can't beat Symfony2. The 
service classes, DI container , Annotation based routes , validations etc 
excellent to use when you get your head around.

Spring/Hibernate also doing similar way.

So is there any possibility in some djago ver2 that they can think about 
those things. I don't think it will hard if it can be done in PHP why can't 
in Pythonn

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/SZj5z-zkCCcJ.
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: My page cound not load image, help!

2012-10-22 Thread Amyth Arora
Serve the image as a static file. in your settings.py file set the
following:

STATIC_URL = '/static/'
STATICFILES_DIRS = ('/path/to/your/image/directory',) # Without a trailing
slash

and then load your image as 


On Mon, Oct 22, 2012 at 5:14 PM, Joel Goldstick wrote:

> On Mon, Oct 22, 2012 at 6:00 AM, Dae James  wrote:
> > The returned html code by my app is : 
> > The "image.jpg" file is in "project_dir/photos/" directory. PS:
> project_dir
> > is my django project's root directory.
> >
> > So why the image could not be loaded. Please help~
> > Thank you~
> >
> Because your image is not in the directory  that your html file shows.
>  Go to the django documentation and try to understand static files.
>
> > 
> > Dae James
>
> --
> Joel Goldstick
>
> --
> 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.
>
>


-- 
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @mytharora
http://techstricks.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: My page cound not load image, help!

2012-10-22 Thread Dae_James
I use *ImageField*(with upload_to = 'photos') to receive user-uploaded 
images. And in my template, I want to use **(image is the object of ImageField) to display them. However, images 
can't be displayed. I think it's not about static files. If it is, what's 
the use of ImageField's url property.

在 2012年10月22日星期一UTC+8下午7时46分04秒,Joel Goldstick写道:
>
> On Mon, Oct 22, 2012 at 6:00 AM, Dae James > 
> wrote: 
> > The returned html code by my app is :  
> > The "image.jpg" file is in "project_dir/photos/" directory. PS: 
> project_dir 
> > is my django project's root directory. 
> > 
> > So why the image could not be loaded. Please help~ 
> > Thank you~ 
> > 
> Because your image is not in the directory  that your html file shows. 
>  Go to the django documentation and try to understand static files. 
>
> >  
> > Dae James 
>
> -- 
> Joel Goldstick 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/BzSpYKaphFcJ.
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: My page cound not load image, help!

2012-10-22 Thread Xavier Ordoquy

Le 22 oct. 2012 à 15:13, Dae_James  a écrit :

> I use ImageField(with upload_to = 'photos') to receive user-uploaded images. 
> And in my template, I want to use (image 
> is the object of ImageField) to display them. However, images can't be 
> displayed. I think it's not about static files. If it is, what's the use of 
> ImageField's url property.

Moreover, images will relate to the MEDIA_*

Static are really meant to be static, ie they won't change as long as you don't 
update your project/applications.
Media are where other files should go. Whether they are uploaded user documents 
or application generated ones, they should go there.

For moreinformation have a look there:
https://docs.djangoproject.com/en/1.4/ref/models/fields/#django.db.models.FileField
And especially the part after: "Using a FileField or an ImageField (see below) 
in a model takes a few steps:"

Regards,
Xavier Ordoquy,
Linovia.

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



Only one profile type of multiple user profiles types gets created.

2012-10-22 Thread Nicolas Emiliani
Hi!

I'm trying to use different types of profiles on django 1.4, I basically
followed this :

https://docs.djangoproject.com/en/dev/topics/auth/#storing-additional-information-about-users

The thing is that the docs only apply if you have one profile type, and i
have four. Doing
some research i found that setting a base profile and inheriting from it
you can can get multiple
profile types. So this is what I did :

class HomesUserProfile(models.Model):
user = models.OneToOneField(User)

class AgentProfile(HomesUserProfile):
homes_user = models.OneToOneField(HomesUserProfile)
agency = models.ForeignKey(Agency, verbose_name='Agencia')
branch = models.ForeignKey(Branch, verbose_name='Sucursal')

class AuditorProfile(HomesUserProfile):
homes_user = models.OneToOneField(HomesUserProfile)
agency = models.ForeignKey(Agency, verbose_name='Agencia')

and then :

AUTH_PROFILE_MODULE = 'homes.HomesUserProfile'

class UserAdmin(contrib_auth.UserAdmin):
inlines=(AgentProfileInline, AuditorProfileInline)

The thing is that now the only profile that ever gets created when creating
a  user
is AgentProfile. I can't get it to create an AuditorProfile not even by
setting the agency
field on the form.

Any ideas what is going on? I'm clueless

Thanks!

-- 
Nicolas Emiliani

Lo unico instantaneo en la vida es el cafe, y es bien feo.

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



ImportError on apache server

2012-10-22 Thread Dae_James
When I run my website on apache, the error as the following picture shows 
happened. However, when I run it on development server, the error doesn't 
happened.



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



Re: Adding values in my database via a ManyToMany relationship represented in admin.py

2012-10-22 Thread Louise OTT


I found where the problem is...

It is not a problem in the ManyToManyField but in the intermediate table. 
Django refused that my intermediate table doesn't have an unique id !

So, in the sql which created django, it created automatically an unique id 
named "id", but in my database I didn't create one (because the couple of 
two foreign key is usually enough).

Next time, I'll be more carefull.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/JapIfF9CQZYJ.
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.



Raising a ValidationError in a custom field's to_python method?

2012-10-22 Thread Nicolas Dandrimont
Hello,

I'm trying to write a custom field for use with the netaddr.EUI python
class (which allows manipulations on MAC Addresses, access to the OUI
database, and other fancy stuff).

To do so, I'm subclassing model.Field, and overriding the to_python and
get_prep_value methods. The class instantiation in to_python can raise
an exception when the format is wrong. I catch this exception and
re-raise a ValidationError.

Unfortunately, when doing a form validation, this ValidationError throws
an error 500 instead of pretty-printing the message in the form. Am I
doing something wrong?

See the relevant snippets below:

#--8<{ fields.py }>8--#
import netaddr
 
from django.core.exceptions import ValidationError
from django.db import models
 
#[...]

class MACAddressField(models.Field):

description = "A MAC Address"

__metaclass__ = models.SubfieldBase

def __init__(self, *args, **kwargs):
kwargs['max_length'] = 12
super(MACAddressField, self).__init__(*args, **kwargs)

def to_python(self, value):
if not isinstance(value, netaddr.EUI):
try:
value = netaddr.EUI(value)
except netaddr.AddrFormatError as e:
raise FormValidationError("Adresse MAC invalide: %s" % 
repr(value))

return value

def get_prep_value(self, value):
if isinstance(value, netaddr.EUI):
value.dialect = netaddr.strategy.eui48.mac_bare
value = '%s' % value
return unicode(value)

#--8<{ models.py }>8--#
 
# [...]

class Machine(models.Model):
"""Une machine"""
proprietaire = models.ForeignKey(User)
batiment = models.ForeignKey(Batiment)
nom = models.CharField(max_length=64)
ip = fields.IPAddressField()
mac = fields.MACAddressField()
creation = models.DateTimeField(default=timezone.now)
expiration = models.DateTimeField(default=lambda: timezone.now() + 
datetime.timedelta(days=90))

@classmethod
def validmachines(cls):
"""Machines valides actuellement"""
return cls.objects.filter(expiration__gte=timezone.now())

def clean(self):
"""Validation du modèle"""
# Validation Nom de machine
nom = self.nom.lower()
if not re.match(r"^[a-z0-9][a-z0-9-]{,63}$", nom):
raise ValidationError(u"Le nom de machine ne peut contenir que des 
caractères alphanumériques et des tirets")
same_name = self.validmachines().filter(nom=nom)
if self.pk:
same_name = same_name.exclude(pk=self.pk)
if same_name:
raise ValidationError(u"Nom de machine déjà utilisé")
self.nom = nom

# Validation adresse IP
if self.ip:
for net in Subnet.objects.filter(batiment = self.batiment).all():
if self.ip in net.net:
break
else:
raise ValidationError(u"Adresse IP hors des réseaux du 
bâtiment")

same_ip = self.validmachines().filter(ip=self.ip)
if self.pk:
same_ip = same_ip.exclude(pk=self.pk)
if same_ip:
raise ValidationError(u"Adresse IP en cours d'utilisation")

def __unicode__(self):
expire = u""
if self.expiration <= timezone.now():
expire = u", expire"
return u"" % (self.nom, self.ip, expire)

#--8<>8--#

Thanks in advance for any hints,
-- 
Nicolas Dandrimont

BOFH excuse #302:
microelectronic Riemannian curved-space fault in write-only file system

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



Getting a strange error message when setting mysql database

2012-10-22 Thread alfa
Hi,

After setting the following: 

'ENGINE': 'django.db.backends.mysql', # postgresql_psycopg2', 
'mysql', 'sqlite3' or 'oracle'.
'NAME': 'testdb',  # Or path to database file 
if using sqlite3.
'USER': 'testuser',  # Not used with sqlite3.
'PASSWORD': 'x',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for 
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for default. 
Not used with sqlite3.

I got the following error:


Unhandled exception in thread started by >
Traceback (most recent call last):
  File 
"/usr/local/lib/python2.6/dist-packages/django/core/management/commands/runserver.py",
 
line 91, in inner_run
self.validate(display_num_errors=True)
  File 
"/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", 
line 266, in validate
num_errors = get_validation_errors(s, app)
  File 
"/usr/local/lib/python2.6/dist-packages/django/core/management/validation.py", 
line 103, in get_validation_errors
connection.validation.validate_field(e, opts, f)
  File 
"/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/validation.py",
 
line 14, in validate_field
db_version = self.connection.get_server_version()
  File 
"/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", 
line 415, in get_server_version
self.cursor().close()
  File 
"/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", 
line 306, in cursor
cursor = self.make_debug_cursor(self._cursor())
  File 
"/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", 
line 387, in _cursor
self.connection = Database.connect(**kwargs)
  File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, in 
Connect
return Connection(*args, **kwargs)
  File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in 
__init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 
'testuser'@'localhost' (using password: YES)")


What is the culprit? 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kD-4PM-BDJIJ.
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: Raising a ValidationError in a custom field's to_python method?

2012-10-22 Thread Nicolas Dandrimont

On lun., oct. 22 2012, Nicolas Dandrimont wrote:
> #--8<{ fields.py }>8--#
> import netaddr
>  
> from django.core.exceptions import ValidationError
> from django.db import models
>  
> [...]
> def to_python(self, value):
> if not isinstance(value, netaddr.EUI):
> try:
> value = netaddr.EUI(value)
> except netaddr.AddrFormatError as e:
> raise FormValidationError("Adresse MAC invalide: %s" % 
> repr(value))
^^^
Oh, well, this is a typo and should read ValidationError...

Cheers,
-- 
Nicolas Dandrimont

BOFH excuse #62:
need to wrap system in aluminum foil to fix 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.



Re: Django Tutorial Equivalent to Ruby on Rails Tutorial by Michael Hartl

2012-10-22 Thread Tommy DANGerous
Thanks everyone for the help. I've gone through several tutorials, such as 
the one on the Django website and at http://lightbird.net/dbe/. Just trying 
to get more familiar with Django before I start trying to write it on my 
own. I'll take a look at the Django Book and the youtube videos you all 
posted. Thank you for all the help!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Q8yrG7g-ny0J.
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: Getting a strange error message when setting mysql database

2012-10-22 Thread alfa
I've just figured out that the password set was wrong. I previously passed 
as the root one, which was wrong. Now, it worked out of the box.


On Monday, October 22, 2012 3:35:44 PM UTC+2, alfa wrote:
>
> Hi,
>
> After setting the following: 
>
> 'ENGINE': 'django.db.backends.mysql', # postgresql_psycopg2', 
> 'mysql', 'sqlite3' or 'oracle'.
> 'NAME': 'testdb',  # Or path to database file 
> if using sqlite3.
> 'USER': 'testuser',  # Not used with sqlite3.
> 'PASSWORD': 'x',  # Not used with sqlite3.
> 'HOST': '',  # Set to empty string for 
> localhost. Not used with sqlite3.
> 'PORT': '',  # Set to empty string for 
> default. Not used with sqlite3.
>
> I got the following error:
>
>
> Unhandled exception in thread started by  of  at 0x2580710>>
> Traceback (most recent call last):
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/core/management/commands/runserver.py",
>  
> line 91, in inner_run
> self.validate(display_num_errors=True)
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/core/management/base.py", 
> line 266, in validate
> num_errors = get_validation_errors(s, app)
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/core/management/validation.py",
>  
> line 103, in get_validation_errors
> connection.validation.validate_field(e, opts, f)
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/validation.py",
>  
> line 14, in validate_field
> db_version = self.connection.get_server_version()
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", 
> line 415, in get_server_version
> self.cursor().close()
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", 
> line 306, in cursor
> cursor = self.make_debug_cursor(self._cursor())
>   File 
> "/usr/local/lib/python2.6/dist-packages/django/db/backends/mysql/base.py", 
> line 387, in _cursor
> self.connection = Database.connect(**kwargs)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/__init__.py", line 81, in 
> Connect
> return Connection(*args, **kwargs)
>   File "/usr/lib/pymodules/python2.6/MySQLdb/connections.py", line 170, in 
> __init__
> super(Connection, self).__init__(*args, **kwargs2)
> _mysql_exceptions.OperationalError: (1045, "Access denied for user 
> 'testuser'@'localhost' (using password: YES)")
>
>
> What is the culprit? 
>

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



django doesnt accept the serializeArray POST data

2012-10-22 Thread David Lee
Hi,all!  I got a problem, 
https://github.com/blueimp/jQuery-File-Upload/issues/1792 , does Django 
doesnt accept the serializeArray POST 
data request or how to do it ? any help will greatly appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/kg6mLqbeYeAJ.
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: Profiling tools?

2012-10-22 Thread Nikolas Stevenson-Molnar
I recommend django-debug-toolbar:
https://github.com/django-debug-toolbar/django-debug-toolbar

_Nik

On 10/21/2012 7:25 PM, zweb wrote:
>
> I am using Django 1.3.1
>
> I want to know in my application how much time is taken by a) database
> access b) creation of XML c) other parts of code. What would be some
> good tools to profile my application?
>
> The code to be profiled is in django view and uses Django ORM and
> Python 2.6 and lxml to generate XML. It is called from AJAX request
> and returns XML.
>
> Please recommend both open source and commercial tools.
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/BuahWkG90JkJ.
> 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.



FormWizard for shop checkout

2012-10-22 Thread KentH
Hi,

I'm trying to use FormWizard for an e-checkout application. Trying to 
perform the actual "charge" in the "done" step is problematic as you can't 
go back if the charge fails.

Is there a right way to do this?

For example of what steps look like, just imagine the steps as listed in 
the FormWizard documentation with the charging in the "done" step.

Thanks for any pointers.

Kent

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/_F74uD-Ks3EJ.
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 doesnt accept the serializeArray POST data

2012-10-22 Thread Doug Ballance
I'm guessing it is a result of not having a csrf token set for the
post:

https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ajax

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



strange problem with dajaxice and javascript

2012-10-22 Thread cingusoft
hi all

i have a javascript callback function that return a data json string from a 
dajaxice view

this is the callback function

function message_callback(data){
alert(data.id);
var id_book = data.id;
var uploader = $('#uploader').pluploadQueue({
url : 
'/admin/ecommerce/books/images/upload/'+id_book.toString()+'/'
});
...

the aleet return the correct id number
but the url is : /admin/ecommerce/books/images/upload/undefined

have someting wrong?
sorry if you think this is a stupid question but i have lost a lot of time 
googleing this problem without any result

have a nice day

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/EWOvfUBXKnAJ.
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: invalid literal for int() with base 10

2012-10-22 Thread Nathan Knight
Just so you know, it is bad practice to use "import * " when importing 
modules in python.
With many modules being used, you can run into conflicting definitions. 
Plus, it increases overhead - potentially an exponential decrease in 
performance! 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/rIiEjKPOpX8J.
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.



environment variable DJANGO_SETTINGS_MODULE is undefined.

2012-10-22 Thread DjgoNy
I have problem importing from  django_tables import tables
and when i do it on manage.py shell i get this error.

>>> import django_tables2
Traceback (most recent call last):
  File "", line 1, in 
  File "build\bdist.win32\egg\django_tables2\__init__.py", line 3, in 

  File "build\bdist.win32\egg\django_tables2\tables.py", line 4, in 
  File "c:\Python27\lib\site-packages\django\db\__init__.py", line 11, in 

if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "c:\Python27\lib\site-packages\django\utils\functional.py", line 
184, in inner
self._setup()
  File "c:\Python27\lib\site-packages\django\conf\__init__.py", line 40, in 
_setup
raise ImportError("Settings cannot be imported, because environment 
variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable 
DJANGO_SETTINGS_MODULE is undefined.
>>>

how do i fix it.
what am i missing here
thank you so much.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/e3UHoYJI0KsJ.
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: urls.py and default values...

2012-10-22 Thread Lachlan Musicman
On Mon, Oct 22, 2012 at 5:39 PM, Tomas Ehrlich  wrote:
> Hello,
> you need to make 'year' argument optional:
>
> def student_reports(request, year=None):
> year = year or datetime.date.today().year
> ...

Perfect - thanks



>
> Another option could be passing extra option to you view function:
> https://docs.djangoproject.com/en/1.4/topics/http/urls/#passing-extra-options-to-view-functions
>
>
> Cheers,
>  Tom
>
> Dne Mon, 22 Oct 2012 15:24:51 +1200
> Lachlan Musicman  napsal(a):
>
>> Hola,
>>
>> I have data across multiple years.
>>
>> I want to run reports on a per year basis, so I have in my urls:
>> url(r'^students/reports/(?P\d{4})/$', student_reports,
>> name='student_reports'),
>>
>> etc.
>>
>> What I want to know though, is how to have this in the urls:
>> url(r'^students/reports/$', student_reports, name='student_reports'),
>>
>> defaulting to the year it's run. (ie, year = datetime.date.today().year)
>>
>> I thought about passing extra options, but it feels like overkill?
>>
>> I have in my views.py:
>>
>> def student_reports(request, year):
>>if not year:
>> year = datetime.date.today().year
>>yada yada
>>
>>
>> but this is failing on not enough arguments...
>>
>>
>> Cheers
>> L.
>>
>>
> z`
>
>
> S pozdravem
>   Tomáš Ehrlich
>
> Email:  tomas.ehrl...@gmail.com
> Tel:+420 608 219 889
> Jabber: elv...@jabber.cz
>
> "Půjdu kamkoliv, pokud je to kupředu." - J. London
>
> --
> 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.
>



-- 
...we look at the present day through a rear-view mirror. This is
something Marshall McLuhan said back in the Sixties, when the world
was in the grip of authentic-seeming future narratives. He said, “We
look at the present through a rear-view mirror. We march backwards
into the future.”

http://www.warrenellis.com/?p=14314

-- 
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: environment variable DJANGO_SETTINGS_MODULE is undefined.

2012-10-22 Thread Mike Dewhirst

On 23/10/2012 8:37am, DjgoNy wrote:

I have problem importing from  django_tables import tables
and when i do it on manage.py shell i get this error.

 >>> import django_tables2
Traceback (most recent call last):
   File "", line 1, in 
   File "build\bdist.win32\egg\django_tables2\__init__.py", line 3, in

   File "build\bdist.win32\egg\django_tables2\tables.py", line 4, in

   File "c:\Python27\lib\site-packages\django\db\__init__.py", line 11,
in 
 if DEFAULT_DB_ALIAS not in settings.DATABASES:
   File "c:\Python27\lib\site-packages\django\utils\functional.py", line
184, in inner
 self._setup()
   File "c:\Python27\lib\site-packages\django\conf\__init__.py", line
40, in _setup
 raise ImportError("Settings cannot be imported, because environment
variable %s is undefined." % ENVIRONMENT_VARIABLE)
ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.
 >>>

how do i fix it.
what am i missing here


You are directly importing a package which is on the Python path so the 
system finds it ok. But, that package (django_tables2) apparently 
expects to be imported by some other bit of code which already knows 
where your settings.py file lives.


If you want to import it directly it needs to know where to look.

You might need a PYTHONPATH environment variable which specifies the 
path to your Django project. If settings.py lives in 
C:\webwork\djngony\project\xyz\settings.py. Then your PYTHONPATH needs 
to include C:\webwork\djngony


The traceback indicates, you need a DJANGO_SETTINGS_MODULE environment 
variable. In my example above it would simply be project.xyz


hth

Mike


thank you so much.

--
You received this message because you are subscribed to the Google
Groups "Django users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/django-users/-/e3UHoYJI0KsJ.
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: Django Troubleshooting

2012-10-22 Thread Sun Simon
Thank you sir. It works!

On Sunday, October 21, 2012 7:55:23 AM UTC+8, Amyth wrote:
>
> Yeah,
>
> those are CLI commands. Although "tar" and "sudo" would not work with 
> windows as they are linux terminal commands. you may follow this easy step 
> by step procedure on how to setup django on 
> windows. 
> Though this was written for windows 7 but the steps are the same for 
> windows XP as well. Only difference is that in windows vista or 7 you need 
> to launch the command prompt specifically as an administrator.
>
>
> On Fri, Oct 19, 2012 at 9:37 AM, Sun Simon 
> > wrote:
>
>> https://www.djangoproject.com/download/
>>
>> I am installing Django for Python on Win XP and came across this problem 
>> during installation:
>>  
>>
>> tar xzvf Django-1.4.2.tar.gz
>> cd Django-1.4.2
>> sudo python setup.py install
>>
>>
>> What does "cd" mean? DOes it mean that I have to use command line to type it?
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/RmTilhDq4WIJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Thanks & Regards
> 
>
> Amyth [Admin - Techstricks]
> Email - aroras@gmail.com , ad...@techstricks.com
> Twitter - @mytharora
> http://techstricks.com/
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/H94xuLEn0MkJ.
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.