prevent change depending on other field values

2012-09-13 Thread Mike Dewhirst
I want to lock a value in a ForeignKey field in a record once two other 
fields are non-blank.


The record can be saved with changes to that ForeignKey field provided 
one of the other two fields is blank.


Other fields in the record can be changed or the record deleted and 
reinserted but it will be a business rule violation to change that 
ForeignKey.


I thought of adding a duplicate field and if both of the other fields 
are non-blank comparing the duplicate with the ForeignKey field to see 
if a violation has occurred. Seems messy.


How can I do this?

Thanks

Mike

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



Re: Cant Import mysite.urls

2012-09-13 Thread Jon Blake
Hi Patrick,
  just got Apache + mod_wsgi to serve part 1 of the tutorial as per Django 
document "How to use Django with Apache and mod_wsgi". Your point taken 
about assuming things are going to be harder than they actually are - my 
redo of part 1 of the tutorial worked pretty well "out of the box" after a 
good night's sleep.

Now to get serving the admin files to work...

On Wednesday, September 12, 2012 9:37:56 AM UTC+10, patrick wrote:
>
> On Tuesday, September 11, 2012 1:44:22 AM UTC-3, Jon Blake wrote:
>>
>> Thanks, Patrick. My reference to utils.py should have been to urls.py, 
>> which I have in my mysite app package.
>>
>> I'm seeing this import error on mysite.urls when I'm attempting to get 
>> Apache + mod_wsgi to serve my app. I don't remember seeing this error with 
>> the development server when I first tried out the tutorials. Probably got 
>> my configs wrong, somewhere in my second try.
>>
>> I'll start a new app, now that I know a little bit more about how this 
>> all works. It's a steep learning curve!
>
>
> It will get better. At one point, I found that the biggest problem I was 
> having that I was expecting things to be harder than they actually were.
>
> You might want to also take a look at the tutorials at: 
> http://lightbird.net/dbe/
>
> They were written for Django 1.2, but should still work in Django 1.4 and 
> get you to build other types of apps, so you'll get more insight into what 
> Django has to offer. 
>

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



Re: -bash: django-admin.py: command not found

2012-09-13 Thread Amyth Arora
Seems like your django-admin.py was not added to your system path, Try the
following command

sudo ln -s /usr/local/lib/python2.6/dist-packages/django/bin/django-admin.py
/usr/local/bin/django-admin.py


-- 
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @a_myth_
http://techstricks.com/

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



Re: get_absolute_url is returning '' instead of url

2012-09-13 Thread Lachlan Musicman
On Fri, Sep 14, 2012 at 2:53 PM, Russell Keith-Magee
 wrote:
> On Fri, Sep 14, 2012 at 10:47 AM, Lachlan Musicman  wrote:
>>> How do I call reverse in the shell? Import it and...?
>>>
>>> reverse(s)?
>>
>> Gah, should have tried that before sending:
>>
> from django.core.urlresolvers import reverse
> reverse(s)
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File 
>> "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
>> line 476, in reverse
>> return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
>> *args, **kwargs))
>>   File 
>> "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
>> line 362, in _reverse_with_prefix
>> raise NoReverseMatch("Error importing '%s': %s." % (lookup_view, e))
>> NoReverseMatch: Error importing 'Friday, Morning 2, Mechanical Tools':
>> 'Session' object has no attribute 'rindex'.
>>
>> Ok, we are getting somewherebut google doesn't turn up anything
>> that I understand/looks applicable?
>
> What's the value of "s" that you're passing to reverse? Reverse takes
> the same arguments as the return value of get_absolute_url() -- i.e.,
> a string URL label, plus a dictionary of kwargs:
>
 reverse('my-url-name', kwargs={'arg1': 'value1'})
>
> The error you're reporting looks like you're passing something other
> than a string into reverse.

I was passing the object into reverse(), not the string...ah newbie
mistakes, they litter the ground around me.

You saw the "problem solved" email? I needed to name the entry in the urls.py...

cheers
L.


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

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

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



Re: get_absolute_url is returning '' instead of url

2012-09-13 Thread Russell Keith-Magee
On Fri, Sep 14, 2012 at 10:47 AM, Lachlan Musicman  wrote:
>> How do I call reverse in the shell? Import it and...?
>>
>> reverse(s)?
>
> Gah, should have tried that before sending:
>
 from django.core.urlresolvers import reverse
 reverse(s)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
> line 476, in reverse
> return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
> *args, **kwargs))
>   File 
> "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
> line 362, in _reverse_with_prefix
> raise NoReverseMatch("Error importing '%s': %s." % (lookup_view, e))
> NoReverseMatch: Error importing 'Friday, Morning 2, Mechanical Tools':
> 'Session' object has no attribute 'rindex'.
>
> Ok, we are getting somewherebut google doesn't turn up anything
> that I understand/looks applicable?

What's the value of "s" that you're passing to reverse? Reverse takes
the same arguments as the return value of get_absolute_url() -- i.e.,
a string URL label, plus a dictionary of kwargs:

>>> reverse('my-url-name', kwargs={'arg1': 'value1'})

The error you're reporting looks like you're passing something other
than a string into reverse.

Yours,
Russ Magee %-)

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



Re: Possible spam from mailing list? ("China Mobile")

2012-09-13 Thread Kurtis Mullins
I actually just received another one of those emails. The funny part is
that it used this exact thread's subject in the message. I'm curious as to
whether this 139.com is emailing everybody who sends an email to the list
or if it only sends emails to people in who are involved in the same
thread(s) as the user responsible.

On Thu, Sep 13, 2012 at 10:32 PM, Rivsen  wrote:

> 13672725...@139.com , he has canceled his cell phone number, please
> administrator kick him.
>
> I use my phone call this number and be informed that the number no longer
> exists.
>
>
> 2012/9/13 Rivsen 
>
>> I received this e-mail too. It's about someone using 139.com email join
>> the group, and now this e-mail address was closed by 139.
>>
>> Maybe hes mobile phone lost or arrears.
>>
>>
>> 2012/9/13 Jon Blake 
>>
>>> I've had a coup[le of these, now.
>>>
>>>
>>> On Tuesday, September 11, 2012 5:27:59 AM UTC+10, Kurtis wrote:

 I just received a very unusual e-mail that included a recent post's
 subject. The post in question was: "Re: form doesn't validate when trying
 to upload file". It was sent directly to my email address; by-passing the
 User Group.

 Google roughly translated this email as coming from "China Mobile" and
 included the domain "139.com". Has anyone else seen this sort of
 thing? Unfortunately, I am unable to read the language and the Google
 Translation isn't very clear; but it's definitely displayed using a very
 clean and fancy template. I'm not sure if it's spam or something else.

 Just figured I'd see if anyone else has gotten an email similar to
 this. Thanks.

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

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



Re: get_absolute_url is returning '' instead of url

2012-09-13 Thread Lachlan Musicman
On Fri, Sep 14, 2012 at 2:47 PM, Lachlan Musicman  wrote:
>> How do I call reverse in the shell? Import it and...?
>>
>> reverse(s)?
>
> Gah, should have tried that before sending:
>
 from django.core.urlresolvers import reverse
 reverse(s)
> Traceback (most recent call last):
>   File "", line 1, in 
>   File 
> "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
> line 476, in reverse
> return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
> *args, **kwargs))
>   File 
> "/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
> line 362, in _reverse_with_prefix
> raise NoReverseMatch("Error importing '%s': %s." % (lookup_view, e))
> NoReverseMatch: Error importing 'Friday, Morning 2, Mechanical Tools':
> 'Session' object has no attribute 'rindex'.
>
> Ok, we are getting somewherebut google doesn't turn up anything
> that I understand/looks applicable?


Have managed to solve the problem by changing my urls.py to:
url(r'^session/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P[-\w]+)/$',
session_view, name='session_view'),

(cf urls.py from the OP)
url(r'^session/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P[-\w]+)/$',
session_view),

I'm confused about what's happening here - but I'm glad it's working.

Thanks for the pointers.

cheers
L.


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

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

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



Re: get_absolute_url is returning '' instead of url

2012-09-13 Thread Lachlan Musicman
> How do I call reverse in the shell? Import it and...?
>
> reverse(s)?

Gah, should have tried that before sending:

>>> from django.core.urlresolvers import reverse
>>> reverse(s)
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
line 476, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
*args, **kwargs))
  File 
"/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
line 362, in _reverse_with_prefix
raise NoReverseMatch("Error importing '%s': %s." % (lookup_view, e))
NoReverseMatch: Error importing 'Friday, Morning 2, Mechanical Tools':
'Session' object has no attribute 'rindex'.

Ok, we are getting somewherebut google doesn't turn up anything
that I understand/looks applicable?

cheers
L.

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

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

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



Re: get_absolute_url is returning '' instead of url

2012-09-13 Thread Lachlan Musicman
On Fri, Sep 14, 2012 at 2:05 PM, Lachlan Musicman  wrote:
> On Fri, Sep 14, 2012 at 1:38 PM, Russell Keith-Magee
>> Something is going wrong in the reversing process, which is raising an
>> exception, which is silently swallowed by the get_absolute_url call.
>> The usual culprit is that either the URL pattern isn't matching what
>> you think, or the object values you're passing into the reversal
>> process aren't what you think they are.
>>
>> My suggestion -- open up a shell, and try making manual calls to
>> reverse(). This will show you whether the problem is with the URL
>> pattern, or with the data from the object.


Ok, this is what I got from where I'm up to in my learn-djshell-quickly:

>>> s = 
>>> Session.objects.filter(slug='mechanical-tools-morning-2').get(date=datetime.date.today)
>>> s.session_number
u'1'
>>> s.date
datetime.date(2012, 9, 14)
>>> s.slug
u'mechanical-tools-morning-2'
>>> s.get_absolute_url()
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/utils/functional.py",
line 11, in _curried
return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
  File 
"/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/db/models/base.py",
line 883, in get_absolute_url
return settings.ABSOLUTE_URL_OVERRIDES.get('%s.%s' %
(opts.app_label, opts.module_name), func)(self, *args, **kwargs)
  File 
"/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/db/models/__init__.py",
line 35, in inner
return reverse(bits[0], None, *bits[1:3])
  File 
"/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
line 476, in reverse
return iri_to_uri(resolver._reverse_with_prefix(view, prefix,
*args, **kwargs))
  File 
"/home/datakid/src/envs/mlhrd/local/lib/python2.7/site-packages/django/core/urlresolvers.py",
line 396, in _reverse_with_prefix
"arguments '%s' not found." % (lookup_view_s, args, kwargs))
NoReverseMatch: Reverse for 'session_view' with arguments '()' and
keyword arguments '{'year': 2012, 'slug':
u'mechanical-tools-morning-2', 'day': 14, 'month': 9}' not found.


How do I call reverse in the shell? Import it and...?

reverse(s)?

cheers
L.


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

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

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



Re: Possible spam from mailing list? ("China Mobile")

2012-09-13 Thread Rivsen
13672725...@139.com , he has canceled his cell phone number, please
administrator kick him.

I use my phone call this number and be informed that the number no longer
exists.

2012/9/13 Rivsen 

> I received this e-mail too. It's about someone using 139.com email join
> the group, and now this e-mail address was closed by 139.
>
> Maybe hes mobile phone lost or arrears.
>
>
> 2012/9/13 Jon Blake 
>
>> I've had a coup[le of these, now.
>>
>>
>> On Tuesday, September 11, 2012 5:27:59 AM UTC+10, Kurtis wrote:
>>>
>>> I just received a very unusual e-mail that included a recent post's
>>> subject. The post in question was: "Re: form doesn't validate when trying
>>> to upload file". It was sent directly to my email address; by-passing the
>>> User Group.
>>>
>>> Google roughly translated this email as coming from "China Mobile" and
>>> included the domain "139.com". Has anyone else seen this sort of thing?
>>> Unfortunately, I am unable to read the language and the Google Translation
>>> isn't very clear; but it's definitely displayed using a very clean and
>>> fancy template. I'm not sure if it's spam or something else.
>>>
>>> Just figured I'd see if anyone else has gotten an email similar to this.
>>> Thanks.
>>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/yZnQCJfOEekJ.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>

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



