Re: Crispy forms and its "coercing to unicode need string or buffer nonetype found"

2016-08-12 Thread RompePC
Ok, I just did again a *unicode(..)* call to a method that before worked 
without it. Sincerely, I just have no idea why now I need to do it.

Solved.

El jueves, 11 de agosto de 2016, 12:58:20 (UTC+2), RompePC escribió:
>
> I was working on an admin panel, and when I try to get to the add/update 
> view of the model, it just throws this error. I've been checking Google for 
> all the morning, but the solutions I've just found aren't the problem I've 
> (no problem with unicode, I check if the related object is None, etc.).
>
> The exception throwed is (line 28):
>
>
> coercing to Unicode: need string or buffer, NoneType found
>
> 18 
> 19 {% if field|is_checkboxselectmultiple %} 
> 20 {% include 'bootstrap3/layout/checkboxselectmultiple.html' %} 
> 21 {% endif %} 
> 22 
> 23 {% if field|is_radioselect %} 
> 24 {% include 'bootstrap3/layout/radioselect.html' %} 
> 25 {% endif %} 
> 26 
> 27 {% if not field|is_checkboxselectmultiple and not field|is_radioselect 
> %} 
> 28 {% if field|is_checkbox and form_show_labels %} 
> 29  
> 30 {% crispy_field field %} 
> 31 {{ field.label|safe }} 
> 32 {% include 'bootstrap3/layout/help_text_and_errors.html' %} 
> 33  
> 34 {% else %} 
> 35  
> 36 {% crispy_field field %} 
> 37 {% include 'bootstrap3/layout/help_text_and_errors.html' %} 
> 38 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8d1df6a3-f941-4df3-a31b-265872ccdd17%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

2016-08-12 Thread ANOOP M.S
any idea why this happens?

