Re: New to Django; walking through djangoproject tutorial; can't get poll to work

2012-12-18 Thread Jeff Tchang
My first guess is that

{% for choice in poll.choice_set.all %}

is empty. So you have no choices attached to the poll. You can verify
this by looking at the generated HTML source and seeing if you have
any radio buttons at all. Since you said you didn't that is my guess.

I didn't go back and look at the tutorial but try creating some
choices for the poll.

-Jeff

On Tue, Dec 18, 2012 at 7:56 PM, Deron  wrote:
> Hi,
>
> First post here. I'm extremely new to Django and I have been fumbling my way
> through the DjangoProject "poll" app tutorial for a couple weeks now. I
> understand a lot of what's going on, but a lot of things are completely lost
> on me as well. That said, I'm to the point of actually using the poll app.
> I've created a view so you can view the poll, select a choice and then click
> "vote." Problem is, when I view the page (/polls/1/) I see my heading which
> is "What's Up?" and I see a "vote" input button, but no radio button. I'm
> not exactly sure why it's not showing up. Anyone want to take a shot in the
> dark on this one? Here's my "detail.html" view (copied straight from the
> tutorial):
>
> {{ poll.question }}
> {% if error_message %}{{ error_message }}{% endif %}
> 
> {% csrf_token %}
> {% for choice in poll.choice_set.all %}
>  value="{{ choice.id }}" />
> {{ choice.choice }} />
> {% endfor %}
> 
> 
>
> --
> 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/-/DtV-YM6VU44J.
> 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: Strange behavior using ModelForms

2012-12-18 Thread Karen Tracey
On Tue, Dec 18, 2012 at 4:11 PM, Francisco Vianna <
francisco.v.via...@gmail.com> wrote:

> After some debugging, I realized they become the same after calling
> "is_valid" to the bound form. Now, I'm not sure if I am missing something
> conceptually about ModelForms binding.
> Its very ackward to me that I can have a 'instance' field in a ModelForm,
> but can't distiguish the data after performing the validation. In my case
> specifically, I need to check first if the email provided by the user is
> valid, and only then check if its diferent from the instance's e-mail in
> order to set my flag. But I can't do it, or I will lose the new e-mail
> provided by the user in the form.
>
> Can anyone enlighten this matter? Is this behavior expected?


Yes, is_valid() called on a model form updates the model form's instance
in-place with the valid cleaned data. This is documented:

https://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-is-valid-method-and-errors

Your form field's clean method would have access to the "old" value, since
that runs before the new value has been fully validated and saved in the
instance.

Karen
-- 
http://tracey.org/kmt/

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



New to Django; walking through djangoproject tutorial; can't get poll to work

2012-12-18 Thread Deron
Hi,

First post here. I'm extremely new to Django and I have been fumbling my 
way through the DjangoProject "poll" app tutorial for a couple weeks now. I 
understand a lot of what's going on, but a lot of things are completely 
lost on me as well. That said, I'm to the point of actually using the poll 
app. I've created a view so you can view the poll, select a choice and then 
click "vote." Problem is, when I view the page (/polls/1/) I see my heading 
which is "What's Up?" and I see a "vote" input button, but no radio button. 
I'm not exactly sure why it's not showing up. Anyone want to take a shot in 
the dark on this one? Here's my "detail.html" view (copied straight from 
the tutorial):

*{{ poll.question }}
{% if error_message %}{{ error_message }}{% endif %}

{% csrf_token %}
{% for choice in poll.choice_set.all %}

{{ choice.choice }}
{% endfor %}

*

-- 
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/-/DtV-YM6VU44J.
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: Strange behavior using ModelForms

2012-12-18 Thread Chris Cogdon
The binding allows the modelform to read the current values of an instance, 
and also to write them back to the same instance when the values are 
changed.

If you're only ever creating new instances, then you don't need to bind it.

On Tuesday, December 18, 2012 6:19:45 PM UTC-8, fvianna wrote:
>
> Because unless I'm getting some real debbuging issues, request.user is 
> also changed during the process.
>
> It happens as if all references were pointing to the same object, when i 
> believe thet, as far as I understand these Django machanisms and 
> functionalities, this should not happen.
>
> The basic issue I'm trying to understand here, I believe, is "What really 
> happens and what is the purpose of binding a modelform to an instance?".
>
>
> On Tue, Dec 18, 2012 at 7:31 PM, Chris Cogdon  > wrote:
>
>> Rather than comparing to instance, why not compare to request.user ?
>>
>>
>> On Tuesday, December 18, 2012 1:11:21 PM UTC-8, fvianna wrote:
>>>
>>> Hello everyone,
>>>
>>> I want to apologize if I came to the wrong place to talk about this, but 
>>> I've been using Django for a while now, and crossed to a very strange 
>>> behavior that hits me as bug, but I'm not quite sure. First time trying to 
>>> get a little deeper and maybe report something to help the community.
>>>
>>> Django's "How to contribute" page lead me to FAQ, and then here.
>>>
>>>
>>>
>>> So, I have a ModelForm to edit some of my auth.User data, here it is:
>>>
>>> class UserForm(ModelForm):
>>> """ ModelForm for user relevant fields """
>>>
>>> class Meta:
>>> model = User
>>> fields = ('first_name', 'last_name', 'email')
>>>
>>> def clean_email(self):
>>> cleaned_data = super(UserForm, self).clean()
>>> unavailable_error = ValidationError("Unavailable")
>>> invalid_error = ValidationError("Invalid")
>>>
>>> email = cleaned_data.get("email")
>>> if email:
>>> try:
>>> user_from_form_email = User.objects.get(email=email)
>>> if user_from_form_email != self.instance:
>>> raise unavailable_error
>>> except User.DoesNotExist:
>>> pass
>>> except User.MultipleObjectsReturned:
>>> raise unavailable_error
>>> else:
>>> raise invalid_error
>>>
>>> # Always return the full collection of cleaned data.
>>> return cleaned_data.get("email")
>>>
>>> Pretty straightforward, with a "unique" verification for the email.
>>> In my view, I receive the form with some edited data from a user. The 
>>> view looks as it follows (just ignore the ajax stuff and error returning):
>>>
>>>
>>> def edit_basic_info(request, id):
>>> response = {'success': False, 'errors': []}
>>>
>>> if request.method == 'POST' and request.is_ajax():
>>> u_form = UserForm(request.POST, instance=request.user)
>>>
>>> if u_form.is_valid():  
>>> if u_form.instance.email != u_form.cleaned_data['email']:
>>> tmp_profile = u_form.instance.get_profile()
>>> tmp_profile.email_confirmed = False
>>> tmp_profile.save()  
>>> 
>>>   u_form.save()
>>> response['success'] = True
>>> else:
>>> response['errors'].append(u_**form.errors)
>>>
>>>
>>> When I get to test if the form e-mail is diferent from the instance 
>>> e-mail in order to set a flag in my model, both emails 
>>>
>>> u_form.instance.email
>>>
>>> and
>>>
>>> u_form.cleaned_data['email']
>>>
>>> are the same. After some debugging, I realized they become the same 
>>> after calling "is_valid" to the bound form. Now, I'm not sure if I am 
>>> missing something conceptually about ModelForms binding.
>>> Its very ackward to me that I can have a 'instance' field in a 
>>> ModelForm, but can't distiguish the data after performing the validation. 
>>> In my case specifically, I need to check first if the email provided by the 
>>> user is valid, and only then check if its diferent from the instance's 
>>> e-mail in order to set my flag. But I can't do it, or I will lose the new 
>>> e-mail provided by the user in the form.
>>>
>>> Can anyone enlighten this matter? Is this behavior expected? 
>>> Thank you for your time. 
>>>
>>  -- 
>> 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/-/e1VZcZs_3loJ.
>>
>> 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 

Re: Django community, is it active?

2012-12-18 Thread Chris Cogdon
But I _want_ to drink the free bear.

On Tuesday, December 18, 2012 3:19:59 PM UTC-8, Cal Leeming [Simplicity 
Media Ltd] wrote:
>
>  Don't drink the free bear though, ...
>


>

-- 
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/-/Je-VbEdMmoQJ.
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: Strange behavior using ModelForms

2012-12-18 Thread Francisco Vianna
Because unless I'm getting some real debbuging issues, request.user is also
changed during the process.

It happens as if all references were pointing to the same object, when i
believe thet, as far as I understand these Django machanisms and
functionalities, this should not happen.

The basic issue I'm trying to understand here, I believe, is "What really
happens and what is the purpose of binding a modelform to an instance?".


On Tue, Dec 18, 2012 at 7:31 PM, Chris Cogdon  wrote:

