Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 Jan. 12, 2011 12:58:03

g.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


I have two application

1. App1 - It has a Model Class "Entry" that has 200000 entries
2. App2 - It has a Model Class "Priority"

In Priority class I am defining a Foreign Key Relationship as

from App1.models import Entry

class Priority(models.Model):
entry = models.ForeignKey(Entry)
priority = models.CharField(max_length=2)

And in App2/admin.py I am simply registering Priority

admin.site.register(Priority)

But on Admin website when I try to add a priority - the control hangs
up and only a blank page is returned after a long time gap.

Can anyone please look into the issue that why it is not letting me
add priorities through Admin? I am able to add from backend,

Thanks

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Jan. 12, 2011 13:30:47

B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


It could be that the query to populate the drop down for the FK is
timing out, causing the page to hang. You should try it with
raw_id_fields, something like this in App2 admin.py:

from django.contrib import admin
from App2.models import Priority

class PriorityAdmin(admin.ModelAdmin):
raw_id_fields = ('entry',)

admin.site.register(Priority,PriorityAdmin)

Regards,
--
Burhan Khalid

On Jan 12, 8:27 am, gupta-django <gupta55...@gmail.com> wrote:
> I have two application
>
> 1. App1 - It has a Model Class "Entry" that has 200000 entries
> 2. App2 - It has a Model Class "Priority"
>
> In Priority class I am defining a Foreign Key Relationship as
>
> from App1.models import Entry
>
> class Priority(models.Model):
>     entry = models.ForeignKey(Entry)
>     priority = models.CharField(max_length=2)
>
> And in App2/admin.py I am simply registering Priority
>
> admin.site.register(Priority)
>
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
>
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
>
> Thanks

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#3 Jan. 12, 2011 13:35:21

Xavier O.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


Hi,

I am not sure the admin is designed for handling so many entries in a foreign
key.
When you try to display Priority, you'll have a combo box with 200.000 entries
which will takes a lot of time to get computed especially if you want to
display entries information in the string representation.
Even if the admin interface would render it, you'll suffer a really poor user
experience.

Maybe you could describe what you are trying to achieve in order to get the
right way to do it ?

Regards,
Xavier.

Le 12 janv. 2011 à 06:27, gupta-django a écrit :

> I have two application
>
> 1. App1 - It has a Model Class "Entry" that has 200000 entries
> 2. App2 - It has a Model Class "Priority"
>
> In Priority class I am defining a Foreign Key Relationship as
>
> from App1.models import Entry
>
> class Priority(models.Model):
> entry = models.ForeignKey(Entry)
> priority = models.CharField(max_length=2)
>
> And in App2/admin.py I am simply registering Priority
>
> admin.site.register(Priority)
>
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
>
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
>
> Thanks
>
> --
> 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.
>

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#4 Jan. 12, 2011 13:36:53

Piotr K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


Hi,

2011/1/12 gupta-django <gupta55...@gmail.com>

> I have two application
>
> 1. App1 - It has a Model Class "Entry" that has 200000 entries
> 2. App2 - It has a Model Class "Priority"
>
> In Priority class I am defining a Foreign Key Relationship as
>
> from App1.models import Entry
>
> class Priority(models.Model):
> entry = models.ForeignKey(Entry)
> priority = models.CharField(max_length=2)
>
> And in App2/admin.py I am simply registering Priority
>
> admin.site.register(Priority)
>
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
>

It's quite obvious why or rather what is IMO wrong here. Are you (or the end
user) really satisfied with a <select> that contains 200000 <option>
elements? That's at least 3,5 MB of plain HTML.

P.S. This is one to one relation, isn't it?

Regards,
Piotr

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#5 Jan. 12, 2011 13:53:14

Matias A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


The given answers are correct, that's your issue without doubt, create an admin
class for your Priority model and setup a raw_id_field:

class PriorityOptions(admin.ModelAdmin):
raw_id_fields = ('entry',)
register(Priority, PriorityOptions)

Regards,
Matías

:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fieldsExcerpts from gupta-django's message of Wed Jan 12 03:27:17 -0200 2011:
> I have two application
>
> 1. App1 - It has a Model Class "Entry" that has 200000 entries
> 2. App2 - It has a Model Class "Priority"
>
> In Priority class I am defining a Foreign Key Relationship as
>
> from App1.models import Entry
>
> class Priority(models.Model):
> entry = models.ForeignKey(Entry)
> priority = models.CharField(max_length=2)
>
> And in App2/admin.py I am simply registering Priority
>
> admin.site.register(Priority)
>
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
>
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
>
> Thanks
>
--
Matías Aguirre <matiasagui...@gmail.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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#6 Jan. 12, 2011 14:06:44

