Re: Ajuda

2023-05-13 Thread Abrao Roberto
nao consigo criar ambiente virtual no vscode, para iniciar um projecto
django

On Thu, May 11, 2023, 15:42 Michael Edet  wrote:

> What help do you need?
>
> On Thu, 11 May 2023, 14:09 Abrao Roberto, 
> wrote:
>
>> Olá pessoal, sou um programador iniciante e quero migrar para Django pois
>> uso streamlit para desenvolver, mas estou tendo problemas serio com
>> ambiente virtual.
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/935e4976-ad97-46a6-9d42-908a94aab245n%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/935e4976-ad97-46a6-9d42-908a94aab245n%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/prr6B3P3rVU/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACM0XWwznxfFP4KVhW9hqOj4SFHMg3LEPS5dEXHmPi3q-_7GGw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CACM0XWwznxfFP4KVhW9hqOj4SFHMg3LEPS5dEXHmPi3q-_7GGw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAAR-p2jCzn8uwUtLQuiXdiGn1s0OGyYVbDWoNZvNXSgJ5ax2Tw%40mail.gmail.com.


Ajuda

2023-05-11 Thread Abrao Roberto
Olá pessoal, sou um programador iniciante e quero migrar para Django pois 
uso streamlit para desenvolver, mas estou tendo problemas serio com 
ambiente virtual. 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/935e4976-ad97-46a6-9d42-908a94aab245n%40googlegroups.com.


Forbidden (403) - CSRF verification failed. Request aborted.

2022-11-22 Thread Carlos Roberto
Hi everyone!

I use ngrok to make my projects available in django. I'm having trouble 
accessing the admin page. After I enter the username and password I get the 
error 403.

Has anyone had the same problem and could help me?

Regards


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/de5c4738-f540-4596-b1bf-0b0b16aabbf2n%40googlegroups.com.


Re: Install -r 309 traceback

2020-08-05 Thread Roberto Melucci
Thanks for your attention, but, as i say yet, i don't go on internet on my
pc, but i go with my smartphone, download the file, and install offline.
But any whl i don't installed, even wxpython i.e.
Why?
Have you a solution for me?
Thanks more.
Robertomelucci.

Il Mer 5 Ago 2020, 13:46 Arief Zulianto  ha scritto:

> try using:
> pip install "Django==3.0.9"
> its tell pip to install django ver. 3.0.9
>
> On Wednesday, August 5, 2020 at 1:52:48 AM UTC+7 robertome...@gmail.com
> wrote:
>
>> I was unable to install django 3 0 9, with pip install -r
>> Django-3.0.9-py3-none-any.whl
>> ... shows me 11 tracebacks, of which the last is in
>> lib / encodings / cp1252.py, line 15, in decode return
>> codecs.charmap_decode (input, errors, decoding_table)
>> I don't have internet on the pc, and it must download the files to the
>> smart.
>> How can I 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/cdb55b73-1170-41e5-9ce3-2911da0b32fbn%40googlegroups.com
> 
> .
>

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


Install -r 309 traceback

2020-08-04 Thread Roberto Melucci
I was unable to install django 3 0 9, with pip install -r 
Django-3.0.9-py3-none-any.whl
... shows me 11 tracebacks, of which the last is in
lib / encodings / cp1252.py, line 15, in decode return codecs.charmap_decode 
(input, errors, decoding_table)
I don't have internet on the pc, and it must download the files to the smart.
How can I 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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/055f65eb-ae20-44d9-a845-8526cef62371o%40googlegroups.com.


Install -r 309 traceback

2020-08-04 Thread Roberto Melucci
Non sono riuscito ad installare django 3 0 9, con pip install -r 
Django-3.0.9-py3-none-any.whl 
... mi segnala ben 11 traceback, di cui l'ultimo è in
lib/encodings/cp1252.py, line 15, in decode return 
codecs.charmap_decode(input,errors,decoding_table)
Non ho internet sul pc, e deve scaricare i files sullo smart.
Come posso fare?

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0058b99b-3347-4036-9a2d-7eef09afdb65o%40googlegroups.com.


TagCloud Generator

2017-05-08 Thread Roberto
Ciao a tutti,
Sto cercando il modo di creare una TagCloud partendo da un file txt 
contenente parole e i loro rispettivi pesi.
Non riesco a dare una direzione al mio lavoro e ho appena cominciato ad 
utilizzare Django.
Se qualcuno mi desse un canovaccio da seguire sarebbe perfetto!

Grazie a tutti per l'attenzione!

-- 
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/894d86ee-6906-4fbb-8b91-a8e5193d1cd1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Add new record in filtered list in the admin interface

2017-02-26 Thread Roberto Russi
In the Admin interface when I add a new record to a filtered list and 
submits it, I come back in a no longer filtered list unlike when I edit a 
record.

How can I fix this problem?

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


In the admin area Pre-select foreingkey fields for filtered list

2017-02-08 Thread Roberto Russi
In the admin I have a list with a filter on a foreing-key field of model.
In the new record form, when the filter is applied, I wont that foreing-key 
field is pre-compiled with the same value of the filter.

Is there a way?

-- 
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/4507087d-3648-4960-adc2-cd19bf3dfae8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


validation of admin form with inlines

2017-02-04 Thread Roberto Russi
I need to validate a form in the admin area checking if the SUM of 'price' 
field in inlines match whit 'amount' field in the main form.

What is best way?   

-- 
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/da935043-5202-4a5f-aa99-b4b990559ce0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


pre-populate new record foreing key in admin django-suit

2017-02-03 Thread Roberto Russi
I need to pre-populate some fields in the form opened when you press the 
plus button to add a new record for a foreingkey field in the admin 
interface.
I'm using Django-Suit. 

-- 
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/2085e2d4-e360-4fc7-b7bd-1418864bb0fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-30 Thread Roberto Russi
Is just what i pictured. But when form_invalid is called?

Il giorno lunedì 30 gennaio 2017 02:35:54 UTC+1, Melvyn Sopacua ha scritto:
>
> On Sunday 29 January 2017 04:10:20 Roberto Russi wrote:
>
> > I need get data from a form when submit is clicked even if data are
>
> > invalid, inconplete or empty.
>
> > I try to override form_invalid in CreateView but it is never called
>
> > and form_valid, obviously, only if data are valid.
>
> > Why form_invalid is never called?
>
>  
>
> Because the form is blocked by client-side validation: it never gets to 
> the server. If you watch the development console closely, you will see that 
> when you press save, there is no incoming request.
>
>  
>
> Add the following clean method to DemoForm, fill in "bla" for demo_code in 
> the form and you will see form_invalid being called.
>
>  
>
> def clean(self):
> if self.data['demo_code'] != 'valid':
> raise ValidationError('{}: Invalid demo code'.format(
> self.data['demo_code']
> ))
>
> -- 
>
> Melvyn Sopacua
>

-- 
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/71fdcf25-d5ac-46a2-9e40-ce3eb3f3e1e3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-29 Thread Roberto Russi
But fields are required! I need to have a control over form also if 'save' 
button is clicked and required fields are not filled.

Il giorno domenica 29 gennaio 2017 20:26:10 UTC+1, Norberto Bensa ha 
scritto:
>
> Are you telling me the following doesn't work for you? 
>
> class DemoCreateView(CreateView): 
> ... 
> def post(self, request, *args, **kwargs): 
>print(request.POST) 
>return super().post(request, *args, **kwargs) 
> ... 
>
>
> Now, at the console: 
>
>
>  ['A3hHKM6Bs6NjJA996ALAsYPcYR7M3NWkzP4wcd6WUX1CEazC1dAK3aD1n8zl1aUU'], 
> 'demo_desc 
> r': [''], 'demo_code': ['']}> 
>
> ... 
>
> BTW, I had to add "blank=True, null=True" to your models, otherwise 
> the fields are marked as required and the browser does validate that. 
>
> HTH, 
> Norberto 
>
>
> 2017-01-29 15:54 GMT-03:00 Roberto Russi <robrus...@gmail.com 
> >: 
> > 
> > I have tried it but post method is called only if form is valid and not 
> if there are mandatory field not filled. 
> > 
> > 
> > Il giorno domenica 29 gennaio 2017 18:30:50 UTC+1, Norberto Bensa ha 
> scritto: 
> >> 
> >> https://ccbv.co.uk is your friend with class based views. 
> >> 
> >> I'd override post(self, request, *args, **kwargs), in request.POST, 
> you'll have your form's data (before it's validated). 
> >> 
> >> HTH, 
> >> Norberto 
> >> 
> >> 2017-01-29 9:10 GMT-03:00 Roberto Russi <robrus...@gmail.com>: 
> >>> 
> >>> I need get data from a form when submit is clicked even if data are 
> invalid, inconplete or empty. 
> >>> I try to override form_invalid in CreateView but it is never called 
> and form_valid, obviously, only if data are valid. 
> >>> Why form_invalid is never called? 
> >>> 
> >>> I have this test project with django 1.10.5 and python 3.5 
> >>> 
> >>> models.py 
> >>> 
> >>> class Demo(models.Model): 
> >>> demo_descr = models.CharField("Description", 
> >>> max_length=50, 
> >>> ) 
> >>> demo_code = models.CharField("Code", 
> >>> max_length=5, 
> >>> ) 
> >>> 
> >>> def __str__(self): 
> >>> return self.demo_descr 
> >>> 
> >>> class Meta: 
> >>> verbose_name = "Test" 
> >>> verbose_name_plural = "Tests" 
> >>> ordering = ["demo_descr"] 
> >>> 
> >>> views.py 
> >>> 
> >>> class DemoForm(forms.ModelForm): 
> >>> class Meta: 
> >>> model = models.Demo 
> >>> fields = ('demo_descr','demo_code') 
> >>> 
> >>> 
> >>> class DemoCreateView(CreateView): 
> >>> form_class = DemoForm 
> >>> success_url = 'demo' 
> >>> template_name = 'test_form.html' 
> >>> model = models.Demo 
> >>> 
> >>> def form_valid(self, form): 
> >>> print('valid') 
> >>> return CreateView.form_valid(self, form) 
> >>> 
> >>> def form_invalid(self, form): 
> >>> print('invalid') 
> >>> return CreateView.form_invalid(self, form) 
> >>> 
> >>> urls.py 
> >>> 
> >>> url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'), 
> >>> 
> >>> 
> >>> test_form.html 
> >>> 
> >>>  
> >>> {% csrf_token %} 
> >>> {{ form.as_p }} 
> >>>  
> >>>  
> >>> 
> >>> -- 
> >>> 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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%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...@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/1262e431-5210-4707-bea6-0e8d8813c33b%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/59d268d9-269e-4875-a405-bc9c7985e506%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: form_invalid

2017-01-29 Thread Roberto Russi
I have tried it but post method is called only if form is valid and not if 
there are mandatory field not filled. 


Il giorno domenica 29 gennaio 2017 18:30:50 UTC+1, Norberto Bensa ha 
scritto:
>
> https://ccbv.co.uk is your friend with class based views.
>
> I'd override post(self, request, *args, **kwargs), in request.POST, you'll 
> have your form's data (before it's validated). 
>
> HTH,
> Norberto
>
> 2017-01-29 9:10 GMT-03:00 Roberto Russi <robrus...@gmail.com 
> >:
>
>> I need get data from a form when submit is clicked even if data are 
>> invalid, inconplete or empty.
>> I try to override form_invalid in CreateView but it is never called and 
>> form_valid, obviously, only if data are valid.
>> Why form_invalid is never called? 
>>
>> I have this test project with django 1.10.5 and python 3.5
>>
>> models.py
>>
>> class Demo(models.Model):
>> demo_descr = models.CharField("Description",
>> max_length=50, 
>> )
>> demo_code = models.CharField("Code",
>> max_length=5,
>> )
>>
>> def __str__(self):
>> return self.demo_descr
>> 
>> class Meta:
>> verbose_name = "Test"
>> verbose_name_plural = "Tests"
>> ordering = ["demo_descr"]
>>
>> views.py
>>
>> class DemoForm(forms.ModelForm):
>> class Meta:
>> model = models.Demo
>> fields = ('demo_descr','demo_code')
>>
>>
>> class DemoCreateView(CreateView):
>> form_class = DemoForm
>> success_url = 'demo'
>> template_name = 'test_form.html'
>> model = models.Demo
>>
>> def form_valid(self, form):
>> print('valid')
>> return CreateView.form_valid(self, form)
>>
>> def form_invalid(self, form):
>> print('invalid')
>> return CreateView.form_invalid(self, form)
>>
>> urls.py
>>
>> url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'),
>>
>>
>> test_form.html
>>
>> 
>> {% csrf_token %}
>> {{ form.as_p }}
>> 
>> 
>>
>> -- 
>> 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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> 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/1262e431-5210-4707-bea6-0e8d8813c33b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


form_invalid

2017-01-29 Thread Roberto Russi
I need get data from a form when submit is clicked even if data are 
invalid, inconplete or empty.
I try to override form_invalid in CreateView but it is never called and 
form_valid, obviously, only if data are valid.
Why form_invalid is never called? 

I have this test project with django 1.10.5 and python 3.5

models.py

class Demo(models.Model):
demo_descr = models.CharField("Description",
max_length=50, 
)
demo_code = models.CharField("Code",
max_length=5,
)

def __str__(self):
return self.demo_descr

class Meta:
verbose_name = "Test"
verbose_name_plural = "Tests"
ordering = ["demo_descr"]

views.py

class DemoForm(forms.ModelForm):
class Meta:
model = models.Demo
fields = ('demo_descr','demo_code')
   

class DemoCreateView(CreateView):
form_class = DemoForm
success_url = 'demo'
template_name = 'test_form.html'
model = models.Demo

def form_valid(self, form):
print('valid')
return CreateView.form_valid(self, form)

def form_invalid(self, form):
print('invalid')
return CreateView.form_invalid(self, form)

urls.py

url(r'^demo$', views.DemoCreateView.as_view(),  name='demo'),


test_form.html


{% csrf_token %}
{{ form.as_p }}



-- 
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/c4ab5b85-13cc-4569-aa0d-5ef4dd6911a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


inline parent value

2016-12-01 Thread Roberto Russi
hi, I have 3 models:

class Orders(models.Model):
brand = models.ForeignKey(
Brands,
verbose_name = "Brand",
null=True,
blank=True,
related_name="ord_brand"
)
dateord = models.DateField("Date")
numbord = models.CharField("Number",
max_length=20,
unique_for_year="dateord", 
)

class OrderRows(models.Model):
order = models.ForeignKey(
Orders,
verbose_name = "Order",
)
product = models.ForeignKey(
Products,
verbose_name = "Product",
)
price = models.DecimalField("Price",
max_digits = 11,
decimal_places=2,
)

class Products(models.Model):
brand = models.ForeignKey(
Brands,
verbose_name = "Brand",
)
code = models.CharField("Code",
max_length=25, 
)
descr = models.CharField("Description",
max_length=50, 
)

In my admin.py I have a ModelForm for Orders and an Inline for OrderRow.
In the Inline I need filter product queryset for records where 
brand=orders.brand.

How can I do it?

-- 
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/3f1d5cc5-6485-4f90-b626-929dc6d0e353%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Inline master

2016-12-01 Thread Roberto Russi
I have 3 models:

class Products(models.Model):
brand = models.ForeignKey(
Brands,
verbose_name = "Brand",
)
code = models.CharField("Code",
max_length=25, 
)
descr = models.CharField("Description",
max_length=50, 
)

