View "functions" that are callables?
Hi, I'm surprised I don't know this, but: Can a view "function" in a urlconf be a callable that is not actually a function, such as a class with a __call__ method? -- 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/F70DCB4E-1307-42C2-AC62-CA2DC98DCD5B%40thebuild.com.
Re: URGENT: DJANGO & COPYRIGHT
> On Feb 1, 2024, at 07:02, Lightning Bit > wrote: > > Can one copyright an entire Django Project if it contains licensed code from > APIs? Or, does the copyrightable code only apply to exclusive algorithms > developed on the backend? A disclaimer: I am not a lawyer, and this is not legal advice. You cannot claim copyright on code that belongs to someone else. The Django code itself, and any Python libraries that you use, belong to someone else. You can claim copyright on code that you (or your organization) produced yourselves. The Django license is here: https://github.com/django/django/blob/main/LICENSE It allows you to *redistribute* Django's code assuming some conditions are met. That is not the same as claiming copyright on it. For other software tools that you might use, you will need to consult their licenses to determine if you are permitted to redistribute them. If you are planning a commercial product based around Django, especially one that includes other PyPI libraries, it's a good (almost mandatory) idea to have a lawyer review the licenses of the various components. You'll want a lawyer who is familiar with open source intellectual property issues. -- 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/056040B8-C0B9-4C23-A0CE-DEF8795ADE86%40thebuild.com.
Re: Error or stack trace redirection in Django
> On Jul 12, 2020, at 19:08, Ram wrote: > > If coding needs to be changed here to avoid stack trace on the user browsers, > what should be changed here? You have DEBUG = True; that will result in the debugging output you see. You shouldn't ever have it turned on for a production website. -- -- Christophe Pettus x...@thebuild.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/0BCA3B5B-7C4E-4D94-89DE-7B94A5C4B201%40thebuild.com.
Re: Async creation of models on form save
> On Aug 18, 2018, at 13:09, 'Alexander Halford' via Django users > wrote: > Is this possible, or am I barking up the wrong tree? It's certainly possible for a synchronous web request to trigger an async action; look at Celery, among other background task managers: http://www.celeryproject.org -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/99644396-B06E-40D6-8A3B-70DB804912A5%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: django models
> On Aug 7, 2018, at 10:14, Ramandeep Kaur wrote: > > My question is that how to delete models in django? Do you need to delete a model *class*, or a model *instance*? -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/6F27F93D-AD7C-4ACD-99A0-D940DF1BC87E%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: sqlite DB missed DEFAULT parameter from table definition
> On Aug 6, 2018, at 10:27, HEMENDRA SINGH HADA > wrote: > > Than How can I achieve my Goal with sqlite and Django ?? > Do you have any solution for that ?? You'll need to either: 1. Add the default to the database using a migration, either using Django's migration framework and the RunSQL migration, or outside of Django, or, 2. Specify the value you want inserted when inserting directly using SQL. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1D4890A9-0284-4E93-89A2-C699F3A788B6%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: sqlite DB missed DEFAULT parameter from table definition
> On Aug 6, 2018, at 10:19, HEMENDRA SINGH HADA > wrote: > > If I am giving is_active field with default value True, Then why its not > showing in "is_active" bool NOT NULL. Django "default=" defaults are implemented in Django, not in the database. Django does not currently set database-level defaults. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/53B45400-4245-44BC-8629-4C3EE66E96D6%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Django keeps object references in case of exception
> On Aug 3, 2018, at 07:23, claudio.cill...@gmail.com wrote: > > It seems to me this is a bug, but I'd like your opinions before actually > filing a bug report. I suspect what you are seeing there is a difference in garbage collection behavior. __del__ is not run immediately upon the reference count reaching 0; it's run when the object is garbage-collected, which can be some time later. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/DBEC950B-5D7E-4FD2-9055-23971FAF7193%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: JSON serializable error
> On Aug 3, 2018, at 07:18, Anusha Kommineni > wrote: > TypeError: datetime.datetime(2018, 2, 12, 0, 0, tzinfo=) is not JSON > serializable The error means what it says; there is no default way of serializing a datetime into JSON. You can use the DjangoJSONEncoder, which does allow serializing datetimes: https://docs.djangoproject.com/en/2.0/topics/serialization/#djangojsonencoder -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/DCF58620-3F8A-4121-A0FD-7CB3C1922531%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Optimizing Prefetch for Postgres IN Limit
> On Jul 25, 2018, at 02:59, Jason wrote: > > Where do you get that in the pg documentation? I can't find that anywhere > (google-fu may be failing me), and we do have some queries with more than 100 > values using IN. It's slightly more complicated than that. Above 100 entries, the PostgreSQL optimizer won't try to do optimizations of the form changing i IN (1, 2 ..., 101) to (i = 1) OR (i = 2) OR (i = 3)... to see if there's a better way of executing the query. It *can* still do an index scan in those cases, although the more entries in the IN list, the less efficient that will be. In general, large IN clauses aren't a great idea; they're better replaced with a join. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8A21227D-94A9-459F-89D0-771D3052C0C0%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: How to formulate a query over two models?
> On Apr 11, 2018, at 16:19, Mark Phillips <m...@phillipsmarketing.biz> wrote: > > Thanks for the link - I have read it before. I need to stay with these > models, so is there a simple query to get my result, or do I have to make > multiple queries and combine the data in python? If you are using PostgreSQL, you can do it as a raw SQL query; otherwise, you'll need to transform the data in Python. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/C504BED8-2CD3-4873-A1EB-E7AD00FA6353%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: How to formulate a query over two models?
> On Apr 11, 2018, at 16:05, Mark Phillips <m...@phillipsmarketing.biz> wrote: > > I have two models: > > # MetaData > # MetaData Value First, you might want to make sure this is *really* the best way of representing your data: http://karwin.blogspot.com/2009/05/eav-fail.html That being said, you might consider getting rid of the MetaDataValue table, and putting the values in as a JSON field on MetaData. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8B07A737-9B74-4389-8423-A6CD3C7BCA58%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: FOREIGN KEY constraint failed
> On Apr 7, 2018, at 12:27, DIlIMBEK TURANOV <dilim...@gmail.com> wrote: > File "/home/den/HTML_Projects/HTML5/test_project/orders/views.py" in checkout > 59. order = Order.objects.create(user=user, customer_name=name, > customer_phone=phone, status_id=1) You're most likely creating an Order object that has a foreign key, but that foreign key isn't properly set. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/EC168E4D-4BA0-4A20-BDF6-01333BB96C5B%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
tox?
On a Django-related project I maintain, someone's submitted a PR that includes a tox.ini file. I'll admit I've not used tox before; how standard is it for Django testing? I like the idea of being able to run tests against multiple versions in parallel, but I don't want to require a tool for testing unless it's very widely used. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5D5F6545-742C-4942-A86E-76359E82B057%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Unicode decoding error
> On Apr 12, 2017, at 02:26, Antonis Christofides > <anto...@djangodeployment.com> wrote: > >> Does this mean I should globally replace "str(" with "|six.text_type(" in a >> 2/3 codebase?| > I don't think so; afaiu this must be done for the return value of __str__(), > not > everywhere. The rules as I understand them are: 1. Define __str__(), not __unicode__() on classes. 2. Decorate your class with @python_2_unicode_compatible. 3. Always return six.text_type from your __str__() function. 4. When casting a class instance to text, use six.text_type(), and not str() (unicode() still works, but it's not Python 3). In Python 3, this is all a no-op: The __str__() method returns Python 3's string class, which is Unicode. In Python 2, the decorator uses your __str__() method for the class' __unicode__() method, and creates a new __str__() method that returns a Python 2 string (not unicode) object, UTF-8 encoded. Personally, I would prefer to use the Python 2 'unicode' type everywhere I can in Python 2, so casting everything to six.text_type (and use from __future__ import unicode_literals etc.) would do that. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/8519F123-1AF9-47A1-A9DC-97C8046AE373%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Unicode decoding error
Thanks, and thanks for accepting my documentation change suggestion! https://github.com/django/django/pull/8349 > On Apr 11, 2017, at 09:52, Tim Graham <timogra...@gmail.com> wrote: > > As documented you must return text and not bytes from __str__() when using > @python_2_unicode_compatible. That means six.text_type(self.a) rather than > str(self.a) (which returns bytes on Python 2). > > On Tuesday, April 11, 2017 at 11:18:02 AM UTC-4, Christophe Pettus wrote: > I've run into the issue described in the code below, where (as far as I can > tell) a natural use of __str__ in Python 2.7 results in a Unicode error. I'm > not quite sure how to write this code to work properly on both Python 2 and > Python 3; what am I missing? > > (Note this issue happens on Python 2.7 regardless of the presence of the > @python_2_unicode_compatible decorator.) > > Models: > > from django.db import models > from django.utils.encoding import python_2_unicode_compatible > > @python_2_unicode_compatible > class A(models.Model): > c = models.CharField(max_length=20) > > def __str__(self): > return self.c > > @python_2_unicode_compatible > class B(models.Model): > a = models.ForeignKey(A) > > def __str__(self): > return str(self.a) > > > Failure example: > > >>> from test.models import A, B > >>> a = A(c=u'répairer') > >>> a.save() > >>> a.id > 1 > >>> a1 = A.objects.get(id=1) > >>> a1 > > >>> b = B(a_id=1) > >>> b.save() > >>> b.id > 1 > >>> b1 = B.objects.get(id=1) > >>> b1 > > >>> print b1 > Traceback (most recent call last): > File "", line 1, in > File > "/Users/xof/Documents/Dev/environments/peep/lib/python2.7/site-packages/django/utils/six.py", > line 842, in > klass.__str__ = lambda self: self.__unicode__().encode('utf-8') > UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: > ordinal not in range(128) > > -- > -- Christophe Pettus >x...@thebuild.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 https://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/96a2e023-bf4b-4584-ae36-30e9d48c8927%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/F2B222CC-D9E4-41D0-92D9-82528B8338A7%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Unicode decoding error
I've run into the issue described in the code below, where (as far as I can tell) a natural use of __str__ in Python 2.7 results in a Unicode error. I'm not quite sure how to write this code to work properly on both Python 2 and Python 3; what am I missing? (Note this issue happens on Python 2.7 regardless of the presence of the @python_2_unicode_compatible decorator.) Models: from django.db import models from django.utils.encoding import python_2_unicode_compatible @python_2_unicode_compatible class A(models.Model): c = models.CharField(max_length=20) def __str__(self): return self.c @python_2_unicode_compatible class B(models.Model): a = models.ForeignKey(A) def __str__(self): return str(self.a) Failure example: >>> from test.models import A, B >>> a = A(c=u'répairer') >>> a.save() >>> a.id 1 >>> a1 = A.objects.get(id=1) >>> a1 >>> b = B(a_id=1) >>> b.save() >>> b.id 1 >>> b1 = B.objects.get(id=1) >>> b1 >>> print b1 Traceback (most recent call last): File "", line 1, in File "/Users/xof/Documents/Dev/environments/peep/lib/python2.7/site-packages/django/utils/six.py", line 842, in klass.__str__ = lambda self: self.__unicode__().encode('utf-8') UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 1: ordinal not in range(128) -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/E6F66BA4-490C-4B7A-A6AB-07BB52B49C2E%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Why was Roberto Rosario silently removed from the Django Software Foundation?
Also speaking as a member of the Board, if anyone feels that they have not received fair treatment by any Django-related organization, we encourage them to contact the board directly so that the matter can be looked into. > On Nov 12, 2016, at 12:01, James Bennett <ubernost...@gmail.com> wrote: > > *puts on DSF Director hat* > > Hi, > > The Board of Directors of the Django Software Foundation is unaware of any > "expulsion" or similar action taken against the person you've named. It seems > likely that you, or whomever told you of it, have been misinformed. > > *takes off DSF Director hat* > > -- > 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/CAL13Cg-DKLw%2BjrxAbBz-hKHSOPuoYVzVXXMEhNG79djbFKsByg%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/A22B2014-9D00-4F4D-9ACB-0688972EAA59%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Sharing apps across sites
Even experts have basic questions sometimes... :) So, I am starting on a project that is different from my usual Django work. In brief, it will be a single database with three separate sites in front of it. The underlying Django implementation will have a significant number of apps in common, with some apps separate. They will share some view functions, while having separate urlconfs, templates, static files, etc. The sites framework is obviously designed for this, but I'm wondering how to structure the actual code: -- One directory and VCS repository, with separate "project" packages for each one within it, and different manage.py's (renamed) for each one. The shared apps and the separate apps would all live at the same level, so it would be something like: root/ shared-app-1/ shared-app-2/ site-a-app/ site-b-app/ site-c-app/ site-a-manage.py site-a/ url.py site-b-manage.py/ ... etc. -- Independent VCS repositories, with the shared apps as submodules or something like that. Thoughts? -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9546A517-78CC-4207-9845-9778E638E017%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Extracting the username:password from the host
On Sep 12, 2016, at 12:40 PM, Carl Meyer <c...@oddbird.net> wrote: > Yes, it should be in `request.META['HTTP_AUTHORIZATION']`; see > https://www.djangosnippets.org/snippets/243/ for an example. ... and now it works. OK, clearly, either me or the server need more coffee. Thank you! -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/276ABF19-EBAE-43D4-8DAC-0D3088E9DCCB%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Extracting the username:password from the host
I've encountered a service that does postbacks as part of its API. The only authentication mechanism is putting the username and password in the POST URL in the form: https://user:p...@example.com/api/endpoint Is there a portable way of extracting that information from the request object? -- -- Christophe Pettus x...@thebuild.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 https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/83CD6EA1-A315-4395-96AC-106DF438AE5A%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Is there a way to make the template process {{ MEDIA_URL }} if it is stored in a model field.
On Aug 30, 2015, at 2:37 PM, Christophe Pettus <x...@thebuild.com> wrote: > On Aug 30, 2015, at 12:43 PM, Dennis Marwood <dennismarw...@gmail.com> wrote: > >> How do I get the template to treat {{ }} in my entry as a variable? > > The Django template language doesn't iterate over the results of expansion; > once a substitution is done, it moves on. So, template language constructs > that "appear" in the result due to variable expansion. As a note, this is a feature, not a bug: If template expansion iterated like that, it would be a serious security hole, since someone could drop template items ( {{ entry.delete }}, anyone?) into user-edited content. -- 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/7995C1A8-4DAB-4E59-B661-325D93A8E9AB%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Is there a way to make the template process {{ MEDIA_URL }} if it is stored in a model field.
On Aug 30, 2015, at 12:43 PM, Dennis Marwood <dennismarw...@gmail.com> wrote: > How do I get the template to treat {{ }} in my entry as a variable? The Django template language doesn't iterate over the results of expansion; once a substitution is done, it moves on. So, template language constructs that "appear" in the result due to variable expansion You could do this by building the template up programmatically, and then passing the output of that process to the appropriate render method. You could also (probably better) write a custom template tag that does the right thing. -- -- Christophe Pettus x...@thebuild.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/524E4D09-5384-41BF-A43D-4C650944C53F%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: "RuntimeError: Error creating new content types."
Well, django_content_type.name definitely in my database. :) This is a project that was migrated from 1.6. The underlying exception was a null value complaint about django_content_type.name; it appears as though (on the production database) it thought that the migration to remove had been applied, but in fact had not been. On Apr 17, 2015, at 1:25 PM, Tim Graham <timogra...@gmail.com> wrote: > The contenttypes name column was removed in Django 1.8. Could you retrieve > the underlying exception before the RuntimeError is raised? > > On Friday, April 17, 2015 at 2:55:07 PM UTC-4, Christophe Pettus wrote: > Digging into this a bit more, the specific exception is that it is trying to > insert a contenttypes row with a null 'name' value. > > The code in question is doing a get_or_create() on the contenttype object. I > assume it should be picking up the name from the name @property on the > ContentType model, but I don't see that ever actually being called. > > > On Apr 17, 2015, at 11:24 AM, Christophe Pettus <x...@thebuild.com> wrote: > > > On Django 1.8, I'm encountering this error when attempting to apply > > migrations on the production system. What's interesting is that it works > > fine on the dev system, and inspecting the django_migrations table, I don't > > see any (meaningful) differences between them (error text below). > > > > There was a model added to the "catalog" application which is not being > > created in django_content_type. > > > > Manually migrating contenttypes individually generates the same error. > > > > -- > > > > $ python manage.py migrate > > Operations to perform: > > Synchronize unmigrated apps: staticfiles, util, treebeard, messages, > > office > > Apply all migrations: info, customers, sessions, admin, contenttypes, > > auth, sites, catalog, coming_soon, orders > > Synchronizing apps without migrations: > > Creating tables... > >Running deferred SQL... > > Installing custom SQL... > > Running migrations: > > Rendering model states... DONE > > Applying auth.0006_require_contenttypes_0002... OK > > Traceback (most recent call last): > > File "manage.py", line 10, in > >execute_from_command_line(sys.argv) > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/__init__.py", > > line 338, in execute_from_command_line > >utility.execute() > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/__init__.py", > > line 330, in execute > >self.fetch_command(subcommand).run_from_argv(self.argv) > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/base.py", > > line 390, in run_from_argv > >self.execute(*args, **cmd_options) > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/base.py", > > line 441, in execute > >output = self.handle(*args, **options) > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", > > line 225, in handle > >emit_post_migrate_signal(created_models, self.verbosity, > > self.interactive, connection.alias) > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/sql.py", > > line 280, in emit_post_migrate_signal > >using=db) > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", > > line 201, in send > >response = receiver(signal=self, sender=sender, **named) > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", > > line 82, in create_permissions > >ctype = ContentType.objects.db_manager(using).get_for_model(klass) > > File > > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", > > line 78, in get_for_model > >"Error creating new content types. Please make sure contenttypes " > > RuntimeError: Error creating new content types. Please make sure > > contenttypes is migrated before trying to migrate apps individually. > > -- > > -- Christophe Pettus > > x...@thebuild.com > > > > -- > > You received this message because you are subscribed to the Google Groups > &g
Re: "RuntimeError: Error creating new content types."
Digging into this a bit more, the specific exception is that it is trying to insert a contenttypes row with a null 'name' value. The code in question is doing a get_or_create() on the contenttype object. I assume it should be picking up the name from the name @property on the ContentType model, but I don't see that ever actually being called. On Apr 17, 2015, at 11:24 AM, Christophe Pettus <x...@thebuild.com> wrote: > On Django 1.8, I'm encountering this error when attempting to apply > migrations on the production system. What's interesting is that it works > fine on the dev system, and inspecting the django_migrations table, I don't > see any (meaningful) differences between them (error text below). > > There was a model added to the "catalog" application which is not being > created in django_content_type. > > Manually migrating contenttypes individually generates the same error. > > -- > > $ python manage.py migrate > Operations to perform: > Synchronize unmigrated apps: staticfiles, util, treebeard, messages, office > Apply all migrations: info, customers, sessions, admin, contenttypes, auth, > sites, catalog, coming_soon, orders > Synchronizing apps without migrations: > Creating tables... >Running deferred SQL... > Installing custom SQL... > Running migrations: > Rendering model states... DONE > Applying auth.0006_require_contenttypes_0002... OK > Traceback (most recent call last): > File "manage.py", line 10, in >execute_from_command_line(sys.argv) > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/__init__.py", > line 338, in execute_from_command_line >utility.execute() > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/__init__.py", > line 330, in execute >self.fetch_command(subcommand).run_from_argv(self.argv) > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/base.py", > line 390, in run_from_argv >self.execute(*args, **cmd_options) > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/base.py", > line 441, in execute >output = self.handle(*args, **options) > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", > line 225, in handle >emit_post_migrate_signal(created_models, self.verbosity, self.interactive, > connection.alias) > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/sql.py", > line 280, in emit_post_migrate_signal >using=db) > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", > line 201, in send >response = receiver(signal=self, sender=sender, **named) > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", > line 82, in create_permissions >ctype = ContentType.objects.db_manager(using).get_for_model(klass) > File > "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", > line 78, in get_for_model >"Error creating new content types. Please make sure contenttypes " > RuntimeError: Error creating new content types. Please make sure contenttypes > is migrated before trying to migrate apps individually. > -- > -- Christophe Pettus > x...@thebuild.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/84FEBC7D-9A57-47FA-9429-A834A2F03021%40thebuild.com. > For more options, visit https://groups.google.com/d/optout. -- -- Christophe Pettus x...@thebuild.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/A15A2A1E-8284-4119-ABF7-D0FB42480224%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
"RuntimeError: Error creating new content types."
On Django 1.8, I'm encountering this error when attempting to apply migrations on the production system. What's interesting is that it works fine on the dev system, and inspecting the django_migrations table, I don't see any (meaningful) differences between them (error text below). There was a model added to the "catalog" application which is not being created in django_content_type. Manually migrating contenttypes individually generates the same error. -- $ python manage.py migrate Operations to perform: Synchronize unmigrated apps: staticfiles, util, treebeard, messages, office Apply all migrations: info, customers, sessions, admin, contenttypes, auth, sites, catalog, coming_soon, orders Synchronizing apps without migrations: Creating tables... Running deferred SQL... Installing custom SQL... Running migrations: Rendering model states... DONE Applying auth.0006_require_contenttypes_0002... OK Traceback (most recent call last): File "manage.py", line 10, in execute_from_command_line(sys.argv) File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line utility.execute() File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 330, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/base.py", line 390, in run_from_argv self.execute(*args, **cmd_options) File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/base.py", line 441, in execute output = self.handle(*args, **options) File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 225, in handle emit_post_migrate_signal(created_models, self.verbosity, self.interactive, connection.alias) File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/core/management/sql.py", line 280, in emit_post_migrate_signal using=db) File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 201, in send response = receiver(signal=self, sender=sender, **named) File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py", line 82, in create_permissions ctype = ContentType.objects.db_manager(using).get_for_model(klass) File "/home/tbc/environments/fugu/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 78, in get_for_model "Error creating new content types. Please make sure contenttypes " RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually. -- -- Christophe Pettus x...@thebuild.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/84FEBC7D-9A57-47FA-9429-A834A2F03021%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Call for Papers for Djangocon US 2014 *extended*
Greetings, The Call for Papers for Djangocon US 2014 has been extended through July 15, 2014. (The web site still shows the old date, but will be updated shortly.) Please share what you know with us! http://djangocon.us/ Best, -- -- Christophe Pettus x...@thebuild.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/B574574F-754C-4626-A8CF-B79CAC5AD1CE%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
The DjangoCon US 2014 CfP is open.
The short version: Go here. Send us papers: http://www.djangocon.us/call_for_proposals/ Djangocon US is back in its home of Portland, Oregon for 2014, and we would like to get your contributions! We are looking for talk proposals (25 minutes, 45 minutes, and tutorials) from the entire Django community. The CfP closes June 28th (soon!), so please get us your wonderful ideas. -- -- Christophe Pettus x...@thebuild.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/2246675A-839F-40B6-876F-9FF4AA5ED23D%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Enumerating objects in foreign key in the admin
Brilliant, thank you! On May 30, 2014, at 10:23 PM, Russell Keith-Magee <russ...@keith-magee.com> wrote: > Hi Christophe, > > The built-in way to handle this is to add a `raw_id_fields` declaration to > your ModelAdmin or Inline definition. This will replace the pulldown select > widget (populated with every possible value) with a single text input that > stores the primary key of the related object, plus a popup that makes it easy > (well... easier) to find the right PK. > > https://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields > > Of course, a custom widget might give you a better UI, but if you're just > looking to make it work and not drag the rendering of the admin UI page to a > crawl, it works. > > Yours, > Russ Magee %-) > > On Sat, May 31, 2014 at 1:17 PM, Christophe Pettus <x...@thebuild.com> wrote: > Right now, when one has a foreign key field in a detail page in the admin, it > appears to enumerate the objects (one at a time) in order to build the > pop-up. Obviously, if the other side of the foreign key relationship has a > lot of entries, this can be a problem. Short of doing a different, custom > widget, is there a way to avoid this? > -- > -- Christophe Pettus >x...@thebuild.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/DBC6EF68-4DE3-432B-9237-D3973D80825F%40thebuild.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 http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAJxq84-ZxjTnJD%2B0jVGkYstK%3DeHV-nbj0gXYOmkCE_%2B7VnHgeQ%40mail.gmail.com. > For more options, visit https://groups.google.com/d/optout. -- -- Christophe Pettus x...@thebuild.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/0DBAA859-A9B9-4BCA-B8A5-B5B60EB0F911%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Enumerating objects in foreign key in the admin
Right now, when one has a foreign key field in a detail page in the admin, it appears to enumerate the objects (one at a time) in order to build the pop-up. Obviously, if the other side of the foreign key relationship has a lot of entries, this can be a problem. Short of doing a different, custom widget, is there a way to avoid this? -- -- Christophe Pettus x...@thebuild.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/DBC6EF68-4DE3-432B-9237-D3973D80825F%40thebuild.com. For more options, visit https://groups.google.com/d/optout.
Re: Django Periodic tasks
On Aug 16, 2013, at 7:36 PM, Some Developer wrote: > Alternately I could get rid of the hourly period task and just work it out > when a customer visits a certain page but that is likely to lead to long load > times and heavy database use. > > Any suggestions on what you would do in this situation? Calculate the value on demand, and cache it with an expiration time, most likely. -- -- Christophe Pettus x...@thebuild.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.
Re: Do we need to setup Database Settings before Using Admin feature in Django?
On Aug 14, 2013, at 11:31 AM, Harmeet Singh wrote: > Can we use the built in ADMIN feature in Django by just configuring > 'django.contrib.admin' under INSTALLED_APPS in settings.py file without > configuring DATABASES settings ? No. In fact, it's not clear what good the Django admin would be without a database to use. The admin works on your Model classes, so it needs a database, and the database tables that correspond to the Model objects, already created. -- -- Christophe Pettus x...@thebuild.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.
Re: Managing transactions using multiple databases
On Jul 6, 2013, at 8:58 PM, Leandro Boscariol wrote: > And also thanks for mentioning xact, I wasn't aware of that! Full disclosure: I wrote it. :) In 1.6, the new atomic() decorator / context manager is the way to go, but xact() works fine for now! -- -- Christophe Pettus x...@thebuild.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.
Re: Managing transactions using multiple databases
On Jul 6, 2013, at 2:54 PM, Leandro Boscariol wrote: > How can I do a transaction management in both databases at the same time? Is > that even possible? You can certainly nest the transaction context managers (atomic() in 1.6+, or you can use xact() in 1.5 and earlier): with xact(using=DATABASE1): with xact(using=DATABASE2): things If an exception occurs, it will rollback both; if it exits normally, it will commit both. Note that this isn't true two-phase commit; it's perfectly possible for the inner transaction to successfully commit but the outer one to fail. If you want proper two-phase commit, you'll (at the moment, at least) have to roll your own. -- -- Christophe Pettus x...@thebuild.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.
Re: Ajax
It's also not clear to me what "(not) supporting Ajax" would even mean. Ajax just sends HTTP requests, and the server responds to them (usually with JSON structures). I have tons of Ajax applications that use Django as the backend, so if it doesn't support it, no one tell that code lest it stop working. :-) On Jun 29, 2013, at 12:05 PM, Russell Keith-Magee wrote: > > Can you provide a little more direction than "The website"? "The website" is > a kinda big place… :-) > > Yours, > Russ Magee %-) > > On Sat, Jun 29, 2013 at 2:08 PM, Gamesbrainiac <gamesbrain...@gmail.com> > wrote: > Then why does itsay on the website that Django does not support Ajax natively? > > On Jun 29, 2013 12:03 PM, "Russell Keith-Magee" <russ...@keith-magee.com> > wrote: > > I'm not sure what you mean. Django completely supports AJAX right now. > > Django is a server-side framework, and the only part of AJAX that is > server-side is the API call. > > An API call is just a view that returns JSON/XML instead of HTML. You can > write that right now in Django. > > If you want a library to make it even easier, there are several options, > including TastyPie and Django-REST-Framework. > > The client-side part of the AJAX problem is outside the domain of Django. > There are plenty of good client-side frameworks; pick one, and you'll find it > can talk perfectly well with Django. > > Yours, > Russ Magee %-) > > On Sat, Jun 29, 2013 at 1:52 PM, Nafiul Islam <gamesbrain...@gmail.com> wrote: > In which version, will Django natively support Ajax? I'm curious because you > need Ajax for almost any site these days, and Django not supporting it > natively has become a bit of a hindrance for me. > > -- > 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. > > > > > -- > 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/2oaiisZw_ZY/unsubscribe. > To unsubscribe from this group and all its topics, 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. > > > > -- > 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. > > > > > -- > 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. > > -- -- Christophe Pettus x...@thebuild.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.
Re: How to have two unicode methods in the models?
On Jun 25, 2013, at 6:54 PM, yeswanth nadella wrote: > How do I add another unicode method so that it will return only first_name > and last_name? You can have as many methods in a model class as you wish, of course, but you can only have one __unicode__, since that's what handles unicode() and str() calls. In those situations, I just create a new method with an appropriate name. -- -- Christophe Pettus x...@thebuild.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.
DjangoCon. US CFP extended
Hi, all, We're extending the CFP for DjangoCon US 2013 through 6/25, since there was a last-minute burst of activity. We are still looking for talks and tutorials; first-time presenters particularly encouraged to participate! The URL is: http://www.djangocon.us/cfp/ (The site is being updated shortly, but if it still says 6/18, don't worry.) Thanks, -- -- Christophe Pettus x...@thebuild.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.
DjangoCon US CFS closes 6/18
Hi, all, Just a gentle reminder that the DjangoCon US Call for Submissions ends June 18th. Thanks! http://www.djangocon.us/cfp/ -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: ORM Prefetch related and only()
On May 29, 2013, at 12:44 PM, Àlex Pérez wrote: > You know the way to simulate the behaviour that i want.? Raw SQL. At the point you are doing a multi-join query and selecting a subset of the fields to be returned, you probably should switch to raw SQL anyway. -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Object Lookup after Save
Well, Django works. :) I'd strongly suggest examining the data at the database layer to see if you are getting the interaction with the database you expect; you might try bringing it up in a test environment and see if you can reproduce it there. On May 28, 2013, at 1:45 PM, Chris Conover wrote: > No, we are not using the TransactionMiddleware. We are using the following > Django middlewares: CommonMiddleware, SessionMiddleware, MessageMiddleware, > and XFrameOptionsMiddleware. We have a few custom middlewares which handle > stuff for the edge caching. Nothing that produces any writes to MySQL. We are > also using Django Reversion which has a middleware. I'm looking at the > underlying code of that middleware to see if that would cause an issue. The > model that is being saved and submitted to the background task is not under > revision control. > > On Tuesday, May 28, 2013 4:31:08 PM UTC-4, Christophe Pettus wrote: > > On May 28, 2013, at 1:26 PM, Chris Conover wrote: > > > # no middleware that does any writes > > Are you using the Transaction Middleware? > > -- > -- Christophe Pettus >x...@thebuild.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?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Object Lookup after Save
On May 28, 2013, at 1:26 PM, Chris Conover wrote: > # no middleware that does any writes Are you using the Transaction Middleware? -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Object Lookup after Save
On May 28, 2013, at 12:20 PM, Chris Conover wrote: > Well, you can inspect the object and see it's primary key. Surely that means > the INSERT is completed? That shows the INSERT is completed, but it doesn't show that any enclosing transaction has committed; that's what the database logs will show you. It's very unlikely that this is a bug in Django or MySQL; those are very well-trod paths in those two applications. -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Object Lookup after Save
I'll admit my MySQL skills are a bit rusty, but can you examine the database logs to confirm that the session is in fact doing the INSERT and a commit before the SELECT? On May 28, 2013, at 10:52, Chris Conover <clc...@gmail.com> wrote: > It's not really feasible to move this project to PostgreSQL. > > I honestly just don't understand the problem. According to the Django > documentation, the ORM functions in autocommit mode by default. In other > words, the changes should be committed as soon as the query is complete, > right? So after an INSERT, you should be able to do a SELECT and the data > should be available. In the code written, the SELECT is definitely coming > after the INSERT. The code is not complex. I'm setting up a local test to > simulate the load on the production system to see if I can reproduce the > issue. > > On Tuesday, May 28, 2013 1:33:10 PM UTC-4, Christophe Pettus wrote: >> >> In the meantime, you can use this: >> >> https://github.com/Xof/xact >> >> On May 28, 2013, at 10:29, Chris Conover <clc...@gmail.com> wrote: >> >>> That seems to only be available in the dev version of Django (now 1.6 >>> alpha). >>> >>> On Wednesday, May 22, 2013 4:43:29 AM UTC-4, Christian Schmitt wrote: >>>> >>>> if you want transactions you need to do : >>>> >>>> with transaction.atomic(): >>>> >>>> like described here: >>>> https://docs.djangoproject.com/en/dev/topics/db/transactions/ >>>> >>>> Am Mittwoch, 22. Mai 2013 10:40:15 UTC+2 schrieb Christian Schmitt: >>>>> >>>>> In Django the normal behavior should be that when you do a save() it will >>>>> automatically commit() your query's to the database. >>>>> so that in obj.save() you should just could access the pk with obj.id >>>>> after you did a obj.save(). >>>>> If you want to maybe stop the commit you need to do a obj = >>>>> obj.save(commit=False), then you could add some things to your obj and >>>>> commit/save it later. >>>>> But as i understood you already do a obj.save() but it doesn't commit >>>>> correctly? Maybe you should just try a PostgreSQL database for testing, >>>>> since I'm not having trouble looking up objects after i saved it. >>>>> >>>>> I often do things like: >>>>> obj.save() >>>>> return HttpResponseRedirect(reverse('view', {'pk': obj.id})) >>>>> and i never run into any exception >>>>> >>>>> >>>>> Am Dienstag, 21. Mai 2013 23:20:53 UTC+2 schrieb Chris Conover: >>>>>> >>>>>> Calling transaction.commit() after object.save results in a >>>>>> TransactionManagementError. I mentioned at the end that I am using MySQL >>>>>> (5.5.27). The issue is not that the Gearman workers are having trouble >>>>>> saving their transactions, it's that they are having trouble looking up >>>>>> the incoming object. I'm assuming the view and workers are separate >>>>>> transactions since I don't see how they could be connected -- though I'm >>>>>> looking into this. >>>>>> >>>>>> On Tuesday, May 21, 2013 1:05:54 PM UTC-4, Tom Evans wrote: >>>>>>> >>>>>>> On Tue, May 21, 2013 at 4:23 PM, Chris Conover <clc...@gmail.com> >>>>>>> wrote: >>>>>>> > Hello, >>>>>>> > >>>>>>> > I'm having an issue looking up objects immediately after they are >>>>>>> > saved and >>>>>>> > am wondering if anyone has any advice on how to address the problem. >>>>>>> > Specifically, I'm saving an object in a view (nothing fancy, a simple >>>>>>> > save()) and then kicking off a Gearman task to do some operations on >>>>>>> > that >>>>>>> > saved object in the background. I pass the newly created object's PK >>>>>>> > as data >>>>>>> > to the Gearman worker which then does a simple >>>>>>> > Objects.objects.get(pk=PK). >>>>>>> > However, almost all of the time this lookup operation fails with an >>>>>>> > DoesNotExist exception. I believe the problem has to do with >>>>>>> > tr
Re: Object Lookup after Save
In the meantime, you can use this: https://github.com/Xof/xact On May 28, 2013, at 10:29, Chris Conoverwrote: > That seems to only be available in the dev version of Django (now 1.6 alpha). > > On Wednesday, May 22, 2013 4:43:29 AM UTC-4, Christian Schmitt wrote: >> >> if you want transactions you need to do : >> >> with transaction.atomic(): >> >> like described here: >> https://docs.djangoproject.com/en/dev/topics/db/transactions/ >> >> Am Mittwoch, 22. Mai 2013 10:40:15 UTC+2 schrieb Christian Schmitt: >>> >>> In Django the normal behavior should be that when you do a save() it will >>> automatically commit() your query's to the database. >>> so that in obj.save() you should just could access the pk with obj.id after >>> you did a obj.save(). >>> If you want to maybe stop the commit you need to do a obj = >>> obj.save(commit=False), then you could add some things to your obj and >>> commit/save it later. >>> But as i understood you already do a obj.save() but it doesn't commit >>> correctly? Maybe you should just try a PostgreSQL database for testing, >>> since I'm not having trouble looking up objects after i saved it. >>> >>> I often do things like: >>> obj.save() >>> return HttpResponseRedirect(reverse('view', {'pk': obj.id})) >>> and i never run into any exception >>> >>> >>> Am Dienstag, 21. Mai 2013 23:20:53 UTC+2 schrieb Chris Conover: Calling transaction.commit() after object.save results in a TransactionManagementError. I mentioned at the end that I am using MySQL (5.5.27). The issue is not that the Gearman workers are having trouble saving their transactions, it's that they are having trouble looking up the incoming object. I'm assuming the view and workers are separate transactions since I don't see how they could be connected -- though I'm looking into this. On Tuesday, May 21, 2013 1:05:54 PM UTC-4, Tom Evans wrote: > > On Tue, May 21, 2013 at 4:23 PM, Chris Conover wrote: > > Hello, > > > > I'm having an issue looking up objects immediately after they are saved > > and > > am wondering if anyone has any advice on how to address the problem. > > Specifically, I'm saving an object in a view (nothing fancy, a simple > > save()) and then kicking off a Gearman task to do some operations on > > that > > saved object in the background. I pass the newly created object's PK as > > data > > to the Gearman worker which then does a simple > > Objects.objects.get(pk=PK). > > However, almost all of the time this lookup operation fails with an > > DoesNotExist exception. I believe the problem has to do with > > transactions. > > Namely, the read in the Gearman worker is happening before the write > > from > > the view is committed to the database. I've tried several things > > including > > refactoring the saving code to be wrapped in a > > @transaction.commit_on_success block, moving the worker submission to > > post_save and adding a long delay before the Gearman worker does the > > lookup. > > Nothing really seems to solve the problem completely. Even with a 60 > > second > > delay, the lookup fails with some frequency. Am I missing something > > here? Is > > there some Django query cache that I can clear? Or should I just > > rewrite all > > this to just to use a look-back perspective. > > > > The stack is Django 1.4 connecting to MySQL 5.5.27. Django is handling > > 200-1000 requests per second and the database is handling about double > > that. > > > > Thanks, > > Chris > > from django import transaction > … > obj.save() > transaction.commit() > task.submit(obj.id) > > You will also need to make sure that gearman is doing things correctly > as well. You haven't mentioned what database you are using, but if > gearman's DB connection is in a read repeated mode, you can do > whatever you like in django but you won't see new data in gearman > until gearman's current transaction is committed. > > Cheers > > Tom > -- > 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
DjangoCon US 2013 CFP is open
Hi, all, The Call for Proposals for DjangoCon US 2013 is now open! We encourage everyone, regardless of speaking experience, to submit a proposal. We're particularly interested this year in hands-on experiences and case-studies: http://www.djangocon.us/cfp/ Thanks! -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Understanding Django transactions
On May 21, 2013, at 12:43 PM, Aymeric Augustin wrote: > Anyway, in this scenario, `atomic` will work as expected. When autocommit is > off, you're always in a transaction, and as a consequence `atomic` uses > savepoints to guarantee atomicity; it'll never commit. You have to call > transaction.commit() at some point to save changes. Just to clarify, `atomic` will commit in this scenario: with atomic: my_model_object.save() You don't have to explicitly call transaction.commit() to issue a commit after the .save(), correct? -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Django 1.6 Connection Pooler
On May 17, 2013, at 12:57 AM, Joe Jasinski wrote: > So I hear that Django 1.6 will ship with a connection pooler built in, which > is awesome. Does this remove the need to have a stand-alone service such as > pgbouncer, or am I misunderstanding how the new built-in connection will > work? Aymeric can give the definitive story, but in my view it's a very handy component, but doesn't (and wasn't intended to) replace a stand-alone connection pooler. The 1.6 connection pool solves the issue of Django opening a new connection on each request by reusing connections at the thread level. It doesn't share connections across multiple processes in the same machine, for example, nor across application servers. For that, you need a stand-alone pooler. It also doesn't help the common problem of multiplexing a lot of potential application-side connections down to the number of active server-side connections that the database server can actually handle. And, of course, if you're using the advanced features of (say) pgPool II, there's a lot of stuff that an app-side pool won't help. So, it's a great and very useful feature, but a stand alone pooler definitely has a role still. -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: How to get ten random records
On Mar 18, 2013, at 9:03 PM, Mike Dewhirst wrote: > No really, I want a maximum of ten random records from the database (Django > 1.4, Postgres 9.1). This is a case where the raw SQL interface might be the right answer: you can just tack an ORDER BY random() clause onto the query. -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: PostgresSQL or MySql with django?
On Mar 18, 2013, at 4:50 PM, Russell Keith-Magee wrote: > Summary - if you issue a SELECT query that contains an "WHERE X IS NONE" > clause, and nothing matches the SELECT, and an object was inserted by the > last statement, the SELECT query returns *the primary key of the object that > was recently inserted*, not an empty result set. Anyone who can rationalize > this behavior without resorting to medicinal grade hallucinogens wins a shiny > new penny. You know what's great? There's lots of code out there that expects this behavior. In fact, there are (sometimes) complaints from people moving from MySQL that PostgreSQL doesn't work that way. I weep for humanity. -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: A question about template fragment caching
On Feb 16, 2013, at 9:16 AM, Christophe Pettus wrote: > > On Feb 16, 2013, at 8:50 AM, ozgur yilmaz wrote: > >> I'm using template fragment caching in my project. I'm wondering what >> the view function do when template fragment caching is active? Are >> queries in the view function be executed? Or bypass the queries and >> read the cached fragment? > > The view function is not bypassed when template fragment caching is active. > Thus, if you do a bunch of expense queries to populate the context, those > queries will still happen; the only step that is skipped is the actual > rendering of the template. It's often a good idea to have those expense > queries be done on-demand in a callable that is invoked by the template, so > they are only called when the template is actually rendered. Of course, QuerySets are (usually) lazy, so if you pass them in to the template via the context unevaluated, and that fragment of the template is cached, the query won't be executed. -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: A question about template fragment caching
On Feb 16, 2013, at 8:50 AM, ozgur yilmaz wrote: > I'm using template fragment caching in my project. I'm wondering what > the view function do when template fragment caching is active? Are > queries in the view function be executed? Or bypass the queries and > read the cached fragment? The view function is not bypassed when template fragment caching is active. Thus, if you do a bunch of expense queries to populate the context, those queries will still happen; the only step that is skipped is the actual rendering of the template. It's often a good idea to have those expense queries be done on-demand in a callable that is invoked by the template, so they are only called when the template is actually rendered. -- -- Christophe Pettus x...@thebuild.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?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: Help me choose OS for django server
On Oct 31, 2012, at 12:41 PM, Javier Guerra Giraldez wrote: > maybe, maybe not. the point is that H.264 is not free, not gratis, > not open. If you are streaming H.264-encoded video free to end users, you don't have to pay fees, and will never have to: http://www.mpegla.com/Lists/MPEG%20LA%20News%20List/Attachments/231/n-10-08-26.pdf If you are changing end users, there are potentially fees, but they are quite modest: http://www.mpegla.com/main/programs/AVC/Documents/AVC_TermsSummary.pdf -- -- Christophe Pettus x...@thebuild.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: Reverse and kwargs...
On Oct 29, 2012, at 5:06 PM, Lachlan Musicman wrote: > Your solution made it work, and I'm a doofus. Let he who is without having spent the entire day looking for a punctuation error in code cast the first stone. :) -- -- Christophe Pettus x...@thebuild.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: Reverse and kwargs...
On Oct 29, 2012, at 4:52 PM, Lachlan Musicman wrote: > Could you please expand on your answer for a beginner? student-reports in the reverse call vs student_reports in the url() definition? -- -- Christophe Pettus x...@thebuild.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: Reverse and kwargs...
- vs _ ? On Oct 29, 2012, at 4:38 PM, Lachlan Musicman wrote: > On Tue, Oct 30, 2012 at 11:14 AM, Nikolas Stevenson-Molnar > <nik.mol...@consbio.org> wrote: >> You're close. Your reverse calls should be: >> >> return redirect(reverse('student-reports', kwargs={'year': year})) > > Thanks - that makes sense. I might have even done that previously, but > I am still getting errors - I must have mistakenly attributed the > error. > > New error is: > Exception Type: NoReverseMatch > Exception Value: Reverse for 'student-reports' with arguments '()' and > keyword arguments '{'year': 2013}' not found. > > but my urls.py includes these lines: > url(r'^students/reports/$', student_reports, name='student_reports'), > url(r'^students/reports/(?P\d{4})/$', student_reports, > name='student_reports'), > > > and the view: > def student_reports(request, year=None): >year = year or datetime.date.today().year > ... > > What am I doing wrong now? > > Cheers > L. > >> >> >> _Nik >> >> On 10/29/2012 4:11 PM, Lachlan Musicman wrote: >>> Hi, >>> >>> I'm struggling to get the syntax right for a url reverse function. >>> >>> I have a form that asks for a Model type (ChoiceField with strings) >>> and a year (CharField). >>> >>> The logic then if/elifs the ChoiceField and then redirects to the >>> appropriate report page (for statistics on the Model type), with an >>> optional year. I've got the urls and the views working, but passing >>> the year arg to the view via the reverse function is not obvious to >>> me, and nothing I've tried seems to work? >>> >>> example code: >>> forms.py >>> class ReportRequestForm(forms.Form): >>>DATA_TYPES = >>> ((1,'Students'),(2,'Enrolments'),(3,'Applicants'),(4,'Staff'),(5,'Results')) >>>year = forms.CharField(max_length=4) >>>data_type = forms.ChoiceField(choices=DATA_TYPES) >>> >>> views.py >>>def ReportRequestForm(self): >>>... >>>if form.is_valid(): >>> year = int(form.cleaned_data['year']) >>> data_type = form.cleaned_data['data_type'] >>> if data_type == '1': >>>return redirect(reverse('student-reports',{year=year,})) >>> elif data_type == '2': >>>return redirect(reverse('applicant-reports',{year=year,})) >>> elif data_type == '3': >>>return redirect(reverse('enrolment-reports',{year=year,})) >>> elif data_type == '4': >>>return redirect(reverse('staff-reports',{year=year,})) >>> >>> >>> What is the correct syntax? >>> >>> Cheers >>> L. >>> >> >> -- >> 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. >> > > > > -- > ...we look at the present day through a rear-view mirror. This is > something Marshall McLuhan said back in the Sixties, when the world > was in the grip of authentic-seeming future narratives. He said, “We > look at the present through a rear-view mirror. We march backwards > into the future.” > > http://www.warrenellis.com/?p=14314 > > -- > 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. > -- -- Christophe Pettus x...@thebuild.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: Append only tables/models
On Oct 25, 2012, at 8:26 AM, Mike Burr wrote: > I know there are DBMS-specific ways of doing this. I know that there > are Django ways of making fields read-only. What I cannot find is a > way to make a table/model append-only. You can always override the .save() method to check to see if the pk field is None, and refuse to save if it is not: https://docs.djangoproject.com/en/1.4/topics/db/models/#overriding-predefined-model-methods That being said, this kind of thing is *much* better done at the DB level, so that you can be certain that there are no other paths that allow data to be updated. -- -- Christophe Pettus x...@thebuild.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: Postgresql Index & expensive queries [n00bie alert]
On Oct 20, 2012, at 11:34 PM, Barry Morrison wrote: > Looking further at Postgresql, what's interesting. Is it creates an 'id' > column and appends '_id' to what is assumed to be the id field (if none is > specified). > > Also, it appears the magic may have already created the indexes: It's not actually PostgreSQL that's creating those. That's Django's standard behavior. 1. It automatically creates an id column for any model that lacks an explicit primary key. 2. It automatically adds an index to foreign key models (for text fields, you get both the standard one and the varchar_pattern_ops one, which is technically no longer required). -- -- Christophe Pettus x...@thebuild.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: PostGIS 2.0.0 problems
On Aug 3, 2012, at 3:55 PM, Thomas Lockhart wrote: > Really? What is the use case requiring a version 2.0.0? PostGIS 2.0 has a lot of stuff in it, including things like KNN indexes; those alone are worth upgrading for. > And typically folks don't jump on a x.0.0 of anything, expecting to see it > settle down after release with some minor fixes and additional releases. Well, 2.0 has been out for four months so far, so it's not exactly a brand-new release. -- -- Christophe Pettus x...@thebuild.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: Avoiding code repetition in views
On Jun 29, 2012, at 12:20 AM, grimmus wrote: > I am doing a site for a DJ that lists upcoming gigs on each page. There's an > include file in each page template to output the list of gigs. > > I am wondering how i can pass the gig information to every page without > having to repeat the code in every page view. > > I hope i have been clear I'm going to take a guess and surmise that you have a lot of different view functions, each one of which needs to pass a list of gigs into the context for the template and then render that page, and you're trying to avoid repeating the code that builds the list of gigs. Is that correct? You might look at whether you really need all those separate view functions, or if they can be rolled together. You might also look at using class-based Views in 1.4 as a way to factor out the gig-list-building code in a reasonable way. -- -- Christophe Pettus x...@thebuild.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: [JOB] Urgent - PHP/Python Developer needed
On Apr 10, 2012, at 1:31 PM, Cal Leeming [Simplicity Media Ltd] wrote: > * MUST be able to work 30+ hours a week. > [...] > The position is full time, offering around $2000/month (roughly £1200/month) > for the right candidate - price/hours are negotiable. Just to be clear, assuming that the job is 30 hours per week, you are really offering $15.38 per hour? That's roughly what a waiter in a mid-range San Francisco restaurant makes, with tips. If that really is your budget, you need to be looking at outsourcing companies, not a list like this one. If that compensation was a typo, apologies! -- -- Christophe Pettus x...@thebuild.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: PostGIS 2.0.0 problems
On Apr 7, 2012, at 12:01 PM, Oleg Korsak wrote: > sorry? which one SQL? :) I'm trying to run tests with Jenkins CI, but > it fails on creating DB. Ah, OK. The automated tests will probably fail, yes. For your application, you can work around this problem by manually created the indexes rather than letting Django do it. -- -- Christophe Pettus x...@thebuild.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: PostGIS 2.0.0 problems
On Apr 7, 2012, at 11:41 AM, Oleg Korsak wrote: > So looks PostGIS 2.0.0 is unusable with Django right now? There's no reason you can't apply the SQL manually for the moment. -- -- Christophe Pettus x...@thebuild.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.
Loading multi-line SQL as part of syncdb
The problem is: This doesn't work, as is well-known, because the current code breaks sql/.sql files into lines, and that fails if the SQL statement is multiline. The fix is generally noted to be, to quote mtredinnick on bug #3214: > If you want to pass in complex SQL, catch the post-syncdb signal and work > directly with a django.db.backend.cursor. You will know precisely what > database you're talking to and can use the appropriate syntax and calling > mechanisms. Except the documentation of the post_syncdb signal says: > It is important that handlers of this signal perform idempotent changes (e.g. > no database alterations) as this may cause the flush management command to > fail if it also ran during the syncdb command. So, either the documentation is overstating the case, or the proposed solution is wrong. Any guidance as to the right way to apply multi-line SQL during syncdb? Best, -- -- Christophe Pettus x...@thebuild.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: Using STATIC_URL in CSS/JS files?
On Jan 3, 2012, at 11:18 AM, Bill Freeman wrote: > This will be even morepainful if you use Django templates as the > templating engine, since you will have to quote all those braces that you need > in CSS and Javascript. I don't believe this is correct; Django's templating engine doesn't choke on single braces. -- -- Christophe Pettus x...@thebuild.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: Using STATIC_URL in CSS/JS files?
On Jan 2, 2012, at 5:56 PM, Victor Hooi wrote: > E.g. I have a CSS file that points to a PNG sprite, and I'd like a way to get > it to point to {{ STATIC_URL}} without hardcoding the URL/path - any way? You can use Django to serve your CSS file if you want to, although you'll want to cache the heck out of it for performance reasons. There are also a wide variety of tools which generate CSS from various input files to allow for various kind of template expansion, and those might be a suitable alternative. -- -- Christophe Pettus x...@thebuild.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: TransactionMiddleware recommendation
On Sep 21, 2011, at 2:27 PM, Joseph Mou wrote: > Why is this preferable over the default auto-commit behavior? If you are certain that every single time you modify the database, you want an immediate commit (no object graphics, no possibility of dangling objects), the default behavior might work for you. However, as soon as you start having interdependent objects, you probably need something more sophisticated. Discussion here: http://thebuild.com/blog/2009/11/07/django-postgresql-and-transaction-management/ -- -- Christophe Pettus x...@thebuild.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: Trouble expressing a query in the ORM
On Sep 9, 2011, at 9:44 AM, Pewpewarrows wrote: > I don't understand the 10-15 limit either. I've done giant "in" queries in > the past that perform fine with large data sets and proper indexing. You can set the rule of thumb whereever you like; eventually, the curves between an IN and a join will cross, however. -- -- Christophe Pettus x...@thebuild.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: Trouble expressing a query in the ORM
On Sep 9, 2011, at 8:41 AM, Simon Riggs wrote: > Not sure I understand the limitation to 10-15 entries. That's my rule of thumb as to when I prefer to re-express a query as a join rather than an IN. Larger values can work just fine, but __in in Django tends to be abused with gigantic inclusion sets. -- -- Christophe Pettus x...@thebuild.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: Trouble expressing a query in the ORM
On Sep 9, 2011, at 6:28 AM, Pewpewarrows wrote: > prop_dates = > Target.objects.annotate(latest_property=Max('property__export_date')).values_list('latest_property', > flat=True) > properties = Property.objects.filter(export_date__in=prop_dates) Note that if prop_dates has more than 10-15 entries, it's going to perform badly (at least on PostgreSQL, and almost certainly on MySQL too). I think this particular situation is definitely a .raw() opportunity. -- -- Christophe Pettus x...@thebuild.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: django transactions.
On Jun 7, 2011, at 7:16 AM, Marc Aymerich wrote: > With this I expect that if the method raise an exception, django rolls > back any database operation executed by this method, even the > operations executed by submethods called by this main method, right? That's correct. > So I got this exception but the changes made on the DB during the > method execution still there. Which back-end are you using? -- -- Christophe Pettus x...@thebuild.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: boolean default
On May 15, 2011, at 2:15 PM, Greg Donald wrote: > How do I set a default for a BooleanField() ? > > I tried > > foo = models.BooleanField( default=False ) > > > but that only produces > > foo boolean NOT NULL, The default= parameter in Django doesn't generate a DEFAULT in the SQL; the default is implemented in the Django ORM. -- -- Christophe Pettus x...@thebuild.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: Slow query on MySQL
On Mar 23, 2011, at 8:45 AM, Brian Neal wrote: > Sorry, my bad. I've been tweaking things in vain. Here are the correct > EXPLAINS. > > http://dpaste.com/524865/ In both cases, what it's doing is grabbing a set of records from Topic, sorting them, then using those to select Posts. In the second one, it is grabbing *all* of the topics to sort, and my guess is that it is spilling to disk in doing the sort, which is why it takes so long (although 7 seconds to sort 12k records is pretty bad... have you considered using PostgreSQL instead? :) ). Looking at the SQL, it looks like the way MySQL executes the IN is to read in and sort all of the Topic records, then probing for the matching ones once they're sorted. Generally, if you can avoid IN, especially in MySQL, it's a good idea. -- -- Christophe Pettus x...@thebuild.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: Select x random rows from DB
If you know this is going to be an important part of the application, it might make sense to have a random primary key, such as a UUID. -- -- Christophe Pettus x...@thebuild.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: Select x random rows from DB
On Feb 21, 2011, at 10:34 AM, Eric Chamberlain wrote: > If you have lots of rows, this query is really slow as the db must build a > new table for the ORDER BY. You can do better if you have a guaranteed ordinal on the rows; otherwise, it has to do a full table scan no matter what. -- -- Christophe Pettus x...@thebuild.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: Select x random rows from DB
On Feb 20, 2011, at 2:19 PM, galago wrote: > What is the best way, to select X random rows from DB? I know that method: > .all().order_by('?')[:X] is not good idea. The best way is to push it onto the DB, using a raw query: random_results = Table.objects.raw("SELECT * FROM table ORDER BY random() LIMIT X") -- -- Christophe Pettus x...@thebuild.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: Dates BC
On Jan 17, 2011, at 2:00 PM, Ben Dembroski wrote: > I'm a relative newbie to both Python and Django, and in the middle of > my first Django project. My client is asking me to store and process > dates -- including dates BC. Unless you have a strong need to do date arithmetic on the dates, or you can use a different database (like PostgreSQL) that has more robust date support, it might be easier to represent the dates as stylized strings, or as integers on a uniform calendar like the proleptic Julian calendar, instead of using the built-in date type. -- -- Christophe Pettus x...@thebuild.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: Database Table Locks/unlocks (for reading, writing or both)
On Jan 12, 2011, at 8:14 AM, Jagdeep Singh Malhi wrote: > I only want to know is Django is able Lock/Unlock the Database tables, > If yes. > How its possible? how its works Django by itself doesn't issue locking instructions to the database, and doesn't have any built-in primitives to do so. You can use direct SQL, bypassing the ORM, to issue those commands if you really need to. But the previous commenter's note is right: Pessimistic locking often kills database performance, and is rarely the best solution. -- -- Christophe Pettus x...@thebuild.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django's documention is horrible
On Jan 10, 2011, at 1:25 PM, Simon W wrote: > For such a good web framework it's a shame that the documention is not > structured well .. at all. I have no doubt that the project would be more than receptive to doc patches to fix the problem. -- -- Christophe Pettus x...@thebuild.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-us...@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: De-coupling settings.py from project
On Dec 30, 2010, at 8:50 AM, eblume wrote: > Is there a way to specify settings like STATIC_URL or FIXTURES_DIRS > per-application rather than per-site? Even better - is there a > mechanism to use a settings.py file in the application rather than in > the site? I think that your overall goal is quite admirable, but this may be an optimization too far. One way to think of the way Django organizes its code is that a project is the platform on which applications are deployed. The role of settings.py (and the top-level urls.py) is to configure the applications for a particular deployment, so things like STATIC_URL that are specific to a particular deployment of the app should not be in the app itself. Thus, the top-level settings.py should include stuff that is: 1. General across all applications, or, 2. Used to configure a particular application for a particular deployment. All that being said, it's no big deal to emulate the urls.py include facility in settings.py; just include your app-specific settings. You can also have a 'settings.py' (or whatever) file within the application that only that app imports. -- -- Christophe Pettus x...@thebuild.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-us...@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: delivering streaming videos
On Dec 25, 2010, at 12:16 AM, 93-interactive wrote: > The reason why i don't want to have the files in the web root is, that > there should be > as user management. certain django users are allowed only to view > certain videos. While you can make this work, you generally do not want an entire Python interpreter sitting around in memory just copying bytes from a file to the web server. It's expensive, and a poor use of resources. I'd strongly encourage you to look at mod_xsendfile (if you are using Apache), or the equivalent functionality in lighttpd. You can maintain full control over who gets to see what videos, without having to tie up a Python/Django instance just doing I/O copies. -- -- Christophe Pettus x...@thebuild.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-us...@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: Massive insertion of records
On Dec 24, 2010, at 6:07 PM, Silva Paulo wrote: > From your answer I may conclude that I should use a "non django" solution to > load the database, isn't it? If this is going to be a one-time bulk load, it will certainly be faster. You might consider using the .import command from SQLite's command line interface: http://www.sqlite.org/sqlite.html -- -- Christophe Pettus x...@thebuild.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-us...@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: case insensitive "in" query
On Dec 24, 2010, at 11:12 AM, Tim Saylor wrote: > Is there an alternative? This is probably a good case for doing a raw query. You can then do something along the lines of "WHERE lower(field) IN ('', '''...)". Depending on the data, creating a functional index on "lower(field)" might help performance. -- -- Christophe Pettus x...@thebuild.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-us...@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: Massive insertion of records
On Dec 24, 2010, at 9:26 AM, Silva Paulo wrote: > I need to do a massive insertion of records in two tables "connectd" by > "foreignkey". Is there a way, using the Django db API, to do it. > e=Foo(...);e.save() seems too slow. It's always going to be very slow to do inserts via the Django ORM compared to going straight to the database. Which DB are you using, and what format is the data in before it gets inserted? -- -- Christophe Pettus x...@thebuild.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django RSS feed consolidator?
Like, say, the one at: http://www.djangoproject.com/community/ You know, something like that? Never mind! On Dec 22, 2010, at 3:04 PM, Christophe Pettus wrote: > Is there a feed consolidator for Django-related RSS feeds? One exists for > the PostgreSQL project, and it's pretty nice to keep track of what PG-related > stuff is being written by various bloggers. If not, is there interest in > such a thing? > > -- > -- Christophe Pettus > x...@thebuild.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-us...@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. > -- -- Christophe Pettus x...@thebuild.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-us...@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 RSS feed consolidator?
Is there a feed consolidator for Django-related RSS feeds? One exists for the PostgreSQL project, and it's pretty nice to keep track of what PG-related stuff is being written by various bloggers. If not, is there interest in such a thing? -- -- Christophe Pettus x...@thebuild.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django vs Postgres Connection
On Dec 17, 2010, at 12:02 PM, armandoperico wrote: > On my local machine everything is running fine, but when i try to > deploy to a running server with apache (mod_wsgi), i'm getting the > following error (database related): > > Caught OperationalError while rendering: could not connect to server: > Permission denied > Is the server running on host "127.0.0.1" and accepting > TCP/IP connections on port 5432? What's your database configuration on the Apache machine? -- -- Christophe Pettus x...@thebuild.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-us...@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: Developing a search engine
On Dec 15, 2010, at 5:57 PM, Sam Lai wrote: > If you're using MySQL, Django can interface with its FTS component - > http://docs.djangoproject.com/en/dev/ref/models/querysets/#search PostgreSQL also has a very good built-in full text search function. You'll need to write a tiny bit of raw SQL, but you can use it with the new .raw() query sets. http://www.postgresql.org/docs/9.0/interactive/textsearch.html -- -- Christophe Pettus x...@thebuild.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-us...@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: I don't get the big picture (admin, etc.)
On Dec 13, 2010, at 7:25 PM, cocolombo wrote: > 1) Should the players use the admin to loggin ? I think that there's a good hint given by the is_staff property of a User. The admin is best used by people you would consider "staff," rather than general users of the site. While it is certainly possible to lock the admin down pretty thoroughly, it's much better to design the public-facing part of your site from scratch, rather than worry about bending the admin to being a good public interface, and locking it down completely against mischief. > 2) Do I use the user objects, to keep information about each players ? > Or a different class called player ? Either way has its merits. There's no reason not to use the User auth system even for people who don't use the admin; it's quite flexible. > 3) Should I create a separate application for the login section of the > site ? In general, yes, that's a good idea. The user login section is an isolatable bit of code that makes perfect sense as an application. > 4) Is registering a new user (confirmation by email, etc) a different > module or is it part in the admin. It's part of the application you built up in #3. :) > 5) I understand the importance of admin to manage my database, but of > course, I don't want the players to access directly the database. Do > the players access the admin with limited privileges, or do they not > touch the admin whatsoever ? See #1. It's far easier to build up the public facing part of the site with what users *can* do, than worry about having missed something in the admin that they *can* do. -- -- Christophe Pettus x...@thebuild.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-us...@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: How to write good form validation in Django?
On Dec 10, 2010, at 4:01 PM, Ali Ghaffari wrote: > How can the view in "/thanks/" be sure that the form was validated? > Are there any common ways to pass the successful validation of the > form to the next view? Or do I need to do something manually such as > setting a flag in request's session? It depends on what your concern is. If the "/thanks/" view is going to do an operation that it simply should not do unless the form was validated, then, yes, you should make sure the state of the application (via the database, session, or something else) is sufficient that the "/thanks/" form can confirm that the operation was really done before doing its part. If "/thanks/" doesn't do anything to the state of the application, then the worst that could happen is that the user accesses it directly, rather than on a redirect, and is told thanks when the application doesn't really mean it. This may or may not be worth guarding against. > How can one write this code in a way that when form is NOT valid and > the page is shown with errors upon submission, if user refreshes the > browser it wouldn't ask the user if they want to POST data again? Well, a refresh in this case on the user's part *is* a request to repost the form data again. What's the condition you are trying to avoid in this sitaution? -- -- Christophe Pettus x...@thebuild.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-us...@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: Beta page and "under construction"
On Dec 9, 2010, at 2:56 PM, Álex González wrote: > I like to upload my beta page to a server, but I only want to show this beta > to certains IPs. If get the IP of the cliente could be possible in the > urls.py file this will be easy, but I can't do that. This seems like a good application for a customer middleware module that redirects to the beta page on the basis of the IP. -- -- Christophe Pettus x...@thebuild.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-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: django-extensions - "Error: no module named django_extensions"
On Dec 8, 2010, at 6:48 PM, Victor Hooi wrote: > Not sure what's going on here? Is the django_extensions module on your PYTHONPATH? -- -- Christophe Pettus x...@thebuild.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-us...@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.
Distinguish between None and False/0/[] in a template?
Pardon if this is a FAQ, but is there a built-in way of distinguishing between None and the other typical false values (False/0/[]) in a template? Something along the lines of: {% if var == None %} ... {% endif %} Thanks! -- -- Christophe Pettus x...@thebuild.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-us...@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: Create an object before calling the save method
On Nov 27, 2010, at 2:56 PM, bnabilos wrote: > What I want to do is creating a title based on what I write in the > ForeignKey field before creating the category so it can be used > immediately. You can do just that. Just accept the title in a CharField, without a choices= option, and then create the Title based on that, then creating the category to refer to it. The code would look something like this: t = Title(title=form.cleaned_data['title']) t.save() # This creates the primary key for the new Title object c = Category(title=t) c.save() You can add appropriate checks if the title and category already exist, to handle those the way you wan tto. -- -- Christophe Pettus x...@thebuild.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-us...@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: Caching middleware causes default page caching
On Nov 26, 2010, at 8:30 PM, ydjango wrote: > I have added following to cache some common DB data and it seems it > has started caching whole pages by default. Some pages appeared to be > retrieved from cache without even hitting the view. Unless I'm missing something, that's exactly what it is supposed to be doing. The cache middleware caches your entire site, all the time, by default. If all you want to do is use the cache framework to store some database objects, you don't need the cache middleware. http://docs.djangoproject.com/en/1.2/topics/cache/#the-per-site-cache -- -- Christophe Pettus x...@thebuild.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-us...@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: percentage of models given field value?
On Nov 24, 2010, at 8:13 PM, Lachlan Musicman wrote: > Thanks Christopher. I've never done raw SQL in Django before. This may > seem like a silly follow up question, but is it standard practice to > put the relevant code, as described by the documentation > (http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly > ) into views.py? Oh, and: Another very logical place to put this is in a custom Manager subclass for the relevant Model; there's documentation on that usage in the docs: http://docs.djangoproject.com/en/1.2/topics/db/managers/#adding-extra-manager-methods -- -- Christophe Pettus x...@thebuild.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-us...@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: percentage of models given field value?
On Nov 24, 2010, at 8:13 PM, Lachlan Musicman wrote: > Thanks Christopher. I've never done raw SQL in Django before. This may > seem like a silly follow up question, but is it standard practice to > put the relevant code, as described by the documentation > (http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly > ) into views.py? It's largely a matter of taste. I prefer putting raw SQL in the Model subclass (as a static or class method), and have the results come back in a form that is usable for the view. There's no reason that the SQL can't be in the view function, but it's cleaner to have the Model encapsulate all of the related data access for a particular model; that way, if the fields in the model subclass change, there's only one place to look. -- -- Christophe Pettus x...@thebuild.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-us...@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.
'is None' in {% if %}
I have a Decimal field that's blank=True, null=True, and NULL and 0.0 are distinct values. I'd like to do something different in a template depending on whether or not the value is None or not, but a standard {% if field %} treats 0.0 and None the same. Right now, I'm checking is None in the application and setting a separate value in the context, but is there a way of doing this directly on the field itself? Thanks! -- -- Christophe Pettus x...@thebuild.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-us...@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: percentage of models given field value?
On Nov 24, 2010, at 4:37 PM, Lachlan Musicman wrote: > Using django 1.2 I wanted to present some statistics on the data that > we have been collecting in our db. > > We have source texts with authors, and target texts with their translators. > > The target text model has a value "Language". > > I get the count of the target texts: all, and then filtered by > language. How would I present each language as a percentage of the > total target text count? This is a great query to write as SQL, rather than using the ORM (I love the Django ORM, but the right tools for the right job). Assuming more or less standard Django names, you could return a list of the languages, the total number of texts for each language, and the percentage of the total with something along the lines of: SELECT language, COUNT(*), (COUNT(*)/(SELECT COUNT(*) FROM app_targettexts)) FROM app_targettexts GROUP BY language This has the advantage that it only hits the database once. If you need the grand total, you can either calculate it in the application, or thorw on: UNION SELECT 'total', COUNT(*), 1.0 FROM app_targettexts -- -- Christophe Pettus x...@thebuild.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-us...@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: In-memory sorting of a QuerySet, yielding a QuerySet
On Nov 24, 2010, at 12:25 AM, bruno desthuilliers wrote: > Err... Would you mean, something like a ChoiceField ?-) Very, very much like a ChoiceField. :) -- -- Christophe Pettus x...@thebuild.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-us...@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: New ManyToManyField Approach
On Nov 23, 2010, at 9:09 PM, sh...@bogomip.com wrote: > Since you've noticed it I have to ask.. since I didn't think it would > be any different.. how does this differ from the current Django > method? The standard Django implementation creates an intermediate table with foreign keys back to the tables on each side, so it's simple to do a query against that intermediate model to handle queries like that. (This is the standard SQL way of handling a many-to-many relationship.) In fact, in your structure, I'm not sure you can actually answer the question "which items refer to user 1," since that information is lost into the hash. If the only question you ever need to answer is "does item 1 refer to this particular set of users?", then that's not a big deal. >> If you are using PostgreSQL, you might look at using intarray or hstore >> fields instead; those have the same advantages you enumerate, but you can >> also index on them in ways that will speed up searches for individual values. > > Outside of the ORM I'll play around with this. You don't need to abandon the ORM to use hstore or intarray; they adapt very nicely to Pyython types and Django model types. -- -- Christophe Pettus x...@thebuild.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-us...@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.