Query executed two times in database (django 1.4, oracle 11g)

2013-09-07 Thread Germán
I'm not familiar with caching internals but perhaps the fact that you are using 
`raw` has something to do with your problem?

-- 
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 generation in django

2013-09-07 Thread Aaron C. de Bruyn
I believe this is what you are looking for:

https://docs.djangoproject.com/en/1.5/topics/http/urls/#reverse-resolution-of-urls

-A


On Sat, Sep 7, 2013 at 8:17 PM, Nafiul Islam wrote:

> I've been busy exploring the different Python Web Frameworks, and it has
> been a rewarding experience. I wanted to ask regarding a certain feature
> that I found in Pyramid, and that is URL 
> generation.
> I wanted to ask if Django had something similar built in (I could not find
> something like this in the docs) or do I have to use a third-party library,
> if so then what library would you recommend?
>
> --
> Kind Regards,
> Nafiul Islam
>
> --
> 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.


URL generation in django

2013-09-07 Thread Nafiul Islam
I've been busy exploring the different Python Web Frameworks, and it has 
been a rewarding experience. I wanted to ask regarding a certain feature 
that I found in Pyramid, and that is URL 
generation.
 
I wanted to ask if Django had something similar built in (I could not find 
something like this in the docs) or do I have to use a third-party library, 
if so then what library would you recommend?

--
Kind Regards,
Nafiul Islam

-- 
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: duplicate entry in django

2013-09-07 Thread Harjot Mann
On Wed, Sep 4, 2013 at 2:17 PM, Babatunde Akinyanmi
 wrote:
> This is usually a side effect of not doing a redirect from the view
> that handles your submitted form.


How can I do it? I mean sometimes if there I fill the form again for
same job no. It accepts the value on submitting. Why it is not giving
me an error at that time that it the data for this entry already
exists. Is it the case of not using primary key. I mean is it
necessary to use primary key in all the tables. Or if we are using the
auto_increment id as primary key, can we so it. How can we expire a
session if we so refreshing of page and resubmitting it?. What is the
best way to do coding in django? How can we maintain an erp based
website in django? How can we improve the database of django app. How
can we understand all the logics of django? Which type of applications
we can make in django? How can we do less code? How can we best learn
django with proper coding standards? How?

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


Re: duplicate entry in django

2013-09-07 Thread Harjot Mann
On Wed, Sep 4, 2013 at 10:42 AM, Laurent Meunier  wrote:
> Can you show use the source code of the view where you create your entry in
> the database?


Sure. Here is the link to code:
http://tny.cz/09090f4c

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


Re: Geodjango and Kriging

2013-09-07 Thread Alex Mandel
On 09/06/2013 03:51 PM, 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
> 

Not really, but you can tie into plenty of backends that give you
kriging ability (Pass data from geodjango and return the results).
Postgis 2.x is going towards having such tools but isn't quite there.
Looking online I see some methods purely in python with Scipy, or you
could use R or GRASS via python, or SAGA via sextant python(QGIS). I
believe gdal even has some interpolation methods built for IDW but not
kriging.

Enjoy,
Alex


-- 
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: ImportError No module named django.core

2013-09-07 Thread voger
Hi, I am as noob as you so maybe this is a case of blind leading blind. 
From what I hear it is considered best practice to first create a 
virtualenv and then install django and any other packages inside that 
virtualenv. Read here for virtualenv 
http://dabapps.com/blog/introduction-to-pip-and-virtualenv-python/?&ei=J7crUq_PM4XFtAaM7IHoCw?&usg=AFQjCNEjUbnsJfGho1bGo4exJlT99Aod2Q?&sig2=aac8nwmTkJdYsk_TVCRf5g?&bvm=bv.51773540,d.Yms


After you created your virtualenv in let's say ~/env then you do

$ source /env/bin/activate

and your prompt becomes (env)[your normal prompt]$

then you do

(env)$ pip install django

and after that you start playing with django.



On 09/07/2013 07:42 PM, pzul wrote:

Hello,
I just installed Django-1.5.2 in a server (using command : python
setup.py install)
But now, as I'm expecting to create a new project (django-admin.py
startproject mysite ), I have this message :
ImportError No module named django.core

What can I do ?
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.


--
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: Django: How to combine 3-party apps!

2013-09-07 Thread alekto . antarctica
Would appreciate if anyone had a tip so I can get started :)

-- 
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: Django-cms + Wymeditor + Heroku + AWS s3 + Cors

2013-09-07 Thread Zach Frank
Having same problem.. did you figure anything out?

Z