Re: get_absolute_url is returning '' instead of url

2012-09-13 Thread Lachlan Musicman
On Fri, Sep 14, 2012 at 1:38 PM, Russell Keith-Magee
 wrote:
> On Fri, Sep 14, 2012 at 9:07 AM, Lachlan Musicman  wrote:
>> Hi,
>>
>> I'm getting blank get_absolute_url problems that I just can't solve. I
>> can get to an object by actually visiting the url that would be
>> constructed - I've checked that: app/session/year/month/day/slug
> …
>> And the view seems to be properly constructed - I've got debug on, and
>> I'm getting the page I expected rendering. It's only the
>> get_absolute_url that's coming back blank.
>
> Something is going wrong in the reversing process, which is raising an
> exception, which is silently swallowed by the get_absolute_url call.
> The usual culprit is that either the URL pattern isn't matching what
> you think, or the object values you're passing into the reversal
> process aren't what you think they are.
>
> My suggestion -- open up a shell, and try making manual calls to
> reverse(). This will show you whether the problem is with the URL
> pattern, or with the data from the object.

Ok - I appreciate your quick and learned response. Unfortunately I'm
not as deep as you are and am still struggling with how the shell
actually works thoroughly, despite a number of attempts.

First: I'm not using reverse explicitly - I did leave a lot of non
useful code out of my post. Should I be importing the url reverse
function somewhere?

Second: if it's happening under the hood, which I expect is the case,
is there an easy way from within the shell to use the data I have
without having to import everything? Previous attempts have stalled at
"hey where is everything? Isn't settings/db/models imported? etc" Am
searching for django shell examples/howtos and revisiting the tutorial
in other tabs. Unfort am on very limited bandwidth connection (in
Kiribati, via satellite, semi regular brown/black outs).

My own thoughts have converged on "I presume if I wrote tests like
every normal dev then this would be a lot easier. Must learn tests.
Sometime soon."

> Next step; put some debug into get_absolute_url itself -- make a
> manual call to reverse inside get_absolute_url, and catch/print any
> exception that is raised.

Directly into the Django code? Ok. I can do that. I'm glad the
weekends coming and that I have the django and py docs in offline
html.

> Hopefully, that should give you enough detail as to the source of the problem.

Really appreciate your help.

L.


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



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

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

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



Re: get_absolute_url is returning '' instead of url

2012-09-13 Thread Russell Keith-Magee
On Fri, Sep 14, 2012 at 9:07 AM, Lachlan Musicman  wrote:
> Hi,
>
> I'm getting blank get_absolute_url problems that I just can't solve. I
> can get to an object by actually visiting the url that would be
> constructed - I've checked that: app/session/year/month/day/slug
…
> And the view seems to be properly constructed - I've got debug on, and
> I'm getting the page I expected rendering. It's only the
> get_absolute_url that's coming back blank.

Something is going wrong in the reversing process, which is raising an
exception, which is silently swallowed by the get_absolute_url call.
The usual culprit is that either the URL pattern isn't matching what
you think, or the object values you're passing into the reversal
process aren't what you think they are.

My suggestion -- open up a shell, and try making manual calls to
reverse(). This will show you whether the problem is with the URL
pattern, or with the data from the object.

Next step; put some debug into get_absolute_url itself -- make a
manual call to reverse inside get_absolute_url, and catch/print any
exception that is raised.

Hopefully, that should give you enough detail as to the source of the problem.

Russ %-)

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



get_absolute_url is returning '' instead of url

2012-09-13 Thread Lachlan Musicman
Hi,

I'm getting blank get_absolute_url problems that I just can't solve. I
can get to an object by actually visiting the url that would be
constructed - I've checked that: app/session/year/month/day/slug

models.py:
class Session(models.Model):
...
@models.permalink
def get_absolute_url(self):
return ('session_view', (), {
'year': self.date.year,
'month': self.date.month,
'day': self.date.day,
'slug': self.slug})

As you can see from the template snippet below, I'm printing out all
that makes up the url, and am getting correct results, except for
get_absolute_url

template:
{% for x in session %}
{{
x.subject.name }} {{ x.date.year }} {{ x.date.month }} {{
x.date.day}} {{ x.slug }}

I'm importing the session_view
urls.py:

from tafe.views import session_create, session_view, timetable_daily_view
...
url(r'^session/(?P\d{4})/(?P\d{1,2})/(?P\d{1,2})/(?P[-\w]+)/$',
session_view),

And the view seems to be properly constructed - I've got debug on, and
I'm getting the page I expected rendering. It's only the
get_absolute_url that's coming back blank.

views.py
@login_required
def session_view(request, year, month, day, slug):
   req_date = datetime.date(int(year), int(month), int(day))
   session = get_object_or_404(Session, slug=slug, date=req_date)

   return render_to_response('tafe/session_detail.html',{'session':session})


I've even checked that the objects have the slugs as per expected in
the admin interface (although visiting the address that the g_a_u
should be returning works, so that was already a given.)

Any ideas? Any tips on where to start looking?

cheers
L.

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

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

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



Re: New to Django, need help starting

2012-09-13 Thread Jono
Dear Kurtis,

I'm brand new to Django and I have a bash and symlink issue I think with 
PATH. I cannot run django-admin.py.
I want to take your advice and reinstall use Mac Brew etc. as you mention 
below.
Would you mind elaborating on what you explain for an absolute n00b like 
myself?

On Wednesday, June 20, 2012 5:07:13 PM UTC+2, Kurtis wrote:
>
> Try "easy_install django" or "pip install django".
>
> Really, though -- I recommend going with a combination of Mac Brew (or 
> ports or whatever third-party distribution) to install Python and pip then 
> install virtualenv and virtualenvwrapper to create a virtual environment, 
> then inside of the virtual environment, install Django and your 
> MySQL-Python (or whatever database driver you need)
>
> It *sounds* like a lot of work but it will make things considerably easier 
> for you in the long run.
>
> If not, just download django (from git) and then run its setup.py and you 
> should be all good to go with runserver and sqlite
>
> On Wed, Jun 20, 2012 at 9:19 AM, Harjot Mann 
>  > wrote:
>
>> do one thing open ur terminal and run the following command
>> python
>> then u will get
>> Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24) 
>> [GCC 4.5.2] on linux2
>> Type "help", "copyright", "credits" or "license" for more information.
>> then type
>> >>> import  django
>> >>> print django.get_version()
>> if you have version 1.4 then it will print 1.4 
>> It is just a verification that ur django is installed or not.
>>
>>
>> On Wed, Jun 20, 2012 at 5:23 PM, Diego pascual lopez 
>> > > wrote:
>>
>>>
>>>
>>> On Wed, Jun 20, 2012 at 1:49 PM, kenneth gonsalves <
>>> law...@thenilgiris.com > wrote:
>>>
 On Wed, 2012-06-20 at 13:15 +0200, Diego pascual lopez wrote:
 > > try typing /path_to_django/bin/django-admin.py startproject
 > >
 >
 > If you don't know the path of the django-admin.py, you can type
 >
 > #which django-admin.py

 it will say 'no django-admin.py'

>>>  
>>> Yes, you have reason.
>>>
>>> Sorry.
>>>
>>> --
 regards
 Kenneth Gonsalves

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


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

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



-bash: django-admin.py: command not found

2012-09-13 Thread Jono
I don't understand PATH and symlink and its relationship to trying to run 
django-admin.py for the first time.

As you experienced users will see below I'm trying to create a new project 
and following the tutorial on djangoproject.com.

Here is what my bash shows...

Jonos-MacBook-Pro:djcode Jono$ django-admin.py startproject mysite
-bash: django-admin.py: command not found
Jonos-MacBook-Pro:djcode Jono$ ln -s 
`pwd`/django-trunk/django/bin/django-admin.py /usr/local/bin
ln: /usr/local/bin/django-admin.py: File exists
Jonos-MacBook-Pro:djcode Jono$ python django-admin.py startproject mysite
python: can't open file 'django-admin.py': [Errno 2] No such file or 
directory

I looked for solutions but I don't understand what the issue is or the 
troubleshooting mentioned here.
https://docs.djangoproject.com/en/dev/faq/troubleshooting/

Please could someone lend a hand?

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



Re: Alternatives to CBVs (class based views)

2012-09-13 Thread Russell Keith-Magee
On Thu, Sep 13, 2012 at 12:58 AM, Cal Leeming [Simplicity Media Ltd]
 wrote:
> Hi all,
>
> There is a lot of debate on whether there is a real future for the Django
> CBVs (class based views).

Sigh.

No - there isn't *any* debate about the future of CBVs. There *are* a
lot of people who apparently don't like them who keep making a lot of
noise. Every single time I've spoken with one of those people at
length, the problem has reduced to either:

 1) I don't like classes/OO. There's no winning these people over.

 2) CBV's aren't documented well. You won't get any argument from me
on (2). I'll take the hit for that -- the initial documentation for
CBVs was my doing, and it has lots of room for improvement.

I'm not aware of anyone in the core that has advocated removing
class-based views from Django.

> Personally, I find them tedious, and just wanted a
> way to keep my views clean.
>
> So, here is a really minimalistic way of having class based views, without
> the fuss.
>
> http://djangosnippets.org/snippets/2814/
>
> This is a fork from:
>
> http://stackoverflow.com/questions/742/class-views-in-django
> http://djangosnippets.org/snippets/2041/
>
> My thanks to eallik for his initial post on stackoverflow for this.
>
> Personally I think Django's CBVs should offer a really minimalistic base
> like this, as well as the existing CBV stuff already in the core - so as to
> not force people into needing to learn an entirely new way of doing things,
> but at the same time allowing them to reap some of the benefits of using
> callable classes as views.
>
> Any thoughts?

What you've described -- a single entry point class-based view base
class -- *does* exist. It's called django.views.generic.View. Override
the "dispatch" method, or write a "get/post/put/etc" method, and
you've got a class-based view.

I also think you should read the discussions that led to the current
form of Class-based views. The pattern you've proposed from Stack
Overflow was one of many suggestions that were made, and were rejected
because of inherent problems with the approach. The discussions are
summarised in the wiki:

https://code.djangoproject.com/wiki/ClassBasedViews

Yours,
Russ Magee %-)

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



Re: Problem Accessing Admin Pages

2012-09-13 Thread Lachlan Musicman
On Fri, Sep 14, 2012 at 7:40 AM, bml1rules  wrote:
> Hey Guys!
>
> I am the webmaster of a Django database and I recently ran into a snag. We
> have an admin section with about 15 privileges. All of a sudden, almost all
> of them are gone. I've tried getting to them by typing in the url, but it
> just takes me back to the main page. However, the pages are still there and
> it just redirects me. I know this isn't much information, but does anyone

If  "it just redirects me" implies that there are other accounts that
*aren't* being redirected, try logging into one of those (admin level)
accounts?

if "it just redirects me" implies 'and there seems to be nothing I can
do', you might need to look into the db via some other method eg:
manage.py shell/phpmyadmin/mysql@command line...

Cheers
L.


> have any idea what I could do to fix this problem?
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/bzAJxJAa3ecJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



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

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

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



Problem Accessing Admin Pages

2012-09-13 Thread bml1rules
Hey Guys!

I am the webmaster of a Django database and I recently ran into a snag. We 
have an admin section with about 15 privileges. All of a sudden, almost all 
of them are gone. I've tried getting to them by typing in the url, but it 
just takes me back to the main page. However, the pages are still there and 
it just redirects me. I know this isn't much information, but does anyone 
have any idea what I could do to fix this problem?

Thanks!

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



Looking for Django Developer Position in Singapore

2012-09-13 Thread lakshmen45
Looking for a django-developer position in singapore. If interested, do
contact me at lakshmen45 at gmail dot com. I will pass you my resume and
details.. Thanks..



