How to proceed with the parametr "limit_choice_to"?
On the one hand it is restriction choice in admin, but on the onther hand if limit_choice_to is {'is_active': True} on model Article, then user posted its article in past and all right. In case if user now is not active, he does not cease to be author of the article but in admin now is not displayed and not possible choiced his. What do you advice? -- 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/def303eb-5b60-4d94-bb91-63e65998e08c%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
I need an expert Postgresql.
I am try to conver from numberic to string a result of annotated field (created by a annotation). I am wrote my Func as next: class ToStr(Func): """ """ function = 'CAST' template = '%(function)s(%(expressions)s as TEXT)' class ToChar(Func): """ """ function = 'CAST' template = '%(function)s(%(expressions)s as VARCHAR)' I have next code for queryset of model: class SolutionQuerySet(models.QuerySet): """ QuerySet for solutions. """ def solutions_with_scopes(self): """Added for each solution new field 'scope' where storage her scope.""" self = self.annotate(scope=models.Sum( models.Case( models.When(opinions__is_useful=True, then=1), models.When(opinions__is_useful=False, then=-1), output_field=models.IntegerField() ) )) self = self.annotate(scope=models.functions.Coalesce('scope', 0)) return self def solutions_with_displayed_scopes(self): """Convert scope of solution to string and return with sign of number: if 0 return 0, if 1 return +1, if -1 return -1.""" self = self.solutions_with_scopes() self = self.annotate(s=ToStr('scope')) self = self.annotate(s1=ToChar('scope')) # self = self.annotate(displayed_scope=models.Case( # models.When(scope__exact=0, then=models.Value('0')), # models.When(scope__lt=0, then=models.Value('-')), # models.When(scope__gt=0, then=models.Value('+')), # output_field=models.CharField(), # )) return self This converting working with SlugField and UUIDField, however not with IntegerField (created by annotate()): *Worked with SlugField:* def solutions_with_displayed_scopes(self): """Convert scope of solution to string and return with sign of number: if 0 return 0, if 1 return +1, if -1 return -1.""" self = self.solutions_with_scopes() self = self.annotate(s=ToStr('slug')) self = self.annotate(s1=ToChar('slug')) In [2]: Solution.objects.solutions_with_displayed_scopes().values('s', > 's1')[0] > Out[2]: {'s': 'how-fix-problem-on-heroku', 's1': > 'how-fix-problem-on-heroku'} *Worked with UUIDField:* def solutions_with_displayed_scopes(self): """Convert scope of solution to string and return with sign of number: if 0 return 0, if 1 return +1, if -1 return -1.""" self = self.solutions_with_scopes() self = self.annotate(s=ToStr('id')) self = self.annotate(s1=ToChar('id')) In [1]: Solution.objects.solutions_with_displayed_scopes().values('s', > 's1')[0] > Out[1]: > {'s': '9f9beadd-be37-4475-9e11-890172987f80', > 's1': '9f9beadd-be37-4475-9e11-890172987f80'} *Not worked with IntegerField:* def solutions_with_displayed_scopes(self): """Convert scope of solution to string and return with sign of number: if 0 return 0, if 1 return +1, if -1 return -1.""" self = self.solutions_with_scopes() self = self.annotate(s=ToStr('scope')) self = self.annotate(s1=ToChar('scope')) In [1]: Solution.objects.solutions_with_displayed_scopes().values('s', > 's1')[0] > Out[1]: {'s': -2, 's1': -2} Must be: In [1]: Solution.objects.solutions_with_displayed_scopes().values('s', > 's1')[0] > Out[1]: {'s': '-2', 's1': '-2'} Can anyone explain, why Postgres have this behaivor? -- 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/aae8bf82-fb2c-43f3-8aae-444925e0af69%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Prefetch Related with Multiple Column Join
Hi Ram, I suggest you open a new feature request to document ForeignObject as a public API. Cheers, Simon Le dimanche 19 juin 2016 02:26:29 UTC-4, Ram Jayaraman a écrit : > > Hi Simon, > > Thanks a lot for the response again! I really appreciate your time. I saw > the uniq_together but didn't realize checks can be silenced in Django. ( `0 > silenced` in the log should have been a clue! ). I silenced it and it does > work great. > > I am not sure if I missed this in the Django docs but this is a really > nice feature for many situations once the models start getting a bit crazy. > I feel this should should be emphasized a bit more in the Docs. I am pretty > terrible at docs so can't offer much help apart there, so it would be great > if the Django docs team can add this. Should I make a ticket for the same ? > > Thanks again > Ram > > On Sunday, June 19, 2016 at 5:30:03 AM UTC+5:30, Simon Charette wrote: >> >> Hi Ram, >> >> As PublisherMediumBilling.publisher and medium are unique together it's >> safe to >> silence the `fields.E310` check failure in this case. >> >> By the way the check was adjusted in Django 1.10 to also take >> `unique_together` >> into account[1]. >> >> Cheers, >> Simon >> >> [1] >> https://github.com/django/django/commit/80dac8c33e7f6f22577e4346f44e4c5ee89b648c >> >> Le samedi 18 juin 2016 13:35:24 UTC-4, Ram Jayaraman a écrit : >>> >>> Hi Simon, >>> >>> Thanks for the post. I just tried this and ForeignObject requires one of >>> the 2 columns being referred to be unique. But thats an interesting object! >>> >>> On Saturday, June 18, 2016 at 8:34:31 PM UTC+5:30, Simon Charette wrote: Hi Ram, I don't have a complete solution for you but I suggest you take a look at the django.db.models.fields.related.ForeignObject class. If I'm not mistaken it should allow you to define multi-column relationships on both your Article and PublisherMediumBilling models and refer to them using the `select_related()` and `prefetch_related()``API while the later uses Python to perform in-memory JOINs. class Article(models.Model): publisher = ForeignKey(Publisher, related_name='articles') medium = ForeignKey(Medium) billing = ForeignObject( 'PublisherMediumBilling', from_fields=['publisher', 'medium'], to_fields=['publisher', 'medium'] ) publisher.articles.select_related('billing') Cheers, Simon Le samedi 18 juin 2016 07:09:03 UTC-4, Ram Jayaraman a écrit : > > I apologize if this is an old question, I did search SO/google for a > good few hours. > > I have the following models. > > Publisher() > name = CharField() > > Medium() > name = CharField() > > Article() > publisher = ForeignKey(Publisher, related_name="articles") > medium = ForeignKey(Medium, related_name="articles") > text = TextField() > > PublisherMediumBilling() > publisher = ForeignKey(Publisher() > medium = ForeignKey(Article) > lots_of_other_columns > ... > class Meta: > unique_together = ['publisher', 'medium'] > > > > I am looking to query all Article from a given publisher, and also > fetch the related PublisherMediumBilling joining on the columns > Publisher and Medium, Prefetch() object doesn't seem to quite work > for this case. > > I can of course filter-query for all PublisherMediumBilling and cache > it and do a in-memory Python JOIN. Is there a way to do through one of > the > ORM Apis ? > -- 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/e40753f1-07b2-4847-ab86-d8162c648e86%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: I need an expert Postgresql.
Hi Seti, I suppose this has to do with your Func subclasses not defining an `output_field`. You might want to have a look at the Cast function's implementation which will be part of Django 1.10 for more details[1]. It should allow you to do the following: self.annotate(s=Cast('scoppe', models.TextField)) Cheers, Simon [1] https://docs.djangoproject.com/en/1.10/ref/models/database-functions/ Le dimanche 19 juin 2016 08:27:50 UTC-4, Seti Volkylany a écrit : > > > I am try to conver from numberic to string a result of annotated field > (created by a annotation). > > I am wrote my Func as next: > > class ToStr(Func): > """ > > > """ > > > function = 'CAST' > template = '%(function)s(%(expressions)s as TEXT)' > > > > > class ToChar(Func): > """ > > > """ > > > function = 'CAST' > template = '%(function)s(%(expressions)s as VARCHAR)' > > > I have next code for queryset of model: > > > class SolutionQuerySet(models.QuerySet): > """ > QuerySet for solutions. > """ > > > def solutions_with_scopes(self): > """Added for each solution new field 'scope' where storage her > scope.""" > > > self = self.annotate(scope=models.Sum( > models.Case( > models.When(opinions__is_useful=True, then=1), > models.When(opinions__is_useful=False, then=-1), > output_field=models.IntegerField() > ) > )) > self = self.annotate(scope=models.functions.Coalesce('scope', 0)) > return self > > > def solutions_with_displayed_scopes(self): > """Convert scope of solution to string and return with sign of > number: > if 0 return 0, if 1 return +1, if -1 return -1.""" > > > self = self.solutions_with_scopes() > self = self.annotate(s=ToStr('scope')) > self = self.annotate(s1=ToChar('scope')) > # self = self.annotate(displayed_scope=models.Case( > # models.When(scope__exact=0, then=models.Value('0')), > # models.When(scope__lt=0, then=models.Value('-')), > # models.When(scope__gt=0, then=models.Value('+')), > # output_field=models.CharField(), > # )) > return self > > This converting working with SlugField and UUIDField, however not with > IntegerField (created by annotate()): > > *Worked with SlugField:* > > def solutions_with_displayed_scopes(self): > """Convert scope of solution to string and return with sign of > number: > if 0 return 0, if 1 return +1, if -1 return -1.""" > > > self = self.solutions_with_scopes() > self = self.annotate(s=ToStr('slug')) > self = self.annotate(s1=ToChar('slug')) > > > In [2]: Solution.objects.solutions_with_displayed_scopes().values('s', >> 's1')[0] >> Out[2]: {'s': 'how-fix-problem-on-heroku', 's1': >> 'how-fix-problem-on-heroku'} > > > *Worked with UUIDField:* > > def solutions_with_displayed_scopes(self): > """Convert scope of solution to string and return with sign of > number: > if 0 return 0, if 1 return +1, if -1 return -1.""" > > > self = self.solutions_with_scopes() > self = self.annotate(s=ToStr('id')) > self = self.annotate(s1=ToChar('id')) > > > > In [1]: Solution.objects.solutions_with_displayed_scopes().values('s', >> 's1')[0] >> Out[1]: >> {'s': '9f9beadd-be37-4475-9e11-890172987f80', >> 's1': '9f9beadd-be37-4475-9e11-890172987f80'} > > > *Not worked with IntegerField:* > > def solutions_with_displayed_scopes(self): > """Convert scope of solution to string and return with sign of > number: > if 0 return 0, if 1 return +1, if -1 return -1.""" > > > self = self.solutions_with_scopes() > self = self.annotate(s=ToStr('scope')) > self = self.annotate(s1=ToChar('scope')) > > > In [1]: Solution.objects.solutions_with_displayed_scopes().values('s', >> 's1')[0] >> Out[1]: {'s': -2, 's1': -2} > > > Must be: > > In [1]: Solution.objects.solutions_with_displayed_scopes().values('s', >> 's1')[0] >> Out[1]: {'s': '-2', 's1': '-2'} > > > > Can anyone explain, why Postgres have this behaivor? > > -- 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/ae22b53e-4ac8-422f-814c-613399fa7f22%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Error running Django tutorial
I was having the exact same problem. In fact I was not modiying the right urls.py On windows dirs i've got: mysite/ urls.py In fact there the in your -- 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/32a8c6ca-047a-4bf4-9e6a-e7e2121a2dc0%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Seek for Django projects
Hi there, I've built a test website by Django and accumulated certain experience of Django. I'd like to get the advice on what I shall do as the next steps to enhance my django and web app skillsets. Is there any project that I can contribute? or how to get a chance to participate the development work of a real website which will be accessed by internet users ? I just like Django very much and want to accumulate more experience from the practice. Thanks Jen -- 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/dcfd7295-b083-40f6-a576-7281065f3c18%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Seek for Django projects
Several CMS projects exist on Github currently that you could contribute to. Also I am currently looking to build a no/low budget CMS for a pet project. We could collaborate on that. Regards, On 6/19/16, Jen wrote: > Hi there, > I've built a test website by Django and accumulated certain experience of > Django. I'd like to get the advice on what I shall do as the next steps to > enhance my django and web app skillsets. > Is there any project that I can contribute? or how to get a chance to > participate the development work of a real website which will be accessed > by internet users ? I just like Django very much and want to accumulate > more experience from the practice. > > Thanks > Jen > > -- > 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/dcfd7295-b083-40f6-a576-7281065f3c18%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Mwaoshe Njemah Lead, Teke Teke www.teketeke.co.ke mo...@teketeke.co.ke 0722 99 19 18 | 0733 66 55 77 -- 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/CANq3jxAJL8mMHpFLA9c9HaMyLD9pyBYc4n3gJzABLT96ZnMAdQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
How is best solution for builing chars in django (in admin too)?
I visit https://www.djangopackages.com/grids/g/charts/ and could not found production/stable good solution for Django project. Who has some expirience builing a real project, please be so kind give me advice. Google Charts do not offer (not offline) -- 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/2f1f1c92-eb76-4189-97f5-ff9f80ca4918%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Who than uses for view RSS or Atom?
Django have a good docs about create RSS or Atom. But no mentions of good solution for human-read this RSS(Atom). Give me advise for good and free choice to solve this the 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/5055103e-124e-4e4e-8b4f-81fc6ca9%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Recommended courses/materials for Python/Django course...
Thanks for the feedback! --Fred Fred Stluka -- mailto:f...@bristle.com -- http://bristle.com/~fred/ Bristle Software, Inc -- http://bristle.com -- Glad to be of service! Open Source: Without walls and fences, we need no Windows or Gates. On 6/17/16 10:04 AM, 06use...@gmail.com wrote: My 2 cents : I have started learning Python and Django from scratch 15 months ago. I have bought 3 books which were VERY useful : 1) Two scoops of Django (Django 1.8) Daniel & Audrey Roy GreenFeld : very good introduction to the Django world 2) Django by Example (Antonio Melé) : excellent implementation of several real-world django projects (code can be dowloaded) 3) Beginning django CMS Nigel George : very good explanation of how to use Django CMS Cheers. -- 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/cd420c85-590b-4a87-aabb-954ec7189d10%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/f3f1925d-8e96-e057-7342-0be244afc326%40bristle.com. For more options, visit https://groups.google.com/d/optout.