> Rather than comparing to instance, why not compare to request.user ?
>
>
> On Tuesday, December 18, 2012 1:11:21 PM UTC-8, fvianna wrote:
>>
>> Hello everyone,
>>
>> I want to apologize if I came to the wrong place to talk about this, but
>> I've been using Django for a while now, and crossed to a very strange
>> behavior that hits me as bug, but I'm not quite sure. First time trying to
>> get a little deeper and maybe report something to help the community.
>>
>> Django's "How to contribute" page lead me to FAQ, and then here.
>>
>>
>>
>> So, I have a ModelForm to edit some of my auth.User data, here it is:
>>
>> class UserForm(ModelForm):
>> """ ModelForm for user relevant fields """
>>
>> class Meta:
>> model = User
>> fields = ('first_name', 'last_name', 'email')
>>
>> def clean_email(self):
>> cleaned_data = super(UserForm, self).clean()
>> unavailable_error = ValidationError("Unavailable")
>> invalid_error = ValidationError("Invalid")
>>
>> email = cleaned_data.get("email")
>> if email:
>> try:
>> user_from_form_email = User.objects.get(email=email)
>> if user_from_form_email != self.instance:
>> raise unavailable_error
>> except User.DoesNotExist:
>> pass
>> except User.MultipleObjectsReturned:
>> raise unavailable_error
>> else:
>> raise invalid_error
>>
>> # Always return the full collection of cleaned data.
>> return cleaned_data.get("email")
>>
>> Pretty straightforward, with a "unique" verification for the email.
>> In my view, I receive the form with some edited data from a user. The
>> view looks as it follows (just ignore the ajax stuff and error returning):
>>
>>
>> def edit_basic_info(request, id):
>> response = {'success': False, 'errors': []}
>>
>> if request.method == 'POST' and request.is_ajax():
>> u_form = UserForm(request.POST, instance=request.user)
>>
>> if u_form.is_valid():
>> if u_form.instance.email != u_form.cleaned_data['email']:
>> tmp_profile = u_form.instance.get_profile()
>> tmp_profile.email_confirmed = False
>> tmp_profile.save()
>>
>>   u_form.save()
>> response['success'] = True
>> else:
>> response['errors'].append(u_**form.errors)
>>
>>
>> When I get to test if the form e-mail is diferent from the instance
>> e-mail in order to set a flag in my model, both emails
>>
>> u_form.instance.email
>>
>> and
>>
>> u_form.cleaned_data['email']
>>
>> are the same. After some debugging, I realized they become the same after
>> calling "is_valid" to the bound form. Now, I'm not sure if I am missing
>> something conceptually about ModelForms binding.
>> Its very ackward to me that I can have a 'instance' field in a ModelForm,
>> but can't distiguish the data after performing the validation. In my case
>> specifically, I need to check first if the email provided by the user is
>> valid, and only then check if its diferent from the instance's e-mail in
>> order to set my flag. But I can't do it, or I will lose the new e-mail
>> provided by the user in the form.
>>
>> Can anyone enlighten this matter? Is this behavior expected?
>> Thank you for your time.
>>
>  --
> 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/-/e1VZcZs_3loJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django community, is it active?

2012-12-18 Thread donarb


On Tuesday, December 18, 2012 1:36:42 PM UTC-8, sparky wrote:
>
>
> ... I'm also finding it hard to find any user groups locally in the UK 
> (I'm based in Manchester, UK).
>
>  
Sometimes Django does not have enough of a user base in an area for its own 
group, you might want to check out the local Python group, some Djangonauts 
may be attending. 

Here's the page for the Manchester Python group, which just happens to be 
meeting this Thursday:

http://madlab.org.uk/content/north-west-python-user-group-27/
 

-- 
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/-/2B2NiNnwWD0J.
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 community, is it active?

2012-12-18 Thread Cal Leeming [Simplicity Media Ltd]
Hi Sparky,

I've personally been using Django for approximately 3 years now - so I'll
offer you my own opinion.

In some ways, it is the most beautiful/perfect framework currently
available.. and in other ways, it leaves a sense of disappointment and
frustration.

* Community - possibly one of the best/most helpful I've seen so far. Don't
drink the free bear though, try and help out where you can!
* Core devs - although sometimes they can seem a bit uppity, they /usually/
know what their talking about and make good decisions
* django-admin - beautiful if you want a simple staff only admin interface
for your data.. terrible if you want to make custom modifications
* Models - the main reason I love Django so much. The models 'just work',
and the query API is lovely. Still room for improvement, but so much better
than sqlalchemy
* Views - class based views are great, but I personally feel that the
pre-made TemplateView/ListView is atrocious. I always use a generic View
and build my own structure.
* Middleware and DB routers - really handy, and again it just works
* Probably tons of other little things that I forgot

There is of course some overhead and a somewhat steep learning curve
(depending on your background) in getting a base project configured, but
don't let this put you off.

Working with a framework is like any relationship... you make sacrifices..
the love you get back depends on what you put in.. and it's not just about
the end goal, it's about how you got there.

Cal


On Tue, Dec 18, 2012 at 10:29 PM, sparky  wrote:

> thanks Nik,
>
>
> On Tuesday, December 18, 2012 9:36:42 PM UTC, sparky wrote:
>>
>> I'm hoping this is the right place to ask such questions, please forgive
>> me if not.
>>
>> I'm making a real time investment in learning another server side
>> language. I have 10 years ColdFusion, 5 years  PHP, JAVA. Having never
>> touched Python let alone the framework Django, for the past 4 weeks I have
>> been testing Django out. Darn, Raspberry Pi started me with my blog (
>> http://www.glynjackson.org/**blog/ ) I
>> have to say its nice, however my concerns are now to do with the community
>> and not so much with the framework itself.
>>
>> No one likes to back a loser and every time I search for Django community
>> I'm faced with a host of negative posts. for example:
>> http://news.ycombinator.com/**item?id=2777883
>>
>>
>> Unlike other languages I'm active in and still use, I'm also finding it
>> hard to find any user groups locally in the UK (I'm based in Manchester,
>> UK).
>>
>> So from the community itself how alive is Django? Should I really invest
>> the time to learn? Does it have a real future and please be honest.
>>
>> other questions
>>
>> 1) is this worth going? --- http://2013.djangocon.eu
>> 2) who are the top blogs people within the Django community who should I
>> be following, blogs feed etc.
>>
>> Sorry for the stupid questions, but and just want a new skillset that I
>> can use for many years to come. Django is really cool
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>  --
> 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/-/_dUN6Su5roIJ.
>
> 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: Templates not found

2012-12-18 Thread Sithembewena Lloyd Dube
Thank you Sergiy and @donarb - my urls.py file was wrng as described by
@donarb.

On Wed, Dec 12, 2012 at 6:38 PM, donarb  wrote:

> When you used the shell, you imported 'tracks.views' but in your urls.py,
> you have musicsite.views.home. The two don't match.
>
>
> On Wednesday, December 12, 2012 6:11:54 AM UTC-8, Lloyd Dube wrote:
>
>> urls.py:
>>
>> urlpatterns = patterns('',
>> # Examples:
>> url(r'^$', 'musicsite.views.home', name='home'),
>> # url(r'^musicsite/', include('musicsite.foo.urls'))**,
>>
>> # Uncomment the admin/doc line below to enable admin documentation:
>> # url(r'^admin/doc/', include('django.contrib.**admindocs.urls')),
>>
>> # Uncomment the next line to enable the admin:
>> url(r'^admin/', include(admin.site.urls)),
>> )
>>
>> I even considered indentation problems, but I have checked that and it is
>> fine.
>>
>>
>> On Tue, Dec 11, 2012 at 5:53 PM, Sergiy Khohlov wrote:
>>
>>> please paste your urls.py
>>>
>>>
>>> 2012/12/11 Sithembewena Lloyd Dube :
>>>
>>> > Hi Segiy,
>>> >
>>> > Thanks for the response. "myproject" is only an alias I used while
>>> posting
>>> > the code on here, in the project code it is actually "tracks".
>>> >
>>> >
>>> > On Tue, Dec 11, 2012 at 1:31 PM, Sergiy Khohlov 
>>> wrote:
>>> >>
>>> >> take a look  you have error related to myproject.view.home   but
>>> >> importing track.view.home 
>>> >>
>>> >> 2012/12/11 Sithembewena Lloyd Dube :
>>>
>>> >> >
>>> >> >
>>> >> > On Tue, Dec 11, 2012 at 4:36 AM, Sithembewena Lloyd Dube
>>> >> > 
>>>
>>> >> > wrote:
>>> >> >>
>>> >> >> Hi all,
>>> >> >>
>>> >> >> I have a Django project running Django 1.4.1. (just upgraded). My
>>> >> >> TEMPLATE_DIRS entry is:
>>> >> >>
>>> >> >> '/home/mymachine/Code/**myproject/templates',
>>> >> >>
>>> >> >>
>>> >> >> and that is exactly where the index template of the new project is
>>> even
>>> >> >> when i use Firefox to locate it.
>>> >> >>
>>> >> >> In my home view, I call render_to_response as follows:
>>> >> >>
>>> >> >> 'def home(request):
>>> >> >> return render_to_response('myapp/**index.html', {})',
>>> >> >>
>>> >> >>
>>> >> >> This raises an exception of type ViewDoesNotExist. If I run python
>>> >> >> manage.py shell, import the view and call it with None as an
>>> argument
>>> >> >> for
>>> >> >> request, it shows that a response object is returned. Yet, the
>>> browser
>>> >> >> will
>>> >> >> not render it.
>>> >> >>
>>> >> >> >>> from tracks.views import home as h
>>> >> >> >>> h(None)
>>> >> >> 
>>> >> >> >>> dir(h(None))
>>> >> >> ['__class__', '__contains__', '__delattr__', '__delitem__',
>>> '__dict__',
>>> >> >> '__doc__', '__format__', '__getattribute__', '__getitem__',
>>> >> >> '__getstate__',
>>> >> >> '__hash__', '__init__', '__iter__', '__module__', '__new__',
>>> >> >> '__reduce__',
>>> >> >> '__reduce_ex__', '__repr__', '__setattr__', '__setitem__',
>>> >> >> '__setstate__',
>>> >> >> '__sizeof__', '__str__', '__subclasshook__', '__weakref__',
>>> >> >> '_base_content_is_iter', '_charset', '_container',
>>> '_convert_to_ascii',
>>> >> >> '_get_content', '_headers', '_set_content', 'close', 'content',
>>> >> >> 'cookies',
>>> >> >> 'delete_cookie', 'flush', 'get', 'has_header', 'items', 'next',
>>> >> >> 'set_cookie', 'set_signed_cookie', 'status_code', 'tell', 'write']
>>> >> >>
>>> >> >> Am I missing something?
>>> >> >>
>>> >> >> Thanks.
>>> >> >>
>>> >> >> --
>>> >> >> Regards,
>>> >> >> Sithu Lloyd Dube
>>> >> >
>>> >> >
>>> >> >
>>> >> >
>>> >> > --
>>> >> > Regards,
>>> >> > Sithu Lloyd Dube
>>> >> >
>>> >> > --
>>> >> > 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
>>> .
>>> >>
>>> >
>>> >
>>> >
>>> > --
>>> > Regards,
>>> > Sithu Lloyd Dube
>>> >
>>> > --
>>> > 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.
>>>