--
View this message in context: 
http://python.6.n6.nabble.com/Looking-for-Django-Developer-Position-in-Singapore-tp4988643.html
Sent from the django-users mailing list archive at Nabble.com.

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



Re: testing a django package

2012-09-13 Thread Jonas Geiregat
Found the answer:

I need to put from tests import * in the tests/__init__.py file 

> Actually, Django TestCases can override the URLConf, which allows you to have 
> a given URL for a given view in your test:
> 
> from django.test import TestCase
> 
> class MyTestCase(TestCase):
> urls = 'mypackage.tests.urls'
> 
> def test_something():
> # Do stuff...
> 
> 
> From there, you can *totally* just create a tests/views.py file where you add 
> your test view with the actual implementation you're missing, and add it in 
> your tests/urls.py file.
> 
> And everything will be fine : )
> 
> Le mercredi 12 septembre 2012 23:36:03 UTC+2, jonas a écrit :
> 
> 
> 
> > I think you could create an urls.py file for your tests and attach 
> > your views there. Then use the test client to direct requests to those 
> > test URLs and assert that the response is what you expect. 
> 
> I didn't know that could work. 
> I think I'll also need to create views that extend these views that I want to 
> test. 
> Since they need actual implementation, I think, such as template_name and 
> model etc .. 
> 
> How would the test client then now where to look for these views, since there 
> will be some reversing involved I think. 
> 
> self.client.get(reverse("ajax_form_view")) 
> 
> I don't see how the client will find my urls.py file and without the broader, 
> actual django application as context ? 
> 
> 
> > 
> > Now, this is probably not going to be practical to test your jQuery 
> > components, but you might want to ask on a JS-focused list regarding 
> > unittesting JS for this purpose. 
> > 
> > Thomas 
> > 
> > 2012/9/12 Jonas Geiregat : 
> >> 
> >> I can now show you what I really would like to write tests for. 
> >> 
> >> https://github.com/jonasgeiregat/django-ajax-forms 
> >> 
> >> The code I would like to test is in ajax_forms/views.py mainly the 
> >> AjaxFormView and the AjaxModelFormView. 
> >> 
> >> Any help is appreciated! 
> >> 
> >> 
> >> Is it a view mix in? 
> >> 
> >> The package actually already changed from containing a view mix in to 
> >> actual 
> >> views that should be subclassed by the users using the package. 
> >> 
> >> It's a bit difficult to tell you much without more information. 
> >> 
> >> For example, a view derived from FormView. Like I said the user should 
> >> subclass this view again as you would normally do with CBV. 
> >> 
> >> Currently the package is just a package/directory with views.py, 
> >> models.py, 
> >> urls.py and of course __init__.py to make it a module. 
> >> 
> >> It's hard to test views without having an actual django project to test it 
> >> again, I think.  Correct me if I'm wrong here. 
> >> So I created an example django project that is using this package in the 
> >> directory below the package, thus the directory containing the README, 
> >> setup.py etc .. files. 
> >> 
> >> The example app will hold a tests.py file which will contain my tests 
> >> which 
> >> will be testing the actual functionality of my views. 
> >> 
> >> Basically I'm asking do I need an actual django project to test just a 
> >> views.py file or can I just write some tests without a containing django 
> >> project to test a views.py file. 
> >> And if so, I'm kinda lost on how you would start on such a task. 
> >> 
> >> A few you things that you may find useful or not for testing : 
> >> 
> >> .  Test cases can override settings such as the urlconf 
> >> .  There's a test client to test views 
> >> .  Class based views can sometimes be tested without any of the former by 
> >> just testing the methods in them 
> >> .   You can always use mocking library 
> >> .  Tests are basically just python code with a lot of asserts, you can 
> >> always add viewed in them 
> >> .  You can use fixtures for test data if you see fit 
> >> 
> >> Hope this helps! 
> >> 
> >> Thomas 
> >> 
> >> On Sep 10, 2012 5:23 PM, "Jonas Geiregat"  wrote: 
> >>> 
> >>> Hello, 
> >>> 
> >>> I've created a simple reusable django package. This package basically 
> >>> consists out of a views.py file, with some helper functions. 
> >>> 
> >>> I want to write some tests for what's in this file. This file contains a 
> >>> mixin , so I probably can't test it directly. 
> >>> 
> >>> What's the best way to test a django package ? 
> >>> 
> >>> Do I need to include some kind of example project that, uses my mixin and 
> >>> has tests files just as one would test a normal django application ? 
> >>> 
> >>> I've tried googling but, there's little about this. Most of the things 
> >>> I've found where related to testing actual django applications. 
> >>> 
> >>> Any help is appreciated. 
> >>> 
> >>> Jonas 
> >>> 
> >>> 
> >>> -- 
> >>> You received this message because you are subscribed to the Google Groups 
> >>> "Django users" group. 
> >>> To post to this group, send email to django...@googlegroups.com. 
> >>> To unsubscribe from this group, send email to 
> >>> 

Re: testing a django package

2012-09-13 Thread Jonas Geiregat
Thanks you for your help. 

I understand now how I should setup testing for a django package. I'm using 
django-registration as an example , which works a similar way.

I have a weird problem at hand.
I'm creating a django package and would like to provide some test cases for it.
The package is named ajax_forms and the full path is part of my PYTHONPATH. 
This directory also contains a tests directory (with the init.py file) a 
tests.py file (containing the tests) and a urls.py file.
Now I want to run the tests.

The ajax_forms parent directory has an example project setup with ajax_forms in 
INSTALLED_APPS.

But I can't seem to let the tests run:

 >> ./manage.py test ajax_forms
Creating test database for alias 'default'...

--
Ran 0 tests in 0.000s

OK
Destroying test database for alias 'default'...

No tests are found so I try to be more specific:

 >> ./manage.py test ajax_forms.tests

raise ValueError("Test label '%s' does not refer to a test" % label)
ValueError: Test label 'ajax_forms.tests' does not refer to a test
(ajax-validation)

Even ./manage.py ajax_forms.tests.tests.AjaxFormViewTest will not find the 
tests and gives the same error as above.

But trying to import the test case from the ./manage.py shell works fine

In [2]: from ajax_forms.tests.tests import AjaxFormViewTest

I'm kinda clueless here, on what's going on.


> 
> 
> 
>> I think you could create an urls.py file for your tests and attach
>> your views there. Then use the test client to direct requests to those
>> test URLs and assert that the response is what you expect.
> 
> I didn't know that could work. 
> I think I'll also need to create views that extend these views that I want to 
> test.
> Since they need actual implementation, I think, such as template_name and 
> model etc ..
> 
> How would the test client then now where to look for these views, since there 
> will be some reversing involved I think.
> 
> self.client.get(reverse("ajax_form_view"))
> 
> I don't see how the client will find my urls.py file and without the broader, 
> actual django application as context ?
> 
> 
>> 
>> Now, this is probably not going to be practical to test your jQuery
>> components, but you might want to ask on a JS-focused list regarding
>> unittesting JS for this purpose.
>> 
>> Thomas
>> 
>> 2012/9/12 Jonas Geiregat :
>>> 
>>> I can now show you what I really would like to write tests for.
>>> 
>>> https://github.com/jonasgeiregat/django-ajax-forms
>>> 
>>> The code I would like to test is in ajax_forms/views.py mainly the
>>> AjaxFormView and the AjaxModelFormView.
>>> 
>>> Any help is appreciated!
>>> 
>>> 
>>> Is it a view mix in?
>>> 
>>> The package actually already changed from containing a view mix in to actual
>>> views that should be subclassed by the users using the package.
>>> 
>>> It's a bit difficult to tell you much without more information.
>>> 
>>> For example, a view derived from FormView. Like I said the user should
>>> subclass this view again as you would normally do with CBV.
>>> 
>>> Currently the package is just a package/directory with views.py, models.py,
>>> urls.py and of course __init__.py to make it a module.
>>> 
>>> It's hard to test views without having an actual django project to test it
>>> again, I think.  Correct me if I'm wrong here.
>>> So I created an example django project that is using this package in the
>>> directory below the package, thus the directory containing the README,
>>> setup.py etc .. files.
>>> 
>>> The example app will hold a tests.py file which will contain my tests which
>>> will be testing the actual functionality of my views.
>>> 
>>> Basically I'm asking do I need an actual django project to test just a
>>> views.py file or can I just write some tests without a containing django
>>> project to test a views.py file.
>>> And if so, I'm kinda lost on how you would start on such a task.
>>> 
>>> A few you things that you may find useful or not for testing :
>>> 
>>> .  Test cases can override settings such as the urlconf
>>> .  There's a test client to test views
>>> .  Class based views can sometimes be tested without any of the former by
>>> just testing the methods in them
>>> .   You can always use mocking library
>>> .  Tests are basically just python code with a lot of asserts, you can
>>> always add viewed in them
>>> .  You can use fixtures for test data if you see fit
>>> 
>>> Hope this helps!
>>> 
>>> Thomas
>>> 
>>> On Sep 10, 2012 5:23 PM, "Jonas Geiregat"  wrote:
 
 Hello,
 
 I've created a simple reusable django package. This package basically
 consists out of a views.py file, with some helper functions.
 
 I want to write some tests for what's in this file. This file contains a
 mixin , so I probably can't test it directly.
 
 What's the best way to test a django package ?
 
 Do I need to include some kind 

Re: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Thomas Lockhart

On 9/13/12 10:37 AM, Bob Aalsma wrote:
Hmm, I'd seen this solution in 
http://keeyai.com/2012/02/17/django-deployment-create-superuser-fails-with-locale-error/ 
but was reluctant to use this as " I have no idea if this causes any 
negative side effects."

A running system is not usually considered a negative side effect ;)

Everything will fail without this mod afaik.


So that is the official repair?
Mac OS does not set the default language environment in a way that 
python (at least) recognizes. This is true for python installations done 
from MacPorts so I think it is independent of the installation 
technique. You will need to do this (slight) mod to manage.py to have 
things work.


Since you are on Mac OS X, I *strongly* recommend using virtualenv to do 
your basic installation of packages. Once you get a mix of python libs 
which may install under the original python installation, or may install 
under the MacPorts installation area, or may install somewhere else, you 
will slowly go nuts trying to keep it straight.


virtualenv gets you a consistent development and runtime environment and 
is very repeatable.


I'm not remembering when in the process you will find failures if you 
are missing that mod to manage.py; I have not tracked down your links to 
other places. Do you want to post the exact error you are seeing?


hth

   - Tom


OK.
Thanks!

Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:


I'm a newbie following the tutorial. In this, creating a superuser
is described, using

manage.py createsuperuser --username=joe --email=j...@example.com  



Using this leads to an error, which I could match to the closed
ticket #16017.

But I couldn't find how to proceed from there. It seems some
software was changed about 4 weeks ago:
"Made createsuperuser more robust when getting current OS username."