On Thursday, October 11, 2012 12:57:30 PM UTC-5, Matteo Suppo wrote:
>
> I found this: 
> http://comments.gmane.org/gmane.comp.python.django.django-cms/1202
>
> and I decided to use tinymce for now. It's not solved though. I will do 
> something, maybe.
>
> On Thursday, October 11, 2012 7:25:19 PM UTC+2, Matteo Suppo wrote:
>>
>> Ok, here's a fun one.
>>
>> I set up a django installation on Heroku, added the django-cms app, 
>> deployed on heroku, and collected the static files on AWS.
>>
>> The problem is Django-CMS tries to load the js file for the wymeditor but 
>> AWS says:
>>
>> MLHttpRequest cannot load 
>> https://s3.amazonaws.com/[...]/cms/js/wymeditor/skins/django/skin.js. 
>> Origin [...] is not allowed by Access-Control-Allow-Origin.
>>
>> I actually searched a lot, and discovered this: 
>> http://docs.amazonwebservices.com/AmazonS3/latest/dev/cors.html
>>
>> Seems like a solution, but even if I activated it, nothing works.
>>
>> I'm at loss. It should work but it doesn't. Am I missing something here? 
>> Maybe it doesn't work the way I thought? Should I ask AWS directly?
>>
>

-- 
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: [SOLVED] NoReverseMatch at /polls/

2013-09-07 Thread voger
Problem solved. I missed a step in the tutorial where name spacing in 
the root URLconf was discussed. I still don't understand it completely 
but the bottom line is that the line number 4 in the file index.html 
should be replaced with


{{ poll.question }}

On 09/07/2013 11:29 PM, voger wrote:

The previous message was delivered as a garbage due to html formating. I
am sending it again as plain text.


Hi everyone. I am trying to walk through the polls tutorial. I am stuck
at the part 4 after the change of the views from function based to class
based. A search in Google brought plenty results but none of them seems
to be related exactly to this situation or maybe it is over my head to
understand what is going on.
When I visit http://127.0.0.1:8000/polls/ i get

NoReverseMatch at /polls/

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}'
not found.

Request Method: GET
Request URL: http://127.0.0.1:8000/polls/
Django Version: 1.5.2
Exception Type: NoReverseMatch
Exception Value:

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}'
not found.

...

In template
/home/voger/PycharmProjects/mysite/polls/templates/polls/index.html,
error at line 4
Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}'
not found.
1 {% if latest_poll_list %}
2 
3 {% for poll in latest_poll_list %}
4 {{ poll.question }}
5 {% endfor %}
6 
7 {% else %}
8 No polls are available.
9 {% endif %}

The offending line is line number 4. The classes used are

class IndexView(generic.ListView):
 template_name = 'polls/index.html'
 context_object_name = 'latest_poll_list'

 def get_queryset(self):
 """Return the last five published polls."""
 return Poll.objects.order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
 model = Poll
 template_name = 'polls/detail.html'

and in /polls/urls.py the urls are

urlpatterns = patterns('',
 url(r'^$', views.IndexView.as_view(), name='index'),
 url(r'^(?P\d+)/$', views.DetailView.as_view(), name='detail'),
 url(r'^(?P\d+)/results/$', views.ResultsView.as_view(),
name='results'),
 url(r'^(?P\d+)/vote/$', views.vote, name='vote'),
)

Can someone please explain what is wrong?



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


Create and save records through ManyToManyField selection.

2013-09-07 Thread Trung Nguyen
I am new comer I struggle to save a record using admin page .
What extra ethod should I add to save ContestScore record.

Thanks.

class School(models.Model):
school_name = models.CharField(max_length=30)
school_city = models.CharField(max_length=30)
coach_name = models.CharField(max_length=30)
coach_fone = models.CharField(max_length=30)
def  __unicode__(self):
return u"%s - %s" % (self.school_name , self.school_city)
class ContestCourse(models.Model):
CONTEST_LEVEL_CHOICES = (
('AV', 'Advantage'),
('BG', 'Beginer'),
)

course = models.CharField(max_length=30)
course_name = models.CharField(max_length=30)
level   =  models.CharField(max_length=2, choices=CONTEST_LEVEL_CHOICES)

def  __unicode__(self):
return u"%s - %s - %s" % (self.course , self.course_name, 
self.level)
 
class Student(models.Model):
YEAR_IN_SCHOOL_CHOICES = (
('FR', 'Freshman'),
('SO', 'Sophomore'),
('JR', 'Junior'),
('SR', 'Senior'),
)
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
grade = models.CharField(max_length=2, 
choices=YEAR_IN_SCHOOL_CHOICES )
schoolName =  models.ForeignKey(School)
def  __unicode__(self):
return u"%s - %s - %s" % (self.first_name , self.last_name, 
self.schoolName)


