Re: How can I create models which only required during tests in Django 1.7c1?

2014-08-29 Thread Yo-Yo Ma
8d0cd8ffc78b531 (get_model(, ) was messier, due to the need for exception handling). On Friday, August 29, 2014 10:57:05 AM UTC-4, Alex Chiaranda wrote: > > Hi, can't you guys mock these models ? > > On Thursday, August 28, 2014 9:31:04 PM UTC-3, Yo-Yo Ma wrote: >> >> Ugh...

Re: How can I create models which only required during tests in Django 1.7c1?

2014-08-28 Thread Yo-Yo Ma
Ugh... same problem here. It seems you can't really create a model in setUp anymore. I'll post a reply, if I find anything. On Wednesday, July 16, 2014 10:17:56 AM UTC-4, Alisue Lambda wrote: > > Hi all. > > Well today I tried Django 1.7c1 with my program and found that the > previous testing s

Re: Pattern for Ajax Forms using Django ModelForm and Class Based Views.

2013-02-09 Thread Yo-Yo Ma
I might be worth checking out some sort of API library, like https://github.com/orokusaki/django-jsonrpc-2-0, which will allow you to perform whatever business logic you need to, and then simply return something like {"success": True, "errors": errors_list} - your templates and ordinary views c

Re: Does ``QuerySet.select_for_update`` lock related (joined) rows as well?

