Re: New field in django

2013-09-09 Thread Harjot Mann
On Mon, Sep 9, 2013 at 10:59 AM, Xavier Ordoquy  wrote:
> The message is: "Table 'tcc_report' already exists"
>
> This means that you already created the tables with syncdb which bypassed 
> south and you're trying to created them again with south.
> You'll be able to recover from this by:
> - ensuring your models are in line with your current DB schema
> - creating an initial migration (provided that you didn't already create 
> migrations)
> - fake the initial migration to tell south you already created the schema for 
> this application
>
> Then you can change your models, create schema or data migrations and apply 
> them.
>
> For more information, have a look at 
> http://south.readthedocs.org/en/latest/convertinganapp.html#converting-other-installations-and-servers


Nothing is working. Please tell me how we can change the data-type of
any field. I urgently need to do this. I tried south, it didn't work.
What should I do?

-- 
Harjot Kaur Mann
Blog: http://harjotmann.wordpress.com/
Daily Dairy: http://harjotmann.wordpress.com/daily-diary/

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


Jobs in Newcastle NSW Australia

2013-09-09 Thread Peter Williams

Hi all

The NSW Rural Doctors Network seeks a GRADUATE SYSTEMS ENGINEER and a 
SYSTEMS ENGINEER TEAM LEADER to be based in our Head Office in 
Newcastle’s CBD. These positions will provide services to the 
Information Management team utilising high-level development languages 
and libraries such as SQL, HTML, Django, Python JavaScript, Linux, Ajax 
and CSS. Employment is open to Australian citizens, permanent residents 
and other applicants with the appropriate visa authorisation to work in 
Australia. The successful candidates will be required to work at the RDN 
office.


http://www.nswrdn.com.au/site/careers

If you know anyone who might be interested, please direct them to the 
URL above. Applications close 27 Sept 2013.


Cheers

Peter

--
Peter J Williams
Information Manager
NSW Rural Doctors Network
Head Office
Suite 19, Level 3
133 King Street
Newcastle NSW 2300
Telephone: (02) 4924-8000
Facsimile: (02) 4924-8010
Mailto:pwilli...@nswrdn.com.au
Web: http://www.nswrdn.com.au




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


Re: Advanced Tutorial (how to write reusable app), last step does not work

2013-09-09 Thread Robin Lery
In order to create a reusable app, you have to create a new 'templates'
folder in your app and place the the absolute path in the templates
directory in your settings.py. And then create the html files as concerned
with your app in the templates directory you created within the app.

Robin


On Tue, Sep 10, 2013 at 1:40 AM, asherakhet06  wrote:

> Hello.  I'm a rookie as well and I'm having exactly this same issue.
>  Trying to figure out what to do, but haven't been successful
> unfortunately.  Based on what I read (convention over configuration),  I
> understand that I should to make a poll_list.html file and store this in
> templates, to get my site to work.  Or should I just change the name of my
> index.html file in templates?  Am I missing something here? Thanks a lot
> guys.
>
> On Friday, July 26, 2013 8:20:26 PM UTC-4, Cate Liu wrote:
>>
>>
>> I am a new newbie to Django.  Great tutorial BTW.  I followed it to the T
>> and 99.9% worked.
>> Except the last step in the Advanced tutorial, the step 3 in 'Using your
>> own package'.
>> I could see http://127.0.0.1:8000/admin/ and create polls without any
>> problem.
>> But http://127.0.0.1:8000/polls/ would give me the following error.
>>
>> I see there are two problems.
>> 1. /Users/nnn/django_exercises/**mysite/templates/polls/index.**html is
>> the wrong location, it should be $$/django_polls/polls/**
>> templates/polls/index.html.
>> 2. What is polls/poll_list.html?  Nowhere in the tutorial ever created
>> this file, no?
>>
>> Thanks for any advice.
>>
>>
>> --**--**
>> --**
>> TemplateDoesNotExist at /polls/
>>
>> polls/index.html, polls/poll_list.html
>>
>>  Request Method: GET  Request URL: http://127.0.0.1:8000/polls/  Django
>> Version: 1.5.1  Exception Type: TemplateDoesNotExist  Exception Value:
>>
>> polls/index.html, polls/poll_list.html
>>
>>  Exception Location: /Library/Python/2.7/site-**packages/django/template/
>> **loader.py in select_template, line 194  Python Executable:
>> /usr/bin/python  Python Version: 2.7.2  Python Path:
>>
>> ['/Users/nnn/django_exercises/**mysite',
>>  '/Users/nnn/py_pkg/lib/python/**django_polls-0.1-py2.7.egg',
>>  '/Users/nnn/py_pkg/lib/python'**,
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python27.zip',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/plat-darwin',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/plat-mac',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/plat-mac/lib-**scriptpackages',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**Extras/lib/python',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/lib-tk',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/lib-old',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**lib/python2.7/lib-dynload',
>>  
>> '/System/Library/Frameworks/**Python.framework/Versions/2.7/**Extras/lib/python/PyObjC',
>>  '/Library/Python/2.7/site-**packages']
>>
>>  Server time: Fri, 26 Jul 2013 16:59:14 -0700
>>
>> Template-loader postmortem
>>
>> Django tried loading these templates, in this order:
>>
>>- Using loader django.template.loaders.**filesystem.Loader:
>>   - /Users/nnn/django_exercises/**mysite/templates/polls/index.**html,
>>   polls/poll_list.html (File does not exist)
>>- Using loader django.template.loaders.app_**directories.Loader:
>>   - 
>> /Library/Python/2.7/site-**packages/django/contrib/auth/**templates/polls/index.html,
>>   polls/poll_list.html (File does not exist)
>>   - 
>> /Library/Python/2.7/site-**packages/django/contrib/admin/**templates/polls/index.html,
>>   polls/poll_list.html (File does not exist)
>>
>>
>>  --
> 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.
>

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


Re: URL Mapping Confusion

2013-09-09 Thread Thomas Lockhart

On 9/9/13 5:40 PM, Chris Kavanagh wrote:
This is just a tutorial I'm going through Tom. I'm not trying to write 
anything, just trying to understand this part. And I apologize for 
making my question(s) confusing, I'm not exactly sure how to ask it.


Let's back up for a second. I'm not trying to match anything, I was 
telling you what I already had in my files (from the tutorial). What I 
do not understand is why the "/articles/" part of the url needs be 
included when I want to go to my  "/create/" view? In other words, why 
does the url need to be "http://127.0.0.1:8000/articles/create; 
INSTEAD OF "http://127.0.0.1:8000/create; ? Am I making sense, lol?


I have "url(r'^create/$', 'article.views.create')" in my urlconf, so 
why must I include "/article/" when I want to go to 
"http://127.0.0.1:8000/create;? You said "All of your "urlconf" paths 
will need to have "/articles" in the path to be found". Why? That is 
my question? I'm obviously not understanding something that I should 
already know. I get that I also have "(r'^articles/', 
include('article.urls'))" in my main urlconf. I thought this line of 
code just linked up the other urlconf in my app package and that's all 
it did.
Well, no it is not "just linked up". Since you put a pattern 
"^/articles/$" to be matched in the primary urls.py file, and since the 
next argument is "include('article.urls')", that secondary 
"article.urls" will never be seen to be matched unless you get a match 
on the leading "/articles/". Go back to my previous response and look at 
the three steps in matching a nested URL.


hth

 - Tom




I hope I made my question a little clearer, lol. I'm not sure how to 
ask what I want to know. But again, THANKS for the help Tom!




On Mon, Sep 9, 2013 at 7:48 PM, Thomas Lockhart 
> wrote:




Tom, thanks so much for the reply. . .Yes, that was a typo,
it should've been "/articles" not "/article".

 I know this is going to be a stupid question, but why do my
"urlconf" paths need to have "/articles"
in it as you said?

There are three steps in the interpretation of the pattern.
1) If the pattern starts with "/articles", try matching within
your "urlconf" file.
2) If the remaining portion of the url matches a pattern in the
"urlconf" file, stop there.
3) If the remaining portion does not match in the "urlconf" file,
keep looking farther down your main url file.

If you don't want the /articles prefix in your paths, write your
patterns more explicitly at the top level.

It *is* pretty typical to have separate apps have distinct
prefixes in their URL paths.

hth

  - Tom
-- 
You received this message because you are subscribed to a topic in

the Google Groups "Django users" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/django-users/43W4LSOuUUw/unsubscribe.
To unsubscribe from this group and all its topics, 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.


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


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


Using PredictionIO with Django - where to put client creation?

2013-09-09 Thread Victor Hooi
Hi,

I have a Django app that I'm using with PredictionIO 
(http://prediction.io/), which is a wrapper around Apache Mahout.

They also have a Python client that sends data to the backend server:

http://pythonhosted.org/PredictionIO/predictionio.html

As part of this, I've attached post_save signals to my Django models, so 
that I create the appropriate PredictionIO users and items when the Django 
models get created.

So in my models.py files, I have things like:

from django.dispatch import receiver
> from django.db.models.signals import post_save
> import predictionio
> ...
> client = 
> predictionio.Client(appkey="pEICENyM27veyCwxj0R7LgeK8WnSg9TV5ediToCciuZAkUkLFVmZw9lOCWEqYu5s")
> ...
> class Product(models.Model):
> ...define Product fields...
> ...
> @receiver(post_save, sender=Product)
> def create_recommender_product(sender, instance=None, created=False, 
> **kwargs):
> if created:
> client.create_item(str(instance.id), ('type1',))


I have a similar setup for my custom User model, and also a post_save 
signal for when a user likes/dislikes a product.

My question is - I've put the client creation code at the top of models.py 
- my understanding was this only gets called once when we first read in 
models.py, then it gets re-used each time.

Is the above good practice?

And also, the prediction.io calls in my post_save functions are all 
blocking - is that a major issue? Should I be shoving this into something 
like Celery, or is the above acceptable?

Cheers,
Victor

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


Re: Mezzanine Gunicorn Problem

2013-09-09 Thread Mario Gudelj
What's the issue Kelvin? Is the gunicorn process dying? I remember having
some issues with starting gunicorn and mezzanine and it was due to locale.
Make sure you have a correct locale in the settings. You can run the locale
command in the shell to obtain it it for the machine you're on:

$ locale
LANG="en_AU.UTF-8"
LC_COLLATE="en_AU.UTF-8"
LC_CTYPE="en_AU.UTF-8"
LC_MESSAGES="en_AU.UTF-8"
LC_MONETARY="en_AU.UTF-8"
LC_NUMERIC="en_AU.UTF-8"
LC_TIME="en_AU.UTF-8"



On 10 September 2013 07:29, Kelvin Wong  wrote:

> This is the command (single line) that I am using for a Django app using
>> Gunicorn (and Supervisor). It is running with a virtualenv which explains
>> the python executable.
>>
>> /home/myapp/.virtualenvs/productionmyapp/bin/python
>> /home/myapp/webapps/production_fido/fido/manage.py run_gunicorn -c
>> /home/myapp/webapps/production_fido/fido/gunicorn_production.py
>>
>> The gunicorn_production.py file is a configuration file.
>>
>  --
> 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.
>

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


Re: URL Mapping Confusion

2013-09-09 Thread Chris Kavanagh
This is just a tutorial I'm going through Tom. I'm not trying to write
anything, just trying to understand this part. And I apologize for making
my question(s) confusing, I'm not exactly sure how to ask it.

Let's back up for a second. I'm not trying to match anything, I was telling
you what I already had in my files (from the tutorial). What I do not
understand is why the "/articles/" part of the url needs be included when I
want to go to my  "/create/" view? In other words, why does the url need to
be "http://127.0.0.1:8000/articles/create; INSTEAD OF "
http://127.0.0.1:8000/create; ? Am I making sense, lol?

I have "url(r'^create/$', 'article.views.create')" in my urlconf, so why
must I include "/article/" when I want to go to "
http://127.0.0.1:8000/create;? You said "All of your "urlconf" paths will
need to have "/articles" in the path to be found". Why? That is my
question? I'm obviously not understanding something that I should already
know. I get that I also have "(r'^articles/', include('article.urls'))" in
my main urlconf. I thought this line of code just linked up the other
urlconf in my app package and that's all it did.

I hope I made my question a little clearer, lol. I'm not sure how to ask
what I want to know. But again, THANKS for the help Tom!



On Mon, Sep 9, 2013 at 7:48 PM, Thomas Lockhart wrote:

>
>   Tom, thanks so much for the reply. . .Yes, that was a typo, it
>> should've been "/articles" not "/article".
>
>  I know this is going to be a stupid question, but why do my "urlconf"
> paths need to have "/articles"
> in it as you said?
>
> There are three steps in the interpretation of the pattern.
> 1) If the pattern starts with "/articles", try matching within your
> "urlconf" file.
> 2) If the remaining portion of the url matches a pattern in the "urlconf"
> file, stop there.
> 3) If the remaining portion does not match in the "urlconf" file, keep
> looking farther down your main url file.
>
> If you don't want the /articles prefix in your paths, write your patterns
> more explicitly at the top level.
>
> It *is* pretty typical to have separate apps have distinct prefixes in
> their URL paths.
>
> hth
>
>   - Tom
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/43W4LSOuUUw/unsubscribe.
> To unsubscribe from this group and all its topics, 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.
>

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


Re: URL Mapping Confusion

2013-09-09 Thread Thomas Lockhart



Tom, thanks so much for the reply. . .Yes, that was a typo, it
should've been "/articles" not "/article".

 I know this is going to be a stupid question, but why do my "urlconf" 
paths need to have "/articles"

in it as you said?

There are three steps in the interpretation of the pattern.
1) If the pattern starts with "/articles", try matching within your 
"urlconf" file.
2) If the remaining portion of the url matches a pattern in the 
"urlconf" file, stop there.
3) If the remaining portion does not match in the "urlconf" file, keep 
looking farther down your main url file.


If you don't want the /articles prefix in your paths, write your 
patterns more explicitly at the top level.


It *is* pretty typical to have separate apps have distinct prefixes in 
their URL paths.


hth

  - Tom

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


Re: URL Mapping Confusion

2013-09-09 Thread Thomas Lockhart

On 9/9/13 3:30 PM, Chris Kavanagh wrote:
I haven't used this group in a long time, so I hope I do everything 
correctly. If I don't, I apologize in advance.


I thought I understand the way django uses URL's in the urlconf to 
match URL's, but I was wrong. Here's my question:


Here's my urlconf. . .
url(r'^all/$', 'article.views.articles'),
url(r'^get/(?P\d+)/$', 'article.views.article'),
url(r'^language/(?P[a-z\-]+)/$', 'article.views.language'),
url(r'^create/$', 'article.views.create'),)

and here's the other one in the site directory.
urlpatterns = patterns('',

(r'^articles/', include('article.urls')),
url(r'^accounts/login/$', 'mysite.views.login'),
url(r'^accounts/auth/$', 'mysite.views.auth_view'),
url(r'^accounts/logout/$', 'mysite.views.logout'),
url(r'^accounts/loggedin/$', 'mysite.views.loggedin'),
url(r'^accounts/invalid/$', 'mysite.views.invalid_login'),
url(r'^accounts/register/$', 'mysite.views.register_user'),
url(r'^accounts/register_success/$', 
'mysite.views.register_success'),)


Here's the question: If I have the URL 
"http://127.0.0.1:8000/articles/create/; it works fine and takes me to 
the correct page. But why does it work when I have the "/article" in 
the url. According to the urlconf last entry r'^create/$', it should 
only match a url with "/create" NOT a url with "/article/create". The 
caret means "starts with" and the $ means "end with", so to get to the 
"create" page it should be a url with just "/create/" in it, right?
I'm a bit confused by your question. All of your "urlconf" paths will 
need to have "/articles" in the path to be found. Although regex does 
use "^" and "$" to denote beginning and end, you have split your pattern 
matching into two stages so they are just matching the pattern available 
in each stage.


Was your mention of "/article" above a typo and you meant "/articles"?

You might want to follow up with a description of what behavior you need 
to help folks give you a solution.


hth

 - Tom

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


Re: URL Mapping Confusion

2013-09-09 Thread Chris Kavanagh


On Monday, September 9, 2013 6:41:23 PM UTC-4, Thomas wrote:
>
> On 9/9/13 3:30 PM, Chris Kavanagh wrote: 
> > I haven't used this group in a long time, so I hope I do everything 
> > correctly. If I don't, I apologize in advance. 
> > 
> > I thought I understand the way django uses URL's in the urlconf to 
> > match URL's, but I was wrong. Here's my question: 
> > 
> > Here's my urlconf. . . 
> > url(r'^all/$', 'article.views.articles'), 
> > url(r'^get/(?P\d+)/$', 'article.views.article'), 
> > url(r'^language/(?P[a-z\-]+)/$', 
> 'article.views.language'), 
> > url(r'^create/$', 'article.views.create'),) 
> > 
> > and here's the other one in the site directory. 
> > urlpatterns = patterns('', 
> > 
> > (r'^articles/', include('article.urls')), 
> > url(r'^accounts/login/$', 'mysite.views.login'), 
> > url(r'^accounts/auth/$', 'mysite.views.auth_view'), 
> > url(r'^accounts/logout/$', 'mysite.views.logout'), 
> > url(r'^accounts/loggedin/$', 'mysite.views.loggedin'), 
> > url(r'^accounts/invalid/$', 'mysite.views.invalid_login'), 
> > url(r'^accounts/register/$', 'mysite.views.register_user'), 
> > url(r'^accounts/register_success/$', 
> > 'mysite.views.register_success'),) 
> > 
> > Here's the question: If I have the URL 
> > "http://127.0.0.1:8000/articles/create/; it works fine and takes me to 
> > the correct page. But why does it work when I have the "/article" in 
> > the url. According to the urlconf last entry r'^create/$', it should 
> > only match a url with "/create" NOT a url with "/article/create". The 
> > caret means "starts with" and the $ means "end with", so to get to the 
> > "create" page it should be a url with just "/create/" in it, right? 
> I'm a bit confused by your question. All of your "urlconf" paths will 
> need to have "/articles" in the path to be found. Although regex does 
> use "^" and "$" to denote beginning and end, you have split your pattern 
> matching into two stages so they are just matching the pattern available 
> in each stage. 
>
> Was your mention of "/article" above a typo and you meant "/articles"? 
>
> You might want to follow up with a description of what behavior you need 
> to help folks give you a solution. 
>
> hth 
>
>   - Tom 
> Tom, thanks so much for the reply. . .Yes, that was a typo, it should've 
> been "/articles" not "/article".

 I know this is going to be a stupid question, but why do my "urlconf" 
paths need to have "/articles"
in it as you said?

Apparently I've missed something in my understanding of how all this works. 
Thanks again for the help!

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


URL Mapping Confusion

2013-09-09 Thread Chris Kavanagh
I haven't used this group in a long time, so I hope I do everything
correctly. If I don't, I apologize in advance.

I thought I understand the way django uses URL's in the urlconf to match
URL's, but I was wrong. Here's my question:

Here's my urlconf. . .
url(r'^all/$', 'article.views.articles'),
url(r'^get/(?P\d+)/$', 'article.views.article'),
url(r'^language/(?P[a-z\-]+)/$', 'article.views.language'),
url(r'^create/$', 'article.views.create'),)

and here's the other one in the site directory.
urlpatterns = patterns('',

(r'^articles/', include('article.urls')),
url(r'^accounts/login/$', 'mysite.views.login'),
url(r'^accounts/auth/$', 'mysite.views.auth_view'),
url(r'^accounts/logout/$', 'mysite.views.logout'),
url(r'^accounts/loggedin/$', 'mysite.views.loggedin'),
url(r'^accounts/invalid/$', 'mysite.views.invalid_login'),
url(r'^accounts/register/$', 'mysite.views.register_user'),
url(r'^accounts/register_success/$', 'mysite.views.register_success'),)

Here's the question: If I have the URL "
http://127.0.0.1:8000/articles/create/; it works fine and takes me to the
correct page. But why does it work when I have the "/article" in the url.
According to the urlconf last entry r'^create/$', it should only match a
url with "/create" NOT a url with "/article/create". The caret means
"starts with" and the $ means "end with", so to get to the "create" page it
should be a url with just "/create/" in it, right?

I've looked at the django docs explanation, I've gone through every web
site that talks about this, I understand regex, but I still don't
understand why this is happening.

Any help is GREATLY appreciated.

Thanks,
Chris Kavanagh

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


Re: Email Validation when adding a user to the backend

2013-09-09 Thread Gladson Simplício Brito
I tell you to upgrade to django 1.5
But to solve palliation:
https://github.com/GoodCloud/django-longer-username


2013/9/9 Russell Keith-Magee 

> Hi,
>
> If you're using Django 1.1, you're probably hitting up against the 30
> character limit for usernames. first name.secondn...@domain.com, for
> example, is 32 characters. You might also be hitting against a specific
> character invalidation -- I'd need to go back and check when we started
> allowing full stops and hyphens in usernames, but it wouldn't surprise me
> if it was after v1.1.
>
> So - How do you update your site?
>
> First step -- upgrade your Django install. At this point Django 1.1 isn't
> officially supported, so it has *known* security problems (all the problems
> we've fixed in Django 1.2, 1.3, 1.4 and 1.5).
>
> Second step - look into Custom User Models, added in Django 1.5 [1]
>
> There are some other approaches that you can take on pre-Django 1.5
> versions, but they involve a bit of hacking to make them work. You'll be
> best served by upgrading and using the new features designed for this
> purpose.
>
> Yours,
> Russ Magee %-)
>
> [1]
> https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#specifying-a-custom-user-model
>
>
>
> On Mon, Sep 9, 2013 at 4:09 AM, vanderkerkoff  wrote:
>
>> Hello there.
>>
>> We're running a 1.1 django application and have run into a bit of a
>> problem.
>>
>> Recently our organisation decided to change its email addresses.
>>
>> Moving from myn...@domain.com, to firstname.secondn...@domain.com
>>
>> I've just tried adding a user to the site and I'm bumping up against an
>> invalid email address stopping the user being added :-(
>>
>> We've done hardly any development of the admin backend, and absolutely
>> nothing at all with the users section of the admin backend.
>>
>> Could anyone point me in the right direction of how I go about allowing
>> this new format of email address in the backend when adding a user?
>>
>> Even switching validation off would be better than the current situation.
>>
>> Any help, greatly appreciated as always.
>>
>> V
>>
>> --
>> 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.
>>
>
>  --
> 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.
>

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


Re: Mezzanine Gunicorn Problem

2013-09-09 Thread Kelvin Wong

>
> This is the command (single line) that I am using for a Django app using 
> Gunicorn (and Supervisor). It is running with a virtualenv which explains 
> the python executable.
>
> /home/myapp/.virtualenvs/productionmyapp/bin/python 
> /home/myapp/webapps/production_fido/fido/manage.py run_gunicorn -c 
> /home/myapp/webapps/production_fido/fido/gunicorn_production.py
>
> The gunicorn_production.py file is a configuration file.
>

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


Re: Email Validation when adding a user to the backend

2013-09-09 Thread Russell Keith-Magee
Hi,

If you're using Django 1.1, you're probably hitting up against the 30
character limit for usernames. first name.secondn...@domain.com, for
example, is 32 characters. You might also be hitting against a specific
character invalidation -- I'd need to go back and check when we started
allowing full stops and hyphens in usernames, but it wouldn't surprise me
if it was after v1.1.

So - How do you update your site?

First step -- upgrade your Django install. At this point Django 1.1 isn't
officially supported, so it has *known* security problems (all the problems
we've fixed in Django 1.2, 1.3, 1.4 and 1.5).

Second step - look into Custom User Models, added in Django 1.5 [1]

There are some other approaches that you can take on pre-Django 1.5
versions, but they involve a bit of hacking to make them work. You'll be
best served by upgrading and using the new features designed for this
purpose.

Yours,
Russ Magee %-)

[1]
https://docs.djangoproject.com/en/1.5/topics/auth/customizing/#specifying-a-custom-user-model



On Mon, Sep 9, 2013 at 4:09 AM, vanderkerkoff  wrote:

> Hello there.
>
> We're running a 1.1 django application and have run into a bit of a
> problem.
>
> Recently our organisation decided to change its email addresses.
>
> Moving from myn...@domain.com, to firstname.secondn...@domain.com
>
> I've just tried adding a user to the site and I'm bumping up against an
> invalid email address stopping the user being added :-(
>
> We've done hardly any development of the admin backend, and absolutely
> nothing at all with the users section of the admin backend.
>
> Could anyone point me in the right direction of how I go about allowing
> this new format of email address in the backend when adding a user?
>
> Even switching validation off would be better than the current situation.
>
> Any help, greatly appreciated as always.
>
> V
>
> --
> 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.
>

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


Re: Geodjango and Kriging

2013-09-09 Thread Derek
As Stefano said - "not really".  GeoDjango is more designed around data 
storage and display, and not processing.

There is an interesting discussion here:
https://groups.google.com/forum/#!topic/scipy-user/3wrplHcl9YY
and a potential library here:
http://hpgl.aoizora.org/

Derek

On Saturday, 7 September 2013 00:51:53 UTC+2, Matthew Scotch wrote:
>
> Hi,
>
> I am new to geodjango and was wondering if it has an API for kriging?
> So far I have not been able to find anything.
> Thanks,
> Matthew
>

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


Meta class ordering by related field in ManyToMany model?

2013-09-09 Thread Brian
I'm setting up a database for data related to sporting event stats.  My 
database has a Game model, which is linked to a TeamGame model (stats 
related specifically to each team that played in that game). These two 
models are linked as ManyToMany, as we're going to have multiple games and 
each game is going to have multiple Teams.  I would like both of these 
models to be ordered by the game's date, which is a column in the Game 
table but I'm having trouble figuring out how to set a Meta class to do 
this in the TeamGame model.  Here's the relevant code for each - can 
someone please help me with the syntax that I'd need to use in the TeamGame 
model to sort by date (and also so that home/away classification doesn't 
interfere with the date sorting)?

class Game(models.Model):
game_id = models.IntegerField(primary_key = True)
date = models.DateField()

team_home = models.ForeignKey(TeamGame, related_name='home')
team_away = models.ForeignKey(TeamGame, related_name='away')

class Meta:
 ordering = ['date']

class TeamGame(models.Model):

team = models.ForeignKey(Team)

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


Re: sorl-thumbnail or easy thumbnail with apache

2013-09-09 Thread Robin Lery
I have used it in the templates. Do i use it in the models for uploaded
images???


On Tue, Sep 10, 2013 at 1:31 AM, Robin Lery  wrote:

> Hello,
> Has anyone tried sorl-thumbnail or easy_thumbnail with apache for users
> uploaded media images??? I am really stuck with these. When I upload it
> using the apache server, it does not load the uploaded image, it only loads
> the ones that have been run through the django's inbuilt server. And only
> when I run the django's inbuilt server it loads the uploaded image. I think
> it does not process the application (sorl-thumbnail or easy_thumbnail) via
> apache... Any help will be greatly appreciated. Thank you!
>

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


sorl-thumbnail or easy thumbnail with apache

2013-09-09 Thread Robin Lery
Hello,
Has anyone tried sorl-thumbnail or easy_thumbnail with apache for users
uploaded media images??? I am really stuck with these. When I upload it
using the apache server, it does not load the uploaded image, it only loads
the ones that have been run through the django's inbuilt server. And only
when I run the django's inbuilt server it loads the uploaded image. I think
it does not process the application (sorl-thumbnail or easy_thumbnail) via
apache... Any help will be greatly appreciated. Thank you!

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


Re: Advanced Tutorial (how to write reusable app), last step does not work

2013-09-09 Thread asherakhet06
Hello.  I'm a rookie as well and I'm having exactly this same issue. 
 Trying to figure out what to do, but haven't been successful 
unfortunately.  Based on what I read (convention over configuration),  I 
understand that I should to make a poll_list.html file and store this in 
templates, to get my site to work.  Or should I just change the name of my 
index.html file in templates?  Am I missing something here? Thanks a lot 
guys.

On Friday, July 26, 2013 8:20:26 PM UTC-4, Cate Liu wrote:
>
>
> I am a new newbie to Django.  Great tutorial BTW.  I followed it to the T 
> and 99.9% worked.
> Except the last step in the Advanced tutorial, the step 3 in 'Using your 
> own package'.
> I could see http://127.0.0.1:8000/admin/ and create polls without any 
> problem.
> But http://127.0.0.1:8000/polls/ would give me the following error.
>
> I see there are two problems.
> 1. /Users/nnn/django_exercises/mysite/templates/polls/index.html is the 
> wrong location, it should be 
> $$/django_polls/polls/templates/polls/index.html.
> 2. What is polls/poll_list.html?  Nowhere in the tutorial ever created 
> this file, no?
>
> Thanks for any advice.
>
>
>
> --
> TemplateDoesNotExist at /polls/ 
>
> polls/index.html, polls/poll_list.html
>
>  Request Method: GET  Request URL: http://127.0.0.1:8000/polls/  Django 
> Version: 1.5.1  Exception Type: TemplateDoesNotExist  Exception Value: 
>
> polls/index.html, polls/poll_list.html
>
>  Exception Location: 
> /Library/Python/2.7/site-packages/django/template/loader.py 
> in select_template, line 194  Python Executable: /usr/bin/python  Python 
> Version: 2.7.2  Python Path: 
>
> ['/Users/nnn/django_exercises/mysite',
>  '/Users/nnn/py_pkg/lib/python/django_polls-0.1-py2.7.egg',
>  '/Users/nnn/py_pkg/lib/python',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
>  '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
>  
> '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC',
>  '/Library/Python/2.7/site-packages']
>
>  Server time: Fri, 26 Jul 2013 16:59:14 -0700
>
> Template-loader postmortem 
>
> Django tried loading these templates, in this order:
>
>- Using loader django.template.loaders.filesystem.Loader: 
>   - /Users/nnn/django_exercises/mysite/templates/polls/index.html, 
>   polls/poll_list.html (File does not exist)
>- Using loader django.template.loaders.app_directories.Loader: 
>   - 
> /Library/Python/2.7/site-packages/django/contrib/auth/templates/polls/index.html,
>  
>   polls/poll_list.html (File does not exist)
>   - 
> /Library/Python/2.7/site-packages/django/contrib/admin/templates/polls/index.html,
>  
>   polls/poll_list.html (File does not exist)
>
>
>

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


Django 1.6, Savepoints, and assertNumQueries

2013-09-09 Thread marky1...@gmail.com
1.6 introduces savepoints, which create additional queries to the databse. 
This behavior breaks tests that use assertNumQueries and did not consider 
savepoints (For example, if you test using a sqlite database). How should 
these tests be fixed? The 
docs
 say 
"if tests using 
assertNumQueries()
 fail 
because of a higher number of queries than expected, check that the extra 
queries are related to savepoints, and adjust the expected number of 
queries accordingly.", but don't say how to do these checks. Looking at it 
again, I think it might just mean "look for obvious errors in your code and 
set the expected number of queries to the new values". Is my interpretation 
correct or is there some way to do these checks programmatically? 

Considering a workaround, this 
ticket mentions 
savepoints=False, but this isn't mentioned anywhere in the docs, so I'm 
guessing it's either not a part of the API (And therefore I shouldn't be 
using it) or it no longer works. (But maybe it's just poorly documented?) 
 Is there some other way I can disable savepoints when testing? Is this a 
bad idea for some reason?

I really don't like just blindly changing the number of queries to the new 
values (For all I know, the different query counts might be due to some 
error in the code), so how should I handle this? (Is just accepting the 
numbers and hoping my code's correct the best I can do?)

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


Django and soaplib xmlns problem

2013-09-09 Thread kl4us
Hi all,
I'm developing a soap service with django 1.5.2, python 2.7.3 and soaplib 
0.8.1. For now a simple method works fine but ... how i can add *xmlns* to 
response?

This is my view.py

from sms.soaplib_handler import DjangoSoapApp, soapmethod, soap_typesfrom 
django.views.decorators.csrf import csrf_exempt

class SmsGatewayService(DjangoSoapApp):

__tns__ = 'http://tempuri.org'

@soapmethod(
soap_types.String, 
soap_types.String, 
soap_types.String, 
soap_types.Integer,
soap_types.Boolean, 
soap_types.Boolean, 
soap_types.String, 
_returns=soap_types.Any
)
def sendSms(
self, 
sendTo, 
numSender,
senderDescription,
timeToLive,
isDelivered,
isStatistics,
messageText
):

retCode = 'OK'

return retCode

sms_gateway_service = csrf_exempt(SmsGatewayService())


This is my soaplib_handler.py

> from soaplib.wsgi_soap import SimpleWSGISoapApp
> from soaplib.service import soapmethod
> from soaplib.serializers import primitive as soap_types
> from django.http import HttpResponse
>
> class DjangoSoapApp(SimpleWSGISoapApp):
> def __call__(self, request):
> django_response = HttpResponse()
> def start_response(status, headers):
> status, reason = status.split(' ', 1)
> django_response.status_code = int(status)
> for header, value in headers:
> django_response[header] = value
> response = super(SimpleWSGISoapApp, self).__call__(request.META, 
> start_response)
> django_response.content = "\n".join(response)
> return django_response


and this is the response when i call the method:

http://schemas.xmlsoap.org/soap/envelope/;>
   
  
 
OK
 
  
   

How i can modify a soap response? I need to have something similar to:

http://schemas.xmlsoap.org/soap/envelope/;>
   
  http://tempuri.org;>
 OK
  
   

I'm newbie to soaplib and newbie++ to django and python.

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


Re: Complex query

2013-09-09 Thread Drew Ferguson
On Mon, 9 Sep 2013 06:57:46 -0700 (PDT)
Yegor Roganov  wrote:

> Thanks for you replies.
> But I wonder how real production web sites deal with this problem. The 
> problem is that I want to display about 30 topics per page which would 
> result in 30+1 queries if implemented naively. If I write the required 
> query in raw SQL, it should be faster, but probably not very fast
> anyway. Also I don't know how to cache properly since topics should be
> ordered by most recent posts (that is, if someone posts to topic on
> third page, this topic should become the first one on the first page).
> 

If you were using Postgres or similar, you could create some triggers
and/or stored-procedures that maintained an active list of 30 target
items - perhaps with a flag in one of the database tables. Then create a
view to generate the list of 30 items you needed.

This way the ORM & Django SQL access is reduced to a single query on the
view. The heavy lifting is all done server-side as comments/articles are
saved

Could this work?
-- 
Drew Ferguson

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


Re: Complex query

2013-09-09 Thread Yegor Roganov
Thanks for you replies.
But I wonder how real production web sites deal with this problem. The 
problem is that I want to display about 30 topics per page which would 
result in 30+1 queries if implemented naively. If I write the required 
query in raw SQL, it should be faster, but probably not very fast anyway. 
Also I don't know how to cache properly since topics should be ordered by 
most recent posts (that is, if someone posts to topic on third page, this 
topic should become the first one on the first page).

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


Re: bad request 400

2013-09-09 Thread Marcin Szamotulski
The problem has solved somehow (reboot). 

Marcin

On 19:08 Sun 08 Sep , Germán wrote:
> If you don't post your code it's quite difficult to help yo
> On Sunday, September 8, 2013 3:34:33 PM UTC-5, Marcin Szamotulski wrote:
> >
> > Hello, 
> >
> > I start working on a new app.  I started in the usual way (with 
> > django-admin.py startproject, configured the settings (nothing special 
> > though) and when I try to use my first view function I always get: 
> > [08/Sep/2013 21:32:31] "GET / HTTP/1.1" 400 26 
> >
> > (BAD REQUEST) 
> >
> > I reviewed my settings which are almost the default ones and could not 
> > find anything special.  Any ideas how to go through this.  I also run 
> > django on pdb but I could not find anything leaeding to this error. 
> >
> > Thanks for help, 
> > Marcin 
> >
> 
> -- 
> 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.

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


Re: How do I output a variable from Models.py to Detail.html?

2013-09-09 Thread Daniel Roseman
On Monday, 9 September 2013 10:24:54 UTC+1, Pepsodent Cola wrote:

> This is my Models code and I want to output the contents of variable *
> blackbox* to my screen.
>
> 1.)  Do I need to write some code in Views.py to transfer my variable 
> "blackbox" from Models to Views to Detail.html?
> 2.)  Or can I access my variable "blackbox" directly from Detail.html?
>
>
> #___
>
> class AltwordManager(models.Manager):
> def dictfetchall2(self, p):
> "Returns all rows from a cursor as a dict."
> *desc = p.description*
> *self.dark = desc*
> return [
> dict(zip([col[0] for col in desc], row))
> for row in p.fetchall()
> ]
>
> def vote_order(self):
> "Returns a 1:M list ordered by votes."
> cursor =  connection.cursor()
> cursor.execute("""
> SELECT navi_polls_word.rosword, navi_polls_altword.alt_ros_word, 
> navi_polls_altword.votes
> FROM navi_polls_altword INNER JOIN navi_polls_word
> ON (navi_polls_altword.rosword_id=navi_polls_word.id)
> ORDER BY votes DESC
> """)
> #row = cursor.fetchall()
> #row = dictfetchall(cursor)
> row = AltwordManager.dictfetchall2(self, cursor)
> *blackbox = self.dark*
> return blackbox
>
> #___
>
>
>

This, like most of your questions, is *really basic stuff* that is well 
covered by the tutorial.

You should stop trying to write this complex manager (which BTW does not do 
what a manager is supposed to do) and go back and do the tutorial, which 
introduces the concepts simply. Then, read the documentation on managers 
and understand what they are actually for - and stop writing SQL unless you 
really need it.

--
DR.

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


How do I output a variable from Models.py to Detail.html?

2013-09-09 Thread Pepsodent Cola
This is my Models code and I want to output the contents of variable *
blackbox* to my screen.

1.)  Do I need to write some code in Views.py to transfer my variable 
"blackbox" from Models to Views to Detail.html?
2.)  Or can I access my variable "blackbox" directly from Detail.html?

#___

class AltwordManager(models.Manager):
def dictfetchall2(self, p):
"Returns all rows from a cursor as a dict."
*desc = p.description*
*self.dark = desc*
return [
dict(zip([col[0] for col in desc], row))
for row in p.fetchall()
]

def vote_order(self):
"Returns a 1:M list ordered by votes."
cursor =  connection.cursor()
cursor.execute("""
SELECT navi_polls_word.rosword, navi_polls_altword.alt_ros_word, 
navi_polls_altword.votes
FROM navi_polls_altword INNER JOIN navi_polls_word
ON (navi_polls_altword.rosword_id=navi_polls_word.id)
ORDER BY votes DESC
""")
#row = cursor.fetchall()
#row = dictfetchall(cursor)
row = AltwordManager.dictfetchall2(self, cursor)
*blackbox = self.dark*
return blackbox
#___


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


Email Validation when adding a user to the backend

2013-09-09 Thread vanderkerkoff
Hello there.

We're running a 1.1 django application and have run into a bit of a problem.

Recently our organisation decided to change its email addresses.

Moving from myn...@domain.com, to firstname.secondn...@domain.com

I've just tried adding a user to the site and I'm bumping up against an 
invalid email address stopping the user being added :-(

We've done hardly any development of the admin backend, and absolutely 
nothing at all with the users section of the admin backend.

Could anyone point me in the right direction of how I go about allowing 
this new format of email address in the backend when adding a user?

Even switching validation off would be better than the current situation.

Any help, greatly appreciated as always.

V

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


Re: Exception Value: global name 'dictfetchall2' is not defined

2013-09-09 Thread Pepsodent Cola
Yeah I will revert back to standalone function later on after I have 
confirmed something.
I just want to output this variable on my screen still don't know how to 
accomplish that with confusing MVC code...

 desc = p.description

Somebody gave me a link to the document specification regarding how the 
content looks like.
But I like to see things with my own eyes before I move on with my Django 
project.






On Monday, September 9, 2013 2:52:03 AM UTC+2, Cal Leeming [Simplicity 
Media Ltd] wrote:
>
> Ah sorry yeah, I forgot you needed @staticmethod decorator on the class 
> method.
>
> To be honest though, that method should be a standalone function, not a 
> method (as James said, you need to re-think your approach!)
>
> Cal
>
>
> On Sun, Sep 8, 2013 at 9:25 PM, Pepsodent Cola 
>  > wrote:
>
>> Hi Cal,
>>
>> I replaced the code with this:
>> row = AltwordManager.dictfetchall2(cursor)
>>
>> Then I got a different error message that I don't understand?
>> ExceptionValue: 
>>
>>   
>>
>>
>> unbound method dictfetchall2() must be called with AltwordManager instance 
>> as first argument (got CursorDebugWrapper instance instead)
>>
>>
>>
>>
>>
>>
>>
>> On Sunday, September 8, 2013 9:54:36 PM UTC+2, Cal Leeming [Simplicity 
>> Media Ltd] wrote:
>>
>>> Try and replace
>>> row = dictfetchall2(cursor)
>>>
>>> With this
>>> row = AltwordManager.dictfetchall2(**cursor)
>>>
>>> Cal
>>>
>>>
>>> On Sun, Sep 8, 2013 at 8:23 PM, Pepsodent Cola wrote:
>>>
  I don't understand how to fix this error message?  Here is the code 
 that made things break.

 Exception Value: global name 'dictfetchall2' is not defined



 #_**__**
 

 def dictfetchall(cursor):
 "Returns all rows from a cursor as a dict."
 desc = cursor.description
 return [
 dict(zip([col[0] for col in desc], row))
 for row in cursor.fetchall()
 ]
 #_**__**
 

 class AltwordManager(models.Manager)**:
 *def dictfetchall2(cursor):*
 "Returns all rows from a cursor as a dict."
 desc = cursor.description
 return [
 dict(zip([col[0] for col in desc], row))
 for row in cursor.fetchall()
 ]

 def vote_order(self):
 "Returns a 1:M list ordered by votes."
 cursor =  connection.cursor()
 cursor.execute("""
 SELECT navi_polls_word.rosword
 FROM navi_polls_altword
 """)
 #row = cursor.fetchall()
 #row = dictfetchall(cursor)
 *row = dictfetchall2(cursor)*
 return row

 ...
 ...
  #_**__**
 



  -- 
 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...@**googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.

 Visit this group at 
 http://groups.google.com/**group/django-users
 .
 For more options, visit 
 https://groups.google.com/**groups/opt_out
 .

>>>
>>>  -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

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


how to turn off logging debug to be printed in apache's error log when django's DEBUG=False

2013-09-09 Thread Nick Jiang
I have set a debug logger to print debug infos to console.
This works fine in development environment. 

But in production, debug info redirect to apache error log file, i guess 
this is one behaviour related to mod_wsgi.
People say there's a setting control in django 1.5 version, but how can i 
turn this debug info to error log behaviour off
in django 1.4.6 version.

Thanks you guys for helping.

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


Re: Complex query

2013-09-09 Thread akaariai
On Monday, September 9, 2013 12:13:09 AM UTC+3, Yegor Roganov wrote:
>
> I found out this is a so called "top n per group" problem and it's not 
> that easy to implement in django. Maybe someone could help me to find 
> another way (for example, alter the schema in some way)?
>

This is something that would be nice to support with prefetch_related(). 
This is exactly the type of query where ORM abstraction would be very 
welcome. Writing this in SQL isn't easy, and the most efficient way to 
write the query varies a lot depending on the used database backend.

Unfortunately I don't see other solutions than running multiple queries or 
using raw SQL.

 - Anssi


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


Re: implement gmail type address adding functionality in django

2013-09-09 Thread Roopa singh
Fred,

   Thanks.


On Mon, Aug 5, 2013 at 7:11 PM, Fred Stluka  wrote:

>  Roopa,
>
> The word to search is "autocomplete".
>
> Check out:
> http://api.jqueryui.com/autocomplete/
>
> It is a JavaScript widget.  We use it with Django.  It runs in our
> Web page, and does an Ajax call to our Django code, which
> pulls the list of completions from our DB.
>
> --Fred
> --
> Fred Stluka -- mailto:f...@bristle.com  --
> http://bristle.com/~fred/
> Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
> Open Source: Without walls and fences, we need no Windows or Gates.
> --
>
> On 8/5/13 6:12 AM, roopasingh...@gmail.com wrote:
>
> Hi,
>
>   What is the name of that technology i want to search in google.
>
> Cheers!
>
>
> On Monday, August 5, 2013 3:29:21 PM UTC+5:30, JirkaV wrote:
>>
>> (not on a PC now)
>>
>> You're looking for quite common functionality - search you favourite
>> search engine for combination of Django, Ajax and "typeahead"
>>
>> HTH
>>
>> Jirka
>> --
>> *From: * roopas...@gmail.com
>> *Sender: * django...@googlegroups.com
>> *Date: *Mon, 5 Aug 2013 00:50:06 -0700 (PDT)
>> *To: *
>> *ReplyTo: * django...@googlegroups.com
>> *Subject: *implement gmail type address adding functionality in django
>>
>>  I want to implement the functionality available for adding email
>> address in gmail in my application.
>>
>> In gmail,in compose mail if we type the 1st character of the email
>> address,it will show the list of suggested email address.The same concept,i
>> want to implement in django for contact name.The list of names are saved in
>> database,so typing any letter of the name,it should show the list of
>> suggested names and from that user can select the name.
>>
>> I need some post or blog to get an idea to do this.
>>
>>
>>  Cheers!
>>
>> Roopa
>>  --
>> 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...@**googlegroups.com.
>> To post to this group, send email to django...@googlegroups.com.
>> Visit this group at 
>> http://groups.google.com/**group/django-users
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out
>> .
>>
>>
>>
> --
> 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.
>
>
>
>  --
> 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.
>
>
>

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