class ContestScore(models.Model):
student =  models.ForeignKey(Student)
courses  =  models.ManyToManyField(ContestCourse, verbose_name = "List 
of enroll courses" )
score   =  models.FloatField()
def  __unicode__(self):
return u"%s - %s - %s - %s" % (self.student, self.course, 
self.score)
def get_courses(self):
return self.course.all()


admin.py
from django.contrib import admin
from contest.models import School
from contest.models import ContestCourse
from contest.models import Student
from contest.models import ContestScore
from contest.models import SchoolScore


class StudentAdmin(admin.ModelAdmin):
list_display = ('first_name', 'last_name', 'grade', 'schoolName')  
search_fields = ['last_name']
class ContestCourseAdmin(admin.ModelAdmin):
list_display = ('course', 'course_name', 'level')  
search_fields = ['course']
class SchoolAdmin(admin.ModelAdmin):
list_display = ('school_name', 'school_city', 'coach_name', 
'coach_fone')  
search_fields = ['school_name']
class ContestScoreAdmin(admin.ModelAdmin):
list_display = ('student',  'score') 
filter_horizontal = ('courses',)
search_fields = ['student']



-- 
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: Django-cms + Wymeditor + Heroku + AWS s3 + Cors

2013-09-07 Thread Zach Frank
Having this same problem... did you fix it? I'm using heroku, django-cms, 
s3 for static files and i'm getting the same domain origin error.. any new 
insights appreciated.

Z

On Thursday, October 11, 2012 12:57:30 PM UTC-5, Matteo Suppo wrote:
>
> I found this: 
> http://comments.gmane.org/gmane.comp.python.django.django-cms/1202
>
> and I decided to use tinymce for now. It's not solved though. I will do 
> something, maybe.
>
> On Thursday, October 11, 2012 7:25:19 PM UTC+2, Matteo Suppo wrote:
>>
>> Ok, here's a fun one.
>>
>> I set up a django installation on Heroku, added the django-cms app, 
>> deployed on heroku, and collected the static files on AWS.
>>
>> The problem is Django-CMS tries to load the js file for the wymeditor but 
>> AWS says:
>>
>> MLHttpRequest cannot load 
>> https://s3.amazonaws.com/[...]/cms/js/wymeditor/skins/django/skin.js. 
>> Origin [...] is not allowed by Access-Control-Allow-Origin.
>>
>> I actually searched a lot, and discovered this: 
>> http://docs.amazonwebservices.com/AmazonS3/latest/dev/cors.html
>>
>> Seems like a solution, but even if I activated it, nothing works.
>>
>> I'm at loss. It should work but it doesn't. Am I missing something here? 
>> Maybe it doesn't work the way I thought? Should I ask AWS directly?
>>
>

-- 
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: NoReverseMatch at /polls/

2013-09-07 Thread voger
The previous message was delivered as a garbage due to html formating. I 
am sending it again as plain text.



Hi everyone. I am trying to walk through the polls tutorial. I am stuck 
at the part 4 after the change of the views from function based to class 
based. A search in Google brought plenty results but none of them seems 
to be related exactly to this situation or maybe it is over my head to 
understand what is going on.

When I visit http://127.0.0.1:8000/polls/ i get

NoReverseMatch at /polls/

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' 
not found.


Request Method: GET
Request URL: http://127.0.0.1:8000/polls/
Django Version: 1.5.2
Exception Type: NoReverseMatch
Exception Value:

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' 
not found.


...

In template 
/home/voger/PycharmProjects/mysite/polls/templates/polls/index.html, 
error at line 4
Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' 
not found.

1 {% if latest_poll_list %}
2 
3 {% for poll in latest_poll_list %}
4 {{ poll.question }}
5 {% endfor %}
6 
7 {% else %}
8 No polls are available.
9 {% endif %}

The offending line is line number 4. The classes used are

class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_poll_list'

def get_queryset(self):
"""Return the last five published polls."""
return Poll.objects.order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
model = Poll
template_name = 'polls/detail.html'

and in /polls/urls.py the urls are

urlpatterns = patterns('',
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^(?P\d+)/$', views.DetailView.as_view(), name='detail'),
url(r'^(?P\d+)/results/$', views.ResultsView.as_view(), 
name='results'),

url(r'^(?P\d+)/vote/$', views.vote, name='vote'),
)

Can someone please explain what is wrong?

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


NoReverseMatch at /polls/

2013-09-07 Thread voger
Hi everyone. I am trying to walk through the polls tutorial. I am stuck 
at the part 4 after the change of the views from function based to class 
based. A search in Google brought plenty results but none of them seems 
to be related exactly to this situation or maybe it is over my head to 
understand what is going on.

When I visit http://127.0.0.1:8000/polls/ i get


 NoReverseMatch at /polls/

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not found.

Request Method: GET
Request URL:http://127.0.0.1:8000/polls/
Django Version: 1.5.2
Exception Type: NoReverseMatch
Exception Value:

Reverse for 'detail' with arguments '(1,)' and keyword arguments '{}' not found.

...

In 
template|/home/voger/PycharmProjects/mysite/polls/templates/polls/index.html|, 
error at line*4*



 Reverse for 'detail' with arguments '(1,)' and keyword arguments
 '{}' not found.

1   {% if latest_poll_list %}
2   
3   {% for poll in latest_poll_list %}
4   {{ poll.question }}
5   {% endfor %}
6   
7   {% else %}
8   No polls are available.
9   {% endif %}


The offending line is line number 4. The classes used are

class IndexView(generic.ListView):
template_name = 'polls/index.html'
context_object_name = 'latest_poll_list'

def get_queryset(self):
"""Return the last five published polls."""
return Poll.objects.order_by('-pub_date')[:5]

class DetailView(generic.DetailView):
model = Poll
template_name = 'polls/detail.html'

and in /polls/urls.py the urls are

urlpatterns = patterns('',
url(r'^$', views.IndexView.as_view(), name='index'),
url(r'^(?P\d+)/$', views.DetailView.as_view(), name='detail'),
url(r'^(?P\d+)/results/$', views.ResultsView.as_view(), 
name='results'),

url(r'^(?P\d+)/vote/$', views.vote, name='vote'),
)

Can someone please explain what is wrong?

--
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: django security

2013-09-07 Thread Natko Perko

I browsed through books like Pro Django, Two scoops, Effective Django etc. 
and I pretty much found the same things as in the documentation. I was 
hoping to find, as I said before, a version for dummies with things 
explained from the basics or sowhat, like how does an attack works and how 
to prevent it. Finding 5 pgs about security in a book of 300 pgs about 
django just makes me sad.. 

-- 
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: What's the new "field" parameter in the ManyToOneRel __init__ function?

2013-09-07 Thread Mark Young
Thank you! That tentatively fixes the issue. Now I just need to talk to the 
original author and make the code not use this API at all...

-- 
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: What's the new "field" parameter in the ManyToOneRel __init__ function?

2013-09-07 Thread Mark Young
Er, it's not part of the API. You know what I mean.

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


ImportError No module named django.core

2013-09-07 Thread pzul
Hello,
I just installed Django-1.5.2 in a server (using command : python setup.py 
install)
But now, as I'm expecting to create a new project (django-admin.py 
startproject mysite ), I have this message : 
ImportError No module named django.core

