Monday, March 2, 2015

Complex Querys And Results Response Processing/Formatting

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 to an html page for viewing by a user.
My problem is I can't seem to get the JSON formatting correct either before I add each piece of response data to the list, or right before I return the list in my HttpResponse so then when it gets sent back to the client page my jQuery/javascript cannot parse the data correctly and it fails.

Any help would be greatly appreciated.

Thanks.

Henry
    

--
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+unsubscribe@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/ec9be9f3-dd43-4c5c-8649-32c27eb01998%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Traversing relationships based on lookup strings

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 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+unsubscribe@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/FB0F25B1-00B0-4CD5-A62D-B9CE44F189C8%40devrx.org.
For more options, visit https://groups.google.com/d/optout.

Re: Using proxy kind of Table in Admin Interface

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('First Name',max_length=150)
   
last =  models.CharField('Last Name',max_length=150)
   
.........

###Meadowvale SDA
###Model Manager
class MeadowvaleManager(models.Manager):
   
def get_queryset(self):
       
return super(MeadowvaleManager, self).get_queryset().filter(churchLoc='meadow-sda')


###Model Proxy
class MeadowvaleMember(Member):
    objects
= MeadowvaleManager()
   
   
class Meta:
        verbose_name
= "MeadowMember"
        proxy
= True
   


####Another SDA
###Model Manager
class AnotherManager(models.Manager):
   
def get_queryset(self):
       
return super(AnotherManager, self).get_queryset().filter(id=1)


###Model Proxy
class AnotherMember(Member):
    objects
= AnotherManager()
   
   
class Meta:
        verbose_name
= "AnotherMember"
        proxy
= True



below is a sample of the admin.py

from members.mymodels.models import MeadowvaleMember,AnotherMember
 
class MeadowvaleMemberAdmin(admin.ModelAdmin):
   
def get_query_set(self,request):
       
return MeadowvaleMember.objects.all()
   
   
class AnotherMemberAdmin(admin.ModelAdmin):
   
def get_query_set(self,request):
       
return AnotherMember.objects.all()

#proxy

admin
.site.register(MeadowvaleMember,MeadowvaleMemberAdmin)
admin
.site.register(AnotherMember,AnotherMemberAdmin)


On Monday, March 2, 2015 at 12:21:47 PM UTC-5, Derek wrote:
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()

    class Meta:
        proxy = True


admin.py

class MainModelAdmin(ModelAdmin):
    """mother of all admin"""
    ...


class MainModelProxyAdmin(MainModelAdmin):
    #add salt to taste
    

admin.site.register(MainModel, MainModelAdmin)
admin.site.register(MainModelProxy, MainModelProxyAdmin)


On Monday, 2 March 2015 18:16:36 UTC+2, Rootz wrote:
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 model manually into the django admin and I got it to work. However when I try to assign permission to each user account for the different proxy models I had created I am only  see only one proxy model in the permission list (django admin interface).

My goal is to create one table that returns a custom QuerySet unique to a user group or user account. Adding to this I would like for this to be visible in the admin interface. Can you guide me as to how can achieve this.

thank you 

--
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+unsubscribe@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/19bc578f-1704-4a58-a068-13b89139c859%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Re: Using proxy kind of Table in Admin Interface

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()

    class Meta:
        proxy = True


admin.py

class MainModelAdmin(ModelAdmin):
    """mother of all admin"""
    ...


class MainModelProxyAdmin(MainModelAdmin):
    #add salt to taste
    

admin.site.register(MainModel, MainModelAdmin)
admin.site.register(MainModelProxy, MainModelProxyAdmin)


On Monday, 2 March 2015 18:16:36 UTC+2, Rootz wrote:
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 model manually into the django admin and I got it to work. However when I try to assign permission to each user account for the different proxy models I had created I am only  see only one proxy model in the permission list (django admin interface).

My goal is to create one table that returns a custom QuerySet unique to a user group or user account. Adding to this I would like for this to be visible in the admin interface. Can you guide me as to how can achieve this.

thank you 

--
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+unsubscribe@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/bef0acd2-3a6b-4c61-b3f8-70e55e46d7d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

[1.7] Django Admin - Secondary, extended user-admin

Hi all,

I need to set up a passwordless login system using tokens, and I need to manage it from the admin backend.

Simplified, the tokens need to be set for a user (one user, one authenticate token, many authorize tokens).
In the site admin interface I need "User tokens" to be its own "ModelAdmin", that is, in addition to the default "Users"-admin section, I need a "User tokens"-admin section.

My problem is how to do this?

Any suggestions welcome.

Thanks.


--
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+unsubscribe@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/b920c6e9-14fa-403e-85f4-ffde34af7501%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

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

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 the upload is
> taking place.
Let a web server handle the actual upload. Nginx is really good at this,
it can easily handle thousands of concurrent connections. Once all the
data is actually transferred to the server, only then does the request
get passed on to your Django app. A worker is not needed until that
point. This is the default behavior if you use a Nginx / Gunicorn (or
uWSGI) / Django stack.

You can also use the Nginx Upload Module, and your Django app will never
need to receive the actual data at all. Nginx will handle the upload,
put it in a location of your choosing, then hand the path on the server
off to your app. http://wiki.nginx.org/HttpUploadModule

_Nik

--
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+unsubscribe@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/54F48FE7.2030103%40consbio.org.
For more options, visit https://groups.google.com/d/optout.

Using proxy kind of Table in Admin Interface

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 model manually into the django admin and I got it to work. However when I try to assign permission to each user account for the different proxy models I had created I am only  see only one proxy model in the permission list (django admin interface).

My goal is to create one table that returns a custom QuerySet unique to a user group or user account. Adding to this I would like for this to be visible in the admin interface. Can you guide me as to how can achieve this.

thank you 

--
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+unsubscribe@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/5f24f7fc-4865-477d-83fe-bb9f98e23189%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.