On Tuesday, July 8, 2008 at 11:05:27 PM UTC+5:30, Rodrigo Culagovski wrote:
>
> In a production site, all of a sudden while trying to edit the site 
> via the admin interface I get: 
>
> ProgrammingError: (2014, "Commands out of sync; you can't run this 
> command now") 
>
> This is when trying to access the record list: "/admin/core/pagina/" 
> This is only while trying to edit this one specific model ('pagina'), 
> I can edit the others without errors. 
> I dumped the database to my development server, and I get the same 
> error. It was working fine right before importing the DB from the 
> production server, so I'm thinking there's a problem in the actual DB. 
> I ran Optimize, Check and Repair on the DB in MySQL Administrator. No 
> dice. 
> I haven't updated or changed anything on either server. Development's 
> running XP, production Linux. 
>
> Full traceback: 
>
> Traceback (most recent call last): 
>
>   File "C:\django\djtrunk\django\core\servers\basehttp.py", line 277, 
> in run 
> self.result = application(self.environ, self.start_response) 
>
>   File "C:\django\djtrunk\django\core\servers\basehttp.py", line 631, 
> in __call__ 
> return self.application(environ, start_response) 
>
>   File "C:\django\djtrunk\django\core\handlers\wsgi.py", line 205, in 
> __call__ 
> response = self.get_response(request) 
>
>   File "C:\django\djtrunk\django\core\handlers\base.py", line 117, in 
> get_response 
> receivers = dispatcher.send(signal=signals.got_request_exception, 
> request=request) 
>
>   File "C:\django\djtrunk\django\dispatch\dispatcher.py", line 360, in 
> send 
> **named 
>
>   File "C:\django\djtrunk\django\dispatch\robustapply.py", line 47, in 
> robustApply 
> return receiver(*arguments, **named) 
>
>   File "C:\django\djtrunk\django\db\__init__.py", line 73, in 
> _rollback_on_exception 
> transaction.rollback_unless_managed() 
>
>   File "C:\django\djtrunk\django\db\transaction.py", line 149, in 
> rollback_unless_managed 
> connection._rollback() 
>
>   File "C:\django\djtrunk\django\db\backends\mysql\base.py", line 195, 
> in _rollback 
> BaseDatabaseWrapper._rollback(self) 
>
>   File "C:\django\djtrunk\django\db\backends\__init__.py", line 24, in 
> _rollback 
> return self.connection.rollback() 
>
> ProgrammingError: (2014, "Commands out of sync; you can't run this 
> command now") 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6894ba6a-193e-4d29-81db-0cca6f1a9a23%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


ANN: django-admin-tools 0.8.0 released

2016-08-12 Thread David Jean Louis
Hello,

We are happy to announce the availability of the version 0.8.0 of
django-admin-tools:
https://pypi.python.org/pypi/django-admin-tools/0.8.0

Django-admin-tools is a collection of extensions/tools for the default
django administration interface, it includes:
* a full featured and customizable dashboard,
* a customizable menu bar,
* tools to make admin theming easier.

This version fixes some issues and adds support for Django 1.10.

Thanks to all the people who contributed to this release.

The project is hosted on Github:
https://github.com/django-admin-tools/django-admin-tools

Django-admin-tools is generously documented, you can browse the
documentation online here:
https://django-admin-tools.readthedocs.org/

Regards,

-- 
The django-admin-tools team
https://github.com/django-admin-tools/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/57AD9FFE.6000102%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django back button issue after log-out

2016-08-12 Thread Abhijeet Singh
It still does not work. Still "Back" button takes it to last session page

On Monday, December 17, 2012 at 7:37:49 PM UTC+5:30, Ashish Sable wrote:
>
> yup... Got the solution just the bower cache needs to be cleared.
>
> from django.views.decorators.cache import cache_control
>
> @cache_control(no_cache=True, must_revalidate=True, no_store=True)
> def view():
>
> After logout it will render to login page.
>
> On Monday, 17 December 2012 18:39:25 UTC+5:30, ke1g wrote:
>>
>>
>>
>> On Mon, Dec 17, 2012 at 5:14 AM, Ashish Sable  
>> wrote:
>>
>>>
>>> I have written simple registration(login,logout) Django apps.
>>>  when i click on logout and then back button from browser 
>>> it shows me previous page. it should redirect me to login page. please 
>>> help
>>>
>>>
>>  The back button in your browser just shows you cached stuff.  It doesn't 
>> contact the server, so there is nothing Django can do.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/867370b7-50cb-49fa-aa0c-0d571be145d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Parent initialization don't working

2016-08-12 Thread RompePC
An intereseting point is that, even after the *super*, *list_filter* remains 
still setted (which is what I want), but then in the web page it doesn't 
show anywhere (as if you just didn't setted it). Maybe there's some hidden 
*__init__* upside model admin that do some clean?

El jueves, 11 de agosto de 2016, 12:58:20 (UTC+2), RompePC escribió:
>
> I'll say first that I'm using *xadmin*, although it doesn't matter for 
> this problem.
> Python 2.7.3 with Django 1.9.5
>
> The problem is in this piece of code (take it as an example):
>
> class ParentAdmin(object):
>def __init__(self):
>  # Boring stuff
>  self.list_filter = ["name"]
>  # Calling super()
>
> class SonAdmin(ParentAdmin):
> # Boring stuff
>
> If I set up *list_filter* in *SonAdmin*, it shows the filter and all goes 
> well. But, if I set up it instead in *ParentAdmin*, it just doesn't show. 
> And its weird because it works when setting list_display the same way. No 
> errors throwed, and no other part of the code is the problem. I think that 
> Django overrides it in some moment, but that wouldn't make sense. Any ideas?
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/631ba41c-2b1c-4876-8978-5345f0e76875%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django 1.10, Issues with prefix_default_language

2016-08-12 Thread Keith Hackbarth
I'm having two issues with "prefix_default_language" that I was hoping to 
shed some insight on. My URL conf is as follows:

urlpatterns += i18n_patterns(
url(r'^(?P.+-parking)/?$', CityView.as_view()),
prefix_default_language=False
)

Issue #1: Prefixes

If a city that matches my regex ALSO begins with a language, it translates 
that language. For example: /de-moines-parking translates into German. I 
would expect /de-moines-parking to be in english and /de/de-moines-parking 
to be in German.

Issue #2: Stacking

Currently, the il8n_patterns is also allowing language tags to stack. For 
example, /de/fr/it/de-moines-parking is loading a successful page instead 
of a 404.

Any insight? Is this a bug or am I missing something obvious in my regex?

Thanks,

Keith


 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b893cd4f-49bf-4a96-8c94-2a717475d05c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


DoesNotExist on ForeignKey Access

2016-08-12 Thread TheBeardedTemplar
Hey all,

I'm quite stumped with a problem that recently started showing up in my 
code. I have a model called a Widget that can have an associated Blob 
object. When a Widget is deleted, I want to make sure that the Blob 
associated with it isn't used elsewhere, and if it's not, delete it. I do 
that via a postDelete hook, as follows:

def postDeleteWidget(sender, **kwargs):
"""
Delete the associated blob when the widgetis deleted.
"""
widget = kwargs['instance']


#Make sure this blob isn't used elsewhere
if widget.blob is not None and Widget.objects.filter(blob=widget.blob).
count() == 0:
widget.blob.delete()

This come is failing when it first looks up widget.blob in these Django 
files:

File "C:\Python27\Lib\site-packages\django\db\models\fields\related.py", 
line 617, in __get__
  rel_obj = qs.get()
File "C:\Python27\Lib\site-packages\django\db\models\query.py", line 334, in 
get
  self.model._meta.object_name

myproject.apps.blobs.models.DoesNotExist: Blob matching query does not exist
.

Now here's the weird part. If I insert "sleep(1)" after getting the widget, 
the code works fine. It deletes the associated blob as expected. I'm really 
at a loss in terms of how to explain this. I'd appreciate any advice. Even 
printing 'widget.blob' before the if statement usually resolves it. Is this 
some kind of race condition involved in accessing a related key on a 
postDelete hook.

Thanks,
-Keilan

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75b34cd3-a987-473a-a5bd-69346fac4096%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DoesNotExist on ForeignKey Access

2016-08-12 Thread Todor Velichkov
Some more code will be helpful, for example the model structure, how do you 
define the the `ForeignKey`? How do you subscribe for the signal?
You are saying that with sleep(1) the code works fine, is this mean that 
you can reproduce the problem at any time?
However test it without fetching the blob object, this would probably fix 
the problem:

if widget.blob_id is not None and Widget.objects.filter(blob_id=widget.
blob_id).count() == 0:
Blob.objects.filter(id=widget.blob_id).delete()


On Friday, August 12, 2016 at 9:00:58 PM UTC+3, TheBeardedTemplar wrote:
>
> Hey all,
>
> I'm quite stumped with a problem that recently started showing up in my 
> code. I have a model called a Widget that can have an associated Blob 
> object. When a Widget is deleted, I want to make sure that the Blob 
> associated with it isn't used elsewhere, and if it's not, delete it. I do 
> that via a postDelete hook, as follows:
>
> def postDeleteWidget(sender, **kwargs):
> """
> Delete the associated blob when the widgetis deleted.
> """
> widget = kwargs['instance']
>
>
> #Make sure this blob isn't used elsewhere
> if widget.blob is not None and Widget.objects.filter(blob=widget.blob
> ).count() == 0:
> widget.blob.delete()
>
> This come is failing when it first looks up widget.blob in these Django 
> files:
>
> File "C:\Python27\Lib\site-packages\django\db\models\fields\related.py", 
> line 617, in __get__
>   rel_obj = qs.get()
> File "C:\Python27\Lib\site-packages\django\db\models\query.py", line 334, 
> in get
>   self.model._meta.object_name
>
> myproject.apps.blobs.models.DoesNotExist: Blob matching query does not 
> exist.
>
> Now here's the weird part. If I insert "sleep(1)" after getting the 
> widget, the code works fine. It deletes the associated blob as expected. 
> I'm really at a loss in terms of how to explain this. I'd appreciate any 
> advice. Even printing 'widget.blob' before the if statement usually 
> resolves it. Is this some kind of race condition involved in accessing a 
> related key on a postDelete hook.
>
> Thanks,
> -Keilan
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/cc1a144f-d1e6-49a8-8121-2ec7ec8c0af6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Crispy forms and its "coercing to unicode need string or buffer nonetype found"

2016-08-12 Thread Constantine Covtushenko
Hi,

Sounds great.

On Fri, Aug 12, 2016 at 11:12 AM, RompePC  wrote:

> Ok, I just did again a *unicode(..)* call to a method that before worked
> without it. Sincerely, I just have no idea why now I need to do it.
>
> Solved.
>
>
> El jueves, 11 de agosto de 2016, 12:58:20 (UTC+2), RompePC escribió:
>>
>> I was working on an admin panel, and when I try to get to the add/update
>> view of the model, it just throws this error. I've been checking Google for
>> all the morning, but the solutions I've just found aren't the problem I've
>> (no problem with unicode, I check if the related object is None, etc.).
>>
>> The exception throwed is (line 28):
>>
>>
>> coercing to Unicode: need string or buffer, NoneType found
>>
>> 18
>> 19 {% if field|is_checkboxselectmultiple %}
>> 20 {% include 'bootstrap3/layout/checkboxselectmultiple.html' %}
>> 21 {% endif %}
>> 22
>> 23 {% if field|is_radioselect %}
>> 24 {% include 'bootstrap3/layout/radioselect.html' %}
>> 25 {% endif %}
>> 26
>> 27 {% if not field|is_checkboxselectmultiple and not field|is_radioselect
>> %}
>> 28 {% if field|is_checkbox and form_show_labels %}
>> 29 
>> 30 {% crispy_field field %}
>> 31 {{ field.label|safe }}
>> 32 {% include 'bootstrap3/layout/help_text_and_errors.html' %}
>> 33 
>> 34 {% else %}
>> 35 
>> 36 {% crispy_field field %}
>> 37 {% include 'bootstrap3/layout/help_text_and_errors.html' %}
>> 38 
>>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/8d1df6a3-f941-4df3-a31b-265872ccdd17%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boXsTZk%2BQoO9h5XEGiyW%2Bvso%3D9jNtyW2%2BMkZv1s2CSRBsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: ProgrammingError: (2014, "Commands out of sync; you can't run this command now")

2016-08-12 Thread Constantine Covtushenko
Hi Anoop,

I've checked that such kind of errors comes from MySQL server. You can
check detailed explanation here
.
Do you have any procedure run on your server?

On Fri, Aug 12, 2016 at 11:37 AM, ANOOP M.S  wrote:

> any idea why this happens?
>
> On Tuesday, July 8, 2008 at 11:05:27 PM UTC+5:30, Rodrigo Culagovski wrote:
>>
>> In a production site, all of a sudden while trying to edit the site
>> via the admin interface I get:
>>
>> ProgrammingError: (2014, "Commands out of sync; you can't run this
>> command now")
>>
>> This is when trying to access the record list: "/admin/core/pagina/"
>> This is only while trying to edit this one specific model ('pagina'),
>> I can edit the others without errors.
>> I dumped the database to my development server, and I get the same
>> error. It was working fine right before importing the DB from the
>> production server, so I'm thinking there's a problem in the actual DB.
>> I ran Optimize, Check and Repair on the DB in MySQL Administrator. No
>> dice.
>> I haven't updated or changed anything on either server. Development's
>> running XP, production Linux.
>>
>> Full traceback:
>>
>> Traceback (most recent call last):
>>
>>   File "C:\django\djtrunk\django\core\servers\basehttp.py", line 277,
>> in run
>> self.result = application(self.environ, self.start_response)
>>
>>   File "C:\django\djtrunk\django\core\servers\basehttp.py", line 631,
>> in __call__
>> return self.application(environ, start_response)
>>
>>   File "C:\django\djtrunk\django\core\handlers\wsgi.py", line 205, in
>> __call__
>> response = self.get_response(request)
>>
>>   File "C:\django\djtrunk\django\core\handlers\base.py", line 117, in
>> get_response
>> receivers = dispatcher.send(signal=signals.got_request_exception,
>> request=request)
>>
>>   File "C:\django\djtrunk\django\dispatch\dispatcher.py", line 360, in
>> send
>> **named
>>
>>   File "C:\django\djtrunk\django\dispatch\robustapply.py", line 47, in
>> robustApply
>> return receiver(*arguments, **named)
>>
>>   File "C:\django\djtrunk\django\db\__init__.py", line 73, in
>> _rollback_on_exception
>> transaction.rollback_unless_managed()
>>
>>   File "C:\django\djtrunk\django\db\transaction.py", line 149, in
>> rollback_unless_managed
>> connection._rollback()
>>
>>   File "C:\django\djtrunk\django\db\backends\mysql\base.py", line 195,
>> in _rollback
>> BaseDatabaseWrapper._rollback(self)
>>
>>   File "C:\django\djtrunk\django\db\backends\__init__.py", line 24, in
>> _rollback
>> return self.connection.rollback()
>>
>> ProgrammingError: (2014, "Commands out of sync; you can't run this
>> command now")
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/6894ba6a-193e-4d29-81db-0cca6f1a9a23%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boWuHCVRMvCQH6h-Ogv-UUbWFWbYBBhETYPTVQiGGYV7HQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DoesNotExist on ForeignKey Access

2016-08-12 Thread TheBeardedTemplar


On Friday, August 12, 2016 at 1:19:17 PM UTC-6, Todor Velichkov wrote:
>
> Some more code will be helpful, for example the model structure, how do 
> you define the the `ForeignKey`? How do you subscribe for the signal?
> You are saying that with sleep(1) the code works fine, is this mean that 
> you can reproduce the problem at any time?
> However test it without fetching the blob object, this would probably fix 
> the problem:
>
> if widget.blob_id is not None and Widget.objects.filter(blob_id=widget.
> blob_id).count() == 0:
> Blob.objects.filter(id=widget.blob_id).delete()
>
>
Hello Todor,

Your solution worked like a charm. It was fetching the blob object causing 
the failure, thank you very much! For the sake of completion, here is the 
code you asked for:

class Widget(models.Model):
client = models.ForeignKey(Client, related_name="layers")
label = models.TextField()
blob = models.ForeignKey(Blob, blank=True, null=True)
date_created = models.DateTimeField(auto_now_add=True, blank=True, null=
True)

And the connection is made using 
signals.post_delete.connect(postDeleteWidget, sender=Widget).
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ea379e82-a7e5-455e-9018-007af3c7c435%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Parent initialization don't working

2016-08-12 Thread Constantine Covtushenko
Sorry, I did not mention your point about xadmin.
Sorry again.

I've checked its github page. It seems like they do not have documentation
in English.

So may be your problem should be addressed to them?
Did you try that?

Else as for me we should go to xadmin code and check there.

On Fri, Aug 12, 2016 at 2:45 PM, RompePC  wrote:

> An intereseting point is that, even after the *super*, *list_filter* remains
> still setted (which is what I want), but then in the web page it doesn't
> show anywhere (as if you just didn't setted it). Maybe there's some hidden
> *__init__* upside model admin that do some clean?
>
> El jueves, 11 de agosto de 2016, 12:58:20 (UTC+2), RompePC escribió:
>>
>> I'll say first that I'm using *xadmin*, although it doesn't matter for
>> this problem.
>> Python 2.7.3 with Django 1.9.5
>>
>> The problem is in this piece of code (take it as an example):
>>
>> class ParentAdmin(object):
>>def __init__(self):
>>  # Boring stuff
>>  self.list_filter = ["name"]
>>  # Calling super()
>>
>> class SonAdmin(ParentAdmin):
>> # Boring stuff
>>
>> If I set up *list_filter* in *SonAdmin*, it shows the filter and all
>> goes well. But, if I set up it instead in *ParentAdmin*, it just doesn't
>> show. And its weird because it works when setting list_display the same
>> way. No errors throwed, and no other part of the code is the problem. I
>> think that Django overrides it in some moment, but that wouldn't make
>> sense. Any ideas?
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/631ba41c-2b1c-4876-8978-5345f0e76875%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boWhBmDTa1A%2Bxf_%2B9D%3D4w%2B97dzUYGGSFfvgr3QCaKW3sWw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DoesNotExist on ForeignKey Access

2016-08-12 Thread Constantine Covtushenko
HI guis,

I need to mention one point that works well for me.
If you check blob existence with:
  hasattr(widget, 'blob')
then django responds False in the case Blob Does Not exist an True
otherwise.

At the same time DB request is performed but DoesNotExist exception is not
raised.

On Fri, Aug 12, 2016 at 11:10 PM, TheBeardedTemplar <
thebeardedtemp...@gmail.com> wrote:

>
>
> On Friday, August 12, 2016 at 1:19:17 PM UTC-6, Todor Velichkov wrote:
>>
>> Some more code will be helpful, for example the model structure, how do
>> you define the the `ForeignKey`? How do you subscribe for the signal?
>> You are saying that with sleep(1) the code works fine, is this mean that
>> you can reproduce the problem at any time?
>> However test it without fetching the blob object, this would probably fix
>> the problem:
>>
>> if widget.blob_id is not None and Widget.objects.filter(blob_id=widget.
>> blob_id).count() == 0:
>> Blob.objects.filter(id=widget.blob_id).delete()
>>
>>
> Hello Todor,
>
> Your solution worked like a charm. It was fetching the blob object causing
> the failure, thank you very much! For the sake of completion, here is the
> code you asked for:
>
> class Widget(models.Model):
> client = models.ForeignKey(Client, related_name="layers")
> label = models.TextField()
> blob = models.ForeignKey(Blob, blank=True, null=True)
> date_created = models.DateTimeField(auto_now_add=True, blank=True,
> null=True)
>
> And the connection is made using signals.post_delete.connect(postDeleteWidget,
> sender=Widget).
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/ea379e82-a7e5-455e-9018-007af3c7c435%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK52boViBOVKOERr0i_pOyOQix9KAJ%3DmtvowRQRr8ci_-aPZNQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DoesNotExist on ForeignKey Access

2016-08-12 Thread Todor Velichkov
@TheBeardedTemplar, 
I'm happy this solves the problem, but its more like a workaround, I'm 
interested to understand how this raise condition is achieved. ;)
One thing that I was thinking that can cause this raise condition is that 
by default Django emulates CASCADE DELETE behavior on ForeignKeys, which 
means that if you delete a Blob object all its widget will also get 
deleted. This means than when you delete a Blob with more than 1 widget, 
its, your post_delete method will be called for each widget, the first one 
can delete the Blob, and then there will be no Blob object for the rest, 
thus DoesNotExists error will be raised. (I'm not sure if this is what 
really is happening, its just a hypothesis).

@Covtushenko,
yes this is a nice trick. 

On Friday, August 12, 2016 at 11:32:22 PM UTC+3, Constantine Covtushenko 
wrote:
>
> HI guis,
>
> I need to mention one point that works well for me.
> If you check blob existence with:
>   hasattr(widget, 'blob')
> then django responds False in the case Blob Does Not exist an True 
> otherwise.
>
> At the same time DB request is performed but DoesNotExist exception is not 
> raised.
>
> On Fri, Aug 12, 2016 at 11:10 PM, TheBeardedTemplar  > wrote:
>
>>
>>
>> On Friday, August 12, 2016 at 1:19:17 PM UTC-6, Todor Velichkov wrote:
>>>
>>> Some more code will be helpful, for example the model structure, how do 
>>> you define the the `ForeignKey`? How do you subscribe for the signal?
>>> You are saying that with sleep(1) the code works fine, is this mean that 
>>> you can reproduce the problem at any time?
>>> However test it without fetching the blob object, this would probably 
>>> fix the problem:
>>>
>>> if widget.blob_id is not None and Widget.objects.filter(blob_id=widget.
>>> blob_id).count() == 0:
>>> Blob.objects.filter(id=widget.blob_id).delete()
>>>
>>>
>> Hello Todor,
>>
>> Your solution worked like a charm. It was fetching the blob object 
>> causing the failure, thank you very much! For the sake of completion, here 
>> is the code you asked for:
>>
>> class Widget(models.Model):
>> client = models.ForeignKey(Client, related_name="layers")
>> label = models.TextField()
>> blob = models.ForeignKey(Blob, blank=True, null=True)
>> date_created = models.DateTimeField(auto_now_add=True, blank=True, 
>> null=True)
>>
>> And the connection is made using 
>> signals.post_delete.connect(postDeleteWidget, sender=Widget).
>>  
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/ea379e82-a7e5-455e-9018-007af3c7c435%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2b62f639-eb95-4b8e-8ce0-6936281f17ab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How t o create more than one application

2016-08-12 Thread Timothy Steele


down votefavori 


I am studying the Django framework, reading the documentation, but have not 
found references on how to create more than one application on the same 
project, where each application has multiple apps.

can some one help plz

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/90b6d09b-02f3-44f5-a271-cd0765bd1998%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How t o create more than one application

2016-08-12 Thread Timothy Steele


On Saturday, August 13, 2016 at 1:37:10 AM UTC+1, Timothy Steele wrote:
>
>
>
> down votefavori 
> 
>
> I am studying the Django framework, reading the documentation, but have 
> not found references on how to create more than one application on the same 
> project, where each application has multiple apps.
>
> can some one help plz
>
Please i have being able to solve it,  thanks to all  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/db4493cb-e695-4ca1-8d92-f6ac287a4736%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.