What can I do ?
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: How to redorder app

2013-09-07 Thread Ranjith Kumar
Thanks Guys, but I'm aware of reordering fields... I'm problem is how to 
reorder models in django admin

On Saturday, 7 September 2013 07:25:19 UTC+5:30, Germán wrote:
>
> If you mean reordering *apps*, as in which order the different apps are 
> arranged, I think there is no simple way.
>
> Reorder the models for an specific app ? Same answer.
>
> On Friday, September 6, 2013 3:16:59 AM UTC-5, Ranjith Kumar wrote:
>>
>> Hello,
>> I trying to reorder the app in django admin, is there anyways we can do 
>> it via admin.py?
>>
>> Thank you!
>>
>> -- 
>> Cheers,
>> Ranjith Kumar K,
>> Chennai.
>>
>> http://ranjithtenz.wordpress.com
>>
>>
>> 

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


Re: Login not working.

2013-09-07 Thread Arun K Reddy
Nigel..the problem with your code is..the view is getting confused with the 
view name with original django login method. So, renaming you view is a 
great idea but istead you can do this
from django.contrib.auth import login as auth_login
and call auth_login instead of login after form validation.
And always validate forms.

On Friday, September 6, 2013 7:05:09 PM UTC+5:30, Nigel Legg wrote:
>
> I am using django.contrib.auth, and have created the folowing:
>
> view:
> def login(request):
> if request.method == 'POST':
> form = AuthenticationForm(request.POST)
> if form.is_valid():
> username = request.POST['username']
> password = request.POST['password']
> user = authenticate(username=username, password=password)
> if user is not None:
> login(request, user)
> if login == True:
> return render_to_response('myapp/list.html')
> else:
> error = 'Disabled account. Pay your bill!!'
> return render_to_response('auth/login.html',
> {'form': form, 'error': error },
> context_instance=RequestContext(request)
> )
> else:
> error = 'invalid login...'
> return render_to_response('auth/login.html',
> {'form': form, 'error': error },
> context_instance=RequestContext(request)
> )
> else:
> form = AuthenticationForm()
> return render_to_response(
> 'auth/login.html', {'form': form},
> context_instance=RequestContext(request)
> )
>
> template:
>  
>  
> 
>  enctype="multipart/formdata"> {% csrf_token %}
>  {{ error }} 
>  {{ form.username.label_tag }} {{ form.username }} 
>  {{ form.password.label_tag }} {{ form.password }} 
>   
> 
>
> When I go to the login page, and enter the user details, it returns with 
> "invalid login", in other words it is failing the is_valid() check.  Am I 
> missing something here?  I have checked through the documentation (django 
> 1.5) and don't appear to be. 
> Any help greatly appreciated. 
>
> Cheers, Nigel 
> 07914 740972
>
>  