So where can I find it?
[I'm assuming there is a procedure for this, but I'm sorry to say
I couldn't find that either]

Regards,
Bob

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/LbEFlfhWbVoJ.

To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


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



Re: not picking up new template

2012-09-13 Thread Larry Martell
On Thu, Sep 13, 2012 at 12:51 PM, Dennis Lee Bieber
 wrote:
> On Thu, 13 Sep 2012 10:52:44 -0600, Larry Martell
>  declaimed the following in
> gmane.comp.python.django.user:
>
>
>> So by stepping through a lot of code, I finally figured this out. The
>> new template was accidently named Rollup and it should have been named
>> RollUp (capital U). Weird thing is that it worked on a mac, but not on
>> CentOS. Thanks much for the help Thomas.
>>
> I'm not familiar with either, but could this be a case of the
> difference between a
>
> case-insensitive/case-preserving
> and
> case-sensitive
>
> operating system.
>
> Most UNIX/Linux variants tend to be the latter. The Mac may use a
> modified file-system to inherit older insensitivity (to avoid confusing
> users). I do know that, on Windows, "RollUp.xyz" and "Rollup.xyz" would
> be the same file.

MacOS is Unix based so this surprised me. Not being case sensitive
confuses me. But the Mac appears to be somewhat inconsistent:

$ ls
RollUp
$ ls -d Rollup
Rollup
$ ls -d RollUp
RollUp
$ find . -name Rollup -print
$ find . -name RollUp -print
./RollUp

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



Re: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Kurtis Mullins
Try installing python using "brew" or another packaging utility

On Thu, Sep 13, 2012 at 1:54 PM, Bob Aalsma wrote:

> Umm, could you be more specific about how/where to put this?
> All the combinations and location I could think of will all still give the
> same error...
>
>
>
>
> Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het
> volgende:
>
>> I'm a newbie following the tutorial. In this, creating a superuser is
>> described, using
>>
>> manage.py createsuperuser --username=joe --email=j...@example.com
>>
>>
>> Using this leads to an error, which I could match to the closed ticket
>> #16017.
>>
>> But I couldn't find how to proceed from there. It seems some software was
>> changed about 4 weeks ago:
>> "Made createsuperuser more robust when getting current OS username."
>>
>> So where can I find it?
>> [I'm assuming there is a procedure for this, but I'm sorry to say I
>> couldn't find that either]
>>
>> Regards,
>> Bob
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/shAajf44XV4J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Basic auth struggle

2012-09-13 Thread Thomas Orozco
Could you us the line where you import login?
On Sep 13, 2012 2:06 PM, "Timster"  wrote:

> What does the rest of your views.py file look like?
>
> Do you happen to have a view named login()?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/ANUnnrLEVB8J.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Bob Aalsma
Umm, could you be more specific about how/where to put this?
All the combinations and location I could think of will all still give the 
same error...



Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
>
> manage.py createsuperuser --username=joe --email=j...@example.com
>
>
> Using this leads to an error, which I could match to the closed ticket 
> #16017.
>
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
>
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I 
> couldn't find that either]
>
> Regards,
> Bob
>

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



Re: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Bob Aalsma
Hmm, I'd seen this solution in 
http://keeyai.com/2012/02/17/django-deployment-create-superuser-fails-with-locale-error/
 
but was reluctant to use this as " I have no idea if this causes any 
negative side effects."
So that is the official repair?
OK.
Thanks!

Op donderdag 13 september 2012 16:58:11 UTC+2 schreef Bob Aalsma het 
volgende:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
>
> manage.py createsuperuser --username=joe --email=j...@example.com
>
>
> Using this leads to an error, which I could match to the closed ticket 
> #16017.
>
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
>
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I 
> couldn't find that either]
>
> Regards,
> Bob
>

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



Re: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Tom Lockhart

On 2012-09-13, at 10:17 AM, Bob Aalsma wrote:

> Django 1.4.1
> Python 2.7.3
> OS X 10.7.4

Ah, OS X…

You need to (slightly) modify your manage.py file to add this near the top:

import os
os.environ.setdefault('LANG','en_CA')

substituting your favorite language setting of course.

hth

- Tom


> 
> 
> Op donderdag 13 september 2012 19:12:30 UTC+2 schreef creecode het volgende:
> Which version of django are you using?
> 
> On Thursday, September 13, 2012 7:58:11 AM UTC-7, Bob Aalsma wrote:
> 
> I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
> manage.py createsuperuser --username=joe --email=j...@example.com
> 
> Using this leads to an error, which I could match to the closed ticket #16017.
> 
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
> 
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I couldn't 
> find that either]
> 
> Toodle-loo.
> creecode 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To view this discussion on the web visit 
> https://groups.google.com/d/msg/django-users/-/UnmJDyc7alQJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



Re: Hung apache threads after upgrading to django 1.4

2012-09-13 Thread Dane
We have extended status on.  Here is a link to our full status output. 
 This does not occur consistently, but under high traffic we see an 
increasing amount of occurrences.

I appreciate the help.

http://pastebin.com/wP8Xfrwf

On Wednesday, September 12, 2012 9:20:10 AM UTC-5, Tom Evans wrote:
>
> On Wed, Sep 12, 2012 at 2:49 PM, Dane  
> wrote: 
> > After using django 1.3 for a while I upgraded to django 1.4 and started 
> > noticing apache threads hanging indefinitely.  I set a timeout to avoid 
> > running out of threads, but it would be nice to know what is causing the 
> > issue in the first place. 
> > 
> > Using an strace, I found that the threads are attempting to read from a 
> > socket and are not doing anything after that. 
> > 
> > The apache logs were not helpful, but we did find the following 
> stacktrace 
> > in our mod_wsgi process: 
>
> The stacktrace doesn't look relevant tbh. 
>
> How are you determining that you have hanging threads? Eg, is the 
> scoreboard completely full? 
>
> It would be easier to debug if you could capture a snapshot of the 
> scoreboard whilst you think you are being affected. mod_status is your 
> friend, turn "ExtendedStatus on". 
>
> Cheers 
>
> Tom 
>

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



Re: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Bob Aalsma
Django 1.4.1
Python 2.7.3
OS X 10.7.4


Op donderdag 13 september 2012 19:12:30 UTC+2 schreef creecode het volgende:
>
> Which version of django are you using?
>
> On Thursday, September 13, 2012 7:58:11 AM UTC-7, Bob Aalsma wrote:
>
> I'm a newbie following the tutorial. In this, creating a superuser is 
>> described, using 
>>
>> manage.py createsuperuser --username=joe --email=j...@example.com
>>
>>
>> Using this leads to an error, which I could match to the closed ticket 
>> #16017.
>>
>> But I couldn't find how to proceed from there. It seems some software was 
>> changed about 4 weeks ago:
>> "Made createsuperuser more robust when getting current OS username."
>>
>> So where can I find it?
>> [I'm assuming there is a procedure for this, but I'm sorry to say I 
>> couldn't find that either]
>>
>
> Toodle-loo.
> creecode 
>

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



Re: newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread creecode
Which version of django are you using?

On Thursday, September 13, 2012 7:58:11 AM UTC-7, Bob Aalsma wrote:

I'm a newbie following the tutorial. In this, creating a superuser is 
> described, using 
>
> manage.py createsuperuser --username=joe --email=j...@example.com 
> 
>
>
> Using this leads to an error, which I could match to the closed ticket 
> #16017.
>
> But I couldn't find how to proceed from there. It seems some software was 
> changed about 4 weeks ago:
> "Made createsuperuser more robust when getting current OS username."
>
> So where can I find it?
> [I'm assuming there is a procedure for this, but I'm sorry to say I 
> couldn't find that either]
>

Toodle-loo.
creecode 

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



Re: not picking up new template

2012-09-13 Thread Larry Martell
On Thu, Sep 13, 2012 at 7:11 AM, Larry Martell  wrote:
> On Wed, Sep 12, 2012 at 11:39 AM, Thomas Orozco  wrote:
>> Can you being up a manage.py shell and load the template from there to
>> identify where's Django is pulling the template from?
>
> I'm trying to do that, but I get:
>
 t = Template('/path/to/template.html')
 t.name
> ''
>
> I get the even on my Mac, where it is working, so clearly I'm doing
> something wrong.
>
>
>> You should be able to go step by step and identify where you're pulling the
>> old template in!
>>
>> If you don't find anything, it's probably because your template actually
>> isn't different from the older one.
>>
>> You should be able to do that using pdb and the Django code base :-)
>
> I may resort to that.

So by stepping through a lot of code, I finally figured this out. The
new template was accidently named Rollup and it should have been named
RollUp (capital U). Weird thing is that it worked on a mac, but not on
CentOS. Thanks much for the help Thomas.


>> There might be a quicker way though, I'll have a look at it.
>>
>> Thomas
>>
>> On Sep 12, 2012 5:59 PM, "Larry Martell"  wrote:
>>>
>>> On Wed, Sep 12, 2012 at 11:56 AM, Thomas Lockhart
>>>  wrote:
>>> > On 9/12/12 8:27 AM, Larry Martell wrote:
>>> >>
>>> >> On my Mac, I changed a template, and the change was picked up, no
>>> >> problem. I checked my change into git, went to another machine, a
>>> >> CentOS box, pulled the change down, but django is not picking it up.
>>> >> I've tried everything I can think of - bounced the server, restarted
>>> >> the browser, cleared the cache and cookies, tried 3 different
>>> >> browsers, deleted it, re-pulled from git, but when I look at the code
>>> >> in the debugger, it's clearly using the old template. There are no
>>> >> errors in the apache log, permissions are fine, I'm tearing my hair
>>> >> out here. Anyone have any ideas as to what's preventing it from
>>> >> picking up the new template, or what I can check to figure out what's
>>> >> going on?
>>> >>
>>> > Need to collect static content for your production server?
>>>
>>> I had already tried that (even thought this change did not effect the
>>> static content).
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.

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



OR together multiple extra clauses

2012-09-13 Thread stratos moros
Hello,

I am having some trouble using Queryset's extra method. I can't find a
way
to OR together multiple such clauses. Here's my case:

I am using Django 1.4 on PostgreSQL 9.2 and I need to perform accent
insensitive queries on some models. In Postgres, this is handled by
the
unaccent function.

The best way I've found to perform this query through Django's ORM is
by using
the extra method, like so:

queryset.extra(
where=['unaccent("table_name"."column_name"::text) LIKE
unaccent(%s)'],
params=['%%%s%%' % value]
)

Since I need to perform similar queries all over my codebase, I've
written
some wrappers around Django's lookups, so the above can be substituted
by:

queryset = contains_ai(queryset, attribute_name, value)

The problem I'm having is that depending on the request I need to
compose
multiple such queries, sometimes with OR statements. As far as I know
the only
way to OR together multiple filters is by using Q objects, but there
is no way
to use extra (or even raw sql) with them. I could write both OR
clauses on the
where clause, but then I will no longer be able to conditionaly
compose
multiple such statements together.

Is there a way to OR together results form the extra method?

Thanks for your help!

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



How to add a ManyToManyField at runtime?

2012-09-13 Thread James Pic
Hello everybody,

This is what I'm trying to do:

def test_basic_addition(self):
# create field
f = models.ManyToManyField(to=X, related_name='bar')
f.contribute_to_class(Y, 'x')

# create table
field = Y._meta.get_field_by_name('x')[0]
through = field.rel.through

fields = tuple((field.name, field) for field in
through._meta.fields)

db.create_table(through._meta.db_table, fields)
db.create_unique(through._meta.db_table,
['%s_id' % name for name, f in fields
if isinstance(f, models.ForeignKey)])


x = X(name='foo')
x.save()
y = Y()
y.save()
y.x.add(x)

print y.x.all()

The exception thrown is:


E
==
ERROR: test_basic_addition (test_app.tests.SimpleTest)
--
Traceback (most recent call last):
  File "/home/jpic/test_project/test_app/tests.py", line 41, in
test_basic_addition
print y.x.all()
  File
"/home/jpic/env/local/lib/python2.7/site-packages/django/db/models/manager.py",
line 116, in all
return self.get_query_set()
  File
"/home/jpic/env/local/lib/python2.7/site-packages/django/db/models/fields/related.py",
line 543, in get_query_set
return super(ManyRelatedManager,
self).get_query_set().using(db)._next_is_sticky().filter(**self.core_filters)
  File
"/home/jpic/env/local/lib/python2.7/site-packages/django/db/models/query.py",
line 621, in filter
return self._filter_or_exclude(False, *args, **kwargs)
  File
"/home/jpic/env/local/lib/python2.7/site-packages/django/db/models/query.py",
line 639, in _filter_or_exclude
clone.query.add_q(Q(*args, **kwargs))
  File
"/home/jpic/env/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
line 1250, in add_q
can_reuse=used_aliases, force_having=force_having)
  File
"/home/jpic/env/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
line 1122, in add_filter
process_extras=process_extras)
  File
"/home/jpic/env/local/lib/python2.7/site-packages/django/db/models/sql/query.py",
line 1316, in setup_joins
"Choices are: %s" % (name, ", ".join(names)))
FieldError: Cannot resolve keyword 'bar' into field. Choices are: id,
name, users