class Orders(models.Model):
brand = models.ForeignKey(
Brands,
verbose_name = "Brand",
null=True,
blank=True,
related_name="ord_brand"
)
ord_date = models.DateField("Date")
ord_numb = models.CharField("Number",
max_length=20,
unique_for_year="ord_date", 
)

class OrderRows(models.Model):
order = models.ForeignKey(
Orders,
verbose_name = "Order",
)
product = models.ForeignKey(
Products,
verbose_name = "Product",
)
price = models.DecimalField("Price",
max_digits = 11,
decimal_places=2,
)

In my Admins.py I have a ModelAdmin for Orders whit a Inline for OrderRows.

How can I filter the product queryset in OrderRows where brand=orders.brand?

-- 
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/f54aaba0-bb94-421a-8902-00c6a9f594dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Graceful Reloading for Schema Changes - UWSGI - Gunicorn?

2015-04-16 Thread Roberto De Ioris

>
>
> Hello Djangonats,
>
> How do you reload Django script changes with UWSGI? I know `touch-reload
> <http://uwsgi-docs.readthedocs.org/en/latest/Options.html#touch-reload>`
> exists with UWSGI however I was looking more into what uwsgi does when the
> schema(s) in the models change? How do you handle database changes without
> affecting or rebooting the server? Rebooting UWSGI does not sound like a
> good idea.
>
> A Load Balancer (HAProxy) ?
>
> *More Questions*
>
> Does something like that exist in Gunicorn?
>
> Regards,
>
> Shapath.
>
>

The topic is huge and there are dozens of approaches, but basically every
WSGI server requires a new (updated) process address space after code
change
(included schema changes if the model is already loaded into memory).

So, even if it may look "extreme", reloading the whole WSGI server is the
only reliable solution (in fact used by everyone).

If you are scared about potential downtimes check this article:

http://uwsgi-docs.readthedocs.org/en/latest/articles/TheArtOfGracefulReloading.html

But take in account that 99% of the times/cases a simple graceful reload
is more than enough.


-- 
Roberto De Ioris
http://unbit.com

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


Re: Problem with uwsgi

2015-02-03 Thread Roberto De Ioris

> Hi all,
>
> We are running our website with nginx and uwsgi at the moment. It is a
> django 1.7.4 application and it has been running perfectly for a couple of
> months. Now however we are getting some errors that I can't really
> explain.
>
> The errors always appear after uwsgi has done a respawn of a process. Then
> we can get 4-5 errors with very strange behavior. Things like "dict has no
> method 'startswith'". They aren't errors in the code because the code will
> run perfectly before and after these errors. We also used to get these
> when
> we deployed a new version of the website and then restarted uwsgi (by
> sending a kill signal to the main process).
>
> Has anyone had the same problems and if so, does anyone know how to remedy
> it? We are getting a lot of false error mails and it's starting to get
> annoying. Also I don't know how our customers are affected when this
> happens, but it's probably not good.
>
> Regards,
>
> Andréas
>


Hi, ensure you are running a stable uWSGI version 1.4.x or 2.x, older
versions have serious bugs. Eventually paste your uWSGI configuration


-- 
Roberto De Ioris
http://unbit.com

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


Re: Flup vs Guicorn vs uWsgi on Nginx

2014-07-30 Thread Roberto De Ioris

> Hi Folks,
>   We are in our initial deployment stage, and have decided to deploy
> django(1.6.X) on Nginx, and trying to decide which WSGI server to use.
>   I am positive all have something to offer and may not be fair just to
> throw out "which one to use", but I was hoping to get some guidance on the
> following items

Unfortunately no-one can give you a satisfing answer, because lot of
things come into play. I will focus on uWSGI and gunicorn as flup is
basically a dead project (afaik)

>
> 0. Handle high concurrent requests

both uWSGI and gunicorn support multiprocessing. As you are using django i
will not suggest you using async approaches (like gevent) even if both
support them.

uWSGI has strong multithreading support too, and gunicorn is working on it
(probably should be ready in the next release). If you are app is not
cpu-bound, multiple threads are a good solution in python (i bet you will
find tons of posts regarding the infamous GIL, but you can ignore them, as
the GIL is released during I/O operations)

In both threads and multiprocessing, do not choose their number using
silly math (like cpu * 2). Start with a low-number (like 4) and constantly
monitor your app to see if you need to raise or decrease them. New-relic
could be a great toy for it.

> 1. Performance / less transnational overhead,

this is nothing related to WSGI servers, your app will be the bottleneck.
Always.

> 2. Compatible with django/Nginx, in a sense easy configuration

both have now pretty decent documentation for newbies, but gunicorn is way
simpler from an architectural point of view, so probably you will find
easier to start with it.
On the other side uWSGI is more sysadmin-oriented so it has dozens of
features for app monitoring and to manage and detect critical conditions.

> 3. Large number of users

with mod_wsgi they are the three most used servers, so i would not waste
time on this point. There is a lot of documentation about all of them. And
remember you can proxy an apache+mod_wsgi in embedded mode behind nginx
too. Lot of users prefer this approach.

Apache can be a good application server.

(disclaimer: i am the uWSGI lead developer)

-- 
Roberto De Ioris
http://unbit.it

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


Re: Django Admin Page not working

2014-02-12 Thread Roberto López López


_Probably_ you will have to execute:

$ python manage.py collectstatic


On 12. feb. 2014 10:19, Puthi SUM wrote:

Hi Developers,

   I am new to Django App Development. My part-1 training is completed 
successfully. But when i go for part-2, my Admin page is not working 
properly. i.e., Admin page is loading with out CSS.



When i am open admin page it showing like above. I am running my 
django in Windows 8.


What Software, i am used is:

Python 3.3, Django 1.6.2 and I use PyCharm 3.0

and please find the attachment. i am attaching my project folder also. 
Please Help me Any one in this group.

--
You received this message because you are subscribed to the Google 
Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to django-users+unsubscr...@googlegroups.com.

To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/860138ae-d915-493d-9643-2148842eb724%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: Mapping SSL certificates to django users

2014-01-13 Thread Roberto De Ioris

> Hi tomaso
>
> Did you maybe found the solution? We have the same issue.
>
> Best regards
> Mitja

Both apache and nginx can set the HTTPS_DN/other_names_as_well variable to
the distinguished name of the x509 peer.

Just add

SSLOptions +StdEnvVars

I use it as a decorator to protect some view:

https://github.com/unbit/uwsgi.it/blob/master/uwsgi_it_api/views.py#L19

this works in mod_wsgi and variables/cgi based proxies like FastCGI,SCGI
or uwsgi

-- 
Roberto De Ioris
http://unbit.it

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


Re: Django storage engine

2013-11-07 Thread Roberto López López

Which is the question?

On 07. nov. 2013 09:15, Harjot Mann wrote:

Is using the InnoDb storage engine as default as per my knowledge in
MySql MyISAM is the default storage engine.



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


Re: supervisor

2013-10-21 Thread Roberto De Ioris

> Hi,
>
> Anyone could share a good process control system software name to use
> with uwsgi ? Apart from supervisor, I couldn't make it work :
> - can't stop it only kill it
> - bug on supervisorctl reload.. Even when using the last version.
>
> Thank you
>


Are you sure you need one ?

uWSGI Emperor is way more capable (in terms of monitoring and management
of bad-behaving apps) and easy to manage (just drop files in a directory)

By the way, if you cannot use distro-included process managers (upstart or
systemd), i find circus a great alternative to suprvisord. I have seen lot
of users happy with 'god' too (it is a ruby app)

-- 
Roberto De Ioris
http://unbit.it

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


Re: Defining new project as a service at nignx

2013-10-15 Thread Roberto López López

Hi Muhammed,

I agree with Javier: a django project is never run. In your case it is
deployed on gunicorn, which reads/interprets your source code. But it's
never started as a service. You can run nginx as a service, though.

Roberto







On 10/15/2013 11:12 AM, Muhammed TÜFEKYAPAN wrote:
> Hello everyone,
>
> Yes I know that but now my problem is our new project doesn't seen on
> services list and so I can't start it.
>
> I use gunicorn.
>
> How can I made it?
>
> On Monday, October 14, 2013 10:03:22 PM UTC+3, Javier Guerra wrote:
>
> On Mon, Oct 14, 2013 at 12:17 PM, Muhammed TÜFEKYAPAN
> <muham...@gmail.com > wrote:
> > I use digitalocean as a server. I upload my django project files
> on my
> > server and start to setup. Made postgresql settings etc but I
> can't define
> > my new project as a new service on nginx. How can I define my
> new projest as
> > a service and make possible to start it as "service blabla start".
> >
> > When I type "service --statıs-all" I can't see my new project now.
>
>
> i think you're mixing two things and missing a third.
>
> 1: AFAIK, nginx doesn't have "services", just serves requests via
> some
> methods, either static files, internal plugins or backend servers.
>
> 2: on most linux distros, the 'service' command manages startup
> scripts; with start/stop commands to run daemons.
>
> 3: nginx doesn't run python applications, you have to run them in an
> app server.  for Django, (and most python frameworks), the best
> option
> is a wsgi server.  One that runs really well with nginx is uWSGI.
> another option is to run gunicorn as an HTTP backend server behind
> nginx.
>
>
> so, which is your deployment strategy?
> (https://docs.djangoproject.com/en/1.6/howto/deployment/
> <https://docs.djangoproject.com/en/1.6/howto/deployment/>)
>
>
> -- 
> Javier
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ef9db670-7a3a-4b84-837a-c9e401840452%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: New to Django

2013-10-15 Thread Roberto López López
>From your link:
https://docs.djangoproject.com/en/1.5/intro/tutorial01/#database-setup





On 10/15/2013 04:07 PM, Mahantesh U wrote:
> yeah ...
> https://docs.djangoproject.com/en/1.5/intro/tutorial01/
>
> And also wanted know how can I set-up mysql with django?
>
> On Tuesday, October 15, 2013 7:31:15 PM UTC+5:30, Lloyd Dube wrote:
>
> You're welcome, Mahantesh :) Did you find the tutorial I mentioned?
>
>
> On Tue, Oct 15, 2013 at 3:56 PM, Mahantesh U
> <mahant.u...@gmail.com > wrote:
>
> Thanks a lot Lloyd Dube  :)
>
>
> On Tuesday, October 15, 2013 5:38:33 PM UTC+5:30, Lloyd Dube
> wrote:
>
> Hi,
>
> Do the tutorial on the official Django website - it will
> show you where else to look when you are done :)
>
>
> On Tue, Oct 15, 2013 at 7:55 AM, Mahantesh U
> <mahant.u...@gmail.com> wrote:
>
> Hi All,
>
>   I am new to Django framework. I worked on Flask
> framework using python. Please share the sites to
> learn Django easily.
>
> Thanks
> Mahantesh
> -- 
> You received this message because you are subscribed
> to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving
> emails from it, send an email to
> django-users...@googlegroups.com.
> To post to this group, send email to
> django...@googlegroups.com.
>
> Visit this group at
> http://groups.google.com/group/django-users
> <http://groups.google.com/group/django-users>.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/78b41661-9ac0-4433-bb16-fd8ea7b8ccd2%40googlegroups.com
> 
> <https://groups.google.com/d/msgid/django-users/78b41661-9ac0-4433-bb16-fd8ea7b8ccd2%40googlegroups.com>.
> For more options, visit
> https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
> -- 
> Regards,
> Sithu Lloyd Dube
>
> -- 
> You received this message because you are subscribed to the
> Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from
> it, send an email to django-users...@googlegroups.com
> .
> To post to this group, send email to
> django...@googlegroups.com .
> Visit this group at
> http://groups.google.com/group/django-users
> <http://groups.google.com/group/django-users>.
> To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/ceaab487-fd63-4fc0-bfb1-b37b765fa577%40googlegroups.com
> 
> <https://groups.google.com/d/msgid/django-users/ceaab487-fd63-4fc0-bfb1-b37b765fa577%40googlegroups.com>.
>
>
> For more options, visit
> https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>
>
> -- 
> Regards,
> Sithu Lloyd Dube
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/fc21b86e-6a92-4c96-b376-0633d75b32e2%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: readonly_fields depending on request

2013-10-15 Thread Roberto López López

Hi Timothy, thanks for your advice.

I'm sorry, I've been quite busy lately on other stuff so I had to leave
this apart. You are right, maybe I am overcomplicating things. I have
simplified my code to:

def get_readonly_fields(self, request, obj=None):
if not request.user.groups.filter(name__exact='administration'):
return ('is_featured', )
return ()

That should make the "featured" checkbox read only for those users not
in the administration group. But it doesn't, when the flow reaches the
line /return ('is_featured', )/, the user can check/uncheck the box in
the admin interface. Do you see any flaw here? Thanks again!

Roberto






On 10/10/2013 04:52 PM, Timothy W. Cook wrote:
> On Thu, Oct 10, 2013 at 10:04 AM, Roberto López López
> <roberto.lo...@uni.no <mailto:roberto.lo...@uni.no>> wrote:
>
> This is, for example, my code overriding get_readonly_fields():
>
> def get_readonly_fields(self, request, obj=None):
> readonly = super(NewsAdmin,
> self).get_readonly_fields(request, obj)
> if request.user.groups.filter(name__exact='administration') or
> request.user.is_superuser:
> return readonly
> else:
> import itertools
> return itertools.chain(readonly, ('is_featured',))
>
>
>
> I do not understand your logic as it compares to your description of
> the problem. 
>
> For your described problem:
> If the user is_superuser then you shouldn't set read_only at all.
>
> If a user is in a specific set of users then set read_only= ['field1',
> 'field2',] as appropriate. 
>
> It is a pretty simple problem it looks like you are making it far too
> complex. 
>
>
>
>
>  
>
>
>
>  
>
>
> On 10/10/2013 02:45 PM, Roberto López López wrote:
> > Hi,
> >
> > In my project I make use of django-admin. I need to have different
> > readonly_fields depending on the user is connected, thus
> administrators
> > will be able to modify all fields, and other users less fields.
> Which
> > method do I have to override? I have already tried
> > ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But
> no success.
> >
> > Any other suggestions?
> >
> > Thanks!
> >
> > Roberto
> >
> >
>
>
> --
>
> Roberto López López
> System Developer
> Parallab, Uni Computing
> +47 55584091
>
> --
> 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
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5256A5E2.9020505%40uni.no.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> -- 
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> Timothy Cook, MSc   +55 21 94711995
> MLHIM http://www.mlhim.org
> Like Us on FB: https://www.facebook.com/mlhim2
> Circle us on G+: http://goo.gl/44EV5
> Google Scholar: http://goo.gl/MMZ1o
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3U69QzDSbc0qyJ_zbgA3BYHCi5zK3%3DaAra-saAq%2Bvj3EA%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: readonly_fields depending on request

2013-10-10 Thread Roberto López López
Hi,

It was something like that:

def get_form(self, request, obj=None, **kwargs):
if not request.user.groups.filter(name__exact='administration')
and not request.user.is_superuser:
import itertools
self.readonly_fields = itertools.chain(self.readonly_fields,
('is_featured', ))
return super(NewsAdmin, self).get_form(request, obj, **kwargs)

Now I see that this was slightly different than what I did with
get_readonly_fields...