2012-09-05 Thread Yo-Yo Ma
Thanks, Tom. That does help. On Wednesday, September 5, 2012 6:02:27 AM UTC-4, Tom Evans wrote: > > On Wed, Sep 5, 2012 at 1:45 AM, Yo-Yo Ma > > wrote: > > restaurant = > > > Restaurant.objects.select_for_update().select_related('owner').get(name=u'

Does ``QuerySet.select_for_update`` lock related (joined) rows as well?

2012-09-04 Thread Yo-Yo Ma
restaurant = Restaurant.objects.select_for_update().select_related('owner').get(name=u'Koala Kafe') Assuming the ``owner`` field points to a ``Person`` table, will the aforementioned query prevent the ``Person`` row returned for the Koala Kafe's owner from being saved in a separate transaction

What happens when you use ``select_for_update`` with ``select_related``?

2012-08-19 Thread Yo-Yo Ma
Given a model ``Employee`` with a foreign key ``company`` pointing to a model called ``Company``, would the following example lock both the ``Employee`` and ``Company`` rows that were selected? employee = Employee.objects.select_for_update().select_related('company').get(pk=1) Or, would only t

AutoField field that increments with regards to a foreign key?

2010-10-21 Thread Yo-Yo Ma
Example: Company has many Tickets Tickets have a PK, as well as a "number". Each Ticket's "number" should be the highest prior "number" for a Ticket with the same Company Ticket: pk: 1, number: 1, company: XYZ Ticket: pk: 2, number: 1, company: Acme Ticket: pk: 1, number: 2, company: XYZ unique_

Re: Something breaking if tag

2010-09-29 Thread Yo-Yo Ma
request.GET.get('subtopic') is returning a string, so your if statement is roughly equivalent to: >>> 1 == '1' False The sub_topic = int(request.GET.get('subtopic')) is the correct way to do that. At first glance it seems like a lot of work, but if Django tried to deserialize URL params automatic

Re: What is the correct way to copy an object from one model to a similar model?

2010-09-29 Thread Yo-Yo Ma
Thanks guys. I appreciate the help. On Sep 29, 6:43 am, bruno desthuilliers wrote: > On 29 sep, 12:31, Steve Holden wrote: > > > On 9/29/2010 5:25 AM, Daniel Roseman wrote: > > > You can use the get_all_field_names method in model._meta to get all > > > the actual fields, and set them on the dup

Re: Import Error

2010-09-28 Thread Yo-Yo Ma
   csrf_token template tag, as well as those that accept the POST data. > > You're seeing the help section of this page because you have DEBUG = True in > your Django settings file. Change that to False, and only the initial error > message will be displayed. > > You can cust

Re: Import Error

2010-09-28 Thread Yo-Yo Ma
(r'^login/', include('macrohms.views.login')), is incorrect. the include() function, pertaining to urls.py is for including other URL confs (so you can have sub-sections of your site contain their own urls.py). You'll want to replace that line with: url(r'^login/$', 'macrohms.views.login')), No

What is the correct way to copy an object from one model to a similar model?

2010-09-28 Thread Yo-Yo Ma
I have two models that are identical in structure except one has 2 extra fields. The second one is used for record keeping and is never edited by users. The system takes the first model and copies it to the second model, adding some extra meta information, all when a certain action is performed aga

Re: How do you set choices in your application?

2010-09-24 Thread Yo-Yo Ma
Anyone have any thoughts. -- 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 opti

How do you set choices in your application?

2010-09-24 Thread Yo-Yo Ma
Let's say I have a model with a field called "status". I could set the choices in three ways: 1) status_choices = ((1, 'Completed'), (2, 'Unfinished'), (3, 'Cancelled')) 2) status_choices = (('COM', 'Completed'), ('UNF', 'Unfinished'), ('CAN', 'Cancelled')) Or, 3 ): db_choices = Choice.obj

Re: Why Django Apps Suck

2010-09-23 Thread Yo-Yo Ma
Hey Russell, Do you think a round table discussion in a real person context with whiteboards and the best of the bunch (ie, at Django con or similar event) would be a good time/place to re architecture of the abstraction layers, perhaps to address some of the concerns brought up in the slide show

Re: Problem with ForeignKey()

2010-09-22 Thread Yo-Yo Ma
Any thoughts on this? On Sep 22, 10:47 am, Yo-Yo Ma wrote: > Anyone know how to do this? > > On Sep 21, 10:35 pm, Yo-Yo Ma wrote: > > > > > I have a model with: > > > parent = ForeignKey('self', blank=True, null=True) > > > In that model I&#x

Re: Problem with ForeignKey()

2010-09-22 Thread Yo-Yo Ma
Anyone know how to do this? On Sep 21, 10:35 pm, Yo-Yo Ma wrote: > I have a model with: > > parent = ForeignKey('self', blank=True, null=True) > > In that model I've overridden clean() to contain: > > if self.parent: >     # Do some stuff > > It ra

Problem with ForeignKey()

2010-09-21 Thread Yo-Yo Ma
I have a model with: parent = ForeignKey('self', blank=True, null=True) In that model I've overridden clean() to contain: if self.parent: # Do some stuff It raises an attribute error saying that parent.pk doesn't exist. How can I get around this. Note that my foreign key is recursive. --

Re: Django Chat App?

2010-09-16 Thread Yo-Yo Ma
This might not be any help since I know nothing of VOIP, but for the chat portion take a look in to Ape ( a comet server written in C ). On Sep 16, 9:41 am, Sithembewena Lloyd Dube wrote: > Indeed it is, but the media server isn't :). > > On Thu, Sep 16, 2010 at 5:35 PM, esatterwh...@wi.rr.com <

Re: How to pass in a file to a model directly

2010-09-15 Thread Yo-Yo Ma
Anyone? On Sep 15, 1:18 pm, Yo-Yo Ma wrote: > I'm wondering how to do this: > > instance = SomeModelWithFile.objects.create( >     file = some_file, >     spam="Spam", >     foo="Foo" > ) > > How can I manually pass in a file like this?

How to pass in a file to a model directly

2010-09-15 Thread Yo-Yo Ma
I'm wondering how to do this: instance = SomeModelWithFile.objects.create( file = some_file, spam="Spam", foo="Foo" ) How can I manually pass in a file like this? In file=some_file should some_file be a FileUpload instance? How do I create one of those? -- You received this mes

Django Nav - is there anything similar that is actively maintained

2010-08-26 Thread Yo-Yo Ma
I haven't tried http://code.google.com/p/django-nav/ but I would imagine that it probably has issues because it hasn't changed since 2007. Does anyone know if there is a very intuitive navigation helper like this, but newer? -- You received this message because you are subscribed to the Google Gr

Building a generic list template - where should I start?

2010-08-25 Thread Yo-Yo Ma
I'm wanting to build out a list template that can display any list of objects in this manor (pseudo code: {% for thing in things %} {{ thing.foo }} {{ thing.bar }} {{ thing.spam }} {{ thing.eggs }} {% endfor %} The problem is, of course, that I want to list more than just "thing

Re: Selling Django

2010-06-17 Thread Yo-Yo Ma
This thread shows a very prevalent side of most developers that makes me ashamed to tell people that I'm a developer. The OP is not saying that we should go out and advertise that Django is a great CMS. In fact he spends half of his post making trying to preemptively shut all the know-it-all folks