Re: i have a question ,whether Django’s cache framework can support transparent proxy deploy mode at isp environment ?

2015-03-02 Thread Avraham Serour
I don't see how they are related, each is on a different layer The final user will request a page from the ISP, it may get from its own cache (squid) or request from your django server. Your django server will produce the response, it may get it from its own cache (memcached) or process it So in

Re: Populating Django app db with JSON data

2015-03-02 Thread aRkadeFR
Hello, Indeed, the data migration is the best way. Check out the documentation here: https://docs.djangoproject.com/en/1.7/ref/migration-operations/#django.db.migrations.operations.RunPython You write your function that will be called by the RunPython and will load your JSON. Migration are order

Re: Melb Django School Second GO

2015-03-02 Thread Lachlan Musicman
Long time on and off list member. I went to the first round of classes and would recommend. Very comfortable space, training leaders knew their Django v well. L. -- "This is a profound psychological violence here. How can one even begin to speak of dignity in labor when one secretly feels one'

Re: Populating Django app db with JSON data

2015-03-02 Thread aRkadeFR
“custom Python code in a historical context” FMPOV, it means that your code will be run exactly at a certain schema of your DB. If your migration is the 3rd one, it will always be run after your first two migrations, thus you will know exactly your schema. The schema is passed to your function (a

Using proxy kind of Table in Admin Interface

2015-03-02 Thread Rootz
Question. How would one go about designing the django table(s) so that I can assign each user account/group a different Model Manager using the same table in the Django admin interface? After doing some reading the closest that comes to this is the Proxy Model but I tried adding the proxy mode

Re: Python / Django slow ? Deciding my next technological stack

2015-03-02 Thread Nikolas Stevenson-Molnar
On 3/1/2015 7:13 AM, Benj wrote: Just a little questions guys: when a user upload a file to server, and that file is a litte big and takes 3 seconds to be uploaded... what's the proper way, if possible, not to block the entire system for these 3 seconds so the server can serve other users while

Re: Using proxy kind of Table in Admin Interface

2015-03-02 Thread Derek
I am not quite sure what you are trying to achieve (without seeing sample code), but here is some very basic code showing how a proxy could work: models.py class MainModel(Model): """mother of models""" ... class MainModelProxy(MainModel): objects = MainModelProxyManager()

Re: Using proxy kind of Table in Admin Interface

2015-03-02 Thread Rootz
Ok below is a sample of the models.py class LocationProfile(models.Model): shortName = models.CharField('Location Name',max_length=100,primary_key = True) longName = models.CharField('Church Name',max_length=100) . class Member(models.Model): first = models.CharField('Fi

Complex Querys And Results Response Processing/Formatting

2015-03-02 Thread Henry Versemann
I'm trying to submit a series of ajax requests from some server code. When I get a response back from each request I'm trying to add that response to a list. Once all of the requests have been sent and all of their responses received and added to the list, then I want to send the final list back

Traversing relationships based on lookup strings

2015-03-02 Thread Francis Devereux
Hi, Is there a Django function that takes a model instance and a lookup string, and returns the value of the related field? For example: the_function_i_am_looking_for(trip, 'booking__client__name') would return the same as: trip.booking.client.name Thanks, Francis -- You received

Re: Traversing relationships based on lookup strings

2015-03-02 Thread James Schneider
Nothing in Django specifically that I'm aware of (although that's not saying much), but you can probably do something pretty slick with the operator library and attrgetter: https://docs.python.org/2/library/operator.html#operator.attrgetter It would probably look something like this (untested):

Re: Traversing relationships based on lookup strings

2015-03-02 Thread James Schneider
Whoops, I meant to swap out 'item' for 'instance' to make it a bit more readable, but got myself distracted and forgot to finish and hit send. So, s/item/instance/... HTH, -James On Mon, Mar 2, 2015 at 2:11 PM, James Schneider wrote: > Nothing in Django specifically that I'm aware of (althoug

Prefetching a single item

2015-03-02 Thread cool-RR
Hi, Say that I have a model Train and it has a ManyToMany to model Seat. I'm looking at a queryset of Train and I want to do a prefetch_related on it, but I don't want to get all the Seat objects; I want only the first Seat object for each Train object. Is this possible with prefetch_related

Re: Complex Querys And Results Response Processing/Formatting

2015-03-02 Thread James Schneider
So, do objects ever get successfully added to the list? I had a bit of trouble following your workflow and figuring out where your issue actually lives. When you say 'send the final list back to an HTML page' do you mean the Django process is generating the HTML and sending it back as a response t

Re: Django OperationalError

2015-03-02 Thread Petar Pilipovic
Hello James, sorry for not uploading mine answer on this mater, I was busy whit something else this day, ok now back to mine Operational Error I have got. I tried to google some solution to this problem had no luck, and I did what have you told me. I heave done some python manage.py sqlflush a

Re: Prefetching a single item

2015-03-02 Thread Simon Charette
Can your seats be part of multiple trains? Is there a reason you defined a ManyToMany from Train to Seat instead of a ForeignKey from Seat to Train? If your schema was defined as the latter the following could probably work (given you only want the first Seat of each Train object): trains = T

Re: Using proxy kind of Table in Admin Interface

2015-03-02 Thread Simon Charette
Hi Rootz, Unfortunately there's a long standing ticket to solve inconsistency with permissions for proxy models so your chosen approach won't work until this is fixed. Simon Le lundi 2 mars 2015 11:16:36 UTC-5, Rootz a écrit : > > Question. > How w

Re: Query optimization - From 3 queries to 2

2015-03-02 Thread Simon Charette
Hi Humberto, The following should do: Provider.objects.prefetch_related( Prefetch('service_types', ServiceType.objects.select_related('service_type_category')) ) P.S. Next time you post a question try to remove data unrelated to your issue from your example (e.g `countries` and `user` refe

Re: Can the new `Prefetch` solve my problem?

2015-03-02 Thread Simon Charette
Hi cool-RR, The following should do: filtered_chairs = Chair.objects.filter(some_other_lookup=whatever) desks = Desk.objects.prefetch_related( PrefetchRelated('chairs', filtered_chairs, to_attr='filered_chairs'), PrefetchRelated('nearby_chairs', filtered_chairs, to_attr='filtered_nearby_