--
Ran 1 test in 0.017s

FAILED (errors=1)
Destroying test database for alias 'default'...


`del X._meta._name_map` doesn't do the trick but i guess that's normal
because it's a reverse field that come from the other model, Y.

Anyway, you can checkout my [test_project][1] which isolates my problem,
and then run `./manage.py test test_app` in your working copy to reproduce
the issue.

  [1]: https://github.com/jpic/test_project/

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



Re: Django and LDAP

2012-09-13 Thread Ivan Pavlović
Thank you sbrandt. I found the same thing, but i don't know how to use it.
Where do i need to copy the files and do i erase some lines of the code or
not, to make them as comments. I'm trying but i am not succeeding at making
it work...

Can you help me about that?

On Thu, Sep 13, 2012 at 10:16 AM, sbrandt wrote:

> Did you know there is django-auth-ldap which is a custom backend for
> authenticating users through LDAP?
> http://pypi.python.org/pypi/django-auth-ldap/
>
> I don't see the point why you fiddle around with writing code on your own.
> I'm using django-auth-ldap since one and a half year in production and it
> works like a charm.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/4Go12iWz_pEJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Separating models from proxies conflicts

2012-09-13 Thread cs


Am Montag, 20. August 2012 15:52:28 UTC+2 schrieb Nacho Mas:
>
> I'm trying to separate my models from my proxies in order to maintain the 
> functionality more easily. The point is that, as my models.py started to 
> grow over and over, I decided to create a new file in each app (proxies.py) 
> where I'd define my proxies. I used to work like this:
>
> # models.py
>
> class MyModel(models.Model):
> prop1 = ...
> prop2 = ...
>
> def f1(self):
> pass
> def f2(self):
> pass
>
>
> However, I wanted to have this structure:
>
> # models.py
>
> class MyModel(models.Model):
> prop1 = ...
> prop2 = ...
>
> # proxies.py
>
> from myapp import models
>
>
> class MyModel(models.MyModel):
>
> def f1(self):
> pass
> def f2(self):
> pass
>
> class Meta:
> proxy = True
>
> But, when I tried to make some tests:
>
> $ python manage.py shell
> Python 2.7.3 (default, Apr 20 2012, 22:44:07) 
> [GCC 4.6.3] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
> (InteractiveConsole)
> >>> from myapp.proxies import MyModel
> >>> MyModel
> 
>
> So, when I ask for the proxy it gives me the model in models.py. And, of 
> course, it keeps the properties defined on the model but lacks all of the 
> methods in the proxy. Could anybody please tell me WTF is going on here?
>
> Thanks for your help :)
>
>
you probably want this:

# models.py

class MyModelBase(models.Model):
prop1 = ...
prop2 = ...

# proxies.py

from myapp import models


class MyModel(models.MyModelBase):

def f1(self):
pass
def f2(self):
pass

class Meta:
proxy = True

$ python manage.py shell

from myapp.proxies import MyModel
m = MyModel()
m.f1()
m.f2()

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



newbie: patch required? procedure? [closed ticket 16017 / createsuperuser]

2012-09-13 Thread Bob Aalsma
I'm a newbie following the tutorial. In this, creating a superuser is 
described, using 

manage.py createsuperuser --username=joe --email=j...@example.com


Using this leads to an error, which I could match to the closed ticket 
#16017.

But I couldn't find how to proceed from there. It seems some software was 
changed about 4 weeks ago:
"Made createsuperuser more robust when getting current OS username."

So where can I find it?
[I'm assuming there is a procedure for this, but I'm sorry to say I 
couldn't find that either]

Regards,
Bob

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



Re: not picking up new template

2012-09-13 Thread Larry Martell
On Wed, Sep 12, 2012 at 2:21 PM, Thomas Orozco  wrote:
> Here's an example:
>
> from django.template import loader
> l = 
> loader.find_template_loader('django.template.loaders.app_directories.Loader')
> # Or W/E loader you happen to use
> l.load_template_source(somewhere/'your_template.html')
>
> This will return a tuple (template string, template_path).
>
> This way you should be able to troubleshoot your issue.
> You could always try wich each loader using:
>
>
> from django.conf import settings
> for loader_name in settings.TEMPLATE_LOADERS:
> l = loader.find_template_loader(loader_name)
> l.load_template_source(somewhere/'your_template.html')

I tried that, but I got:

ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

So I tried setting that, first to the absolute path to my setting
file, and I got:

Import by filename is not supported.

Then to the relative path:

relative imports require the 'package' argument

Then to just settings.py:

No module named settings.py


>
> 2012/9/12 Thomas Orozco 
>>
>> Can you being up a manage.py shell and load the template from there to 
>> identify where's Django is pulling the template from?
>>
>> You should be able to go step by step and identify where you're pulling the 
>> old template in!
>>
>> If you don't find anything, it's probably because your template actually 
>> isn't different from the older one.
>>
>> You should be able to do that using pdb and the Django code base :-)
>> There might be a quicker way though, I'll have a look at it.
>>
>> Thomas
>>
>> On Sep 12, 2012 5:59 PM, "Larry Martell"  wrote:
>>>
>>> On Wed, Sep 12, 2012 at 11:56 AM, Thomas Lockhart
>>>  wrote:
>>> > On 9/12/12 8:27 AM, Larry Martell wrote:
>>> >>
>>> >> On my Mac, I changed a template, and the change was picked up, no
>>> >> problem. I checked my change into git, went to another machine, a
>>> >> CentOS box, pulled the change down, but django is not picking it up.
>>> >> I've tried everything I can think of - bounced the server, restarted
>>> >> the browser, cleared the cache and cookies, tried 3 different
>>> >> browsers, deleted it, re-pulled from git, but when I look at the code
>>> >> in the debugger, it's clearly using the old template. There are no
>>> >> errors in the apache log, permissions are fine, I'm tearing my hair
>>> >> out here. Anyone have any ideas as to what's preventing it from
>>> >> picking up the new template, or what I can check to figure out what's
>>> >> going on?
>>> >>
>>> > Need to collect static content for your production server?
>>>
>>> I had already tried that (even thought this change did not effect the
>>> static content).
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users+unsubscr...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: not picking up new template

2012-09-13 Thread Larry Martell
On Wed, Sep 12, 2012 at 11:39 AM, Thomas Orozco  wrote:
> Can you being up a manage.py shell and load the template from there to
> identify where's Django is pulling the template from?

I'm trying to do that, but I get:

>>> t = Template('/path/to/template.html')
>>> t.name
''

I get the even on my Mac, where it is working, so clearly I'm doing
something wrong.


> You should be able to go step by step and identify where you're pulling the
> old template in!
>
> If you don't find anything, it's probably because your template actually
> isn't different from the older one.
>
> You should be able to do that using pdb and the Django code base :-)

I may resort to that.

> There might be a quicker way though, I'll have a look at it.
>
> Thomas
>
> On Sep 12, 2012 5:59 PM, "Larry Martell"  wrote:
>>
>> On Wed, Sep 12, 2012 at 11:56 AM, Thomas Lockhart
>>  wrote:
>> > On 9/12/12 8:27 AM, Larry Martell wrote:
>> >>
>> >> On my Mac, I changed a template, and the change was picked up, no
>> >> problem. I checked my change into git, went to another machine, a
>> >> CentOS box, pulled the change down, but django is not picking it up.
>> >> I've tried everything I can think of - bounced the server, restarted
>> >> the browser, cleared the cache and cookies, tried 3 different
>> >> browsers, deleted it, re-pulled from git, but when I look at the code
>> >> in the debugger, it's clearly using the old template. There are no
>> >> errors in the apache log, permissions are fine, I'm tearing my hair
>> >> out here. Anyone have any ideas as to what's preventing it from
>> >> picking up the new template, or what I can check to figure out what's
>> >> going on?
>> >>
>> > Need to collect static content for your production server?
>>
>> I had already tried that (even thought this change did not effect the
>> static content).
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Potential Bug with hidden_intial_fields

2012-09-13 Thread cs
Hello,

while working on a mechanism for optimistic offline locking for django 
modelforms we discovered the following issue:


After a failed form validation this forms hidden_initial-fields (rendered 
via the field argument show_hidden_initial=True) will be rendered 
containing the submitted data of the corresponding regular fields not the 
data the hidden_initial_fields have submitted 
This might cause confusion because: if the form was not saved the value was 
not saved in the database but is now considered as current db-state in the 
hidden_initial_field
in addition if a succesive submit is triggered the form will now not 
identify a form.has_changed-event for the corresponding field


IMHO the hidden_initial_field should recieve its POST/GET data from the 
hidden_initial_field-data instead of the POST/GET data from the original 
field after a submit

The question is: Is this considered as a bug or is it just some feature not 
used the desired way

any comment on this are welcome

cs



A simplified way to reproduce this: 

-field ('label') has the argument show_hidden_initial=True
-open the view with an instance from the database
-change the value of the label field and save -> form will be declared 
invalid and form.label_initial will contain the new value despite that the 
form could not be saved
-in addition if save is clicked again the form is valid and 
form.changed_data will be empty


class MyModel(models.Model)
label = models.CharField()


class MyModelForm(forms.Form)
def __init__(*args, **kwargs):
super(MyModelForm, self).__init__(*args, **kwargs)
for f in self.fields.keys():
self.fields[f].show_hidden_initial = True

class Meta:
model = MyModel

  def clean(self):
cleaned_data = super(MyModelForm, self).clean()

if self.changed_data:
self._errors['label'] = ErrorList(['form has changed'])

return cleaned_data


def myView(request, modelId=None):

if modelId:
instance = MyModel.objects.get(pk=modelId)
else:
instance = None

if request.method == 'POST':
form = MyModelForm(request.POST, instance=instance)

if form.is_valid():
instance = form.save()
return HttpResponse('Success')
else:
form = MyModelForm(instance=instance)

template = '''{{form}}'''

t = template.Template(output)
c = template.Context({'form':form})
return t.render(c) 




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



Re: Basic auth struggle

2012-09-13 Thread Timster
What does the rest of your views.py file look like?

Do you happen to have a view named login()?

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



Re: tastypie - some feedback / comments

2012-09-13 Thread Jani Tiainen

13.9.2012 11:23, sbrandt kirjoitti:

After evaluating some API creation frameworks, namely tastypie, pistion
and django rest framework, it came out that I would never use the first
two in my projects.