On 10/10/2013 03:00 PM, Timothy W. Cook wrote:
> Can you post the code you tried with get_form()?  It should be the
> solution.
>
>
>
> On Thu, Oct 10, 2013 at 9:45 AM, Roberto López López
> <roberto.lo...@uni.no <mailto:roberto.lo...@uni.no>> wrote:
>
> Hi,
>
> In my project I make use of django-admin. I need to have different
> readonly_fields depending on the user is connected, thus
> administrators
> will be able to modify all fields, and other users less fields. Which
> method do I have to override? I have already tried
> ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But no
> success.
>
> Any other suggestions?
>
> Thanks!
>
> Roberto
>
>
> --
> 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
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/5256A163.3000907%40uni.no.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> -- 
> MLHIM VIP Signup: http://goo.gl/22B0U
> 
> Timothy Cook, MSc   +55 21 94711995
> MLHIM http://www.mlhim.org
> Like Us on FB: https://www.facebook.com/mlhim2
> Circle us on G+: http://goo.gl/44EV5
> Google Scholar: http://goo.gl/MMZ1o
> LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CA%2B%3DOU3V6vOGGaG7_M9xmEPY232%3DpVXqMKSrxH-hMbCOwDo2Axg%40mail.gmail.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: readonly_fields depending on request

2013-10-10 Thread Roberto López López
This is, for example, my code overriding get_readonly_fields():

def get_readonly_fields(self, request, obj=None):
readonly = super(NewsAdmin, self).get_readonly_fields(request, obj)
if request.user.groups.filter(name__exact='administration') or
request.user.is_superuser:
return readonly
else:
import itertools
return itertools.chain(readonly, ('is_featured',))



On 10/10/2013 02:45 PM, Roberto López López wrote:
> Hi,
>
> In my project I make use of django-admin. I need to have different
> readonly_fields depending on the user is connected, thus administrators
> will be able to modify all fields, and other users less fields. Which
> method do I have to override? I have already tried
> ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But no success.
>
> Any other suggestions?
>
> Thanks!
>
> Roberto
>
>


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


readonly_fields depending on request

2013-10-10 Thread Roberto López López
Hi,

In my project I make use of django-admin. I need to have different
readonly_fields depending on the user is connected, thus administrators
will be able to modify all fields, and other users less fields. Which
method do I have to override? I have already tried
ModelAdmin.get_readonly_fields() and ModelAdmin.get_form(). But no success.

Any other suggestions?

Thanks!

Roberto


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


Re: proper way to override text plugin widget

2013-10-07 Thread Roberto López López
wrong list, sorry :-(


On 10/07/2013 11:23 AM, Roberto López López wrote:
> Hi,
>
> The users of my project prefer ckeditor, so I am wondering how to use it
> for cms.plugins.text . I am already making use of django-ckeditor in
> other parts of the application. Can anyone enlighten me please?
>
> Thanks,
>
> Roberto
>
>


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


proper way to override text plugin widget

2013-10-07 Thread Roberto López López

Hi,

The users of my project prefer ckeditor, so I am wondering how to use it
for cms.plugins.text . I am already making use of django-ckeditor in
other parts of the application. Can anyone enlighten me please?

Thanks,

Roberto


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


Re: Django Pagination

2013-10-03 Thread Roberto López López
On 10/03/2013 04:13 PM, Roberto López López wrote:
> *return HttpResponse(json.dumps([players]) ,
> content_type='application/json')*
better without the square brackets

*return HttpResponse(json.dumps(players) ,
content_type='application/json')*

-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: Django Pagination

2013-10-03 Thread Roberto López López
Try this (I have not tried the code myself, but I think that it should
work):

*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)
page = request.GET.get('page')
try:
players = paginator.page(page)
except PageNotAnInteger:
players = paginator.page(1)
except EmptyPage:
players = paginator.page(paginator.num_pages)
*
*return HttpResponse(json.dumps([players]) ,
content_type='application/json')*



On 10/03/2013 04:07 PM, Hélio Miranda wrote:
> Already got it, I did so:
> *queryset = Player.objects.filter(name=namepost)*
> *paginator = Paginator(queryset, 2)*
> *return HttpResponse(json.dumps([item.get_json() for item in
> paginator.object_list]) , content_type='application/json')*
>
> But I return all the records ... I should not return only 2?
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: Django Pagination

2013-10-03 Thread Roberto López López
Better to say:

*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)
page = request.GET.get('page')
try:
players = paginator.page(page)
except PageNotAnInteger:
players = paginator.page(1)
except EmptyPage:
players = paginator.page(paginator.num_pages)
*
*return HttpResponse(json.dumps(players) ,
content_type='application/json')*


On 10/03/2013 04:07 PM, Hélio Miranda wrote:
> Already got it, I did so:
> *queryset = Player.objects.filter(name=namepost)*
> *paginator = Paginator(queryset, 2)*
> *return HttpResponse(json.dumps([item.get_json() for item in
> paginator.object_list]) , content_type='application/json')*
>
> But I return all the records ... I should not return only 2?
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: model inheritance

2013-10-02 Thread Roberto López López

Is there maybe a way to set the cmsplugin_news.News.Meta.abstract option
to True? In order to prevent accessing the parent model to fetch the
inherited data.



On 10/02/2013 03:45 PM, Leonardo Giordani wrote:
> Are you sure your DB has been synced after putting the
> ForeignKey(News) in your Department model?
> Can you post somewhere the following models: News, OldNews, Department?
>
> Regards,
>
> Leo
>
> Leonardo Giordani
> Author of The Digital Cat <http://lgiordani.github.com>
> My profile on About.me <http://about.me/leonardo.giordani> - My GitHub
> page <https://github.com/lgiordani> - My Coderwall profile
> <https://coderwall.com/lgiordani>
>
>
> 2013/10/2 Roberto López López <roberto.lo...@uni.no
> <mailto:roberto.lo...@uni.no>>
>
> Hi,
>
> I am extending a 3rd party model in my application, using
> multi-table inheritance. I can create an instance and modify it,
> but when I try to list the created objects at
> http://localhost:8000/en/admin/news/news/ , I am getting a nice
> exception:
>
> Traceback:
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   140. response = response.render()
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in render
>   105. self.content = self.rendered_content
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in rendered_content
>   82. content = template.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   140. return self._render(context)
> File
>     
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
>     File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74.     return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   63. result = block.nodelist.render(context)
> File
>

Re: model inheritance

2013-10-02 Thread Roberto López López

Hi Leonardo, thanks for your answer.

Yes, it has been synced.

The model itself is a little bit bigger, as you can notice from the code
https://dpaste.de/c3Rg I am using as well the News model from
https://github.com/wildfish/cmsplugin_news/blob/master/cmsplugin_news/models.py

Regards,

Roberto