-- 
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: Login not working.

2013-09-07 Thread Vibhu Rishi
Hi Nigel,

You could also try using django-registration . I found that it made a lot
of the things I was trying with user login/registration easier.

Vibhu



On Fri, Sep 6, 2013 at 8:05 PM, Nigel Legg  wrote:

> I have removed the form.is_valid check and renamed the view, this now
> works (except for not directing to the correct page, it does appear to be
> logging in now)
> Thanks!
>
> Cheers, Nigel
> 07914 740972
>
>
>
> On 6 September 2013 14:35, Nigel Legg  wrote:
>
>> I am using django.contrib.auth, and have created the folowing:
>>
>> view:
>> def login(request):
>> if request.method == 'POST':
>> form = AuthenticationForm(request.POST)
>> if form.is_valid():
>> username = request.POST['username']
>> password = request.POST['password']
>> user = authenticate(username=username, password=password)
>> if user is not None:
>> login(request, user)
>> if login == True:
>> return render_to_response('myapp/list.html')
>> else:
>> error = 'Disabled account. Pay your bill!!'
>> return render_to_response('auth/login.html',
>> {'form': form, 'error': error },
>> context_instance=RequestContext(request)
>> )
>> else:
>> error = 'invalid login...'
>> return render_to_response('auth/login.html',
>> {'form': form, 'error': error },
>> context_instance=RequestContext(request)
>> )
>> else:
>> form = AuthenticationForm()
>> return render_to_response(
>> 'auth/login.html', {'form': form},
>> context_instance=RequestContext(request)
>> )
>>
>> template:
>> 
>>  
>> 
>> > enctype="multipart/formdata"> {% csrf_token %}
>>  {{ error }} 
>>  {{ form.username.label_tag }} {{ form.username }} 
>>  {{ form.password.label_tag }} {{ form.password }} 
>>   
>> 
>>
>> When I go to the login page, and enter the user details, it returns with
>> "invalid login", in other words it is failing the is_valid() check.  Am I
>> missing something here?  I have checked through the documentation (django
>> 1.5) and don't appear to be.
>> Any help greatly appreciated.
>>
>> Cheers, Nigel
>> 07914 740972
>>
>>
>  --
> 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.
>



-- 
Simplicity is the ultimate sophistication. - Leonardo da Vinci
Life is really simple, but we insist on making it complicated. - Confucius

-- 
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: What's the new "field" parameter in the ManyToOneRel __init__ function?

2013-09-07 Thread akaariai
On Saturday, September 7, 2013 6:52:14 AM UTC+3, Mark Young wrote:
>
> For a little bit of context, here's an example of code that perviously 
> worked but now doesn't:
>
> class CategoryAdminForm(forms.ModelForm):
> """Form for Category's Admin"""
> parent = TreeNodeChoiceField(
> label=_('Parent category'),
> level_indicator='|--', required=False,
> empty_label=_('No parent category'),
> queryset=Category.objects.all())
>
> def __init__(self, *args, **kwargs):
> super(CategoryAdminForm, self).__init__(*args, **kwargs)
> rel = ManyToOneRel(Category, 'id')
> self.fields['parent'].widget = RelatedFieldWidgetWrapper(
> self.fields['parent'].widget, rel, self.admin_site)
>

Seems to be the other side of the relation. So, you need the foreign key 
pointing to Category.id, from the above code it isn't obvious what that 
field is. Maybe something like Category._meta.get_field('parent_id') is 
correct?

This might allow both 1.5 and 1.6 to work:
 if django's version is 1.6:
rel = ManyToOneRel(Category._meta.get_field('parent_id'), Category, 
'id')
else:
rel = ManyToOneRel(Category, 'id')

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