Sorry that I can't provide more detailed information, but it's about a
year ago. Both had issues with their architecture and philosophy not
being clear, straight or smart enough to me. The latter,
django-rest-framework (http://pypi.python.org/pypi/djangorestframework)
was very young at this time and followed the then-new paradigm of class
based views. Since it behaves like other django views (URL config,
mixins, etc.) it is very nice to use and extensible.

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


I'm also fan (and user) of django-rest-framework. Just because it's 
quite easily to be extended with all kind of stuff you need (specially 
since I work with ExtJS 4 which does have support that resembles REST 
from some parts), allows me to define URLs I want and does quite much 
stuff OOTB.


Also in few cases I really work things that do not bound to any models, 
querysets or whatsoever django-rest-framework just works with them as well.


--
Jani Tiainen

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

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



Re: Submitting data from a form

2012-09-13 Thread Tom Evans
On Thu, Sep 13, 2012 at 6:26 AM, KVR  wrote:
> Hi,
> I am a Django learner .
> I need to do a requirement as described below.
>
> 1.There is a column in a model
> 2.I want to create a template with a select button in that.
> 3.On selecting an option and submitting, the column should be updated with
> the submitted value.
>
> Please give me some idea on how to do this?
>

The Django tutorial is a 4 part tutorial guiding you through creating
a model, creating a view that uses that model, and creating forms to
create or edit a model. It is specifically designed to take someone
who has never used django to a point where they can create models,
views and forms to process those models.

I suggest you attempt to complete the tutorial, and come ask questions
on here iff you get stuck.

https://docs.djangoproject.com/en/1.4//intro/tutorial01/

Cheers

Tom

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



How to use admin Calendar widget in django application

2012-09-13 Thread Anwar Shaikh
Hello ,

I am trying to implement  admin calendar widget in application. There is no 
media folder in my application I have googled a lot but ddnt find a way to 
add in my application can anybody help me 

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



Submitting data from a form

2012-09-13 Thread KVR
Hi,
I am a Django learner .
I need to do a requirement as described below.

1.There is a column in a model
2.I want to create a template with a select button in that.
3.On selecting an option and submitting, the column should be updated with 
the submitted value.

Please give me some idea on how to do this?

Regards,
KVR 

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



Re: Unhelpful template traceback

2012-09-13 Thread David Barnett
For posterity, I think the link should have been 
https://code.djangoproject.com/ticket/11461.

David

On Monday, January 4, 2010 11:14:24 AM UTC-8, Margie Roginski wrote:
>
>
> I had also noticed that errors from templates were quite hard to
> debug.  Some time ago I saw this thread on on this group:
>
>
> http://groups.google.com/group/django-users/browse_thread/thread/ee29c542dcc0dc95/aaa3f89a2a77fa3f?lnk=gst=template_debug#aaa3f89a2a77fa3f
>
> I applied the very simple patch, which is listed in
> http://code.djangoproject.com/ticket/11451
>
> (Here's my own notes on what the patch is)
> File: /site-packages/django/template/debug.py
>
> # raise wrapped # remove this line, add next line, see ticket
> 11451
>  raise wrapped, None, wrapped.exc_info[2]
>
> After applying this patch I found the the traceback errors made much
> more sense.  The tracebacks are complete now and point me to a line
> that is meaningful.
>
> I believe this is some sort of issue only with python 2.6, so if you
> are not on 2.6, it is probably not a solution for you, but if you are
> on 2.6, give it a try.
>
> Margie
>
>
> On Jan 4, 9:08 am, Thomas Steinacher  wrote:
> > The actual error is not my point. I know that it's somewhere in a
> > reverse/url method, but there is no way I can test it. The point is
> > that there is no helpful template traceback in the deployment error e-
> > mails. Maybe I should direct this to django-developers instead or file
> > a ticket?
> >
> > On Jan 4, 6:05 pm, Victor Loureiro Lima 
> > wrote:
> >
> > > You are probably calling {{ model.property.url }} or {{
> > > model.get_absolute_url }} on some property/model (either FileField or
> > > ImageField in case of property) of some model of yours that doesnt 
> know how
> > > to reverse back to its URL, so the template gives an error because it 
> doesnt
> > > know how to render its own value. You should check if the models is 
> correct
> > > and if its possible to access it thru the regex of URL.
> >
> > >  Maybe if you iterate thru all objects trying to get_absolute_url them 
> you
> > > could reproduce some sort of error.
> >
> > > That would be my guess =)
> >
> > > Victor Lima
> >
> > > 2010/1/4 Thomas Steinacher 
> >
> > > > Hey guys,
> >
> > > > I sometimes get errors which occur rarely, so it is very difficult to
> > > > reproduce them in a development environment. The traceback always
> > > > looks similar to the traceback attached below (which is just an
> > > > example).
> >
> > > > My question: How can I make the Django error mails show the template
> > > > file name and line number where the error occurred? It is really
> > > > annoying as I currently see no way to debug this type of errors other
> > > > than guessing, which is very difficult, especially when templates are
> > > > very complex.
> >
> > > > Thanks,
> >
> > > > Thomas
> >
> > > > File "/home/mysite/django-mysite3/django/template/loader.py", line
> > > > 173, in render_to_string
> > > >  return t.render(context_instance)
> >
> > > > File "/home/mysite/django-mysite3/django/template/__init__.py", line
> > > > 184, in render
> > > >  return self._render(context)
> >
> > > > File "/home/mysite/django-mysite3/django/template/__init__.py", line
> > > > 178, in _render
> > > >  return self.nodelist.render(context)
> >
> > > > File "/home/mysite/django-mysite3/django/template/__init__.py", line
> > > > 787, in render
> > > >  bits.append(self.render_node(node, context))
> >
> > > > File "/home/mysite/django-mysite3/django/template/__init__.py", line
> > > > 800, in render_node
> > > >  return node.render(context)
> >
> > > > File "/home/mysite/django-mysite3/django/template/defaulttags.py",
> > > > line 384, in render
> > > >  raise e
> >
> > > > NoReverseMatch: Reverse for 'view_user_pictures' with arguments '()'
> > > > and keyword arguments '{'username': ''}' not found.
> >
> > > > --
> >
> > > > You received this message because you are subscribed to the Google 
> Groups
> > > > "Django users" group.
> > > > To post to this group, send email to 
> > > > django...@googlegroups.com
> .
> > > > To unsubscribe from this group, send email to
> > > > django-users...@googlegroups.com 
> > > >  groups.com>
> > > > .
> > > > For more options, visit this group at
> > > >http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: tree.io installation with django

2012-09-13 Thread Cal Leeming [Simplicity Media Ltd]
I think this looks like an incompatible Django version to be honest,
coupled with some other weird/wonderful problems.

The invalid syntax thing is also a bit odd, as it looks valid to me.

My advice would be to start again from scratch with the installation
tutorial, and see if you can get any further -

Cal

On Wed, Sep 12, 2012 at 7:52 PM, Fabian Weiss
wrote:

> Hi Cal! :)
>
> THX for you reply, but I need more informations! I changed the line you
> said in settings.py, but what shall I do know? Again python manage.py
> update_ve and ./bin/patch??
> I tried again the last step:
>
> python manage.py installdb
>> Traceback (most recent call last):
>>   File "manage.py", line 74, in 
>> import settings
>>   File "/srv/http/de.immersight.project/treeio/settings.py", line 59, in
>> 
>> MEDIA_ROOT = path.join(STATIC_DOC_ROOT, 'media/')
>> NameError: name 'STATIC_DOC_ROOT' is not defined
>
>
> when I reload the apache I have still 500 internal error. Here is the
> errorlog:
>
> tail ../logs/errorlog
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24] SyntaxError:
>> invalid syntax
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24] mod_wsgi
>> (pid=17796): Target WSGI script
>> '/srv/http/de.immersight.project/treeio/wsgi' cannot be loaded as Python
>> module.
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24] mod_wsgi
>> (pid=17796): Exception occurred processing WSGI script
>> '/srv/http/de.immersight.project/treeio/wsgi'.
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24] Traceback (most
>> recent call last):
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24]   File
>> "/srv/http/de.immersight.project/treeio/wsgi", line 9, in 
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24] import
>> django.core.handlers.wsgi
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24]   File
>> "/usr/local/lib/python3.2/dist-packages/django/core/handlers/wsgi.py", line
>> 131
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24] path_info =
>> force_unicode(environ.get('PATH_INFO', u'/'))
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24]
>>   ^
>> [Wed Sep 12 20:46:23 2012] [error] [client 109.193.24.24] SyntaxError:
>> invalid syntax
>
>
> I really urgently have to set up this system :(
> Would be great if I can accomplish this!! Thanks alot for your help!
> Greetings Fabian
>
>
>
>
> Am Mittwoch, 12. September 2012 12:14:51 UTC+2 schrieb Cal Leeming
> [Simplicity Media Ltd]:
>>
>> Hmm - this should really just work out of the box, but looking at the
>> docs, it doesn't give you much information about running wsgi/fcgi etc.
>>
>> Try this;
>>
>> Change this line:...
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/6aEUH98wPG0J.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Syncdb is producing different databases on different machines.

2012-09-13 Thread Brian McKeever
I appreciate your help. Thank you.

On Wednesday, September 12, 2012 11:28:44 AM UTC-6, Brian McKeever wrote:
>
> I actually figured it out.
>
> I created a new virtualenv on my development machine and installed the 
> requirements to it, and from that virtualenv, syncdb fails to install the 
> invitationuser table. I guess whoever is in charge of the django-invitation 
> repository introduced a bug without changing the version number.
>
> On Wednesday, September 12, 2012 11:23:11 AM UTC-6, Cal Leeming 
> [Simplicity Media Ltd] wrote:
>>
>> lol wtf.
>>
>> Perhaps the code on the production server isn't fully up to date? Did you 
>> check the database to ensure the table definitely doesn't already exist? 
>> Did you try running "manage.py sql" on the production server to see if the 
>> SQL is printed out for the missing table?
>>
>> Cal
>>
>> On Wed, Sep 12, 2012 at 6:14 PM, Brian McKeever  wrote:
>>
>>> I am not using any database router.
>>>
>>> These are my database settings:
>>> DATABASES = {
>>> 'default': {
>>> 'ENGINE': 'django.db.backends.postgresql_psycopg2',
>>> 'NAME': 'my database name',
>>> 'USER': 'my admin name',
>>> 'HOST': 'localhost',
>>> 'PASSWORD' : 'my password'
>>>
>>> }
>>> }
>>>
>>> On Wednesday, September 12, 2012 11:02:10 AM UTC-6, Cal Leeming 
>>> [Simplicity Media Ltd] wrote:
>>>
 Are you using any sort of custom db router? (look for DATABASE_ROUTERS 
 in settings).

 On Wed, Sep 12, 2012 at 5:05 PM, Brian McKeever wrote:

> On my development machine, upon freshly creating my postgresql 
> database, when I run syncdb, it creates two invitation tables - 
> invitation_invitationkey and invitation_invitationuser. 
> On my production server, upon freshly creating my postgresql database, 
> when I run syncdb, it only creates invitation_invitationkey. Why isn't it 
> creating the invitationuser table?
>
> Both machines have the same revision of code.
> Both machines are using virtualenvs with the same packages installed 
> including the same version numbers. 
> Both tables belong to the django-invitation package.
>
> I don't know how to go about debugging this. Any help would be 
> appreciated. Thank you.
>
>  -- 
> You received this message because you are subscribed to the Google 
> Groups "Django users" group.
> To view this discussion on the web visit https://groups.google.com/d/*
> *msg/django-users/-/**ixGlcrj7IhMJ
> .
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to django-users...@**
> googlegroups.com.
>
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>

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

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



Re: Alternatives to CBVs (class based views)

2012-09-13 Thread Dan Gentry
It would be helpful to see some more complex examples with these classes. 
 One thing I like about the CBVs is that they include all of the necessary 
code for common functions.  I have used them extensively (once I figured 
them out).

On Wednesday, September 12, 2012 12:59:12 PM UTC-4, Cal Leeming [Simplicity 
Media Ltd] wrote:
>
> Hi all,
>
> There is a lot of debate on whether there is a real future for the Django 
> CBVs (class based views). Personally, I find them tedious, and just wanted 
> a way to keep my views clean.
>
> So, here is a really minimalistic way of having class based views, without 
> the fuss.
>
> http://djangosnippets.org/snippets/2814/
>
> This is a fork from:
>
> http://stackoverflow.com/questions/742/class-views-in-django 
> http://djangosnippets.org/snippets/2041/
>
> My thanks to eallik for his initial post on stackoverflow for this.
>
> Personally I think Django's CBVs should offer a really minimalistic base 
> like this, as well as the existing CBV stuff already in the core - so as to 
> not force people into needing to learn an entirely new way of doing things, 
> but at the same time allowing them to reap some of the benefits of using 
> callable classes as views.
>
> Any thoughts?
>
> Cal
>

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



Re: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Coulson Thabo Kgathi
ok thanks let me try it now

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



Re: Request for comments - django-cutemodel (model logging and field change auditing)

2012-09-13 Thread Cal Leeming [Simplicity Media Ltd]
On Thu, Sep 13, 2012 at 9:42 AM, Derek  wrote:

> Cal
>
> Great post; I think you summed up my feelings about django-reversion as
> well, although articulated extremely clearly.
>
> If CuteModel (where does that name come from??)
>

Cute was the first word that came to my head, thought it sounded catchy

can address the issue of reverting a change to a record (or, even better,
> all changes made at one time to a record), then I think it will be a great
> alternative option for many folk.
>

Yeah after the last few posts, I realised there were a few structural
changes that needed to be made - one of those being that field changes need
to be grouped by a Revision() object, so you can revert the entire revision
or just bits from it.

I also figured that the API needs to expose data to the original save()
method call, such as the revision object, so they can integrate this into
their existing application (for example, if they have 3 models that get
saved in 1 form save, they might want to take all 3 IDs, then create an
extra revision layer that lets them revert them all in one go - rather than
try and normalize this, exposing the revision object would give the user
enough control)


>
> Cheers,
> Derek
>
>
> On Tuesday, 11 September 2012 21:11:06 UTC+2, Cal Leeming [Simplicity
> Media Ltd] wrote:
>
>> Thanks for letting me know about django-reversion, it has made for
>> interesting reading.
>>
>> From what I can see there are two big differences between them;
>>
>> * CuteModel is designed with performance/scalability in mind (as some of
>> our projects are tipping into the 700+mil row count and rising)
>> * CuteModel is designed to be as simple and easy as possible - where as
>> django-reversion left me feeling a bit confused.
>>
>> Looking at django-reversion, it certainly looks close to cutemodel, but
>> there are a few differences;
>>
>> * Changes are serialized into the database, this adds a significant extra
>> size and CPU overhead (Version.serialized_data)
>> * Object references are stored as a TextField, this is not good for
>> performance (Version.object_id)
>> * Creates a new serialized object every time a row is added - this is
>> really really not good for performance(*.VERSION_ADD)
>> * Requires an additional model for every model you have if you want to
>> store custom meta data (cutemodel only requires 1)
>> * Uses signal rather than overriding the subclass - although this is
>> probably a better approach - thoughts anyone??
>> * In some ways the API is quite nice, but in others it seems a bit clunky.
>> * Requires you to create initial revisions dump - again, not good if you
>> have a lot of rows
>>
>> That being said - there are definitely some good points from that app,
>> and a lot of features that would be great for CuteModel, such as;
>>
>> * Grouping together field changes into a 'revision'
>> * Better low level API support
>> * Ability to revert a change
>>
>> I'm certainly going to add those into the todos list - thanks for your
>> feedback!
>>
>> Cal
>>
>> On Tue, Sep 11, 2012 at 2:46 PM, jondykeman  wrote:
>>
>>> Hello,
>>>
>>> I am in a very similar situation. I would in an environment that deals
>>> with sensitive data collection. Everything has to be two-factor
>>> authenticated, in the secure server zone etc. As part of this we need
>>> logging of every action ever taken, by whom, when, and what the changes
>>> were.
>>>
>>> At first I implemented my own custom solution which was less than ideal,
>>> but it worked. That was a model of creating a new record for each field any
>>> time there was a change to the value, but via a lot of manual checking
>>> code.
>>>
>>> I am not starting to migrate to a slicker solution. I am taking
>>> advantage of django-reversion.
>>>
>>> https://github.com/etianen/**django-reversion
>>>
>>> This provides row level auditing out of the box, and then you just need
>>> to take advantage of the pre_commit_signal to track field changes as well.
>>>
>>> @receiver(reversion.pre_**revision_commit)
>>> def it_worked(sender, **kwargs):
>>> currentVersion = kwargs.pop('versions')[0].**field_dict
>>> pastVersion = reversion.get_for_object(**kwargs.pop('instances')[0])[0]*
>>> *.field_dict
>>>  changes = set(currentVersion.items()) - set(pastVersion.items())
>>> changedVars = []
>>> for var in changes:
>>>  changedVars.append(var[0])
>>> comment = "Changed: %s" % ", ".join(changedVars)
>>> revision = kwargs.pop('revision')
>>>  revision.comment = comment
>>> revision.save()
>>> kwargs['revision'] = revision
>>>
>>> Rather than the string tracking which fields I am going to switch to a
>>> dict of changed or not for each variable.
>>>
>>> I will check out cutemodel for sure and let you know.
>>>
>>> Thanks,
>>>
>>> JD
>>>
>>>
>>> On Tuesday, September 11, 2012 3:46:54 AM UTC-6, Cal Leeming [Simplicity
>>> Media Ltd] wrote:



 On Mon, Sep 10, 2012 at 11:07 PM, 

Re: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Jani Tiainen

13.9.2012 11:04, Coulson Thabo Kgathi kirjoitti:

how i plot a point atleast manually is what i cant find how to do.

If atleast i could know how, which i think is done in the models.py then
i would be good to go afterwards

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


What you really mean by "plot"?

If you mean that show it somehow somewhere on a map then there is really 
nothing "built in" in Django for that. IIRC admin can show only

one (first?) geometry field defined.

So you need to have some kind of mapengine to actually produce map also 
known as WMS (or WFS).


Mapserver, Mapnik or Geoserver being propably one of the most used ones.

After you have done that you can build HTML page that uses some means to 
show map. OpenLayers is for that - it's javascript library to work with 
(interactive) maps on a webpage.


Now you should have all pieces that allows you to put together stuff 
that can show your points from a database.




--
Jani Tiainen

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

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



Re: Userena, how to set the avatar (mugshot) at signup time?

2012-09-13 Thread Bastian
Well it's easy, just follow the FAQ to add some extra fields and in the 
forms.py :

from django import forms
from userena.forms import SignupForm

class SignupFormExtra(SignupForm):
avatar = forms.ImageField()

def save(self):
new_user = super(SignupFormExtra, self).save()

profile = new_user.get_profile()
profile.mugshot = self.cleaned_data['avatar']
profile.save()

return new_user

Cheers.


On Wednesday, September 12, 2012 12:20:45 PM UTC+2, Bastian wrote:
>
> Hello,
>
> I use userena to manage signups and profiles. It works fine and users can 
> set up their avatar in the profile but I'd like them to set it up during 
> signup time. When they register they need to fill username, email, password 
> and sometimes other basic stuffs needed to create a user account. I'd like 
> to add the avatar (mugshot) to that list. What would be the way to go?
>
> I am trying to inherit the signup form as shown in the userena FAQ (
> http://docs.django-userena.org/en/latest/faq.html#how-do-i-add-extra-fields-to-forms)
>  
> to add the avatar there but I don't know: A) if it's a good option and B) 
> how to render the mugshot (ThumbnailerImageField) in a form (tried 
> forms.ImageField without success).
>
> Any help is welcome!
> Bastian
>

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



Re: Alternatives to CBVs (class based views)

2012-09-13 Thread Cal Leeming [Simplicity Media Ltd]
Ah, thanks for letting me know - the original snippet by eallik had support
for this, but I must have stripped it out not realising.

On Thu, Sep 13, 2012 at 1:34 AM, Matt Schinckel  wrote:

> One really small nitpick: when returning a 405, it is a requirement that
> you return a header with the acceptable methods:
>>
>>
> > 10.4.6 405 Method Not Allowed
>
> > The method specified in the Request-Line is not allowed for the resource
> identified by the Request-URI. The response MUST include an Allow header
> containing a list of valid methods for the requested resource.
>
> (From http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/8vKvmPp9uTgJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Problems with simple "hello world" test - "ImportError: Could not import settings"

2012-09-13 Thread James Bennett
On Thu, Sep 13, 2012 at 4:25 AM, DJ-Tom  wrote:
> Basically I always try to have the same environment for development as I
> also use for actual production - I'm lucky that my projects are small enough
> so i can do that :-) to avoid last minute surprises when trying to deploy
> the application to the public.

This is a fine thing to do once you understand Django and know what
you're doing with it. But for a beginner's tutorial aimed at someone
who knows nothing about Django, the development server is far more
ideal since it avoids throwing in a pile of "oh, and before you even
start, go learn how to set up and run Apache and a bunch of other
stuff so that you can use a production server stack to learn Django"
:)

As such, the tutorial doesn't and shouldn't mention trying to set up
Apache or other production deployment setups. It should simply teach
people how to write Django applications and understand how the pieces
of the framework fit together.

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



Re: Problems with simple "hello world" test - "ImportError: Could not import settings"

2012-09-13 Thread DJ-Tom


> Ok... GREAT! Now it works :-) (well... sort of, more below... ) but I had 
>> to restart Apache to make config changes effective... is that "normal"?
>>
>> I think important things like "you have to restart the webserver to make 
>> changes life" should go into the tutorial in *BIG RED LETTERS* 
>>
>
>
> The tutorial, by design, doesn't mention Apache at all. That's because 
> it's heavily recommended that you use the built-in devserver for 
> development, for precisely this reason. That's what it's for.
>
>
Basically I always try to have the same environment for development as I 
also use for actual production - I'm lucky that my projects are small 
enough so i can do that :-) to avoid last minute surprises when trying to 
deploy the application to the public.

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



Basic auth struggle

2012-09-13 Thread pearlball
Struggling with my very basic django auth login system. When a new user 
registers, they are first redirected to `/user/user_id` as I'd like (the 
user is being created fine), but they are then redirected to 
`/login?next=/user/user_id/` which is being done by the @login_decorator 
over the `user` view (the behaviour stops when I remove this decorator). 
(nb. Debug toolbar is breaking up the redirect sequence for me to see). 
However, if I then manually  I include Register view below. I can't see why 
it is not logging in immediately upon registration. The login method seems 
to be all there:

def register(request):
> if request.method == 'POST':
> form = UserCreationForm(request.POST)
> if form.is_valid():
> new_user = form.save()
> new_user = authenticate(username = 
> request.POST['username'],
> password = 
> request.POST['password1'])
> login(request, new_user)
> context = RequestContext(request)
> context['user_id'] = new_user.id`
> url = '/user/%s/' % new_user.id
> return HttpResponseRedirect(url)
> else:
> form = UserCreationForm()
> return render_to_response("registration/register.html", {'form': 
> form},
>   context_instance=RequestContext(request))


Can you help? Thanks.

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



Re: Changing the text on the admin "change_list.html"

2012-09-13 Thread Derek
I see I was not specific enough.  I do not want to change the model name; 
just the wrapper text that is used for *all* models.

Thanks
Derek

On Tuesday, 11 September 2012 19:41:07 UTC+2, Melvyn Sopacua wrote:
>
> That would be the verbose name in the models' meta class. I think
> Op 8 sep. 2012 18:34 schreef "Derek"  
> het volgende:
>
>> I need to alter the text that appears above every change list in my app:
>>
>> "Select *modelname* to change"
>>
>> However, I cannot see this text in the change_list.html file -
>> whereabouts is this text kept, and can it be overridden?
>>
>> Thanks
>> Derek
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>  

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



Re: Request for comments - django-cutemodel (model logging and field change auditing)

2012-09-13 Thread Derek
Cal

Great post; I think you summed up my feelings about django-reversion as 
well, although articulated extremely clearly.

If CuteModel (where does that name come from??) can address the issue of 
reverting a change to a record (or, even better, all changes made at one 
time to a record), then I think it will be a great alternative option for 
many folk.

Cheers,
Derek

On Tuesday, 11 September 2012 21:11:06 UTC+2, Cal Leeming [Simplicity Media 
Ltd] wrote:
>
> Thanks for letting me know about django-reversion, it has made for 
> interesting reading.
>
> From what I can see there are two big differences between them;
>
> * CuteModel is designed with performance/scalability in mind (as some of 
> our projects are tipping into the 700+mil row count and rising)
> * CuteModel is designed to be as simple and easy as possible - where as 
> django-reversion left me feeling a bit confused.
>
> Looking at django-reversion, it certainly looks close to cutemodel, but 
> there are a few differences;
>
> * Changes are serialized into the database, this adds a significant extra 
> size and CPU overhead (Version.serialized_data)
> * Object references are stored as a TextField, this is not good for 
> performance (Version.object_id)
> * Creates a new serialized object every time a row is added - this is 
> really really not good for performance(*.VERSION_ADD)
> * Requires an additional model for every model you have if you want to 
> store custom meta data (cutemodel only requires 1)
> * Uses signal rather than overriding the subclass - although this is 
> probably a better approach - thoughts anyone??
> * In some ways the API is quite nice, but in others it seems a bit clunky.
> * Requires you to create initial revisions dump - again, not good if you 
> have a lot of rows
>
> That being said - there are definitely some good points from that app, and 
> a lot of features that would be great for CuteModel, such as;
>
> * Grouping together field changes into a 'revision'
> * Better low level API support
> * Ability to revert a change
>
> I'm certainly going to add those into the todos list - thanks for your 
> feedback!
>
> Cal
>
> On Tue, Sep 11, 2012 at 2:46 PM, jondykeman  > wrote:
>
>> Hello,
>>
>> I am in a very similar situation. I would in an environment that deals 
>> with sensitive data collection. Everything has to be two-factor 
>> authenticated, in the secure server zone etc. As part of this we need 
>> logging of every action ever taken, by whom, when, and what the changes 
>> were.
>>
>> At first I implemented my own custom solution which was less than ideal, 
>> but it worked. That was a model of creating a new record for each field any 
>> time there was a change to the value, but via a lot of manual checking 
>> code. 
>>
>> I am not starting to migrate to a slicker solution. I am taking advantage 
>> of django-reversion.
>>
>> https://github.com/etianen/django-reversion
>>
>> This provides row level auditing out of the box, and then you just need 
>> to take advantage of the pre_commit_signal to track field changes as well.
>>
>> @receiver(reversion.pre_revision_commit)
>> def it_worked(sender, **kwargs):
>> currentVersion = kwargs.pop('versions')[0].field_dict
>> pastVersion = 
>> reversion.get_for_object(kwargs.pop('instances')[0])[0].field_dict
>>  changes = set(currentVersion.items()) - set(pastVersion.items())
>> changedVars = []
>> for var in changes:
>>  changedVars.append(var[0])
>> comment = "Changed: %s" % ", ".join(changedVars)
>> revision = kwargs.pop('revision')
>>  revision.comment = comment
>> revision.save()
>> kwargs['revision'] = revision
>>
>> Rather than the string tracking which fields I am going to switch to a 
>> dict of changed or not for each variable.
>>
>> I will check out cutemodel for sure and let you know.
>>
>> Thanks,
>>
>> JD
>>
>>
>> On Tuesday, September 11, 2012 3:46:54 AM UTC-6, Cal Leeming [Simplicity 
>> Media Ltd] wrote:
>>>
>>>
>>>
>>> On Mon, Sep 10, 2012 at 11:07 PM, Kurt Pruhs  wrote:
>>>
 Hey Cal,

 This looks like a great tool. I know I've implemented code like this in 
 another project. I was planning on doing a field change audit module for 
 an 
 application I'm currently working on. I will definitely look at 
 django-cutemodel and see if it works for what I need, and how I can 
 contribute. 
 My current project is a time clock system for human resources to manage 
 hourly workers. We need field change auditing for security, we need the 
 ability to produce reports from it, and ability to restore from audit 
 history (in case of record tampering). 
>>>
>>>
>>> I think django-cutemodel would be a pretty good fit for this 
>>> requirement, although it doesn't yet have any sort of administration 
>>> interface to produce reports, and the documentation isn't exactly great.
>>>
>>> Restore from audit history functionality is something we need for 
>>> ourselves too, so I've 

Re: tastypie - some feedback / comments

2012-09-13 Thread sbrandt
After evaluating some API creation frameworks, namely tastypie, pistion and 
django rest framework, it came out that I would never use the first two in 
my projects.

Sorry that I can't provide more detailed information, but it's about a year 
ago. Both had issues with their architecture and philosophy not being 
clear, straight or smart enough to me. The latter, django-rest-framework 
(http://pypi.python.org/pypi/djangorestframework) was very young at this 
time and followed the then-new paradigm of class based views. Since it 
behaves like other django views (URL config, mixins, etc.) it is very nice 
to use and extensible.

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



Re: Django and LDAP

2012-09-13 Thread sbrandt
Did you know there is django-auth-ldap which is a custom backend for 
authenticating users through LDAP? 
http://pypi.python.org/pypi/django-auth-ldap/

I don't see the point why you fiddle around with writing code on your own. 
I'm using django-auth-ldap since one and a half year in production and it 
works like a charm.

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



Re: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Coulson Thabo Kgathi
how i plot a point atleast manually is what i cant find how to do. 

If atleast i could know how, which i think is done in the models.py then i 
would be good to go afterwards

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



Re: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Jani Tiainen

13.9.2012 10:51, Coulson Thabo Kgathi kirjoitti:

What i did so far is create a GeoDjango project, the define models as
shown below
#models.py looks like thi

from django.db import models

# Create your models here.
# This is an auto-generated Django model module created by ogrinspect.
from django.contrib.gis.db import models

class Locations(models.Model):
 zid = models.IntegerField()
 name = models.CharField(max_length=20)
 elev = models.FloatField()
 icon = models.IntegerField()
 point = models.PointField() #this i
tried to do it for the poin to be ploted
 geom = models.MultiLineStringField(srid=4326)
 objects = models.GeoManager()


# Auto-generated `LayerMapping` dictionary for Locations model
locations_mapping = {
 'zid' : 'ZID',
 'name' : 'NAME',
 'elev' : 'ELEV',
 'icon' : 'ICON',
 'point' : 'POINT'
 'geom' : 'MULTILINESTRING',
}


The rest of the files i followed the GeoDjango tutorial

but this does not seem to be working, First i tred bt using a .kml file
convert it to a shapefile then import it to generate models bt does not work

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


How are you trying to plot your points?

Have you tried to manually insert at least one known point to be sure 
that problem is not somewhere in your import process?


--
Jani Tiainen

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

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



Re: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Coulson Thabo Kgathi
What i did so far is create a GeoDjango project, the define models as shown 
below
#models.py looks like thi

from django.db import models

# Create your models here.
# This is an auto-generated Django model module created by ogrinspect.
from django.contrib.gis.db import models

class Locations(models.Model):
zid = models.IntegerField()
name = models.CharField(max_length=20)
elev = models.FloatField()
icon = models.IntegerField()
point = models.PointField() #this i tried 
to do it for the poin to be ploted
geom = models.MultiLineStringField(srid=4326)
objects = models.GeoManager()


# Auto-generated `LayerMapping` dictionary for Locations model
locations_mapping = {
'zid' : 'ZID',
'name' : 'NAME',
'elev' : 'ELEV',
'icon' : 'ICON',
'point' : 'POINT'
'geom' : 'MULTILINESTRING',
}


The rest of the files i followed the GeoDjango tutorial

but this does not seem to be working, First i tred bt using a .kml file 
convert it to a shapefile then import it to generate models bt does not work

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



Re: Django Tutorial

2012-09-13 Thread maha
Tell us what the urls.py and settings.py.
Have you uncomment the line django.admin.site in settings.py

On Sunday, September 9, 2012 6:32:14 AM UTC+5:30, David Perez wrote:
>
> Hi,
>
> I am new to Django, I am actually starting its tutorial. On part 2 it 
> enables the admin site, but I can't log in to it. The following error comes 
> up (see at the bottom):
>
> If I remember correctly I did not get prompt to create a superuser when I 
> wrote *python manage.py syncdb*, so I am not sure if I do not have a 
> superuser. I tried to create it with *python manage.py createsuperuser 
> --username=david* but it is not working.
>
> I am most certain it is something simple...and I tried to follow the steps 
> as exact as I could. I appreciate your help.
>
> David
>
>
> DoesNotExist at /admin/
>
> Site matching query does not exist.
>
> Request Method:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
> 1.4.1Exception Type:DoesNotExistException Value:
>
> Site matching query does not exist.
>
> Exception 
> Location:/Library/Python/2.7/site-packages/django/db/models/query.py 
> in get, line 366Python Executable:/usr/bin/pythonPython Version:2.7.1Python 
> Path:
>
> ['/Users/Dperezc/Desktop/Estudios independientes/Django/Proyecto1_Poll',
>  '/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:Sat, 8 Sep 2012 18:45:28 -0600
>
>
>
>
>

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



Re: Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to informati

2012-09-13 Thread Jani Tiainen

13.9.2012 10:29, Coulson Thabo Kgathi kirjoitti:

Can i be able to plot a points on maps with geodjango? i figured i can
plot polygons on a map but struggling to plot points is it possible? if
it is how do i do it or help with a link to information where i can find
how to do that. i have been searching and cant find much infor about it.


You can.


If i can atleast plot a point like points on the map below, that would
be great

HoustonCrimeMaps




How have you tried to do that exactly?

--
Jani Tiainen

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

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



Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to information w

2012-09-13 Thread Coulson Thabo Kgathi
Can i be able to plot a points on maps with geodjango? i figured i can plot 
polygons on a map but struggling to plot points is it possible? if it is 
how do i do it or help with a link to information where i can find how to 
do that. i have been searching and cant find much infor about it.

If i can atleast plot a point like points on the map below, that would be 
great

[image: HoustonCrimeMaps]

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



Re: Model Validation with Exception Handling

2012-09-13 Thread Jani Tiainen

Hi,

I'm using following piece of code with ExtJS:


def extjs_validate_instance(instance):
"""Validate given Django model instance.
Return ExtJS formatted error response.
"""
try:
instance.full_clean() # Validate
except ValidationError, e:
opts = instance._meta
nice_messages = []
for fname, msgs in e.message_dict.items():
nice_messages.append({
'name' : 
force_unicode(opts.get_field_by_name(fname)[0].verbose_name),

'error' : ', '.join(msgs),
})

response_obj = {
'success': False,
'items' : nice_messages}
raise ErrorResponse(status.HTTP_200_OK, response_obj)


Now it returns dict "nice_messages" which contains fieldname and 
message(s) associated with that field.



13.9.2012 2:36, Kurtis Mullins kirjoitti:

Just a quick example of a field that can have two completely different
error types but both throw a ValidationError while running full_clean().

Let's say my Model includes an email address. The email address must be
unique. It could either fail because 1. It's not Unique (or) 2. It's an
invalid email address.

What I really want to do is determine the exception/error-type so that I
can handle it appropriately.

On Wed, Sep 12, 2012 at 7:09 PM, Kurtis > wrote:

Hey Guys,

Do you have any suggestions on a good way to grab error types during
Model Validation? I'm not using Forms or HTML. First, here's a
simplified snippet showing my current format for Model Data Validation.

my_object = MyModel(**data_dict)
try:
 my_object.full_clean()
 my_object.save()
 return SuccessJSONResponse()
except ValidationError, e:
 print e.message_dict # Testing
 # ... build some custom JSON data from the error
 return ErrorJSONResponse(json_data)

This works fine for properly validating the data and being able to
print out errors. It also allows me to easily see which fields threw
errors. Unfortunately, it doesn't provide me with the types of
errors in a "programmatic" fashion as far as I can tell. For
example, a field can fail because it's a duplicate entry or it can
fail because it didn't meet the criteria of the field-type (e.g.
max_length).

What I'm hoping for is there's a way I can still easily validate my
data using my Model but get more specific information about the
types of errors. If it's an IntegrityError then I need to build a
custom response indicating which field had failed along with an
"internal" (to the project) error code and a description. If it's
some other specific error (for example, maybe an email address isn't
a "valid" email address) then I'd like to identify the error type,
field name, and display that error accordingly. Hopefully that makes
sense :)

I'm not sure if I'm just over-looking something or trying to do
things the hard way but I'm up for suggestions. Keep in mind that
Forms + HTML are out of the question since this is an API-only
application.

Thanks!
- Kurtis

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


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



--
Jani Tiainen

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

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