On 10/02/2013 03:45 PM, Leonardo Giordani wrote:
> Are you sure your DB has been synced after putting the
> ForeignKey(News) in your Department model?
> Can you post somewhere the following models: News, OldNews, Department?
>
> Regards,
>
> Leo
>
> Leonardo Giordani
> Author of The Digital Cat <http://lgiordani.github.com>
> My profile on About.me <http://about.me/leonardo.giordani> - My GitHub
> page <https://github.com/lgiordani> - My Coderwall profile
> <https://coderwall.com/lgiordani>
>
>
> 2013/10/2 Roberto López López <roberto.lo...@uni.no
> <mailto:roberto.lo...@uni.no>>
>
> Hi,
>
> I am extending a 3rd party model in my application, using
> multi-table inheritance. I can create an instance and modify it,
> but when I try to list the created objects at
> http://localhost:8000/en/admin/news/news/ , I am getting a nice
> exception:
>
> Traceback:
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
> in get_response
>   140. response = response.render()
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in render
>   105. self.content = self.rendered_content
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
> in rendered_content
>   82. content = template.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   140. return self._render(context)
> File
>     
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
>     File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74.     return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
> in render
>   124. return compiled_parent._render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in _render
>   134. return self.nodelist.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
> in render
>   830. bit = self.render_node(node, context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
> in render_node
>   74. return node.render(context)
> File
> 
> "/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py&

model inheritance

2013-10-02 Thread Roberto López López
Hi,

I am extending a 3rd party model in my application, using multi-table
inheritance. I can create an instance and modify it, but when I try to
list the created objects at http://localhost:8000/en/admin/news/news/ ,
I am getting a nice exception:

Traceback:
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
in get_response
  140. response = response.render()
File
    
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
in render
  105. self.content = self.rendered_content
    File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/response.py"
in rendered_content
  82. content = template.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  140. return self._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  124. return compiled_parent._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
    in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  124. return compiled_parent._render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in _render
  134. return self.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  63. result = block.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/loader_tags.py"
in render
  63. result = block.nodelist.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  830. bit = self.render_node(node, context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/debug.py"
in render_node
  74. return node.render(context)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/template/base.py"
in render
  1185. _dict = func(*resolved_args,
**resolved_kwargs)
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
in result_list
  286. 'results': list(results(cl))}
File

"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/templatetags/admin_list.py"
in results
  264. yield ResultList(None, item

KeyError: Key 'slug' not found in Form

2013-09-28 Thread Roberto López López

Hi,

I am trying to translate my model using django-modeltranslation and the
SlugField is giving me a lot of trouble. I have successfully registered
the fields for translation, as you can see in the db table description:

| Table "public.news_news"
Column|   Type   |   Modifiers  
  
--+--+
 id   | integer  | not null default 
nextval('news_news_id_seq'::regclass)
 title| character varying(255)   | not null
 title_en | character varying(255)   | 
 title_nb | character varying(255)   | 
 slug | character varying(50)| not null
 slug_en  | character varying(50)| 
 slug_nb  | character varying(50)||

But when I try to add a new News item, I am getting the following error:

|Traceback: File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/core/handlers/base.py"
 in get_response
  115. response = callback(request, *callback_args, 
**callback_kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
 in wrapper
  372. return self.admin_site.admin_view(view)(*args, **kwargs) 
File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/utils/decorators.py"
 in _wrapped_view
  91. response = view_func(request, *args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/views/decorators/cache.py"
 in _wrapped_view_func
  89. response = view_func(request, *args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/sites.py"
 in inner
  202.     return view(request, *args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/utils/decorators.py"
 in _wrapper
  25. return bound_func(*args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/utils/decorators.py"
 in _wrapped_view
  91.     response = view_func(request, *args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/utils/decorators.py"
 in bound_func
  21. return func(self, *args2, **kwargs2) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/db/transaction.py"
 in inner
  223. return func(*args, **kwargs) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/options.py"
 in add_view
  1036. model_admin=self) File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/contrib/admin/helpers.py"
 in __init__
  35. } for field_name, dependencies in prepopulated_fields.items()] 
File 
"/home/roberto/.virtualenvs/ve_news/local/lib/python2.7/site-packages/django/forms/forms.py"
 in __getitem__
  111. raise KeyError('Key %r not found in Form' % name)

Exception Type: KeyError at /en/admin/news/news/add/ Exception Value: u"Key 
'slug' not found in Form"|

My admin.py :

|from cmsplugin_news.admin import NewsAdmin as OldNewsAdmin

class NewsAdmin(OldNewsAdmin, TranslationAdmin,):
fields = ('title', 'slug')
form = NewNewsForm|

models.py:

|class News(models.Model):
title = models.CharField(_('Title'), max_length=255)
slug = models.SlugField(
_('Slug'), unique_for_date='pub_date',
)|

and forms.py:

|class NewNewsForm(forms.ModelForm):
class Meta:
model = News
fields = ('title', 'slug', )|

As well, this is my translation.py where I declare the fields that
should be translated by django-modeltranslation. I suppose anyhow that
the error is not here, as the fields are already translated in db:

|class NewsTranslationOptions(TranslationOptions):
fields = ('title', 'slug', 'excerpt', 'content')

translator.register(News, NewsTranslationOptions)|

Any help please? I am really stuck! Thanks!

Roberto

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


django admin: integrate django-modeltranslation + django-ckeditor into 3rd party module

2013-09-26 Thread Roberto López López

Hi,

I want to integrate django-modeltranslation into the cmsplugin_news
package. I mean, register some fields in the News class to have a
translation in the DB for each of the settings.LANGUAGES defined.


class NewNewsForm(forms.ModelForm):
class Meta:
model = News
fields = ('title', 'slug', 'excerpt', 'content',
'is_published', 'pub_date')
widgets = {
'content': CKEditorWidget(),
'excerpt': CKEditorWidget(),
}

class NewNewsAdmin(TranslationAdmin):
form = NewNewsForm

class Media:
js = (
   
'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
   
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js',
'modeltranslation/js/tabbed_translation_fields.js',
)
css = {
'screen':
('modeltranslation/css/tabbed_translation_fields.css',),
}

admin.site.register(News, NewsAdmin)


This works ok, if we just take into account django-modeltranslation. But
the django-ckeditor widget is not loading. Using firebug I have seen
that some static files are not loaded, so I tried loading them manually
by modifying the Media class. Anyhow the editor continues not working:

class Media:
js = (
   
'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js',
   
'http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jquery-ui.min.js',
'modeltranslation/js/tabbed_translation_fields.js',
'ckeditor/ckeditor/ckeditor.js',
'ckeditor/ckeditor/config.js?t=D26D',
'ckeditor/ckeditor/styles.js?t=D26D',
)
css = {
'all': [cms_static_url(path) for path in (
'css/rte.css',
'css/pages.css',
'css/change_form.css',
'css/jquery.dialog.css',
'css/plugin_editor.css',
)],
'screen':
('modeltranslation/css/tabbed_translation_fields.css',),
}

Does anyone have any idea about how to make the editor work? Thank you
very much!

Regards,

Roberto

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


Re: Recommended dev environment for a Django project deployed to Linode

2013-09-25 Thread Roberto López López

Check virtualenvwrapper

http://virtualenvwrapper.readthedocs.org/en/latest/



On 09/25/2013 08:06 PM, Jorge Arevalo wrote:
> Fine. I don't think my boss is going to pay for PyCharm license, so
> I'll probably go for Eclipse now (I don't really like it too much, but
> if works, it's ok for me)
>
> About virtualenv, is there any method to provide something like a
> script to create a virtualenv, install the needed software and have a
> working environment in a few commands? Something like "vagrantfile for
> virtualenv" http://docs.vagrantup.com/v2/vagrantfile/index.html
>
> Again, many thanks for your useful insights
>
> On Tuesday, September 17, 2013 4:29:14 PM UTC+2, Vernon D. Cole wrote:
>
> Answering the other half of your question:  The choice of IDE is
> not nearly as important as its ease of integration with your
> dvcs.  If you are already familiar with a good one, don't change.
>
> On my present project, my boss and I are both using PyCharm, and
> my other co-worker is using Eclipse, since he is more comfortable
> (and therefore, more productive) with it. Both IDE's have good
> integration with git (my least favourite dvcs, but the boss's
> choice) and our sharing is done using a group private repository
> on github.  This is on Ubuntu Linux, it all works well.   In the
> evening hours, I use PyCharm on Windows 7 to contribute to an open
> source project hosted on bitbucket using mercurial. Both projects
> end up being tested on the same Linode.
>
> Yes, use virtualenv.  I also made the mistake of thinking of it as
> a virtual computer.  It is not.  It is only a method of separating
> Python library directories so that you can experiment with
> different configurations easily.  It does not slow anything down,
> and actually makes installation of packages easier.  Use
> virtualenvwrapper to make switching environments easy.  PyCharm
> also supports virtual environments as well as django projects. It
> is commercial, and suffers from a few Java idiosyncrasies, but the
> boss paid for the license ;-) so I don't mind.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re: m2m_changed signal not caught

2013-09-17 Thread Roberto López López

Thanks for your advice, but that dint't solve the issue :-/

@receiver(m2m_changed, sender=News.department.through)



On 09/17/2013 05:02 PM, John DeRosa wrote:
> From memory, I _think_ this catches the signal from the Department
> model, not the News model. To catch it when you edit the relationship
> from a *News* model form, you need to hook it up
> ("sender=News.department.through"). 
>
> On Sep 17, 2013, at 3:59 AM, Roberto López López <roberto.lo...@uni.no
> <mailto:roberto.lo...@uni.no>> wrote:
>
>>
>> Hi,
>>
>> I need to use the m2m_changed signal to assign permissions over an
>> object. But somehow, I cannot make it work.
>>
>> To summarise, my models.py is as follows:
>>
>> from cmsplugin_news.models import News
>> from django.contrib.auth.models import Group
>> from django.db import models
>> from guardian.shortcuts import assign_perm, remove_perm
>>
>>
>> class Department(models.Model):
>> news = models.ManyToManyField(
>> News, blank=True, related_name='departments'
>> )
>> write_group = models.ForeignKey(Group, blank=True)
>>
>>
>> @receiver(m2m_changed, sender=Department.news.through)
>> def _m2m_changed_news_departments(sender, instance, action,
>> reverse, model, pk_set, **kwargs):
>> if action == "pre_add":
>> for pk in pk_set:
>> d = Department.objects.get(pk__exact=pk)
>> assign_perm('cmsplugin_news.change_news',
>> d.write_group, instance)
>> assign_perm('cmsplugin_news.delete_news',
>> d.write_group, instance)
>> elif action == "pre_remove":
>> for pk in pk_set:
>> d = Department.objects.get(pk__exact=pk)
>> remove_perm('cmsplugin_news.change_news',
>> d.write_group, instance)
>> remove_perm('cmsplugin_news.delete_news',
>> d.write_group, instance)
>>
>>
>> The point is that the signal is never caught. I am editing the m2m
>> relation from the admin interface (as an inline in cmsplugin_news).
>> When I add/delete a department from the formset, the signal is never
>> caught by my method.
>>
>> Any help here? Thank you very much.
>>
>> Roberto
>>
>>
>>
>> -- 
>> 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
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


m2m_changed signal not caught

2013-09-17 Thread Roberto López López

Hi,

I need to use the m2m_changed signal to assign permissions over an
object. But somehow, I cannot make it work.

To summarise, my models.py is as follows:

from cmsplugin_news.models import News
from django.contrib.auth.models import Group
from django.db import models
from guardian.shortcuts import assign_perm, remove_perm


class Department(models.Model):
news = models.ManyToManyField(
News, blank=True, related_name='departments'
)
write_group = models.ForeignKey(Group, blank=True)


@receiver(m2m_changed, sender=Department.news.through)
def _m2m_changed_news_departments(sender, instance, action, reverse,
model, pk_set, **kwargs):
if action == "pre_add":
for pk in pk_set:
d = Department.objects.get(pk__exact=pk)
assign_perm('cmsplugin_news.change_news', d.write_group,
instance)
assign_perm('cmsplugin_news.delete_news', d.write_group,
instance)
elif action == "pre_remove":
for pk in pk_set:
d = Department.objects.get(pk__exact=pk)
remove_perm('cmsplugin_news.change_news', d.write_group,
instance)
remove_perm('cmsplugin_news.delete_news', d.write_group,
instance)


The point is that the signal is never caught. I am editing the m2m
relation from the admin interface (as an inline in cmsplugin_news). When
I add/delete a department from the formset, the signal is never caught
by my method.

Any help here? Thank you very much.

Roberto


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


Re: New field in django

2013-09-08 Thread Roberto López López
You have to fake the migration.


On 09/08/2013 09:12 PM, Harjot Mann wrote:
> I am trying to add a new field to model class in django using south
> but when I am running ./manage.py migrate app, I am getting this error
> http://202.164.53.122/~harjotmann/southerror
>


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Re:

2013-08-21 Thread Roberto López López
I got it as well.



On 08/21/2013 07:50 PM, Mike Doroshenko II wrote:
> How/Why am I getting this? Has anyone else received this?
>
> To: django-users+unsubscr...@googlegroups.com
> On 08/21/2013 02:44 AM, Shahmi Junoh wrote:
>> Hi,
>>
>> I would like to unsubscribe from getting the updates.
>>
>> Thanks in advance.
>>
>> Regards,
>> Shahmi
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> Mike Doroshenko, Junior Sys Admin
> TecKnoQuest Inc.
> mi...@tecknoquest.com
> www.tecknoquest.com
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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


Creating libraries that use django ORM and they use each other.

2013-07-29 Thread Roberto Bouza
Hello,

I'm building a set of common libraries and a few other specific libraries. 
As of right now the common library works great as an independent library 
that can be used by applications.

The problem I'm having now is that I'm building a new library that will use 
the common library. This new library needs to load its settings and 
configure them but the common library
already did that for its own settings. A call to configure again triggers 
an already configured error. 

So a nice thing will be to append the new settings to the ones already 
configured and trigger a reload. Is this possible or feasible? are there 
any other options?

Thank you.

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




Re: working with images in django

2013-07-28 Thread Roberto López López

I use https://pypi.python.org/pypi/django-ckeditor/4.0.2 and I'm quite
happy. There's not too much else to code than what's explained there.




On 07/28/2013 04:21 PM, Robert Brown wrote:
> Hello, can anyone suggest where I might find some of example of
> working with images in django.  I want to store them and pull them
> into text documents, about one every couple of paragraphs.  I am
> finding a lot of posts on this site about the img class but most of
> them seem to address very specific problems.  I am looking more for a
> beginners how to do it discussion or tutorial.
>
> Thanks,
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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




Re: flatpages-tinymce

2013-07-28 Thread Roberto López López

Your message is quite confusing and difficult to understand, I have to
say. What are you asking for? To show tinymce within your change_form or
within the admin app? What do you mean by "flat pages"? Which error are
you getting?



On 07/28/2013 08:35 AM, Karl Arunachal wrote:
> Hello,
> I am trying to use tinymce in the flat pages. But i just can't show it
> up in my admin. Please help me out where am going wrong.
>
> The javascript file is in:
>
> C:\Users\Kakar\web\cms\static\js\tinymce\tinymce.min.js
>
> urls.py:
>
> |(r'^tiny_mce/(?P.*)$','django.views.static.serve',{'document_root':'C:/Users/Kakar/web/cms/static/js/tinymce'}),
>
> |In my templates dir i have another admin folder, which have the
> change_form.html, and right after {{ media }}:
>
> |
> 
> tinyMCE.init({
> mode: "textareas",
> theme: "simple"
> });
> |
> Please help me out. Thank you.
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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




Re: flatpages-tinymce

2013-07-28 Thread Roberto López López
On 07/28/2013 08:35 AM, Karl Arunachal wrote:
> ||


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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




Re: Error.

2013-07-27 Thread Roberto López López
Well, I suppose you are running that locally or have access to the
server. So show the logs.



On 07/27/2013 01:40 PM, Nigel Legg wrote:
>
> I have provided all the information I have. That's all there is on the
> screen in the browser. There is no trace.
>
> On 27 Jul 2013 12:26, "Roberto López López" <roberto.lo...@uni.no
> <mailto:roberto.lo...@uni.no>> wrote:
>
>
> Could be. But if you don't provide more information (i.e. detailed
> information about how you get that error, error stacktrace, logs), you
> won't get an answer.
>
>
> On 07/27/2013 01:21 PM, Nigel Legg wrote:
> > I've just set up a new view / url etc, which has quite a bit of
> > processing behind it.  When I click on the link for it, I get the
> > "Connecting" message for a few minutes, and then just "A server
> error
> > has occurred. Please contact the administrator." appears.  Is this a
> > time out message?
> > Regards,
> > Nigel Legg
> > 07914 740972 <tel:07914%20740972>
> > http://www.trevanianlegg.co.uk
> > http://twitter.com/nigellegg
> > http://uk.linkedin.com/in/nigellegg
> >
> > --
> > 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
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> > To post to this group, send email to
> django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
> > Visit this group at http://groups.google.com/group/django-users.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
> --
>
> Roberto López López
> System Developer
> Parallab, Uni Computing
> +47 55584091 <tel:%2B47%2055584091>
>
> --
> 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
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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




Re: Error.

2013-07-27 Thread Roberto López López

Could be. But if you don't provide more information (i.e. detailed
information about how you get that error, error stacktrace, logs), you
won't get an answer.


On 07/27/2013 01:21 PM, Nigel Legg wrote:
> I've just set up a new view / url etc, which has quite a bit of
> processing behind it.  When I click on the link for it, I get the
> "Connecting" message for a few minutes, and then just "A server error
> has occurred. Please contact the administrator." appears.  Is this a
> time out message?
> Regards,
> Nigel Legg
> 07914 740972
> http://www.trevanianlegg.co.uk
> http://twitter.com/nigellegg
> http://uk.linkedin.com/in/nigellegg
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

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




Abstract models instrospection

2013-07-08 Thread Roberto Bouza
Hello,

Hope someone can explain to me what is happening here?

I have this models:

*class InfrastructureBaseModel(models.Model):*

*class Meta:*

*abstract = True*

*app_label = 'infrastructure'*

*
*

*class ConsumerClasifications(InfrastructureBaseModel):*

*product_environment = models.ForeignKey('ProductEnvironments')*

*consumer = models.ForeignKey('Consumers')*

*class Meta(InfrastructureBaseModel.Meta):*

*db_table = 'consumer_clasifications'*

*
*

I'm trying to instrospect this classes using inspect:


*from models import *
*

*import inspect
*

*inspect.getmembers(InfrastructureBaseModel.Meta)
*

*
*

*[('__doc__', None), ('__module__', 'models'), ('abstract', False), 
('app_label', u'infrastructure')]*


Why am I getting False when inspecting, if the class has True on the 
abstract field? Maybe this is not the right forum, but any help is 
appreciated.


Thank you


-- Roberto

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




Re: What is the best practice to learn Django 1.5?

2013-06-28 Thread Roberto López López
Two scoops of django is also a good book https://django.2scoops.org/


On 06/28/2013 03:45 PM, Gabriel wrote:
>
> Hey, you could also try Getting Started With Djangorest, that's a
> series of classes in everything you might need to become a Django dev.
>
> -Gabe
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: how to properly use the m2m_changed signal?

2013-06-28 Thread Roberto López López

Changing the m2m_changed signal on Project.departments.through to
post_save on ProjectDepartmentMembership did the trick.

m2m_changed signal seems to work as long as you don't explicitly define
the "through" model.



On 06/28/2013 02:06 PM, Roberto López López wrote:
>
> I am doing tests and the m2m_changed signal seems to work perfectly as
> long as I have not defined a "through" model. Is there any trick here?
>
> Thanks!
>
>
>
>
> On 06/28/2013 12:14 PM, Roberto López López wrote:
>>
>> I have tried as well using the post_save signal and overriding the
>> save() method. But in none of those cases Project.departments is
>> populated yet when reaching my code :-/
>>
>>
>>
>> On 06/28/2013 11:50 AM, Roberto López López wrote:
>>>
>>> Hi,
>>>
>>> I am trying to listen to the m2m_changed signal on my models, but I
>>> can't make it work. Even the execution flow does not reach the
>>> linked method!
>>>
>>> class Project(models.Model):
>>> departments =
>>> models.ManyToManyField('department.Department',
>>> related_name='projects',
>>> 
>>> through='project.ProjectDepartmentMembership')
>>>
>>> @receiver(m2m_changed, sender=Project.departments.through)
>>> def _on_change_m2m(sender, instance, action, reverse, model,
>>> pk_set, using, **kwargs):
>>> pass
>>>
>>> As interface I am using the django admin, and departments appears as
>>> an inline of Project
>>>
>>> Any help please? Thanks.
>>>
>>> Cheers,
>>>
>>> Roberto
>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>
>>
>> -- 
>> Kind regards,
>>
>> Roberto López López
>>
>>
>> System Developer
>> Parallab, Uni Computing
>> Høyteknologisenteret, Thormøhlensgate 55
>> N-5008 Bergen, Norway
>> Tel:(+47) 555 84091
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>
>
> -- 
> Kind regards,
>
> Roberto López López
>
>
> System Developer
> Parallab, Uni Computing
> Høyteknologisenteret, Thormøhlensgate 55
> N-5008 Bergen, Norway
> Tel:(+47) 555 84091
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: how to properly use the m2m_changed signal?

2013-06-28 Thread Roberto López López

I am doing tests and the m2m_changed signal seems to work perfectly as
long as I have not defined a "through" model. Is there any trick here?

Thanks!




On 06/28/2013 12:14 PM, Roberto López López wrote:
>
> I have tried as well using the post_save signal and overriding the
> save() method. But in none of those cases Project.departments is
> populated yet when reaching my code :-/
>
>
>
> On 06/28/2013 11:50 AM, Roberto López López wrote:
>>
>> Hi,
>>
>> I am trying to listen to the m2m_changed signal on my models, but I
>> can't make it work. Even the execution flow does not reach the linked
>> method!
>>
>> class Project(models.Model):
>> departments = models.ManyToManyField('department.Department',
>> related_name='projects',
>> 
>> through='project.ProjectDepartmentMembership')
>>
>> @receiver(m2m_changed, sender=Project.departments.through)
>> def _on_change_m2m(sender, instance, action, reverse, model,
>> pk_set, using, **kwargs):
>> pass
>>
>> As interface I am using the django admin, and departments appears as
>> an inline of Project
>>
>> Any help please? Thanks.
>>
>> Cheers,
>>
>> Roberto
>>
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>  
>>  
>
>
> -- 
> Kind regards,
>
> Roberto López López
>
>
> System Developer
> Parallab, Uni Computing
> Høyteknologisenteret, Thormøhlensgate 55
> N-5008 Bergen, Norway
> Tel:(+47) 555 84091
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Help in finding how to learn Django

2013-06-28 Thread Roberto López López
https://docs.djangoproject.com/en/1.5/intro/




On 06/28/2013 09:49 AM, subsn...@gmail.com wrote:
> Hi all,
>
> What is the best way to learn Django 1.5 thouroughly? I have been a
> .NET developer and have a really good understanding of OOP, HTML5, CSS
> and JavaScript. I also have an entry-level knowledge of Python. I am
> completely new to MVC (or MVT, in this case).
>
> I have a need to build apps with Django that provide users with
> features such as finding each other based on geographical distance,
> upload pictures and edit them online, natural language search, etc...
> (just to highlight that I need to know more than how to build a poll
> app or a simple blog).
>
> My understanding is that the entry point to learn Django is by
> completing the tutorial at the Django project site. Then, what? What
> path would you recommend? I have seen that lots of learning resources
> on the web target versions lower than 1.5 and I couldn't really find
> books on 1.5. When reading reviews on learning material on 1.4, I
> often see they are outdated and not really applying to 1.5.
>
> Also, I briefly looked at what it takes to deploy a Django app.
> Virtualenv, git, pip, etc... are all things unknown to me and it looks
> a bit scary for a guy used to deploy apps by uploading the compiled
> binaries through FTP.
>
> Help in defining a clear path to learn how to bend Django to my will
> would be invaluable!
>
> Thank you for your time.
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Django-admin-tools unicode problem

2013-06-28 Thread Roberto López López

Hi,

I can perfectly understand Portuguese, but it's not the case for many
users of this mailing list. Please, stick to English...

Cheers,

Roberto



On 06/28/2013 01:35 PM, Sandro Dutra wrote:
> Como o Gilberto postou, pode haver um problema quando o teu editor de
> textos salva o arquivo do template, tente abrir este template pelo
> bloco de notas e ao 'salvar como' deve haver um campo lá embaixo para
> selecionar a 'Codificação', selecione UTF-8 e salve ou tente a
> configuração relativa no editor de textos que está a utilizar, talvez
> isto resolva o problema.
>
> Eu já tive esses problemas quando usava Notepad++, mas tenho utilizado
> PyCharm e não tive mais este tipo de problema, há opções gratuitas que
> devem lidar com isto também, tais como Sublime e Aptana.
>
>
> 2013/6/27 Jaimerson Leandro Amaro de Araújo <jaimersonara...@gmail.com
> <mailto:jaimersonara...@gmail.com>>
>
> Cara, o problema é que a exceção tá sendo no template do
> aplicativo, que lê as informações do banco de dados. Alterar os
> arquivos do admin-tools é inviável em termos de portabilidade na
> hora do deploy. O que eu quero saber é se é possível mudar o
> encoding padrão desse app.
>
> Em quarta-feira, 26 de junho de 2013 11h22min18s UTC-3, Odin
> escreveu:
>
> Jaimerson, ainda assim creio que você deva tentar adicionar ao
> topo de suas views e/ou dos módulos usados do admin-tools a
> linha:
>
> # -*- coding: utf-8 -*- ou # -*- coding: iso-8859-1 -*-
>
> Isso permitirá ao Python ler o arquivo no encoding definido.
>
>
> 2013/6/26 Jaimerson Leandro Amaro de Araújo
> <jaimers...@gmail.com>
>
> Uh, I know it`s an encoding problem, I was hoping there
> was a way of changing default charset for that app.
>
> Em quarta-feira, 26 de junho de 2013 10h16min02s UTC-3,
> Odin escreveu:
>
> Think it's an encode problem. I never use this app but
> try to add this line o top of your views file:
>
> # -*- coding: utf-8 -*-
>
>
> 2013/6/26 Jaimerson Leandro Amaro de Araújo
> <jaimers...@gmail.com>
>
> (I posted this on django-admin-tools mail list,
> but apparently there's no one alive there)
>
>
> Hello, I'm stuck in a encoding issue, on the
> dashboard template. Some of my models have fields
> with non-ascii characters (like "à" or "á"), and
> when I try to load the page, I get the following
> error:
>
>
>   DjangoUnicodeDecodeError at /
>
> 'ascii' codec can't decode byte 0xc3 in position 5: 
> ordinal not in range(128).
> You passed in  at 0xb581d98c> ()
>
> [...]
>
>
> Unicode error hint
>
> The string that could not be encoded/decoded was:
> *Conte��do*
>
> Please, advise. --
> You received this message because you are
> subscribed to the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving
> emails from it, send an email to
> django-users...@googlegroups.com.
> To post to this group, send email to
> django...@googlegroups.com.
>
> Visit this group at
> http://groups.google.com/group/django-users.
> For more options, visit
> https://groups.google.com/groups/opt_out.
>  
>  
>
>
> -- 
> You received this message because you are subscribed to
> the Google Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails
> from it, send an email to django-users...@googlegroups.com.
> To post to this group, send email to
> django...@googlegroups.com.
> Visit this group at
> http://groups.google.com/group/django-users.
> For more options, visit
> https://groups.google.com/groups/opt_out.
>  
>  
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and sto

Re: how to properly use the m2m_changed signal?

2013-06-28 Thread Roberto López López

I have tried as well using the post_save signal and overriding the
save() method. But in none of those cases Project.departments is
populated yet when reaching my code :-/



On 06/28/2013 11:50 AM, Roberto López López wrote:
>
> Hi,
>
> I am trying to listen to the m2m_changed signal on my models, but I
> can't make it work. Even the execution flow does not reach the linked
> method!
>
> class Project(models.Model):
> departments = models.ManyToManyField('department.Department',
> related_name='projects',
> 
> through='project.ProjectDepartmentMembership')
>
> @receiver(m2m_changed, sender=Project.departments.through)
> def _on_change_m2m(sender, instance, action, reverse, model,
> pk_set, using, **kwargs):
> pass
>
> As interface I am using the django admin, and departments appears as
> an inline of Project
>
> Any help please? Thanks.
>
> Cheers,
>
> Roberto
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




how to properly use the m2m_changed signal?

2013-06-28 Thread Roberto López López

Hi,

I am trying to listen to the m2m_changed signal on my models, but I
can't make it work. Even the execution flow does not reach the linked
method!

class Project(models.Model):
departments = models.ManyToManyField('department.Department',
related_name='projects',

through='project.ProjectDepartmentMembership')

@receiver(m2m_changed, sender=Project.departments.through)
def _on_change_m2m(sender, instance, action, reverse, model, pk_set,
using, **kwargs):
pass

As interface I am using the django admin, and departments appears as an
inline of Project

Any help please? Thanks.

Cheers,

Roberto


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




Re: redirection problem

2013-06-26 Thread Roberto López López

Update: if I disable 'django.middleware.locale.LocaleMiddleware', it's
not redirecting anymore. But I need to have i18n support in my website!

Any idea?



On 06/26/2013 05:09 PM, Roberto López López wrote:
> Hi,
>
> After creating an object from the admin interface I'm redirected to a
> "localized" version of the url. For example, if the original url is
> http://127.0.0.1:8000/admin/project/project/2/ , I'm redirected to
> http://127.0.0.1:8000/en/admin/project/project/2/ .
>
> I suppose this has to do with the middleware in my settings file:
>
> MIDDLEWARE_CLASSES = (
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware',
> 'django.middleware.locale.LocaleMiddleware',
> 'django.middleware.common.CommonMiddleware',
> 'django.middleware.doc.XViewMiddleware',
> # Uncomment the next line for simple clickjacking protection:
> # 'django.middleware.clickjacking.XFrameOptionsMiddleware',
> 'cms.middleware.page.CurrentPageMiddleware',
> 'cms.middleware.user.CurrentUserMiddleware',
> 'cms.middleware.toolbar.ToolbarMiddleware',
> 'cms.middleware.language.LanguageCookieMiddleware',
> )
>
> Any suggestion please? Thanks!
>
> Roberto
>
>


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




redirection problem

2013-06-26 Thread Roberto López López

Hi,

After creating an object from the admin interface I'm redirected to a
"localized" version of the url. For example, if the original url is
http://127.0.0.1:8000/admin/project/project/2/ , I'm redirected to
http://127.0.0.1:8000/en/admin/project/project/2/ .

I suppose this has to do with the middleware in my settings file:

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.doc.XViewMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.language.LanguageCookieMiddleware',
)

Any suggestion please? Thanks!

Roberto


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




Re: countries phone prefixes

2013-06-20 Thread Roberto López López

Ok, answering my own question: django-country-dialcode



On 06/20/2013 11:35 AM, Roberto López López wrote:
> Hi,
>
> I need a sort of prepopulated foreign key with countries and their phone
> prefixes, to add to my models. Does anyone know any 3rd party package or
> service providing this? Thanks.
>
> Cheers,
>
> Roberto
>


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




countries phone prefixes

2013-06-20 Thread Roberto López López
Hi,

I need a sort of prepopulated foreign key with countries and their phone
prefixes, to add to my models. Does anyone know any 3rd party package or
service providing this? Thanks.

Cheers,

Roberto

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




Re: m2m_changed signal registration

2013-06-19 Thread Roberto López López

Btw I have opened a stackoverflow thread:
http://stackoverflow.com/questions/17149305/post-save-signal-and-relations

At the beginning I was thinking of using a post_save signal, but an user
there suggested me to better use the m2m_changed.




On 06/18/2013 04:12 PM, Roberto López López wrote:
>
> Hi,
>
> I am having trouble registering a function to the m2m_changed signal.
> My code is as follows:
>
>  1. from django.db.models.signals import m2m_changed
>  2. from django.db import models
>  3. from django.dispatch.dispatcher import receiver
> 4.
>  5. class Project(models.Model):
>  6. employees = models.ManyToManyField('staff.Person',
> through='project.PersonProjectMembership',
>  7. related_name='projects')
> 8.
>  9. class PersonProjectMembership(models.Model):
> 10. project = models.ForeignKey('project.Project',
> related_name="person_memberships")
> 11. person = models.ForeignKey('staff.Person',
> related_name="project_memberships")
> 12. lead = models.BooleanField(default=False)
> 13. position = models.CharField(max_length=50)
> 14. project_manager = models.BooleanField(
> 15. default=False
> 16. )
>17.
> 18. class Meta:
> 19. permissions = (
> 20. ('view_personprojectmembership', _('View person project membership')),
> 21. )
>22.
> 23. @receiver(m2m_changed, sender=Project.employees.through)
> 24. def _on_save_project_assign_privileges(sender, instance, action,
> reverse, model, pk_set, using, **kwargs):
> 25. # [...]
>
> Somehow it doesn't seem to work, the execution point never reaches the
> _on_save_project_assign_privileges function when I modify the m2m
> relation (I am using the admin interface for that). On the other side,
> I have another method registered to the post_save signal for the same
> object and it works correctly.
>
> I have read the signals documentation -concretely the m2m_changed-,
> re-read my code, googled for it, asked in other sites... but I have
> not been able to find a solution. Any help please? Thanks!
>
> Roberto
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Problem setting up django server

2013-06-18 Thread Roberto
Are you in a virtualenv? Can you run $python manage.py shell? 

Which version of python have you installed? Django v1.5 requires python >= 
v2.6.5, and from your stacktrace it seems you just have v2.6.
https://docs.djangoproject.com/en/1.5/faq/install/#what-are-django-s-prerequisites


On Tuesday, 18 June 2013 17:00:23 UTC+2, smy28 wrote:
>
> I just installed Django and I'm trying to initially set up the server, as 
> detailed in the 'Part 1' Tutorial. I haven't configured any settings yet. 
> Whenever I run the command "python manage.py runserver", I get the 
> following message:
>
>
>
> Validating models...
>
> Unhandled exception in thread started by  of  at 0x100592e90>>
> Traceback (most recent call last):
>   File 
> "/Library/Python/2.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 92, in inner_run
> self.validate(display_num_errors=True)
>   File "/Library/Python/2.6/site-packages/django/core/management/base.py", 
> line 280, in validate
> num_errors = get_validation_errors(s, app)
>   File 
> "/Library/Python/2.6/site-packages/django/core/management/validation.py", 
> line 35, in get_validation_errors
> for (app_name, error) in get_app_errors().items():
>   File "/Library/Python/2.6/site-packages/django/db/models/loading.py", 
> line 166, in get_app_errors
> self._populate()
>   File "/Library/Python/2.6/site-packages/django/db/models/loading.py", 
> line 72, in _populate
> self.load_app(app_name, True)
>   File "/Library/Python/2.6/site-packages/django/db/models/loading.py", 
> line 96, in load_app
> models = import_module('.models', app_name)
>   File "/Library/Python/2.6/site-packages/django/utils/importlib.py", line 
> 35, in import_module
> __import__(name)
>   File "/Library/Python/2.6/site-packages/django/contrib/auth/models.py", 
> line 21, in 
> from django.contrib.contenttypes.models import ContentType
>   File 
> "/Library/Python/2.6/site-packages/django/contrib/contenttypes/models.py", 
> line 127, in 
> class ContentType(models.Model):
>   File "/Library/Python/2.6/site-packages/django/db/models/base.py", line 
> 97, in __new__
> new_class.add_to_class('_meta', Options(meta, **kwargs))
> TypeError: Error when calling the metaclass bases
> __init__() keywords must be strings
>
>
>
>
> Any ideas as to why this is?
> Thanks in advance!!
>

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




m2m_changed signal registration

2013-06-18 Thread Roberto López López

Hi,

I am having trouble registering a function to the m2m_changed signal. My
code is as follows:

 1. from django.db.models.signals import m2m_changed
 2. from django.db import models
 3. from django.dispatch.dispatcher import receiver
 4.
 5. class Project(models.Model):
 6. employees = models.ManyToManyField('staff.Person',
through='project.PersonProjectMembership',
 7. related_name='projects')
 8.
 9. class PersonProjectMembership(models.Model):
10. project = models.ForeignKey('project.Project',
related_name="person_memberships")
11. person = models.ForeignKey('staff.Person',
related_name="project_memberships")
12. lead = models.BooleanField(default=False)
13. position = models.CharField(max_length=50)
14. project_manager = models.BooleanField(
15. default=False
16. )
17.
18. class Meta:
19. permissions = (
20. ('view_personprojectmembership', _('View person project membership')),
21. )
22.
23. @receiver(m2m_changed, sender=Project.employees.through)
24. def _on_save_project_assign_privileges(sender, instance, action,
reverse, model, pk_set, using, **kwargs):
25. # [...]


Somehow it doesn't seem to work, the execution point never reaches the
_on_save_project_assign_privileges function when I modify the m2m
relation (I am using the admin interface for that). On the other side, I
have another method registered to the post_save signal for the same
object and it works correctly.

I have read the signals documentation -concretely the m2m_changed-,
re-read my code, googled for it, asked in other sites... but I have not
been able to find a solution. Any help please? Thanks!

Roberto


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




Re: request_finished signal not being called with Django 1.5.1 with uwsgi

2013-05-31 Thread Roberto De Ioris

> I've created a ticket https://code.djangoproject.com/ticket/20537
>
> Not sure if this can be fixed in Django or a stern warning in the
> documentation can suffice.


Honestly (i am the main uWSGI author) whoever is using a uWSGI version <
1.2.6 should be worried by dozens more things (no more support, no more
security updates, known bugs, basically broken newrelic support, broken
threads and i do not even know what scary things you can find in it ...)

We are talking about a package of 2 years ago... and this specific problem
is caused by a (serious) bug in ancient uWSGI releases with WSGI specs, so
why django should bother ?


-- 
Roberto De Ioris
http://unbit.it

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




Re: Multiprocess and Global State

2013-05-23 Thread Roberto De Ioris

> I all,
>
> Environment:
> - Django 1.5.1
> - mongoengine 0.8.1
>
> I use mongoengine to store and manage user accounts authentication.
>
> it work fine with the development server and uwsgi : only if I use a
> single
> process or thread mode.
>
> If i use more than 1 process, sometime ( when i refresh my application ),
> i
> am redirected on my login form.
>
> All my request must be authentified, i use a middleware to do this :
>
> from django.http import HttpResponse,HttpResponseRedirect
>> class AuthenticationMiddleware(object):
>>
>> _LOGIN_PATH = "/accounts/login_view/"
>>
>> def process_request(self, request):
>> if (request.path != self._LOGIN_PATH) and not request.is_ajax():
>> if not request.user.is_authenticated():
>> return HttpResponseRedirect( self._LOGIN_PATH+'?next=%s'
>> %
>> request.path)
>> return None
>
>
> I think , there are unshared data between the processes who causes this
> problem.
>
> What do you think?
>
>
> Note : it works well with gunicorn
>
> Ch.
>


If it works well with gunicorn it could be a problem with how (or better
'when') you open the connection to mongodb.

Add --lazy-apps to uWSGI options to load the application after fork()
(like gunicorn)


-- 
Roberto De Ioris
http://unbit.it

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




Re: Pls help me

2013-05-15 Thread Roberto López López
com/group/django-users?hl=en>.
> For more options, visit
> https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>  
>  
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: form validation

2013-05-11 Thread Roberto López López

Problem solved with BaseInlineFormSet.clean() :-)




On 05/11/2013 06:56 PM, Roberto López López wrote:
>
> Hi everyone,
>
> I need to do some validation in my model. So far, I have been able to
> validate normal forms, but I want to validate forms with an inline, to
> ensure that at least one of those inlines match the requirement.
>
> My code:
>
> class PDMAdminForm(ModelForm):
> class Meta:
> model = PersonDepartmentMembership
>
> def clean(self):
> previous_leaders = []
> if self.instance:  # the instance is already on the db
> previous_leaders =
> self.instance.department.employee_memberships.filter(lead__exact=True)
> lead = self.cleaned_data['lead'] # access fields from the
> form itself
> # do some validations and eventually throw
> ValidationErrrors [...]
> return self.cleaned_data
>
> This works great for a single inline. But if I have several
> PersonDepartmentMembership instances to be created, I don't know how
> to check the value of those other (I just want to ensure that at least
> one fo them has lead==True).
>
> Does anyone know how to do this cross validation? Thank you very much
> for your suggestions.
>
> Regards,
>
> Roberto
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

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




form validation

2013-05-11 Thread Roberto López López

Hi everyone,

I need to do some validation in my model. So far, I have been able to
validate normal forms, but I want to validate forms with an inline, to
ensure that at least one of those inlines match the requirement.

My code:

class PDMAdminForm(ModelForm):
class Meta:
model = PersonDepartmentMembership

def clean(self):
previous_leaders = []
if self.instance:  # the instance is already on the db
previous_leaders =
self.instance.department.employee_memberships.filter(lead__exact=True)
lead = self.cleaned_data['lead'] # access fields from the
form itself
# do some validations and eventually throw ValidationErrrors
[...]
return self.cleaned_data

This works great for a single inline. But if I have several
PersonDepartmentMembership instances to be created, I don't know how to
check the value of those other (I just want to ensure that at least one
fo them has lead==True).

Does anyone know how to do this cross validation? Thank you very much
for your suggestions.

Regards,

Roberto


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




django-guardian VS django admin

2013-04-28 Thread Roberto López López
Hi,

I have problems setting up django-guardian to work properly in my web
application. Object permissions seem to be correct after testing with
the django shell, but somehow admin doesn't seem to react to the
permission system.

I have a Department model:

class Department(models.Model):
name = models.CharField(_('department name'), max_length=50,
default=_('Department name'))
description = models.TextField(_('department description'))
# etc.


I'm catching the post_save signal to assign user rights:

@receiver(post_save, sender=Department)
def _on_save_department(sender, instance, created, **kwargs):
# users to give privileges
superusers = User.objects.filter(is_superuser__exact=True)
try:
department_leader_user = instance.leader_user()

# assign privileges
assign_perm('change_department', department_leader_user,
instance)
except ObjectDoesNotExist:
pass

for u in User.objects.all():
remove_perm('view_department', u, instance)
remove_perm('change_department', u, instance)
remove_perm('delete_department', u, instance)
for u in filter(lambda x: x is not None, superusers):
assign_perm('view_department', u, instance)
assign_perm('change_department', u, instance)
assign_perm('delete_department', u, instance)

The signal receiver seem to work, as I said I have checked the user
rights on the django shell.

I have as well a DepartmentAdmin:

class PersonDepartmentMembershipInline(admin.StackedInline):
model = PersonDepartmentMembership
extra = 2


class GroupDepartmentMembershipInline(admin.StackedInline):
model = GroupDepartmentMembership
extra = 1


class DepartmentAdmin(GuardedModelAdmin):
inlines = (PersonDepartmentMembershipInline,
GroupDepartmentMembershipInline,)

admin.site.register(Department, DepartmentAdmin)

According to the documentation this should be enough to integrate
django-guardian into the admin interface. Even though, when I log in
with a user from different department, he's able to modify the other
department. Any help please? Thanks in advance.

Regards,

Roberto




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




Re: WSGIPythonPath and

2013-04-12 Thread Roberto López López

Thank you very much Joey and Nik, I will talk about your proposed
solutions with our sysadmin.

Best,

Roberto



On 04/12/2013 01:11 AM, Nikolas Stevenson-Molnar wrote:
> Another direction might be to run a separate WSGI HTTP server (like
> gunicorn) and proxy to it from Apache. Saves the hassle of messing
> around with mod_wsgi.
> 
> _Nik
> 
> On 4/11/2013 3:20 PM, Joey Espinosa wrote:
>>
>> I had basically the same issue as you.
>>
>> With only one Django app deployed, it's easy to just stick your
>> WSGIPythonPath directive in /etc/apache2/apache.conf.
>>
>> But with multiple different virtualenvs, you need to do something like
>> this:
>>
>> http://stackoverflow.com/questions/4614121/running-python-from-a-virtualenv-with-apache-mod-wsgi-on-windows
>>
>> Hope that helps. I've implemented this solution myself.
>>
>> --
>> Joey Espinosa
>> Python Developer
>> http://about.me/joelinux
>>
>> On Apr 11, 2013 5:20 PM, "Roberto López López" <roberto.lo...@uni.no
>> <mailto:roberto.lo...@uni.no>> wrote:
>>
>>
>> Hi Joey,
>>
>> All of them are in different virtualenvs.
>>
>>
>>
>> On 04/11/2013 11:02 PM, Joey Espinosa wrote:
>>>
>>> I meant Python libs/binary.
>>>
>>> --
>>> Joey "JoeLinux" Espinosa
>>> Python Developer
>>> http://about.me/joelinux
>>>
>>> On Apr 11, 2013 5:00 PM, "Joey Espinosa"
>>> <jlouis.espin...@gmail.com <mailto:jlouis.espin...@gmail.com>> wrote:
>>>
>>> Do all your sites share the same Python, or are they in
>>> different virtualenvs?
>>>
>>> --
>>> Joey "JoeLinux" Espinosa
>>> Python Developer
>>> http://about.me/joelinux
>>>
>>> On Apr 11, 2013 3:39 PM, "Roberto López López"
>>> <roberto.lo...@uni.no <mailto:roberto.lo...@uni.no>> wrote:
>>>
>>>
>>> Hi everyone,
>>>
>>> We are trying to deploy a django application on our
>>> apache server
>>> (mod_wsgi) following
>>> 
>>> https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/
>>> We
>>> have different virtualhosts defined as well in httpd.conf.
>>>
>>> We are now stuck, apache is throwing the following error:
>>>
>>> WSGIPythonPath cannot occur within  section
>>>
>>> Can anyone give us any hint? Thank you very much!
>>>
>>> Roberto
>>>
>>>
>>> --
>>> 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
>>> <mailto:django-users%2bunsubscr...@googlegroups.com>.
>>> To post to this group, send email to
>>> django-users@googlegroups.com
>>> <mailto:django-users@googlegroups.com>.
>>> Visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit
>>> https://groups.google.com/groups/opt_out.
>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the
>>> Google Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it,
>>> send an email to django-users+unsubscr...@googlegroups.com
>>> <mailto:django-users+unsubscr...@googlegroups.com>.
>>> To post to this group, send email to
>>> django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
>>> Visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>  
>>>  
>>
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>&g

Re: WSGIPythonPath and

2013-04-11 Thread Roberto López López

Hi Joey,

All of them are in different virtualenvs.



On 04/11/2013 11:02 PM, Joey Espinosa wrote:
>
> I meant Python libs/binary.
>
> --
> Joey "JoeLinux" Espinosa
> Python Developer
> http://about.me/joelinux
>
> On Apr 11, 2013 5:00 PM, "Joey Espinosa" <jlouis.espin...@gmail.com
> <mailto:jlouis.espin...@gmail.com>> wrote:
>
> Do all your sites share the same Python, or are they in different
> virtualenvs?
>
> --
> Joey "JoeLinux" Espinosa
> Python Developer
> http://about.me/joelinux
>
> On Apr 11, 2013 3:39 PM, "Roberto López López"
> <roberto.lo...@uni.no <mailto:roberto.lo...@uni.no>> wrote:
>
>
> Hi everyone,
>
> We are trying to deploy a django application on our apache server
> (mod_wsgi) following
> https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/
> We
> have different virtualhosts defined as well in httpd.conf.
>
> We are now stuck, apache is throwing the following error:
>
> WSGIPythonPath cannot occur within  section
>
> Can anyone give us any hint? Thank you very much!
>
> Roberto
>
>
> --
> 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
> <mailto:django-users%2bunsubscr...@googlegroups.com>.
> To post to this group, send email to
> django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at
> http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

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




WSGIPythonPath and

2013-04-11 Thread Roberto López López

Hi everyone,

We are trying to deploy a django application on our apache server
(mod_wsgi) following
https://docs.djangoproject.com/en/1.4/howto/deployment/wsgi/modwsgi/ We
have different virtualhosts defined as well in httpd.conf.

We are now stuck, apache is throwing the following error:

WSGIPythonPath cannot occur within  section

Can anyone give us any hint? Thank you very much!

Roberto


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




Re: field lookups problem

2013-03-22 Thread Roberto López López

Hi Anssi, thanks for your answer.

I already thought about that, but checking the code from
django.db.models.base.Model#__eq__() is not telling me the same:

def __eq__(self, other):
return isinstance(other, self.__class__) and self._get_pk_val()
== other._get_pk_val()



On 03/22/2013 05:02 PM, akaariai wrote:
> On 22 maalis, 15:44, Roberto López López <roberto.lo...@uni.no> wrote:
>> Hi,
>>
>> I have a problem with my data model while doing field lookups. This is
>> my models.py:
>>
>> from django.db import models, IntegrityError
>>
>> # Create your models here.
>>
>> class Model1(models.Model):
>> title = models.CharField(max_length=15)
>> models2 = models.ManyToManyField('Model2', through='ThroughModel')
>>
>> def __unicode__(self):
>> return self.title
>>
>> class Model2(models.Model):
>> title = models.CharField(max_length=15)
>>
>> def __unicode__(self):
>> return self.title
>>
>> class ThroughModel(models.Model):
>> model1 = models.ForeignKey(Model1)
>> model2 = models.ForeignKey(Model2)
>> lead = models.BooleanField(default=False)
>>
>> def __unicode__(self):
>> return u'{0} - {1} - {2}'.format(self.model1, self.model2,
>> self.lead)
>>
>> Testing it on the django shell:
>>
>>>>> m1 = Model1.objects.create(title='blabla')
>>>>> m2 = Model2.objects.create(title='blabla2')
>>>>> m1.__eq__(m2)
>> False # OBVIOUSLY>>> t = 
>> ThroughModel.objects.create(model1=m1, model2=m2)
>>>>> ThroughModel.objects.filter(model1__exact=m1)
>> []# OK>>> 
>> ThroughModel.objects.filter(model1__exact=m2)
>>
>> []# NOT OK!!!
>>
>> Am I missing anything? Can anyone spot the problem?
>>
>> Thanks for your advice.
>>
>> Regards,
>>
>> Roberto
> The problem here is that Django doesn't do any verification that the
> given model values for lookups are of correct type.  My bet is that
> m1.pk == m2.pk. So, Django will create a query using m2.pk in
> model1__exact=m2, and this is the reason you get the results you get.
>
>  - Anssi
>

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




field lookups problem

2013-03-22 Thread Roberto López López


Hi,

I have a problem with my data model while doing field lookups. This is
my models.py:

from django.db import models, IntegrityError

# Create your models here.

class Model1(models.Model):
title = models.CharField(max_length=15)
models2 = models.ManyToManyField('Model2', through='ThroughModel')

def __unicode__(self):
return self.title

class Model2(models.Model):
title = models.CharField(max_length=15)

def __unicode__(self):
return self.title

class ThroughModel(models.Model):
model1 = models.ForeignKey(Model1)
model2 = models.ForeignKey(Model2)
lead = models.BooleanField(default=False)

def __unicode__(self):
return u'{0} - {1} - {2}'.format(self.model1, self.model2,
self.lead)




Testing it on the django shell:

>>> m1 = Model1.objects.create(title='blabla')
>>> m2 = Model2.objects.create(title='blabla2')
>>> m1.__eq__(m2)
False # OBVIOUSLY
>>> t = ThroughModel.objects.create(model1=m1, model2=m2)
>>> ThroughModel.objects.filter(model1__exact=m1)
[]# OK
>>> ThroughModel.objects.filter(model1__exact=m2)
[]# NOT OK!!!



Am I missing anything? Can anyone spot the problem?

Thanks for your advice.

Regards,

Roberto


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




Re: django templates - iterate over several lists

2013-03-08 Thread Roberto López López

Thank you very much!


On 03/08/2013 03:12 PM, Javier Guerra Giraldez wrote:
> On Fri, Mar 8, 2013 at 5:07 AM, Roberto López López
> <roberto.lo...@uni.no> wrote:
>> I'd like to avoid having to concatenate them in the view and pass that
>> as another parameter.
> 
> 
> two ideas come to mind:
> 
> - itertools.chain() on the view.  it's equivalent to concatenating,
> but done lazily, so there's _very_ little overhead.
> 
> - add them in the template.  the 'add' filter is supposed to work with
> lists too.
> 
> needless to say, i'd far prefer the first option.  view functions are
> supposed to gather and organize all the info and templates should have
> as little behaviour as possible.
> 
> 

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




django templates - iterate over several lists

2013-03-08 Thread Roberto López López

Hi,

How can I iterate over several list objects available in my template?
I'd like to avoid having to concatenate them in the view and pass that
as another parameter.

I mean something like this:

{% for x in list1, list2, list3... listN %}
{% if not forloop.first %}, {% endif %}write some stuff
{% endfor %}

Thanks for your input!

Roberto


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




Re: I screwed up my django site using touch

2013-03-07 Thread Roberto López López

If you are using pycharm, you just need to use the local history to
check which indents you have changed.

(right click over the file you want to check - local history - show
history - ...)


On 03/07/2013 03:58 PM, frocco wrote:
> The problem with the stack trace, is that I could not tell what views.py
> it was talking about.
> I use PyCharm, but at work I think I used notepad++ to make a quick change.
> 
> I understand now that is is a python problem, but what bothers me is
> that I could not resolve it via the trace.
> I may have been reading it wrong, but nothing it said pointed me to the
> views.py that was in error.
> I wish I had the full trace again so I could post it.
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  



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




Re: I screwed up my django site using touch

2013-03-07 Thread Roberto López López


In python indentation really matters. Two consecutive lines, with
different indentation, do not belong to the same execution block. So:

def function(self):
   this_code_belong_to_the_function()
   this_code_also()
   if(True):
   this_as_well()
this_doesnt()

And code indented using tabs is not the same as code indented with
spaces. For sake of simplicity, people tend to use just 4 spaces instead
of tabs (somebody mentioned that some days ago on the mailing list if I
remember well). You can configure that in your editor/ide.





On 03/07/2013 03:06 PM, frocco wrote:
> I do not understand what the error indentation means.
> I am new to django, coming from PHP.
> I was using touch, because unlike PHP, I wanted changes to show without
> kicking users off.
> now I am afraid to use touch.
> 
> 
> On Thursday, March 7, 2013 8:54:15 AM UTC-5, Roberto López López wrote:
> 
> 
> Check the history of the files you've touched, and rollback all
> indentation changes.
> 
> 
> 
> On 03/07/2013 02:49 PM, frocco wrote:
> > Hello,
> >
> > I am not sure what happened, I did a touch wsgi and then a touch
> wsgi.py
> > I got an error afterwards and could not recover from it. I could not
> > find the views.py it was complaining about.
> > I tried to reload the site from a backup and still had errors. I
> ended
> > up recreating the site on webfaction and uploading each app until
> it was
> > working.
> >
> >
> >   IndentationError at /
> >
> > unindent does not match any outer indentation level (views.py,
> line 29)
> >
> > Django Version:1.5
> > Exception Type:IndentationError
> > Exception Value:
> >
> > unindent does not match any outer indentation level (views.py,
> line 29)
> >
> > Exception Location:
> > /home/frocco/webapps/ntw/lib/python2.7/django/utils/importlib.py in
> > import_module, line 35
> > Python Executable:/usr/local/bin/python
> > Python Version:2.7.3
> > Python Path:
> >
> > ['/home/frocco/webapps/ntw',
> >  '/home/frocco/webapps/ntw/myproject',
> >  '/home/frocco/webapps/ntw/lib/python2.7',
> >  '/home/frocco/lib/python2.7/pip-1.2.1-py2.7.egg',
> >  '/home/frocco/lib/python2.7',
> >  '/usr/local/lib/python27.zip',
> >  '/usr/local/lib/python2.7',
> >  '/usr/local/lib/python2.7/plat-linux2',
> >  '/usr/local/lib/python2.7/lib-tk',
> >  '/usr/local/lib/python2.7/lib-old',
> >  '/usr/local/lib/python2.7/lib-dynload',
> >  '/usr/local/lib/python2.7/site-packages',
> >  '/usr/local/lib/python2.7/site-packages/PIL']
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to django-users...@googlegroups.com .
> > To post to this group, send email to django...@googlegroups.com
> .
> > Visit this group at
> http://groups.google.com/group/django-users?hl=en
> <http://groups.google.com/group/django-users?hl=en>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.
> >  
> >  
> 
> 
> -- 
> Kind regards,
> 
> Roberto L�pez L�pez
> 
> 
> System Developer
> Parallab, Uni Computing
> H�yteknologisenteret, Thorm�hlensgate 55
> N-5008 Bergen, Norway
> Tel:(+47) 555 84091
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: models i18n

2013-03-07 Thread Roberto López López

Yes, I meant that. It works great, and fits perfectly my needs. I give
it an AAA+

Thanks again.




On 03/07/2013 02:58 PM, Johan ter Beest wrote:
> 
> On Mar 6, 2013, at 4:20 PM, Roberto López López <roberto.lo...@uni.no> wrote:
> 
>>
>> Thanks for your suggestion Johan.
>>
>> Just another question, which I've not seen answered in the
>> documentation: is there any custom filter/tag to access those translated
>> fields from a template? Thanks
> 
> If you do {% load i18n %} somewhere in your template then you can use the {{ 
> employee.position }} tag for the translated one based on the user's language 
> setting or you could specifically use {{ employee.position_en }} to target 
> the English translation if you so desire. 
> 
> Is this what you meant?
> 
> Johan
> 
>>
>> Best,
>>
>> Roberto
>>
>> On 03/05/2013 10:39 PM, Johan ter Beest wrote:
>>>
>>> On Mar 5, 2013, at 10:31 PM, Roberto López López <roberto.lo...@uni.no
>>> <mailto:roberto.lo...@uni.no>> wrote:
>>>
>>>> Hi guys,
>>>>
>>>> I am developing a django application and between my requirements there
>>>> is being able to set the model fields into different languages.
>>>>
>>>> For example:
>>>>
>>>> class Employee(models.Model):
>>>>   position = models.CharField()
>>>>   # etc.
>>>>
>>>> The employee position won't be the same in English and Spanish. Ideally,
>>>> when an user fills in the data for an employee using the admin, there
>>>> will be one tab for each language defined in the settings file.
>>>>
>>>> Do you have any suggestion about how to deal with this issue?
>>>
>>> Django-modeltranslation: https://github.com/deschler/django-modeltranslation
>>>
>>> Very nice and easy, I use it all the time, works like a charm. You can
>>> do the tabs with some custom CSS and JS in the Admin through a Media
>>> class like this:
>>>
>>> class Media:
>>>js = (
>>>'modeltranslation/js/force_jquery.js',
>>>
>>> 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js',
>>>'modeltranslation/js/tabbed_translation_fields.js',
>>>)
>>>css = {
>>>'screen':
>>> ('modeltranslation/css/tabbed_translation_fields.css',),
>>>}
>>>
>>> Johan
>>>
>>>>
>>>> Thanks!
>>>>
>>>>
>>>> -- 
>>>> 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
>>>> <mailto:django-users+unsubscr...@googlegroups.com>.
>>>> To post to this group, send email to django-users@googlegroups.com
>>>> <mailto:django-users@googlegroups.com>.
>>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>>
>>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>>
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
> 


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: I screwed up my django site using touch

2013-03-07 Thread Roberto López López

Check the history of the files you've touched, and rollback all
indentation changes.



On 03/07/2013 02:49 PM, frocco wrote:
> Hello,
> 
> I am not sure what happened, I did a touch wsgi and then a touch wsgi.py
> I got an error afterwards and could not recover from it. I could not
> find the views.py it was complaining about.
> I tried to reload the site from a backup and still had errors. I ended
> up recreating the site on webfaction and uploading each app until it was
> working.
> 
> 
>   IndentationError at /
> 
> unindent does not match any outer indentation level (views.py, line 29)
> 
> Django Version:   1.5
> Exception Type:   IndentationError
> Exception Value:  
> 
> unindent does not match any outer indentation level (views.py, line 29)
> 
> Exception Location:
> /home/frocco/webapps/ntw/lib/python2.7/django/utils/importlib.py in
> import_module, line 35
> Python Executable:/usr/local/bin/python
> Python Version:   2.7.3
> Python Path:  
> 
> ['/home/frocco/webapps/ntw',
>  '/home/frocco/webapps/ntw/myproject',
>  '/home/frocco/webapps/ntw/lib/python2.7',
>  '/home/frocco/lib/python2.7/pip-1.2.1-py2.7.egg',
>  '/home/frocco/lib/python2.7',
>  '/usr/local/lib/python27.zip',
>  '/usr/local/lib/python2.7',
>  '/usr/local/lib/python2.7/plat-linux2',
>  '/usr/local/lib/python2.7/lib-tk',
>  '/usr/local/lib/python2.7/lib-old',
>  '/usr/local/lib/python2.7/lib-dynload',
>  '/usr/local/lib/python2.7/site-packages',
>  '/usr/local/lib/python2.7/site-packages/PIL']
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: models i18n

2013-03-06 Thread Roberto López López

Thanks for your suggestion Johan.

Just another question, which I've not seen answered in the
documentation: is there any custom filter/tag to access those translated
fields from a template? Thanks

Best,

Roberto

On 03/05/2013 10:39 PM, Johan ter Beest wrote:
> 
> On Mar 5, 2013, at 10:31 PM, Roberto López López <roberto.lo...@uni.no
> <mailto:roberto.lo...@uni.no>> wrote:
> 
>> Hi guys,
>>
>> I am developing a django application and between my requirements there
>> is being able to set the model fields into different languages.
>>
>> For example:
>>
>> class Employee(models.Model):
>>position = models.CharField()
>># etc.
>>
>> The employee position won't be the same in English and Spanish. Ideally,
>> when an user fills in the data for an employee using the admin, there
>> will be one tab for each language defined in the settings file.
>>
>> Do you have any suggestion about how to deal with this issue?
> 
> Django-modeltranslation: https://github.com/deschler/django-modeltranslation
> 
> Very nice and easy, I use it all the time, works like a charm. You can
> do the tabs with some custom CSS and JS in the Admin through a Media
> class like this:
> 
> class Media:
> js = (
> 'modeltranslation/js/force_jquery.js',
>
> 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js',
> 'modeltranslation/js/tabbed_translation_fields.js',
> )
> css = {
> 'screen':
> ('modeltranslation/css/tabbed_translation_fields.css',),
> }
> 
> Johan
> 
>>
>> Thanks!
>>
>>
>> -- 
>> 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
>> <mailto:django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/django-users?hl=en.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

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




i18n

2013-03-06 Thread Roberto López López

Hi,

I am setting up i18n in my django app. I have added the following to my
settings.py:

PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))

LOCALE_PATHS = (
os.path.join(PROJECT_PATH, 'locale'),
)

LANGUAGES = [
('en', _('English')),
('nb', _('Norwegian')),
]

And created a locale/ directory into my project root.

Then I've run the command:

django-admin.py makemessages --all

...without any error, but it doesn't generate anything into locale/. I
know I've created locale/ in the correct location, as I got some errors
running the command until I created it there.

myprojectroot$ find . -iname '*.po'
myprojectroot$  ### NONE!!!

Any suggestions please? Thanks :-)

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




Re: reverse foreign key relationship usage

2013-03-06 Thread Roberto López López

Hi Fatih,

This is extremely useful in case you have two different relations
between the same model. As a rough example, consider the two following
models:

class Person(models.Model):
name = models.CharField(max_length=30)

class Car(models.Model):
model = models.CharField(max_length=20)
owner = models.OneToOne(Person, related_name='owned_car')
users = models.ForeignKey(Person, related_name='used_car')

In case of not having a different related_name for each of those two
relations, you wouldn't be able to get the person's car or the car this
person uses. (This person may own a car but use his company car, or a
friend's, a rental one...)





On 03/06/2013 08:30 AM, Fatih Tiryakioglu wrote:
> Hello all,
> 
> In Appendix B:Database API, it says "related_name (keyword) is
> particularly useful if a model has two foreign keys to the same second
> model." which is about 'related_name' keyword used reverse foreign key
> relationships. 
> e.g. blog = ForeignKey(Blog, related_name='entries').
> 
> What does it mean? Where should I use related_name instead of simply
> reversing by "x_set" keyword.
> 
> Thanks.
> 
> 
> --
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




models i18n

2013-03-05 Thread Roberto López López
Hi guys,

I am developing a django application and between my requirements there
is being able to set the model fields into different languages.

For example:

class Employee(models.Model):
position = models.CharField()
# etc.

The employee position won't be the same in English and Spanish. Ideally,
when an user fills in the data for an employee using the admin, there
will be one tab for each language defined in the settings file.

Do you have any suggestion about how to deal with this issue?

Thanks!


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




Re: Use variable in my template?

2013-02-28 Thread Roberto López López

of course, your model should be something like this:

class Marke(models.Model):
marke = models.ImageField(upload_to="images/")

or wherever you prefer to put your images into the media folder




On 02/28/2013 12:06 PM, Maria wrote:
> Hello everyone,
>  
> I have a variable I want to have access to in my Django template. But
> somehow I can't manage to do that.
>  
> I got *Django/mytemplates/polls/detail.html (template) *where I want to
> insert an image:
>  
> 
> {% load staticfiles %}
> 
> 
> 
>  type="text/css" media="screen" />
> 
> 
> 
>   alt="Picture" />
>  
> 
>  
>  
> and
>  
> *Django/mysite/polls/marke.py* :
>  
> 
> from choice import*
> 
> global marke
> marke = read_m()
> 
> The value of marke is *marke3 *and I have an image marke3.jpg. I
> successfully used another variable to insert an image (poll.id) but this
> time it wont work.
> The folder 'polls' is in my INSTALLED_APPS.
>  
> What can I do?
>  
>  
>  
>  
>  
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Use variable in my template?

2013-02-28 Thread Roberto López López

I don't understand exactly what do you mean, but if those images are
uploaded by the user (for example, using the admin app), they should be
"{{ MEDIA_URL }}{{ marke.marke }}" instead of "{{ STATIC_URL }}images/{{
marke.marke }}.jpg"



On 02/28/2013 12:06 PM, Maria wrote:
> Hello everyone,
>  
> I have a variable I want to have access to in my Django template. But
> somehow I can't manage to do that.
>  
> I got *Django/mytemplates/polls/detail.html (template) *where I want to
> insert an image:
>  
> 
> {% load staticfiles %}
> 
> 
> 
>  type="text/css" media="screen" />
> 
> 
> 
>   alt="Picture" />
>  
> 
>  
>  
> and
>  
> *Django/mysite/polls/marke.py* :
>  
> 
> from choice import*
> 
> global marke
> marke = read_m()
> 
> The value of marke is *marke3 *and I have an image marke3.jpg. I
> successfully used another variable to insert an image (poll.id) but this
> time it wont work.
> The folder 'polls' is in my INSTALLED_APPS.
>  
> What can I do?
>  
>  
>  
>  
>  
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: problem in displaying data on html

2013-02-28 Thread Roberto López López

If you just output a m2m field that's normal. If you rather prefer to
iterate over it and show all the related objects, use a for loop...


On 02/28/2013 02:43 PM, Avnesh Shakya wrote:
> hi i have one problem, i want to display data from database on html page
> all data is displaying but one attribute(university name) which i
> defined as models.ManyToManyField(University) is not being displyed,
> it's not generating error but it showing msz on html page-
> 
> instead of showing university name
> 
> plz help me...
> thanks
>  
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Redirect and execute after 2 seconds?

2013-02-27 Thread Roberto López López

Hi again Maria,

Try to combine the solutions proposed in those two pages:

http://stackoverflow.com/questions/2133166/loop-timer-in-javascript#2133217
http://stackoverflow.com/questions/948227/should-i-use-window-navigate-or-document-location-in-javascript#948242

That should be more than enough.

Roberto



On 02/27/2013 04:19 PM, Maria wrote:
> Hello Alan,
>  
> I'd love to learn something new but unfortunately I dont have the time
> since my project is due very soon. Is there no easy or short way to get
> this time variable into my code? Also, how do I "look for everything
> that happens on the client-side"? I am sorry for my incompetence.. :D
>  
> 
> Am Mittwoch, 27. Februar 2013 16:06:05 UTC+1 schrieb Alan Plum:
> 
> Hi Maria,
> 
> as Bill explained, you should be looking at JavaScript for
> everything that happens on the client-side (i.e. after the page has
> left the server).
> 
> However you should consider shifting more of the logic to the
> client-side in this case. For time-based actions with such a short
> duration the additional overhead involved in sending and receiving a
> web page could affect the results quite dramatically, especially
> when the user is on a dodgy connection (think mobile or dial-up).
> 
> You may want to look into learning AJAX to communicate between the
> client and server without requiring a full page reload and into a
> front-end library like jQuery for adding the necessary client-side
> logic to hide and reveal elements on the page (i.e. client-side) or
> provide dynamic updates after the page has been sent by the server
> (Django).
> 
> There are some good live coding exercises and screencasts available
> online if you want to learn more about jQuery or other front-end
> libraries or just JavaScript in general.
> 
> 
> Yours,
> 
> Alan
> 
> On 27.02.2013 15:01, Maria wrote:
>> Hi everyone! :)
>>  
>> I am working on a project for my studies, it is a web poll where
>> you can only answer yes or no by clicking on buttons.
>>  
>> If the user clicked on one button, the result will be saved in a
>> text-file and the user will be redirected to another page with a
>> random id:
>>  
>>
>> return HttpResponseRedirect ('/polls/'+str(sid))
>>
>>  
>> *If the user doesnt click on any button quickly enough, I want the
>> page to redirect them after 3 seconds to another page with a
>> random id AND i want to save the id of the question that wasnt
>> answered.*  How can I do it? I searched the web but only found the
>> time.sleep function. As far as I understood, I cant use the sleep
>> function because the site has to do other stuff while the 3
>> seconds pass.
>>  
>> I would be very thankful for any help on this!
>>  
>> Kind regards,
>>  
>> Maria
>> -- 
>> You received this message because you are subscribed to the Google
>> Groups "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at
>> http://groups.google.com/group/django-users?hl=en
>> <http://groups.google.com/group/django-users?hl=en>.
>> For more options, visit https://groups.google.com/groups/opt_out
>> <https://groups.google.com/groups/opt_out>.
>>  
>>  
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Redirect and execute after 2 seconds?

2013-02-27 Thread Roberto López López

Maria, that code (your "after three seconds") has to be run on the
client, so django has nothing to do with it. As Bill suggests, you
should try some javascript here.



On 02/27/2013 04:10 PM, Maria wrote:
> _like this:_
> if user clicks button
>   save answer
>   return HttpResponseRedirect ('/polls/'+str(sid))
> else *after 3 seconds*
>   save this page for later
>   return HttpResponseRedirect ('/polls/'+str(sid))
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  


-- 
Kind regards,

Roberto López López


System Developer
Parallab, Uni Computing
Høyteknologisenteret, Thormøhlensgate 55
N-5008 Bergen, Norway
Tel:(+47) 555 84091

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




Re: Begginer

2013-02-27 Thread Roberto López López


Try https://docs.djangoproject.com/en/1.5/intro/



On 02/27/2013 09:29 AM, Akshay Ramesh wrote:
> Hi I am new to Djnago and would like to have some help from you. Where
> should I start from ?
> 

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




Re: m2m relation just working in one direction

2013-02-24 Thread Roberto López López

Mike,

Cool, you are right! Changing the related_name to something different
than groups seems to solve the problem. Thank you very much :-)

Roberto



On 02/24/2013 11:30 PM, Mike Dewhirst wrote:
> Roberto
>
> I'm not entirely sure but it is possible that your group is getting
> mixed up with the contrib.auth group. I would try changing the name of
> my group temporarily to something else just to eliminate that.
>
> Mike
>
> On 25/02/2013 8:58am, Roberto López López wrote:
>> Hi,
>>
>> I have a problem involving a relation between two entities, Person and
>> Group.
>>
>>  from django.contrib.auth.models import User
>>  from django.db import models
>>
>>  class Group(models.Model):
>>  employees = models.ManyToManyField('staff.Person',
>> related_name='groups')
>>  leader = models.OneToOneField('staff.Person',
>> related_name='led_group')
>>
>>  class Person(User):
>>  pass
>>
>>
>> $ python manage.py shell
>>
>>  In [1]: from group.models import Group
>>
>>  In [2]: from staff.models import Person
>>
>>  In [3]: p = Person.objects.create(username='person1',
>> first_name='person 1')
>>
>>  In [5]: g = Group.objects.create(group_name='group 1', leader=p)
>>
>>  In [9]: g.employees.all()
>>  Out[9]: []
>>
>>  In [10]: g.employees.add(p)
>>
>>  In [11]: g.employees.all()
>>  Out[11]: []
>>
>>  In [16]: p.groups.all()
>>  Out[16]: []
>>
>>
>> As you can see, when I add a person through the group, it's not added to
>> group.employees but to person.groups. Can you see any mistake in my
>> code? Thanks in advance for your suggestions :-)
>>
>

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




m2m relation just working in one direction

2013-02-24 Thread Roberto López López
Hi,

I have a problem involving a relation between two entities, Person and
Group.

from django.contrib.auth.models import User
from django.db import models

class Group(models.Model):
employees = models.ManyToManyField('staff.Person',
related_name='groups')
leader = models.OneToOneField('staff.Person',
related_name='led_group')

class Person(User):
pass


$ python manage.py shell

In [1]: from group.models import Group

In [2]: from staff.models import Person

In [3]: p = Person.objects.create(username='person1',
first_name='person 1')

In [5]: g = Group.objects.create(group_name='group 1', leader=p)

In [9]: g.employees.all()
Out[9]: []

In [10]: g.employees.add(p)

In [11]: g.employees.all()
Out[11]: []

In [16]: p.groups.all()
Out[16]: []


As you can see, when I add a person through the group, it's not added to
group.employees but to person.groups. Can you see any mistake in my
code? Thanks in advance for your suggestions :-)

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




Re: Django gracefully shutdown

2012-12-08 Thread Roberto De Ioris

>
> Hello!
>
> After lot of work I'm ready to deploy my site on production. I'll use
> Nginx
> with uWSGI or fastCGI (not sure yet), and my doubt is how can I shutdown
> my
> production Django app gracefully (for make changes for example). Of course
> I can kill django-python-fcgi processes and restart everything again but
> is
> that correct? Can someone give me some hints please?
>
> Thanks!
>

There are various way to accomplish that in uWSGI. As always there is no
'one fit for all' solution so you have to evaluate yourself.

For example lot of people are satisfied with simple 'binary-patching'
approach (sending SIGHUP to the master) where the sockets are not closed
between reloads.

Other people (generally the ones with very high-loaded sites) cannot
tolerate the slowdown of the application during the reload, so they prefer
to spawn a whole new stack (with the new code) and simply move the
connections to the new one as soon as the new app is ready (and eventually
move back to the old instance if something is wrong)

This second approach requires a bit of effort (compared to the simple
SIGHUP approach) but is fore sure the most versatile.

Regarding fastcgi (read: flup, as fastcgi is only a communication
protocol) i do not think it is still "on par" with more modern solutions
like uWSGI, gunicorn and mod_wsgi.

Again, if you want a simple pure-python application server, gunicorn is a
better solution than flup (IMHO)

-- 
Roberto De Ioris
http://unbit.it

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



RES: Django-tables2

2012-08-24 Thread Roberto Ferreira Junior
Hi Matt,

 

When I use linkcolum instead of a template tag, my collum cell
does not display nothing!

 

Muito Obrigado,

--

Roberto Ferreira Junior

robefe...@gmail.com

11 98009942

 

De: django-users@googlegroups.com [mailto:django-users@googlegroups.com] Em
nome de MattDale
Enviada em: sexta-feira, 24 de agosto de 2012 09:15
Para: django-users@googlegroups.com
Assunto: Re: Django-tables2

 

Here's an example of one of my tables.

 

class NeedsTable(tables.Table):

needQuantity = tables.Column()

prod_id = tables.Column()

description = tables.LinkColumn('needsdetail', args=[A('pk')])

department = tables.Column()

order = tables.Column()

priority = tables.Column(accessor='order.event.priority')

show = tables.Column(accessor='order.event.name')

preppedQuantity = tables.Column()

prepdate = tables.Column()



class Meta:

order_by = 'priority'

attrs = {'class': 'general_table'}

 

URLS.py - 

url(r'^qcarea/needs/detail/(?P\d+)/$', 'needs.views.needsdetail',
name='needsdetail') 

 

LinkColumn uses reverse() to get its view and you use the Accessor(A) to
pass the pk to the args of the reverse call.  This means that you must name
your URL in your urls.py.  

 

In your example, I can't quite figure out what you are attempting with the
TemplateColumn.  To me it seems like you need to create two link columns.  

Good Luck

 


On Thursday, August 23, 2012 1:28:01 PM UTC-4, Robert wrote:

Hi All,

 

I would like to ask something, I´m trying to render a table
using Django-tables2 and that table has a link column that I want to link
with another page, I cant figure out how can I link my model, and pass my PK
to url.py.  Here’s My code:

 

 

## Models.py:  ##



 

class Projetos(models.Model):

 

#FIELDS

nome_projeto = models.CharField("Projeto", max_length=150, null='true',)

desc_oferta = models.CharField("Descrição da oferta", max_length=500,
null='true',) #aumentar

integrador = models.CharField("Integrador", max_length=150,
null='true',)

contend_provider = models.CharField("Contend Provider", max_length=150,
null='true',)

marca_servico = models.CharField("Marca do Serviço", max_length=150,
null='true',)

valor_retry = models.IntegerField("Valor de retry", null='true',)

la =  models.IntegerField("Large account", null='true',)

lanc_comercial = models.DateField("Lançamento comercial", null='true')

term_projeto = models.DateField("Término do projeto", null='true')

data_acordo = models.DateField("Data de Acordo", null='true')

data_revisao = models.DateField("Data de Revisão", null='true')

ura_id =  models.IntegerField("URA ID", null='true')

ura_desc = models.CharField("Descição URA",max_length=150, null='true')

 



## tables.py  ##



 

TEMPLATE = '''

 

   Edit

 

upload

 

'''

 

 

class ProjetosMain(tables.Table):

 

pdb.set_trace()

nome_projeto = tables.Column(verbose_name='Projeto',orderable=False)

integrador =
tables.Column(verbose_name='Integrador',orderable=False)

contend_provider = tables.Column(verbose_name='CP',orderable=False)

status = tables.Column(verbose_name='Status',orderable=False)

term_projeto =
tables.Column(verbose_name='Vigencia',orderable=False)

 

Acoes = tables.TemplateColumn(TEMPLATE)

 

class Meta:

attrs = {'class': 'bordered'}

#

##  url.py ##

#

 

urlpatterns = patterns('',

 

# Main Page portal

(r'^$', portal_main_page),

 

# Home Page

(r'home/$', portal_main_page),

 

# Project Page

url(r'projetos/$', projetos_main_page),

url(r'projetos/?P\d{1,2,3,4}/edit/', project_edit,
name="project_edit"),

url(r'projetos/?P\d{1,2,3,4}/docs/', project_docs,
name="project_docs"),

 

# Upload File

(r'^uploadfile/$', uploadfile),

(r'^uploadsuccess/$', uploadsuccess),

 

)

 

 

Best Regards / Muito Obrigado,

--

Roberto Ferreira Junior

robefe...@gmail.com  

11 98009942

 

-- 
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/-/vm2VIX0jZOAJ.
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-tables2

2012-08-23 Thread Roberto Ferreira Junior
Hi All,

 

I would like to ask something, I´m trying to render a table
using Django-tables2 and that table has a link column that I want to link
with another page, I cant figure out how can I link my model, and pass my PK
to url.py.  Here’s My code:

 

 

## Models.py:  ##



 

class Projetos(models.Model):

 

#FIELDS

nome_projeto = models.CharField("Projeto", max_length=150, null='true',)

desc_oferta = models.CharField("Descrição da oferta", max_length=500,
null='true',) #aumentar

integrador = models.CharField("Integrador", max_length=150,
null='true',)

contend_provider = models.CharField("Contend Provider", max_length=150,
null='true',)

marca_servico = models.CharField("Marca do Serviço", max_length=150,
null='true',)

valor_retry = models.IntegerField("Valor de retry", null='true',)

la =  models.IntegerField("Large account", null='true',)

lanc_comercial = models.DateField("Lançamento comercial", null='true')

term_projeto = models.DateField("Término do projeto", null='true')

data_acordo = models.DateField("Data de Acordo", null='true')

data_revisao = models.DateField("Data de Revisão", null='true')

ura_id =  models.IntegerField("URA ID", null='true')

ura_desc = models.CharField("Descição URA",max_length=150, null='true')

 



## tables.py  ##



 

TEMPLATE = '''

 

   Edit

 

upload

 

'''

 

 

class ProjetosMain(tables.Table):

 

pdb.set_trace()

nome_projeto = tables.Column(verbose_name='Projeto',orderable=False)

integrador =
tables.Column(verbose_name='Integrador',orderable=False)

contend_provider = tables.Column(verbose_name='CP',orderable=False)

status = tables.Column(verbose_name='Status',orderable=False)

term_projeto =
tables.Column(verbose_name='Vigencia',orderable=False)

 

Acoes = tables.TemplateColumn(TEMPLATE)

 

class Meta:

attrs = {'class': 'bordered'}

#

##  url.py ##

#

 

urlpatterns = patterns('',

 

# Main Page portal

(r'^$', portal_main_page),

 

# Home Page

(r'home/$', portal_main_page),

 

# Project Page

url(r'projetos/$', projetos_main_page),

url(r'projetos/?P\d{1,2,3,4}/edit/', project_edit,
name="project_edit"),

url(r'projetos/?P\d{1,2,3,4}/docs/', project_docs,
name="project_docs"),

 

# Upload File

(r'^uploadfile/$', uploadfile),

(r'^uploadsuccess/$', uploadsuccess),

 

)

 

 

Best Regards / Muito Obrigado,

--

Roberto Ferreira Junior

 <mailto:robefe...@gmail.com> robefe...@gmail.com

11 98009942

 

-- 
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: Noob question

2012-08-02 Thread Roberto Ferreira Junior
Thanks guys for all replies, an especial thanks to Kurtis, I followed all
your tips and my code looks very clean and objective, agree to leave the
underscore from classes name! Although I really appreciate hungarian
notation, without them my vars is so much objective! :)

Cheers

On Thu, Aug 2, 2012 at 3:34 PM, Tomas Neme <lacrymol...@gmail.com> wrote:

> as Kurtis says, drop the explicit Primary Keys, and drop the hungarian
> notation as well (don't declare the variable type on it's name): I
> don't need to be reminded that the name of a project will be a string,
> it's pretty obvious. Also, python standards talk against using
> underscore in class names, so standard naming would be HeaderEnrich
> instead of Header_Enrich. Underscores for field names are good. I'd
> also use less abbreviations.
>
> also, I'd name the FK on that model just "projeto", since what you'll
> get when you do `headerenrichobject.projeto` will be a Projeto object,
> not it's ID
>
> Try to forget the underlying database, the ORM is there to abstract you
> from it.
>
> But all these are style things, the syntax looks good, so it's all
> your call, but getting used to standardized style will make your life
> easier, as well as the life of people who try to help you in mailing
> lists and IRC channels
>
> --
> "The whole of Japan is pure invention. There is no such country, there
> are no such people" --Oscar Wilde
>
> |_|0|_|
> |_|_|0|
> |0|0|0|
>
> (\__/)
> (='.'=)This is Bunny. Copy and paste bunny
> (")_(") to help him gain world domination.
>
> --
> 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.
>
>


-- 
--
Roberto Ferreira Junior
+5511-98009942
robefe...@gmail.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: Any clue why Facebook iframe would be blank?

2012-06-23 Thread Roberto De Ioris

> On Fri, Jun 22, 2012 at 3:59 AM, Gabriel - Iulian Dumbrava <
> gabriel.dumbr...@gmail.com> wrote:
>
>> Hi,
>> I think something similar happen to me when I set the width of the
>> iframe
>> to be too narrow. I'm not very sure, but maybe you cand check it out.
>>
>> Gabriel
>>
>
> Hey Garbiel,
>
> I actually figured out the issue on my end. From what I gather, uWSGI
> doesn't handle small POST data sizes well. I had to change a couple of
> uWSGI configuration parameters (as seen on Stackoverflow).
> As far as I can tell -- my stuff is all good now, both in the Fluid and
> fixed-size layouts.
>
> If you need any help debugging yours, let me know! And thanks for the
> feedback.
>
>

This is a common problem in all of the proxied setup:

http://flask.pocoo.org/snippets/47/

The real fix is always reading POST datas when they are available (even if
you are not interested in them). Not reading them means your communication
socket with the webserver will be clobbered soon or later.

If you do not want to change your code you can use the uWSGI
--post-buffering option that will automatically buffer post data in memory
(or to disk).

-- 
Roberto De Ioris
http://unbit.it

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



  1   2   >