Re: trouble with pre_delete signal method

2012-12-18 Thread Mike Dewhirst

Thomas

Thanks for replying

On 19/12/2012 12:06am, Thomas Orozco wrote:

Hi,


Could you provide the following information?
 - What's the relationship between A and B (model code of the field,
if there is, would be great)


There is no relationship at all. A and B are separately and 
independently related to Item.


A and B are actually copied from 'a' and 'b' which *are* related but 
exist purely as a stand-alone reference. When Item gets an A record (and 
it can have many) it is copied from its 'a' reference record. Item then 
automatically gets copies of all the corresponding 'b' reference records 
as B records - except duplicates are semi-skipped.


Where a duplicate would have occurred, I append the A_code into a 
special field on the B record to indicate which A records were/are 
"interested" in that B record. When A records are deleted, it is 
necessary to delete their corresponding B records - unless another A 
record is still interested in which case we just remove the deleted 
A_code from the special field.


I could send you the model code off-list if you wish.


 - The code of your pre_delete signal handler / the method it calls.


#  this lives in models.A_Part.py   #   #   #

from django.db.models.signals import pre_delete, post_delete

def cleanup_bparts(sender, instance, **kwargs):
instance.item.delete_bparts(a_code=instance.a_code)

pre_delete.connect(cleanup_bparts, sender=A_Part, weak=False)
#post_delete.connect(cleanup_bparts, sender=A_Part, weak=False)

#   #   #   #   #   #   #   #   #   #   #   #

... and the item.delete_bparts() code ...


def delete_bparts(self, a_code):
qs_bpart = B_Part.objects.filter(item=self,
 a_partcodes__contains=a_code)
for bpart in qs_bpart:
acodes = bpart.a_partcodes.split()
if len(acodes) == 1:
bpart.delete()
else:
acodes.remove(a_code)
bpart.a_partcodes = ' '.join(acodes)
bpart.save()



I think you have a ForeignKey field that is required or limited and that
is causing the ValidationError.
Indeed, that line 988 is in the code for ModelChoiceField


I have been through all the fk fields and they are all null=True, 
blank=True and in Postgress each _id column is nullable.


I also had an ordering sequence on some of the models and I removed all 
that as well.


As mentioned earlier, embedded print statements seem to prove the 
delete_bparts() code is working nicely.


When I comment out the pre-delete connection, the A_Part record gets 
delete as expected - but obviously it doesn't clean up the B records.


Thanks 

Mike




Best,

Thomas

2012/12/17 Mike Dewhirst >

I'm getting a baffling ValidationError.

Request URL: http://127.0.0.1:8000/admin/__assembly/item/4/

Django Version: 1.4.3
Exception Type: ValidationError
Exception Value:[u'Select a valid choice. That choice is not
one of the available choices.']

Exception Location:
C:\usr\bin\lib\site-packages\__django\forms\models.py in to_python,
line 988
Python Version: 2.7.3

Background ...

I have an Item model which has two one-to-many relationships with
other types of child records (call them A and B models).

In the Admin, when the user adds an A record, some B records get
added automatically.

The next A record to get added does much the same but if there are
any B duplicates it doesn't try to add those but instead just adds
its mark to a special field in the B record which is already there.

My code - which from embedded print statements appears to be doing
exactly what I want - will either delete the B record or just remove
the mark previously added. Eventually when the last A record is
deleted the idea is that the last B records will go at the same time.

Unfortunately, at the final hurdle we get the ValidationError at
line 988 in to_python.

The local vars nominate ...

self
value   u'251'
key 'pk'

... and that is the pk of the A record which triggers the Item code
via a pre_delete signal.

Summarising:

- the deletion/mark removal method lives in the Item model
- the pre-delete signal is detected in the A record
- the signal connects a stub method in the A record
- the stub method in the A record calls the Item method
- the Item method iterates over a filtered queryset of B records and
uses the passed value (the aforesaid mark from the A record) to
decide whether to delete the B record or just remove the mark and
save it

None of my code appears in the TraceBack so I assume the Admin is
trying to delete the A record. I've tried both pre_delete and
post_delete signals in the A record.

Why is it so?

Thanks for any hints

Mike


--

Re: Django community, is it active?

2012-12-18 Thread sparky
thanks Nik,

On Tuesday, December 18, 2012 9:36:42 PM UTC, sparky wrote:
>
> I'm hoping this is the right place to ask such questions, please forgive 
> me if not.
>
> I'm making a real time investment in learning another server side 
> language. I have 10 years ColdFusion, 5 years  PHP, JAVA. Having never 
> touched Python let alone the framework Django, for the past 4 weeks I have 
> been testing Django out. Darn, Raspberry Pi started me with my blog (
> http://www.glynjackson.org/blog/) I have to say its nice, however my 
> concerns are now to do with the community and not so much with the 
> framework itself.
>
> No one likes to back a loser and every time I search for Django community 
> I'm faced with a host of negative posts. for example: 
> http://news.ycombinator.com/item?id=2777883  
>
> Unlike other languages I'm active in and still use, I'm also finding it 
> hard to find any user groups locally in the UK (I'm based in Manchester, 
> UK).
>
> So from the community itself how alive is Django? Should I really invest 
> the time to learn? Does it have a real future and please be honest.
>
> other questions
>
> 1) is this worth going? --- http://2013.djangocon.eu
> 2) who are the top blogs people within the Django community who should I 
> be following, blogs feed etc.
>
> Sorry for the stupid questions, but and just want a new skillset that I 
> can use for many years to come. Django is really cool
>
>
>
>
>
>
>
>
>
>

-- 
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/-/_dUN6Su5roIJ.
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 community, is it active?

2012-12-18 Thread Nikolas Stevenson-Molnar
I expect that most of the people on this list have chosen Django for
their project(s), which would probably make our view a little skewed ;)

That said, the thread you reference is basically a framework religion
war. You may have noticed: there are extremely negative comments about
every framework on that post.

Personally, I give Django a definite "yes". It sees active development
(and with useful improvements!), great documentation, tons of 3rd party
libraries, a helpful community, and is proven on a number of
high-profile projects (maybe you've heard of Instagram?)

_Nik

On 12/18/2012 1:36 PM, sparky wrote:
> I'm hoping this is the right place to ask such questions, please
> forgive me if not.
>
> I'm making a real time investment in learning another server side
> language. I have 10 years ColdFusion, 5 years  PHP, JAVA. Having never
> touched Python let alone the framework Django, for the past 4 weeks I
> have been testing Django out. Darn, Raspberry Pi started me with my
> blog (http://www.glynjackson.org/blog/) I have to say its nice,
> however my concerns are now to do with the community and not so much
> with the framework itself.
>
> No one likes to back a loser and every time I search for Django
> community I'm faced with a host of negative posts. for example:
> http://news.ycombinator.com/item?id=2777883 
>
> Unlike other languages I'm active in and still use, I'm also finding
> it hard to find any user groups locally in the UK (I'm based in
> Manchester, UK).
>
> So from the community itself how alive is Django? Should I really
> invest the time to learn? Does it have a real future and please be honest.
>
> other questions
>
> 1) is this worth going? --- http://2013.djangocon.eu
> 2) who are the top blogs people within the Django community who should
> I be following, blogs feed etc.
>
> Sorry for the stupid questions, but and just want a new skillset that
> I can use for many years to come. Django is really cool
>
>
>
>
>
>
>
>
>
> -- 
> 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/-/njMLaUXa0yQJ.
> 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.



