Re: PostgreSQL get_object_or_404 matching query does not exist when indeed it does?

2017-02-18 Thread Nikoleta Misheva
I missed that it is message.user.username when pasting it here but anyway it does not work. I checked it's class and it is str събота, 18 февруари 2017 г., 21:47:27 UTC+2, Daniel Roseman написа: > > On Saturday, 18 February 2017 17:37:49 UTC, Nikoleta Misheva wrote: >> >> I am querying

Re: Subquery has too many columns

2017-02-18 Thread Melvyn Sopacua
On Saturday 18 February 2017 22:27:46 Elton Pereira wrote: > class ProdutoServicoManager(models.Manager): > def get_queryset(self): > expression = models.Sum(models.F('custounitario__valor') * > models.F('custounitario__quantidade')) > total_expr =

Subquery has too many columns

2017-02-18 Thread Elton Pereira
When I change the *base_manager_name* and try to update the model an exception is raised . This is my code: class ProdutoServicoManager(models.Manager): def get_queryset(self): expression = models.Sum(models.F('custounitario__valor') *

Re: PostgreSQL get_object_or_404 matching query does not exist when indeed it does?

2017-02-18 Thread Daniel Roseman
On Saturday, 18 February 2017 17:37:49 UTC, Nikoleta Misheva wrote: > > I am querying PostgreSQL using *get_object_or_404 * but it throws and > exception *PairUsers matching query does not exist *and after that *During > handling of the above exception, another exception >

Django forms.CharField subclass with additional attribute

2017-02-18 Thread Sandeep Raheja
I am trying to generate a form dynamically and want to assign indentation of form fields. I am trying to assign an custom attribute offset to forms.CharField in subclass. I plan to use this logic to create a form dynamically from an xml file, where the fields would be indented based on the

Subclassing forms.CharField with additional attribute

2017-02-18 Thread Sandeep Raheja
I am trying to generate a form dynamically and want to assign indentation of form fields. I am trying to assign an custom attribute offset to forms.CharField in subclass. I plan to use this logic to create a form dynamically from an xml file, where the fields would be indented based on the

PostgreSQL get_object_or_404 matching query does not exist when indeed it does?

2017-02-18 Thread Nikoleta Misheva
I am querying PostgreSQL using *get_object_or_404 * but it throws and exception *PairUsers matching query does not exist *and after that *During handling of the above exception, another exception occurred:django.http.response.Http404: No PairUsers matches the given query *when indeed I

Re: file fields

2017-02-18 Thread ايهاب توفيق
thank you for your help I solve the problem and it working بتاريخ الخميس، 26 يناير، 2017 1:04:28 ص UTC+2، كتب ايهاب توفيق: > > I am new in django and to know how to use multiple file field in the same > model can any one help me > -- You received this message because you are subscribed to the

short_description not working

2017-02-18 Thread Qikai Gu
Hi folks, I'm following the first django app tutorial (polls) and I'm stuck at part 7 : the `short_description` doesn't work. The short_description I have provided 'Published recently?' in models.py

How to get list of all record on basis of year and month

2017-02-18 Thread ankur
Hello, I am new in django. I would like to display the list of all record of particular month and year.Please find below model structure of my table. class Order_Detail(models.Model): Order_Date_Time=models.DateTimeField(default=datetime.datetime.now(),blank=True,null=True) and for

Re: set initial value for field when a model insert page loaded in django admin

2017-02-18 Thread Derek
I have cut and trimmed this from of some of my own code, so may not be 100%: class MyModelForm(ModelForm): class Meta: model = MyModel def __init__(self, *args, **kwargs): super(MyModelForm, self).__init__(*args, **kwargs) self.fields['my_field'].initial=

Add new primary key to model

2017-02-18 Thread Joakim Hove
Hello; I have a model with a CharField which is used as primary key: class MyModel( Model ): string_id = CharField("StringID" , primary_key = True ) I would now like to migrate this model to have a normal integer AutoField as primary key, and the string_id field should just be

Re: Question about m2m and forms

2017-02-18 Thread Carlo Ascani
Il giorno venerdì 17 febbraio 2017 20:09:15 UTC+1, Matthew Pava ha scritto: > > Hi Carlos, > You probably want to create a new widget and override its > label_from_instance method. > > class BModelMultipleChoiceField(forms.ModelMultipleChoiceField): > def label_from_instance(self,