Piotr Z.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


I'd also take a look at XHR requests (Web Console or Firebug's Net panel)


On 01/12/11 13:53, Matias Aguirre wrote:
> The given answers are correct, that's your issue without doubt, create an
> admin
> class for your Priority model and setup a raw_id_field:
>
> class PriorityOptions(admin.ModelAdmin):
> raw_id_fields = ('entry',)
> register(Priority, PriorityOptions)
>
> Regards,
> Matías
>
> :
>http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.raw_id_fields>
> Excerpts from gupta-django's message of Wed Jan 12 03:27:17 -0200 2011:
>> I have two application
>>
>> 1. App1 - It has a Model Class "Entry" that has 200000 entries
>> 2. App2 - It has a Model Class "Priority"
>>
>> In Priority class I am defining a Foreign Key Relationship as
>>
>> from App1.models import Entry
>>
>> class Priority(models.Model):
>> entry = models.ForeignKey(Entry)
>> priority = models.CharField(max_length=2)
>>
>> And in App2/admin.py I am simply registering Priority
>>
>> admin.site.register(Priority)
>>
>> But on Admin website when I try to add a priority - the control hangs
>> up and only a blank page is returned after a long time gap.
>>
>> Can anyone please look into the issue that why it is not letting me
>> add priorities through Admin? I am able to add from backend,
>>
>> Thanks
>>


--
bloghttp://piotr.zalewa.infojobshttp://webdev.zalewa.infotwithttp://twitter.com/zalunfacehttp://facebook.com/zaloon--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#7 Jan. 13, 2011 06:59:25

D.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


You could also consider using an AJAX-based "autocomplete" approach;
see:http://code.djangoproject.com/wiki/AutoCompleteSolutionsOn Jan 12, 7:27 am, gupta-django <gupta55...@gmail.com> wrote:
> I have two application
>
> 1. App1 - It has a Model Class "Entry" that has 200000 entries
> 2. App2 - It has a Model Class "Priority"
>
> In Priority class I am defining a Foreign Key Relationship as
>
> from App1.models import Entry
>
> class Priority(models.Model):
>     entry = models.ForeignKey(Entry)
>     priority = models.CharField(max_length=2)
>
> And in App2/admin.py I am simply registering Priority
>
> admin.site.register(Priority)
>
> But on Admin website when I try to add a priority - the control hangs
> up and only a blank page is returned after a long time gap.
>
> Can anyone please look into the issue that why it is not letting me
> add priorities through Admin? I am able to add from backend,
>
> Thanks

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#8 Jan. 13, 2011 16:33:05

Sean W.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


On Wed, Jan 12, 2011 at 10:59 PM, Derek <gamesb...@gmail.com> wrote:

> You could also consider using an AJAX-based "autocomplete" approach;
> see:
>http://code.djangoproject.com/wiki/AutoCompleteSolutions>
> On Jan 12, 7:27 am, gupta-django <gupta55...@gmail.com> wrote:
> > I have two application
> >
> > 1. App1 - It has a Model Class "Entry" that has 200000 entries
> > 2. App2 - It has a Model Class "Priority"
> >
> > In Priority class I am defining a Foreign Key Relationship as
> >
> > from App1.models import Entry
> >
> > class Priority(models.Model):
> > entry = models.ForeignKey(Entry)
> > priority = models.CharField(max_length=2)
> >
> > And in App2/admin.py I am simply registering Priority
> >
> > admin.site.register(Priority)
> >
> > But on Admin website when I try to add a priority - the control hangs
> > up and only a blank page is returned after a long time gap.
> >
> > Can anyone please look into the issue that why it is not letting me
> > add priorities through Admin? I am able to add from backend,
> >
> > Thanks


The time gap is created because Django is trying to generate a select input
with 200,000 options in it.

I'd recommend choosing another widget type, probably an autocomplete of some
sort...http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.formfield_overridesSean

--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#9 Jan. 14, 2011 00:14:50

f.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


django ajax select will work (jQuery):http://code.google.com/p/django-ajax-selects/--
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 athttp://groups.google.com/group/django-users?hl=en.

Offline

#10 Jan. 14, 2011 00:54:23

Matias A.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Need HELP urgently


Don't see the need to use an ajax solution when a simple raw field makes the
work properly. Don't get me wrong, it's good to have several options, just that
I don't see the need.

Regards,
Matías

Excerpts from felix's message of Thu Jan 13 22:14:43 -0200 2011:
> django ajax select will work (jQuery):
>http://code.google.com/p/django-ajax-selects/>
--
Matías Aguirre <matiasagui...@gmail.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 athttp://groups.google.com/group/django-users?hl=en.

Offline

Board footer

Moderator control

Enjoy the 19th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support