Django community, is it active?

2012-12-18 Thread sparky
I'm hoping this is the right place to ask such questions, please forgive me 
if not.

I'm making a real time investment in learning another server side language. 
I have 10 years ColdFusion, 5 years  PHP, JAVA. Having never touched Python 
let alone the framework Django, for the past 4 weeks I have been testing 
Django out. Darn, Raspberry Pi started me with my blog 
(http://www.glynjackson.org/blog/) I have to say its nice, however my 
concerns are now to do with the community and not so much with the 
framework itself.

No one likes to back a loser and every time I search for Django community 
I'm faced with a host of negative posts. for example: 
http://news.ycombinator.com/item?id=2777883  

Unlike other languages I'm active in and still use, I'm also finding it 
hard to find any user groups locally in the UK (I'm based in Manchester, 
UK).

So from the community itself how alive is Django? Should I really invest 
the time to learn? Does it have a real future and please be honest.

other questions

1) is this worth going? --- http://2013.djangocon.eu
2) who are the top blogs people within the Django community who should I be 
following, blogs feed etc.

Sorry for the stupid questions, but and just want a new skillset that I can 
use for many years to come. Django is really cool









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



Re: invalid syntax inside urls.py

2012-12-18 Thread carlos
and coma before url admin !!!

Cheers


On Tue, Dec 18, 2012 at 3:32 PM, Chris Cogdon  wrote:

> Need a comma between the view name, and {'queryset...' and your
> parenthesis are not nested properly.
>
>
> On Tuesday, December 18, 2012 12:19:24 PM UTC-8, maiquel wrote:
>>
>> 'm trying to do the following
>>
>> Artigo.objects.all () inside urls.py
>>
>> urlpatterns = patterns ('',
>>  # url (r '^ blog / $', 'blog.views.archive_index.**index')
>>  (r '^ $', 'django.views.generic.date_**based.archive_index'
>>  {'queryset': Artigo.objects.all ()), # invalid syntax
>>  'date_field', 'publication'})
>>  (url (r '^ admin /', include (admin.site.urls)),
>> )
>>
>> []`s
>>
>> Maiquel Knechtel
>>
>  --
> 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/-/GZSERIT-4NoJ.
>
> 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: Converting Django app into a Desktop app

2012-12-18 Thread Chris Cogdon
Personally, I'd prefer something that didn't require packaging up 
additional programs (xampp and python, in this example).

It should be _perfectly possible_ to find a native-python moderate 
performance webserver, then wrap up that, django, the application and the 
python interpreter into a single package.


On Tuesday, December 18, 2012 12:14:59 PM UTC-8, peter_julian wrote:
>
>  Don't realy mathers is xampp comes or not with python, you just need to 
> add wsgi module to xampp. and then configure your app to run from
> xampp.
>  
>  

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



Re: invalid syntax inside urls.py

2012-12-18 Thread Chris Cogdon
Need a comma between the view name, and {'queryset...' and your parenthesis 
are not nested properly.

On Tuesday, December 18, 2012 12:19:24 PM UTC-8, maiquel wrote:
>
> 'm trying to do the following
>
> Artigo.objects.all () inside urls.py
>
> urlpatterns = patterns ('',
>  # url (r '^ blog / $', 'blog.views.archive_index.index')
>  (r '^ $', 'django.views.generic.date_based.archive_index'
>  {'queryset': Artigo.objects.all ()), # invalid syntax
>  'date_field', 'publication'})
>  (url (r '^ admin /', include (admin.site.urls)),
> )
>
> []`s
>
> Maiquel Knechtel
>

-- 
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/-/GZSERIT-4NoJ.
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: Strange behavior using ModelForms

2012-12-18 Thread Chris Cogdon
Rather than comparing to instance, why not compare to request.user ?

On Tuesday, December 18, 2012 1:11:21 PM UTC-8, fvianna wrote:
>
> Hello everyone,
>
> I want to apologize if I came to the wrong place to talk about this, but 
> I've been using Django for a while now, and crossed to a very strange 
> behavior that hits me as bug, but I'm not quite sure. First time trying to 
> get a little deeper and maybe report something to help the community.
>
> Django's "How to contribute" page lead me to FAQ, and then here.
>
>
>
> So, I have a ModelForm to edit some of my auth.User data, here it is:
>
> class UserForm(ModelForm):
> """ ModelForm for user relevant fields """
>
> class Meta:
> model = User
> fields = ('first_name', 'last_name', 'email')
>
> def clean_email(self):
> cleaned_data = super(UserForm, self).clean()
> unavailable_error = ValidationError("Unavailable")
> invalid_error = ValidationError("Invalid")
>
> email = cleaned_data.get("email")
> if email:
> try:
> user_from_form_email = User.objects.get(email=email)
> if user_from_form_email != self.instance:
> raise unavailable_error
> except User.DoesNotExist:
> pass
> except User.MultipleObjectsReturned:
> raise unavailable_error
> else:
> raise invalid_error
>
> # Always return the full collection of cleaned data.
> return cleaned_data.get("email")
>
> Pretty straightforward, with a "unique" verification for the email.
> In my view, I receive the form with some edited data from a user. The view 
> looks as it follows (just ignore the ajax stuff and error returning):
>
>
> def edit_basic_info(request, id):
> response = {'success': False, 'errors': []}
>
> if request.method == 'POST' and request.is_ajax():
> u_form = UserForm(request.POST, instance=request.user)
>
> if u_form.is_valid():  
> if u_form.instance.email != u_form.cleaned_data['email']:
> tmp_profile = u_form.instance.get_profile()
> tmp_profile.email_confirmed = False
> tmp_profile.save()  
> 
>   u_form.save()
> response['success'] = True
> else:
> response['errors'].append(u_form.errors)
>
>
> When I get to test if the form e-mail is diferent from the instance e-mail 
> in order to set a flag in my model, both emails 
>
> u_form.instance.email
>
> and
>
> u_form.cleaned_data['email']
>
> are the same. After some debugging, I realized they become the same after 
> calling "is_valid" to the bound form. Now, I'm not sure if I am missing 
> something conceptually about ModelForms binding.
> Its very ackward to me that I can have a 'instance' field in a ModelForm, 
> but can't distiguish the data after performing the validation. In my case 
> specifically, I need to check first if the email provided by the user is 
> valid, and only then check if its diferent from the instance's e-mail in 
> order to set my flag. But I can't do it, or I will lose the new e-mail 
> provided by the user in the form.
>
> Can anyone enlighten this matter? Is this behavior expected? 
> Thank you for your time. 
>

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



Strange behavior using ModelForms

2012-12-18 Thread Francisco Vianna
Hello everyone,

I want to apologize if I came to the wrong place to talk about this, but 
I've been using Django for a while now, and crossed to a very strange 
behavior that hits me as bug, but I'm not quite sure. First time trying to 
get a little deeper and maybe report something to help the community.

Django's "How to contribute" page lead me to FAQ, and then here.



So, I have a ModelForm to edit some of my auth.User data, here it is:

class UserForm(ModelForm):
""" ModelForm for user relevant fields """

class Meta:
model = User
fields = ('first_name', 'last_name', 'email')

def clean_email(self):
cleaned_data = super(UserForm, self).clean()
unavailable_error = ValidationError("Unavailable")
invalid_error = ValidationError("Invalid")

email = cleaned_data.get("email")
if email:
try:
user_from_form_email = User.objects.get(email=email)
if user_from_form_email != self.instance:
raise unavailable_error
except User.DoesNotExist:
pass
except User.MultipleObjectsReturned:
raise unavailable_error
else:
raise invalid_error

# Always return the full collection of cleaned data.
return cleaned_data.get("email")

Pretty straightforward, with a "unique" verification for the email.
In my view, I receive the form with some edited data from a user. The view 
looks as it follows (just ignore the ajax stuff and error returning):


def edit_basic_info(request, id):
response = {'success': False, 'errors': []}

if request.method == 'POST' and request.is_ajax():
u_form = UserForm(request.POST, instance=request.user)

if u_form.is_valid():  
if u_form.instance.email != u_form.cleaned_data['email']:
tmp_profile = u_form.instance.get_profile()
tmp_profile.email_confirmed = False
tmp_profile.save()  

  u_form.save()
response['success'] = True
else:
response['errors'].append(u_form.errors)


When I get to test if the form e-mail is diferent from the instance e-mail 
in order to set a flag in my model, both emails 

u_form.instance.email

and

u_form.cleaned_data['email']

are the same. After some debugging, I realized they become the same after 
calling "is_valid" to the bound form. Now, I'm not sure if I am missing 
something conceptually about ModelForms binding.
Its very ackward to me that I can have a 'instance' field in a ModelForm, 
but can't distiguish the data after performing the validation. In my case 
specifically, I need to check first if the email provided by the user is 
valid, and only then check if its diferent from the instance's e-mail in 
order to set my flag. But I can't do it, or I will lose the new e-mail 
provided by the user in the form.

Can anyone enlighten this matter? Is this behavior expected? 
Thank you for your time. 

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



invalid syntax inside urls.py

2012-12-18 Thread maiquel
'm trying to do the following

Artigo.objects.all () inside urls.py

urlpatterns = patterns ('',
 # url (r '^ blog / $', 'blog.views.archive_index.index')
 (r '^ $', 'django.views.generic.date_based.archive_index'
 {'queryset': Artigo.objects.all ()), # invalid syntax
 'date_field', 'publication'})
 (url (r '^ admin /', include (admin.site.urls)),
)

[]`s

Maiquel Knechtel

-- 
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/-/zZiszdLoKcAJ.
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: Converting Django app into a Desktop app

2012-12-18 Thread peter

On 12/18/2012 05:18 PM, Chris Cogdon wrote:

No Python included with xampp... this makes me sad ;_;


On Tuesday, December 18, 2012 11:43:56 AM UTC-8, peter_julian wrote:

You can use xampp. Create a automatic installer that install xampp
and django with your app.
Just like Kordi EDMS. http://www.kordil.net/.

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

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 not read the hole article, but the author say 'It works'.

http://www.leonardaustin.com/technical/install-python-and-django-with-xampp-on-windows-7

Is run in windows definitely is going to run on unix :)

--
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: Converting Django app into a Desktop app

2012-12-18 Thread peter

On 12/18/2012 05:18 PM, Chris Cogdon wrote:

No Python included with xampp... this makes me sad ;_;


On Tuesday, December 18, 2012 11:43:56 AM UTC-8, peter_julian wrote:

You can use xampp. Create a automatic installer that install xampp
and django with your app.
Just like Kordi EDMS. http://www.kordil.net/.

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

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.
Don't realy mathers is xampp comes or not with python, you just need to 
add wsgi module to xampp. and then configure your app to run from

xampp.

--
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: template caching context variables when no caching enabled.

2012-12-18 Thread Chris Cogdon
Parameter 2 to "render_to_response" is only expecting a dictionary, not a 
Context/RequestContext, so, it will grab your 'dictionary-like object' and 
wrap it in its own Context, meaning that none of your template context 
processors will run  (since those require a RequestContext)

I suggest using the even more shortcutty "render":

return render ( request, 'document_manager/document_revert.html', context )

which to me is just cleaner than anything


> Any idea why this happens?
>

-- 
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/-/GaVvlhAqk4sJ.
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: Converting Django app into a Desktop app

2012-12-18 Thread Chris Cogdon
No Python included with xampp... this makes me sad ;_;


On Tuesday, December 18, 2012 11:43:56 AM UTC-8, peter_julian wrote:
>
>  You can use xampp. Create a automatic installer that install xampp and 
> django with your app.
> Just like Kordi EDMS. http://www.kordil.net/.
>  

-- 
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/-/KmUdBqv7KZoJ.
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 with timeout

2012-12-18 Thread Chris Cogdon
Nice find!

If you turn debugging on for "django.db.backends", it will show you what 
SQL queries are being issued, and the time taken for each.

LOGGING['handlers']['console'] = { 'level':'DEBUG', 'class': 
'logging.StreamHandler' }
LOGGING['loggers']['django.db.backends'] = { 'handlers':['console'], 
'level':'DEBUG' }

(you could also just modify the existing LOGGING variable)

On Monday, December 17, 2012 11:42:07 PM UTC-8, Szabo, Patrick (LNG-VIE) 
wrote:
>
>   Nevermind…select_related() did the trick. 
>
> 226 queries cut to 4…amazing this little statement J
>
>
>   

-- 
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/-/9t-bjnbj08MJ.
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: cached template loader

2012-12-18 Thread Chris Cogdon
your two versions are actually identical :)

The missing comma, I assume, was missing 
after django.template.loaders.app_directories.Loader ... without the comma 
there, python sees two strings right next to each other, and thus 
concatenates them, resulting in a single parameter 
: 
'django.template.loaders.app_directories.Loaderdjango.template.loaders.filesystem.Loader'

On Tuesday, December 18, 2012 2:40:02 AM UTC-8, Tom Martin wrote:
>
> I had the same problem and discovered that I was missing a comma in the 
> settings file:
>
> TEMPLATE_LOADERS = (
> ('django.template.loaders.cached.Loader, (
> 'django.template.loaders.app_directories.Loader',
> 'django.template.loaders.filesystem.Loader,
> ))
> )
>
> should have been:
>
> TEMPLATE_LOADERS = (
> ('django.template.loaders.cached.Loader, (
> 'django.template.loaders.app_directories.Loader',
> 'django.template.loaders.filesystem.Loader,
> ))
> )
>
> Pretty subtle issue, I'm not sure how the missing comma causes it.
>
> On Tuesday, July 6, 2010 1:45:27 PM UTC+1, Sævar Öfjörð wrote:
>>
>> I've also tried passing this through 
>> django.shortcuts.render_to_response, but I get the same error. 
>> - Sævar 
>>
>> On Jul 6, 2:41 pm, Sævar Öfjörð  wrote: 
>> > Hi, I've been using the default template loaders and it works fine. 
>> > Now I want to add the cached template loader, but I get an error. 
>> > 
>> > I'm using a wrapper function to return responses that include the 
>> > request in the context, like this: 
>> > 
>> > # file helpers/helpers.py 
>> > from django.template import RequestContext, loader 
>> > from django.http import  HttpResponse 
>> > 
>> > def return_response(request, dictionary, template, headers={}): 
>> > t = loader.get_template(template) 
>> > c = RequestContext(request, dictionary) 
>> > res = HttpResponse(t.render(c)) 
>> > for h, v in headers.iteritems(): 
>> > res[h] = v 
>> > return res 
>> > 
>> > The stacktrace: 
>> > 
>> > Traceback: 
>> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
>> > django/core/handlers/base.py" in get_response 
>> >   106. response = middleware_method(request, 
>> > e) 
>> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
>> > django/core/handlers/base.py" in get_response 
>> >   100. response = callback(request, 
>> > *callback_args, **callback_kwargs) 
>> > File "/home/django/project/project/views.py" in index 
>> >   24.   return helpers.return_response(request, d, 'frontpage.html') 
>> > File "/home/django/project/project/helpers/helpers.py" in 
>> > return_response 
>> >   129.  t = loader.get_template(template) 
>> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
>> > django/template/loader.py" in get_template 
>> >   157. template, origin = find_template(template_name) 
>> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
>> > django/template/loader.py" in find_template 
>> >   128. loader = find_template_loader(loader_name) 
>> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
>> > django/template/loader.py" in find_template_loader 
>> >   104. func = TemplateLoader(*args) 
>> > 
>> > Exception Type: TypeError at / 
>> > Exception Value: __init__() takes exactly 2 arguments (1 given) 
>> > 
>> > Is there some different way I should approach the template loading?
>
>

-- 
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/-/_14fNKjl3HQJ.
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: web gui for email server

2012-12-18 Thread Chris Cogdon
I don't know of any. (Nothing comes up 
on http://www.djangopackages.com/grids/g/email/) But I might be able to say 
why you might not find any.

Desktop e-mail clients usually consist of the interface plus a local cache. 
The client connects to the mail storage and (via POP or IMAP) retrieves 
what messages there are, and may retrieve a copy of the messages, and cache 
them for quicker access and indexing.

Conversely, a web based client often does _not_ include a cache, but 
instead simply uses a connection to the mail storage via IMAP as its 
database, which still has some rudimentary features such as searching and 
indexing, etc. So, why bother having a separate database if IMAP does just 
about all you need?

And since there's no local database, the actual web app itself becomes 
stateless, and thus a lot of Django's benefit is not used. Sure, there can 
be some.. such as maintaining session state separately from the IMAP 
connection.




On Tuesday, December 18, 2012 8:02:13 AM UTC-8, davidjensen wrote:
>
> I am using the mailgun emailserver which has an api but not a web gui. 
> mailgun suggests using an desktop client. Are there web guis for email 
> servers written for django?
>

-- 
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/-/zG_u_hJtpLAJ.
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: Converting Django app into a Desktop app

2012-12-18 Thread peter

On 12/18/2012 04:27 PM, Loai Ghoraba wrote:

@ all thanks for your responses, I will try to investigate them

@Chris: you got me right :) I can use runserver, but it would be too 
light, or make the client install and configure apache (which is not a 
good idea if the client is a normal user, not a programmer).


On Tue, Dec 18, 2012 at 9:23 PM, Chris Cogdon > wrote:


I think what Loai is asking for is a way to "wrap up" the
python/django application, along with a light-weight webserver
(not as light-weight as "runserver" though), so it looks like a
stand-alone application... apart from needing to run a web browser
to connect to it.
eNo module named _tkinter, please install the python-tk package
I, too, am very interested in this.

Just doing some cursory poking around, here's some starting points:

Python Freeze: http://wiki.python.org/moin/Freeze

cx_Freeze: http://cx-freeze.sourceforge.net

Py2Exe: http://wiki.python.org/moin/Py2Exe

py2app: http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html


These handle turning the python program into a stand-alone
executable. It doesn't solve the web-server issue, though. There
are a ton of choices there (eg: gunicorn, twisted, tornado,
web.py) but I have no opinion on which one is going to both
"freeze" well, serve static files well, and work well with Django



On Tuesday, December 18, 2012 8:06:19 AM UTC-8, Loai Ghoraba wrote:

Hi

I am very comfortable with Django, and I was wondering about
whether there is some way to convert a Django web app into a
Desktop app (may be not 100%), so that I can distribute it to
users. May be wrapping it in a light web server "if there is
something like 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/-/ruJ-QX6bLO8J.

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 can use xampp. Create a automatic installer that install xampp and 
django with your app.

Just like Kordi EDMS. http://www.kordil.net/.

--
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: Converting Django app into a Desktop app

2012-12-18 Thread Loai Ghoraba
@ all thanks for your responses, I will try to investigate them

@Chris: you got me right :) I can use runserver, but it would be too light,
or make the client install and configure apache (which is not a good idea
if the client is a normal user, not a programmer).

On Tue, Dec 18, 2012 at 9:23 PM, Chris Cogdon  wrote:

> I think what Loai is asking for is a way to "wrap up" the python/django
> application, along with a light-weight webserver (not as light-weight as
> "runserver" though), so it looks like a stand-alone application... apart
> from needing to run a web browser to connect to it.
> eNo module named _tkinter, please install the python-tk package
> I, too, am very interested in this.
>
> Just doing some cursory poking around, here's some starting points:
>
> Python Freeze: http://wiki.python.org/moin/Freeze
>
> cx_Freeze: http://cx-freeze.sourceforge.net
>
> Py2Exe: http://wiki.python.org/moin/Py2Exe
>
> py2app: http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html
>
>
> These handle turning the python program into a stand-alone executable. It
> doesn't solve the web-server issue, though. There are a ton of choices
> there (eg: gunicorn, twisted, tornado, web.py) but I have no opinion on
> which one is going to both "freeze" well, serve static files well, and work
> well with Django
>
>
>
> On Tuesday, December 18, 2012 8:06:19 AM UTC-8, Loai Ghoraba wrote:
>>
>> Hi
>>
>> I am very comfortable with Django, and I was wondering about whether
>> there is some way to convert a Django web app into a Desktop app (may be
>> not 100%), so that I can distribute it to users. May be wrapping it in a
>> light web server "if there is something like 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/-/ruJ-QX6bLO8J.
>
> 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: Converting Django app into a Desktop app

2012-12-18 Thread Chris Cogdon
I think what Loai is asking for is a way to "wrap up" the python/django 
application, along with a light-weight webserver (not as light-weight as 
"runserver" though), so it looks like a stand-alone application... apart 
from needing to run a web browser to connect to it.

I, too, am very interested in this.

Just doing some cursory poking around, here's some starting points:

Python Freeze: http://wiki.python.org/moin/Freeze

cx_Freeze: http://cx-freeze.sourceforge.net

Py2Exe: http://wiki.python.org/moin/Py2Exe

py2app: http://svn.pythonmac.org/py2app/py2app/trunk/doc/index.html


These handle turning the python program into a stand-alone executable. It 
doesn't solve the web-server issue, though. There are a ton of choices 
there (eg: gunicorn, twisted, tornado, web.py) but I have no opinion on 
which one is going to both "freeze" well, serve static files well, and work 
well with Django



On Tuesday, December 18, 2012 8:06:19 AM UTC-8, Loai Ghoraba wrote:
>
> Hi
>
> I am very comfortable with Django, and I was wondering about whether there 
> is some way to convert a Django web app into a Desktop app (may be not 
> 100%), so that I can distribute it to users. May be wrapping it in a light 
> web server "if there is something like 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/-/ruJ-QX6bLO8J.
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: Converting Django app into a Desktop app

2012-12-18 Thread acheraime
Use a module like tastiepy develop your desktop client in your preferred 
language and have it communicate to django via REST.

Sent from my iPhone

On Dec 18, 2012, at 1:43 PM, Jonas Geiregat  wrote:

> 
> 
>> Hi
>> 
>> I am very comfortable with Django, and I was wondering about whether there 
>> is some way to convert a Django web app into a Desktop app (may be not 
>> 100%), so that I can distribute it to users. May be wrapping it in a light 
>> web server "if there is something like this". 
>> 
> 
> You might try http://www.python-camelot.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.

-- 
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: Converting Django app into a Desktop app

2012-12-18 Thread Jonas Geiregat


> Hi
> 
> I am very comfortable with Django, and I was wondering about whether there is 
> some way to convert a Django web app into a Desktop app (may be not 100%), so 
> that I can distribute it to users. May be wrapping it in a light web server 
> "if there is something like this". 
> 
> 
> 

You might try http://www.python-camelot.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: template caching context variables when no caching enabled.

2012-12-18 Thread John Tipton
I believe I may have solved it, this is the view that kept causing it to 
happen:
def document_revert(request, pk):
version = get_object_or_404(reversion.models.Version, pk=pk)
document_version = version.object_version.object
context = RequestContext(request, {'document': document_version})
context = set_context_vars(context, Document, request)
if request.method == 'POST':
if request.POST['Revert'] == 'Confirm Revert':
version.revert()
return HttpResponseRedirect(lazy(reverse, str)('document', 
args=[document_version.id]))
else:
return render_to_response('document_manager/document_revert.html', 
context)

I changed the function and it seems to have stopped happening.  Here is the 
updated view:
def document_revert(request, pk):
version = get_object_or_404(reversion.models.Version, pk=pk)
document_version = version.object_version.object
#context = RequestContext(request, {'document': document_version})
context = {
   'document': document_version,
   }
context = set_context_vars(context, Document, request)
if request.method == 'POST':
if request.POST['Revert'] == 'Confirm Revert':
version.revert()
return HttpResponseRedirect(lazy(reverse, str)('document', 
args=[document_version.id]))
else:
return render_to_response('document_manager/document_revert.html', 
context, context_instance=RequestContext(request))

Any idea why this happens?

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



template caching context variables when no caching enabled.

2012-12-18 Thread John Tipton
 

I've got the following function that I include in my views to set context 
variables.  Occasionally my templates start caching these variables, no 
matter what model my views are based on.

def set_context_vars(context, model, request=None):
"""
Set Extra Context Variables
"""
print 'Conext Model: %s' % model._meta.verbose_name.title()
context['modelTitle'] = model._meta.verbose_name.title()
context['modelTitlePlural'] = model._meta.verbose_name_plural.title()
context['modelNamePlural'] = model._meta.verbose_name_plural.lower()
context['modelName'] = model._meta.verbose_name.lower()
context['modelSlug'] = slugify(model._meta.verbose_name.lower())
context['modelSlugPlural'] = 
slugify(model._meta.verbose_name_plural.lower())
context['modelViewCreate'] = '%s-create' % 
slugify(model._meta.verbose_name.lower())
context['modelViewUpdate'] = '%s-update' % 
slugify(model._meta.verbose_name.lower())
context['modelViewList'] = '%s' % 
slugify(model._meta.verbose_name_plural.lower())
context['modelViewDelete'] = '%s-delete' % 
slugify(model._meta.verbose_name.lower())
context['modelViewDetail'] = '%s' % 
slugify(model._meta.verbose_name.lower())
 
# Set Permissions
emPerms = {}
permsModelName = model._meta.verbose_name.replace(' ', '')
app_label = model._meta.app_label
if request and request.user:
if request.user.has_perm('%s.add_%s' % (app_label, permsModelName)):
emPerms['add'] = True
if request.user.has_perm('%s.change_%s' % (app_label, permsModelName)):
emPerms['change'] = True
if request.user.has_perm('%s.delete_%s' % (app_label, permsModelName)):
emPerms['delete'] = True
context['emPerms'] = emPerms
 
return context

-- 
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/-/0rTwTj-P178J.
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.



Templates caching context when it shouldn't

2012-12-18 Thread John Tipton
 

I've got the following function that I include in my views to set context 
variables: http://dpaste.org/FIZnG/.  Occasionally my templates start 
caching these variables, no matter what model my views are based on.  I do 
not have any caching enabled as far as I know, and the console prints the 
correct value.

Does any one know how to keep django from caching these context variables?

Thanks,

John

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



web gui for email server

2012-12-18 Thread davidjensen
I am using the mailgun emailserver which has an api but not a web gui. 
mailgun suggests using an desktop client. Are there web guis for email 
servers written for django?

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



Converting Django app into a Desktop app

2012-12-18 Thread Loai Ghoraba


Hi

I am very comfortable with Django, and I was wondering about whether there 
is some way to convert a Django web app into a Desktop app (may be not 
100%), so that I can distribute it to users. May be wrapping it in a light 
web server "if there is something like 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/-/-kBVrtdpjo4J.
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: 【HELP】AttributeError: 'AdminSite' object has no attribute 'urls'

2012-12-18 Thread Thomas Orozco
Haha indeed, silly me!

Well I think that's the error cause then : the urls property apparently
didn't exist in Django 1.0!

Cheers,

Thomas
On Dec 18, 2012 3:14 PM, "Ramiro Morales"  wrote:

> On Tue, Dec 18, 2012 at 10:12 AM, Thomas Orozco  wrote:
> > What version of django are you using?
> >
> > admin.site.urls was introducd four years ago
> > (
> https://github.com/django/django/commit/1f84630c87f8032b0167e6db41acaf50ab710879
> ),
> > but maybe you're running an older version?
>
> On Fri, Dec 14, 2012 at 11:06 PM, 向浩  wrote:
> > Environment:
> >
> > Request Method: GET
> > Request URL: http://127.0.0.1:8000/admin/
> > Django Version: 1.0.4
> > Python Version: 2.7.3
>
> --
> Ramiro Morales
>
> --
> 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: getting "DateTimeField received a naive datetime" error but have no DateTimeFields

2012-12-18 Thread bobhaugen
Tom, thank you for that very useful tip!  My feeble python-fu has now been 
strengthened.

On Monday, December 17, 2012 8:27:28 AM UTC-6, Tom Evans wrote
>
>
> Following the thread I see that you have figured out where and why 
> this is coming from. There is a simple tip you can use to speed this 
> up in future, simply run python with warnings set to error, and any 
> Warnings will be converted into RuntimeErrors - so you get a lovely 
> stack trace showing exactly how and when the warning was issued. 
>
> You can configure python to stop only on certain Warnings, but the 
> simplest way is to turn all Warnings into Errors: 
>
> python -W error manage.py  
>
> Full details on what you can specify with -W here: 
>
> http://docs.python.org/2/library/warnings.html#the-warnings-filter 
>
> 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/-/R9E0V7qFg5YJ.
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: 【HELP】AttributeError: 'AdminSite' object has no attribute 'urls'

2012-12-18 Thread Ramiro Morales
On Tue, Dec 18, 2012 at 10:12 AM, Thomas Orozco  wrote:
> What version of django are you using?
>
> admin.site.urls was introducd four years ago
> (https://github.com/django/django/commit/1f84630c87f8032b0167e6db41acaf50ab710879),
> but maybe you're running an older version?

On Fri, Dec 14, 2012 at 11:06 PM, 向浩  wrote:
> Environment:
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/admin/
> Django Version: 1.0.4
> Python Version: 2.7.3

-- 
Ramiro Morales

-- 
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: 【HELP】AttributeError: 'AdminSite' object has no attribute 'urls'

2012-12-18 Thread vinoth kumar renganathan
1 . check whether u imported url in the file mysite/urls.py

2.make sure that you added url before the command(r'^admin/',
include(admin.site.urls))

-- 
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: 【HELP】AttributeError: 'AdminSite' object has no attribute 'urls'

2012-12-18 Thread Thomas Orozco
What version of django are you using?

admin.site.urls was introducd four years ago (
https://github.com/django/django/commit/1f84630c87f8032b0167e6db41acaf50ab710879),
but maybe you're running an older version?

Best,

Thomas


2012/12/15 向浩 

> Environment:
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/admin/
> Django Version: 1.0.4
> Python Version: 2.7.3
> Installed Applications:
> ['django.contrib.auth',
>  'django.contrib.admin',
>  'django.contrib.contenttypes',
>  'django.contrib.sessions',
>  'django.contrib.sites',
>  'mysite.books']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
>  'django.contrib.sessions.middleware.SessionMiddleware',
>  'django.contrib.auth.middleware.AuthenticationMiddleware')
>
>
> Traceback:
> File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py"
> in get_response
>   82. request.path_info)
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
> in resolve
>   181. for pattern in self.urlconf_module.urlpatterns:
> File "/usr/local/lib/python2.7/dist-packages/django/core/urlresolvers.py"
> in _get_urlconf_module
>   205. self._urlconf_module = __import__(self.urlconf_name,
> {}, {}, [''])
> File "/home/xhao/djcode/mysite/../mysite/urls.py" in 
>   16. (r'^admin/', include(admin.site.urls)),
>
> Exception Type: AttributeError at /admin/
> Exception Value: 'AdminSite' object has no attribute 'urls'
>
>  --
> 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/-/SdlHuLExd9YJ.
> 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: trouble with pre_delete signal method

2012-12-18 Thread Thomas Orozco
Hi,


Could you provide the following information?
- What's the relationship between A and B (model code of the field, if
there is, would be great)
- The code of your pre_delete signal handler / the method it calls.

I think you have a ForeignKey field that is required or limited and that is
causing the ValidationError.
Indeed, that line 988 is in the code for ModelChoiceField


Best,

Thomas

2012/12/17 Mike Dewhirst 

> I'm getting a baffling ValidationError.
>
> Request URL:
> http://127.0.0.1:8000/admin/**assembly/item/4/
> Django Version: 1.4.3
> Exception Type: ValidationError
> Exception Value:[u'Select a valid choice. That choice is not one
> of the available choices.']
>
> Exception Location: C:\usr\bin\lib\site-packages\**django\forms\models.py
> in to_python, line 988
> Python Version: 2.7.3
>
> Background ...
>
> I have an Item model which has two one-to-many relationships with other
> types of child records (call them A and B models).
>
> In the Admin, when the user adds an A record, some B records get added
> automatically.
>
> The next A record to get added does much the same but if there are any B
> duplicates it doesn't try to add those but instead just adds its mark to a
> special field in the B record which is already there.
>
> My code - which from embedded print statements appears to be doing exactly
> what I want - will either delete the B record or just remove the mark
> previously added. Eventually when the last A record is deleted the idea is
> that the last B records will go at the same time.
>
> Unfortunately, at the final hurdle we get the ValidationError at line 988
> in to_python.
>
> The local vars nominate ...
>
> self
> value   u'251'
> key 'pk'
>
> ... and that is the pk of the A record which triggers the Item code via a
> pre_delete signal.
>
> Summarising:
>
> - the deletion/mark removal method lives in the Item model
> - the pre-delete signal is detected in the A record
> - the signal connects a stub method in the A record
> - the stub method in the A record calls the Item method
> - the Item method iterates over a filtered queryset of B records and uses
> the passed value (the aforesaid mark from the A record) to decide whether
> to delete the B record or just remove the mark and save it
>
> None of my code appears in the TraceBack so I assume the Admin is trying
> to delete the A record. I've tried both pre_delete and post_delete signals
> in the A record.
>
> Why is it so?
>
> Thanks for any hints
>
> 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+unsubscribe@**
> 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: cached template loader

2012-12-18 Thread Tom Martin
I had the same problem and discovered that I was missing a comma in the 
settings file:

TEMPLATE_LOADERS = (
('django.template.loaders.cached.Loader, (
'django.template.loaders.app_directories.Loader',
'django.template.loaders.filesystem.Loader,
))
)

should have been:

TEMPLATE_LOADERS = (
('django.template.loaders.cached.Loader, (
'django.template.loaders.app_directories.Loader',
'django.template.loaders.filesystem.Loader,
))
)

Pretty subtle issue, I'm not sure how the missing comma causes it.

On Tuesday, July 6, 2010 1:45:27 PM UTC+1, Sævar Öfjörð wrote:
>
> I've also tried passing this through 
> django.shortcuts.render_to_response, but I get the same error. 
> - Sævar 
>
> On Jul 6, 2:41 pm, Sævar Öfjörð  wrote: 
> > Hi, I've been using the default template loaders and it works fine. 
> > Now I want to add the cached template loader, but I get an error. 
> > 
> > I'm using a wrapper function to return responses that include the 
> > request in the context, like this: 
> > 
> > # file helpers/helpers.py 
> > from django.template import RequestContext, loader 
> > from django.http import  HttpResponse 
> > 
> > def return_response(request, dictionary, template, headers={}): 
> > t = loader.get_template(template) 
> > c = RequestContext(request, dictionary) 
> > res = HttpResponse(t.render(c)) 
> > for h, v in headers.iteritems(): 
> > res[h] = v 
> > return res 
> > 
> > The stacktrace: 
> > 
> > Traceback: 
> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
> > django/core/handlers/base.py" in get_response 
> >   106. response = middleware_method(request, 
> > e) 
> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
> > django/core/handlers/base.py" in get_response 
> >   100. response = callback(request, 
> > *callback_args, **callback_kwargs) 
> > File "/home/django/project/project/views.py" in index 
> >   24.   return helpers.return_response(request, d, 'frontpage.html') 
> > File "/home/django/project/project/helpers/helpers.py" in 
> > return_response 
> >   129.  t = loader.get_template(template) 
> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
> > django/template/loader.py" in get_template 
> >   157. template, origin = find_template(template_name) 
> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
> > django/template/loader.py" in find_template 
> >   128. loader = find_template_loader(loader_name) 
> > File "/home/django/project/virtualenv/lib/python2.6/site-packages/ 
> > django/template/loader.py" in find_template_loader 
> >   104. func = TemplateLoader(*args) 
> > 
> > Exception Type: TypeError at / 
> > Exception Value: __init__() takes exactly 2 arguments (1 given) 
> > 
> > Is there some different way I should approach the template loading?

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



Python Django Rockstars- I need you

2012-12-18 Thread Seena Shah
I am currently urgently looking for some amazing Python Django Rockstars to 
join my client in Berlin.

They offer great benefits and a fantastic working environment.

please contact me on seena.s...@darwinrecruitment.com if you want to hear 
more.

-- 
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/-/Se4bAMdA1lYJ.
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: Theming Django with Diazo/XSLT

2012-12-18 Thread 4 The good Life we work
Hallo Ariel,

thank you for letting me know.
I've looked at the site and will give it a try.

Thanks,
Michael

On 12/18/2012 11:03 AM, Ariel Calzada wrote:
> Hi Michael!
>
> Django doesn't use approach of DIAZO/XSLT theming by default. You can
> use diazo in an indepedently way (
> WSGI http://docs.diazo.org/en/latest/quickstart.html ).
>
> Regards,
> ARIEL
>
> 2012/12/18 4 The good Life we work <4thegdl...@googlemail.com
> >
>
> Hallo Derek,
>
> thank for your reply. I was thinking about the templates.
> The admin area is fine for now, though it could be changed through
> diazo too if needed.
>
> Thanks,
> Michael
>
> On Tue 18 Dec 2012 08:28:12 AM CET, Derek wrote:
> > You do not say which part of Django you need to theme.  Assuming its
> > the admin, I suggest you look at Grappelli[1] as they have done
> > extensive work in  theming. You could either provide your own
> CSS and
> > override any templates as needed; or start from scratch but with
> their
> > approach/code as an example.
> >
> > Derek
> >
> > [1] https://django-grappelli.readthedocs.org/en/latest/index.html
> >
> > On Friday, 14 December 2012 23:55:31 UTC+2, 4 The good Life we
> work wrote:
> >
> > Hallo,
> >
> > I'm used to theme Plone with Diazo/ XSLT.
> > 
> > Is there any tutorial for Django?
> >
> > Thanks,
> > Michael
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To post to this group, send email to django-users@googlegroups.com
> .
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>
>
> -- 
> La Salvaje Esperanza
>
> Éramos dioses y nos volvieron esclavos.
> Éramos hijos del sol y nos consolaron
> con medallas de lata.
> Éramos poetas y nos pusieron a recitar
> oraciones pordioseras.
> Éramos felices y nos civilizaron.
> Quién refrescará la memoria de la tribu.
> Quién revivirá nuestros dioses.
> Que la salvaje esperanza siempre sea tuya, querida alma inamansable.
>
> -Gonzalo Arango-
>
>
> -- 
> 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: Theming Django with Diazo/XSLT

2012-12-18 Thread Ariel Calzada
Hi Michael!

Django doesn't use approach of DIAZO/XSLT theming by default. You can use
diazo in an indepedently way ( WSGI
http://docs.diazo.org/en/latest/quickstart.html ).

Regards,
ARIEL

2012/12/18 4 The good Life we work <4thegdl...@googlemail.com>

> Hallo Derek,
>
> thank for your reply. I was thinking about the templates.
> The admin area is fine for now, though it could be changed through
> diazo too if needed.
>
> Thanks,
> Michael
>
> On Tue 18 Dec 2012 08:28:12 AM CET, Derek wrote:
> > You do not say which part of Django you need to theme.  Assuming its
> > the admin, I suggest you look at Grappelli[1] as they have done
> > extensive work in  theming. You could either provide your own CSS and
> > override any templates as needed; or start from scratch but with their
> > approach/code as an example.
> >
> > Derek
> >
> > [1] https://django-grappelli.readthedocs.org/en/latest/index.html
> >
> > On Friday, 14 December 2012 23:55:31 UTC+2, 4 The good Life we work
> wrote:
> >
> > Hallo,
> >
> > I'm used to theme Plone with Diazo/ XSLT.
> > 
> > Is there any tutorial for Django?
> >
> > Thanks,
> > Michael
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
La Salvaje Esperanza

Éramos dioses y nos volvieron esclavos.
Éramos hijos del sol y nos consolaron
con medallas de lata.
Éramos poetas y nos pusieron a recitar
oraciones pordioseras.
Éramos felices y nos civilizaron.
Quién refrescará la memoria de la tribu.
Quién revivirá nuestros dioses.
Que la salvaje esperanza siempre sea tuya, querida alma inamansable.

-Gonzalo Arango-

-- 
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: Theming Django with Diazo/XSLT

2012-12-18 Thread 4 The good Life we work
Hallo Derek,

thank for your reply. I was thinking about the templates.
The admin area is fine for now, though it could be changed through 
diazo too if needed.

Thanks,
Michael

On Tue 18 Dec 2012 08:28:12 AM CET, Derek wrote:
> You do not say which part of Django you need to theme.  Assuming its
> the admin, I suggest you look at Grappelli[1] as they have done
> extensive work in  theming. You could either provide your own CSS and
> override any templates as needed; or start from scratch but with their
> approach/code as an example.
>
> Derek
>
> [1] https://django-grappelli.readthedocs.org/en/latest/index.html
>
> On Friday, 14 December 2012 23:55:31 UTC+2, 4 The good Life we work wrote:
>
> Hallo,
>
> I'm used to theme Plone with Diazo/ XSLT.
> 
> Is there any tutorial for Django?
>
> Thanks,
> Michael
>

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



Re: IntegrityError

2012-12-18 Thread Satinderpal Singh
On Tue, Dec 18, 2012 at 12:25 PM, Sandeep kaur  wrote:
> On Tue, Dec 18, 2012 at 2:48 AM, Satinderpal Singh
>  wrote:
>> I created a search box for searching the information about the client
>> so that this information uses to create the report.
>
> add these lines :
>
>> def search(request):
> 
>>   {% endfor %}
>>
>> i want to get job id to be saved through header view:
>> def header(request):
>job =Job.objects.get(id=request.GET['q'])
>> if request.method=='POST':
>> form = headForm(request.POST)
>> if form.is_valid():
>> cd = form.cleaned_data
>profile = form.save(commit=False)
>profile.job = job
>profile.save()
>form.save()
>> HttpResponseRedirect(reverse('Automation.report.views.result'))
>>
>> But get the following error:
>> IntegrityError at /report/header/
>> (1048, "Column 'job_id' cannot be null")
>>
>> Please anybody tell me where i am wrong?
>>
> Hope this helps you.
Yeah it works! Thanks.

--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

-- 
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: IntegrityError

2012-12-18 Thread Satinderpal Singh
On Tue, Dec 18, 2012 at 11:21 AM, Chris Cogdon  wrote:
> Can you post the code for the model, and the complete exception trace?

class head(models.Model):
job = models.ForeignKey(Job, null=True)
Header_column_1 = models.CharField(max_length=255,blank=True)
Header_column_2 = models.CharField(max_length=255,blank=True)
Footer_column_3 = models.CharField(max_length=255,blank=True)

def __str__(self):
return self.refrence_no

>
> On Monday, December 17, 2012 1:18:54 PM UTC-8, Satinderpal Singh wrote:
>>
>> I created a search box for searching the information about the client
>> so that this information uses to create the report.
>> def search(request):
>> query = request.GET.get('q', '')
>> if query:
>> results = Job.objects.filter(id =
>>
>> query).values('client__client__name','client__client__address_1','clientjob__material__name','suspencejob__field__name','id','job_no','date','site','report_type',)
>> else:
>> results = []
>> return render_to_response("report/search.html", {"results":
>> results,"query": query})
>>
>> I want to save the value of job in the report table to create a report
>> like:
>>   {% for job in results %}
>> Job Id : {{ job.id }}
>> Name:{{job.client__client__name}}
>> Job No. : {{job.job_no}}
>> Site : {{job.site}}
>> Reference Letter No : {{job.Reference_Letter_no}}
>> Letter Date : {{job.Letter_date}}
>> Address : {{job.client__client__address_1}}
>> Material : {{job.clientjob__material__name}}
>> Report
>>   {% endfor %}
>>
>> i want to get job id to be saved through header view:
>> def header(request):
>> if request.method=='POST':
>> form = headForm(request.POST)
>> if form.is_valid():
>> cd = form.cleaned_data
>> form.save()
>> return
>> HttpResponseRedirect(reverse('Automation.report.views.result'))
>>
>> But get the following error:
>> IntegrityError at /report/header/
>> (1048, "Column 'job_id' cannot be null")
>>
>> Please anybody tell me where i am wrong?
>>
>>
>>
>>
>> --
>> Satinderpal Singh
>> http://satindergoraya.blogspot.in/
>> http://satindergoraya91.blogspot.in/
>
> --
> 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/-/8St7erk3yrAJ.
> 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.



--
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

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