Search Results

Search found 448 results on 18 pages for 'foreignkey'.

Page 1/18 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Global name not defined error in Django/Python trying to set foreignkey

    - by Mark
    Summary: I define a method createPage within a file called PageTree.py that takes a Source model object and a string. The method tries to generate a Page model object. It tries to set the Page model object's foreignkey to refer to the Source model object which was passed in. This throws a NameError exception! I'm trying to represent a website which is structured like a tree. I define the Django models Page and Source, Page representing a node on the tree and Source representing the contents of the page. (You can probably skip over these, this is a basic tree implementation using doubly linked nodes). class Page(models.Model): name = models.CharField(max_length=50) parent = models.ForeignKey("self", related_name="children", null=True); firstChild = models.ForeignKey("self", related_name="origin", null=True); nextSibling = models.ForeignKey("self", related_name="prevSibling", null=True); previousSibling = models.ForeignKey("self", related_name="nxtSibling", null=True); source = models.ForeignKey("Source"); class Source(models.Model): #A source that is non dynamic will be refered to as a static source #Dynamic sources contain locations that are names of functions #Static sources contain locations that are places on disk name = models.CharField(primary_key=True, max_length=50) isDynamic = models.BooleanField() location = models.CharField(max_length=100); I've coded a python program called PageTree.py which allows me to request nodes from the database and manipulate the structure of the tree. Here is the trouble making method: def createPage(pageSource, pageName): page = Page() page.source = pageSource page.name = pageName page.save() return page I'm running this program in a shell through manage.py in Windows 7 manage.py shell from mysite.PageManager.models import Page, Source from mysite.PageManager.PageTree import * ... create someSource = Source(), populate the fields, and save it ... createPage(someSource, "test") ... NameError: global name 'source' is not defined When I type in the function definition for createPage into the shell by hand, the call works without error. This is driving me bonkers and help is appreciated.

    Read the article

  • foreignkey problem

    - by realshadow
    Hey, Imagine you have this model: class Category(models.Model): node_id = models.IntegerField(primary_key = True) type_id = models.IntegerField(max_length = 20) parent_id = models.IntegerField(max_length = 20) sort_order = models.IntegerField(max_length = 20) name = models.CharField(max_length = 45) lft = models.IntegerField(max_length = 20) rgt = models.IntegerField(max_length = 20) depth = models.IntegerField(max_length = 20) added_on = models.DateTimeField(auto_now = True) updated_on = models.DateTimeField(auto_now = True) status = models.IntegerField(max_length = 20) node = models.ForeignKey(Category_info, verbose_name = 'Category_info', to_field = 'node_id' The important part is the foreignkey. When I try: Category.objects.filter(type_id = 15, parent_id = offset, status = 1) I get an error that get returned more than category, which is fine, because it is supposed to return more than one. But I want to filter the results trough another field, which would be type id (from the second Model) Here it is: class Category_info(models.Model): objtree_label_id = models.AutoField(primary_key = True) node_id = models.IntegerField(unique = True) language_id = models.IntegerField() label = models.CharField(max_length = 255) type_id = models.IntegerField() The type_id can be any number from 1 - 5. I am desparately trying to get only one result where the type_id would be number 1. Here is what I want in sql: SELECT c.*, ci.* FROM category c JOIN category_info ci ON (c.node_id = ci.node_id) WHERE c.type_id = 15 AND c.parent_id = 50 AND ci.type_id = 1 Any help is GREATLY appreciated. Regards

    Read the article

  • Django - foreignkey problem

    - by realshadow
    Hey, Imagine you have this model: class Category(models.Model): node_id = models.IntegerField(primary_key = True) type_id = models.IntegerField(max_length = 20) parent_id = models.IntegerField(max_length = 20) sort_order = models.IntegerField(max_length = 20) name = models.CharField(max_length = 45) lft = models.IntegerField(max_length = 20) rgt = models.IntegerField(max_length = 20) depth = models.IntegerField(max_length = 20) added_on = models.DateTimeField(auto_now = True) updated_on = models.DateTimeField(auto_now = True) status = models.IntegerField(max_length = 20) node = models.ForeignKey(Category_info, verbose_name = 'Category_info', to_field = 'node_id' The important part is the foreignkey. When I try: Category.objects.filter(type_id = type_g.type_id, parent_id = offset, status = 1) I get an error that get returned more than category, which is fine, because it is supposed to return more than one. But I want to filter the results trough another field, which would be type id (from the second Model) Here it is: class Category_info(models.Model): objtree_label_id = models.AutoField(primary_key = True) node_id = models.IntegerField(unique = True) language_id = models.IntegerField() label = models.CharField(max_length = 255) type_id = models.IntegerField() The type_id can be any number from 1 - 5. I am desparately trying to get only one result where the type_id would be number 1. Here is what I want in sql: SELECT n.*, l.* FROM objtree_nodes n JOIN objtree_labels l ON (n.node_id = l.node_id) WHERE n.type_id = 15 AND n.parent_id = 50 AND l.type_id = 1 Any help is GREATLY appreciated. Regards

    Read the article

  • Django ForeignKey created empty?

    - by Scott Willman
    This seems very basic and I must be missing something, but here goes anyways... With two models like so: class School(models.Model): name = models.CharField("Official School Name", max_length=128) address = models.TextField("Address of the School", max_length=256) mascot = models.CharField("Name of the School Mascot", max_length=128) class StudentProfile(models.Model): name = models.CharField(max_length=128) school = models.ForeignKey(School) If the student gets created before the school, how do I give 'school' a default empty value? Is it blank or null or what? Thanks!

    Read the article

  • Django modelform ForeignKey List

    - by Harry
    How do you get each item in the ForeignKey field in a list, for example: class Delegate(models.Model): excursion = models.ForeignKey(Excursion, limit_choices_to = {'is_activity': False}, related_name='excursion', null=True, blank=True) Template: {% for object in formset.excursion_set.all %} {{ object.lable }} etc {% endfor %} My reason is that I don't want the options to display as a dropdown, but in a custom way that I will style etc.

    Read the article

  • Django Formset validation with an optional ForeignKey field

    - by Camilo Díaz
    Having a ModelFormSet built with modelformset_factory and using a model with an optional ForeignKey, how can I make empty (null) associations to validate on that form? Here is a sample code: ### model class Prueba(models.Model): cliente = models.ForeignKey(Cliente, null = True) valor = models.CharField(max_length = 20) ### view def test(request): PruebaFormSet = modelformset_factory(model = Prueba, extra = 1) if request.method == 'GET': formset = PruebaFormSet() return render_to_response('tpls/test.html', {'formset' : formset}, context_instance = RequestContext(request)) else: formset = PruebaFormSet(request.POST) # dumb tests, just to know if validating if formset.is_valid(): return HttpResponse('0') else: return HttpResponse('1') In my template, i'm just calling the {{ form.cliente }} method which renders the combo field, however, I want to be able to choose an empty (labeled "------") value, as the FK is optional... but when the form gets submitted it doesn't validate. Is this normal behaviour? How can i make this field to skip required validation?

    Read the article

  • Editting ForeignKey from "child" table

    - by profuel
    I'm programming on py with django. I have models: class Product(mymodels.Base): title = models.CharField() price = models.ForeignKey(Price) promoPrice = models.ForeignKey(Price, related_name="promo_price") class Price(mymodels.Base): value = models.DecimalField(max_digits=10, decimal_places=3) taxValue = models.DecimalField("Tax Value", max_digits=10, decimal_places=3) valueWithTax = models.DecimalField("Value with Tax", max_digits=10, decimal_places=3) I want to see INPUTs for both prices when editing product, but cannot find any possibility to do that. inlines = [...] works only from Price to Product, which is stupid in this case. Thanx for adnvance.

    Read the article

  • how to change display text in django admin foreignkey dropdown

    - by FurtiveFelon
    Hi all, I have a task list, with ability to assign users. So i have foreignkey to User model in the database. However, the default display is username in the dropdown menu, i would like to display full name (first last) instead of the username. If the foreignkey is pointing to one of my own classes, i can just change the str function in the model, but User is a django authentication model, so i can't easily change it directly right? Anyone have any idea how to accomplish this? Thanks a lot!

    Read the article

  • Django: order by count of a ForeignKey field?

    - by AP257
    This is almost certainly a duplicate question, in which case apologies, but I've been searching for around half an hour on SO and can't find the answer here. I'm probably using the wrong search terms, sorry. I have a User model and a Submission model. Each Submission has a ForeignKey field called user_submitted for the User who uploaded it. class Submission(models.Model): uploaded_by = models.ForeignKey('User') class User(models.Model): name = models.CharField(max_length=250 ) My question is pretty simple: how can I get a list of the three users with the most Submissions? I trued creating a num_submissions method on the User model: def num_submissions(self): num_submissions = Submission.objects.filter(uploaded_by=self).count() return num_submissions and then doing: top_users = User.objects.filter(problem_user=False).order_by('num_submissions')[:3] but this fails, as do all the other things I've tried. Can I actually do it using a smart database query? Or should I just do something more hacky in the views file?

    Read the article

  • Django - Passing arguments to models through ForeignKey attributes

    - by marshall
    I've got a class like this: class Image (models.Model): ... sizes = ((90,90), (300,250)) def resize_image(self): for size in sizes: ... and another class like this: class SomeClassWithAnImage (models.Model): ... an_image = models.ForeignKey(Image) what i'd like to do with that class is this: class SomeClassWithAnImage (models.Model): ... an_image = models.ForeignKey(Image, sizes=((90,90), (150, 120))) where i'm can specify the sizes that i want the Image class to use to resize itself as a argument rather than being hard coded on the class. I realise I could pass these in when calling resize_image if that was called directly but the idea is that the resize_image method is called automatically when the object is persisted to the db. if I try to pass arguments through the foreign key declaration like this i get an error straight away. is there an easy / better way to do this before I begin hacking down into django?

    Read the article

  • Django ForeignKey TemplateSyntaxError and ProgrammingError

    - by Daniel Garcia
    This is are my models i want to relate. i want for collection to appear in the form of occurrence. class Collection(models.Model): id = models.AutoField(primary_key=True, null=True) code = models.CharField(max_length=100, null=True, blank=True) address = models.CharField(max_length=100, null=True, blank=True) collection_name = models.CharField(max_length=100) def __unicode__(self): return self.collection_name class Meta: db_table = u'collection' ordering = ('collection_name',) class Occurrence(models.Model): id = models.AutoField(primary_key=True, null=True) reference = models.IntegerField(null=True, blank=True, editable=False) collection = models.ForeignKey(Collection, null=True, blank=True, unique=True), modified = models.DateTimeField(null=True, blank=True, auto_now=True) class Meta: db_table = u'occurrence' Every time i go to check the Occurrence object i get this error TemplateSyntaxError at /admin/hotiapp/occurrence/ Caught an exception while rendering: column occurrence.collection_id does not exist LINE 1: ...LECT "occurrence"."id", "occurrence"."reference", "occurrenc.. And every time i try to add a new occurrence object i get this error ProgrammingError at /admin/hotiapp/occurrence/add/ column occurrence.collection_id does not exist LINE 1: SELECT (1) AS "a" FROM "occurrence" WHERE "occurrence"."coll... What am i doing wrong? or how does ForeignKey works?

    Read the article

  • Show models.ManyToManyField as inline, with the same form as models.ForeignKey inline

    - by Kristian
    I have a model similar to the following (simplified): models.py class Sample(models.Model): name=models.CharField(max_length=200) class Action(models.Model): samples=models.ManyToManyField(Sample) title=models.CharField(max_length=200) description=models.TextField() Now, if Action.samples would have been a ForeignKey instead of a ManyToManyField, when I display Action as a TabularInline in Sample in the Django Admin, I would get a number of rows, each containing a nice form to edit or add another Action. However; when I display the above as an inline using the following: class ActionInline(admin.TabularInline): model=Action.samples.through I get a select box listing all available actions, and not a nifty form to create a new Action. My question is really: How do I display the ManyToMany relation as an inline with a form to input information as described? In principle it should be possible since, from the Sample's point of view, the situation is identical in both cases; Each Sample has a list of Actions regardless if the relation is a ForeignKey or a ManyToManyRelation. Also; Through the Sample admin page, I never want to choose from existing Actions, only create new or edit old ones.

    Read the article

  • Django QuerySet ordering by number of reverse ForeignKey matches

    - by msanders
    I have the following Django models: class Foo(models.Model): title = models.CharField(_(u'Title'), max_length=600) class Bar(models.Model): foo = models.ForeignKey(Foo) eg_id = models.PositiveIntegerField(_(u'Example ID'), default=0) I wish to return a list of Foo objects which have a reverse relationship with Bar objects that have a eg_id value contained in a list of values. So I have: id_list = [7, 8, 9, 10] qs = Foo.objects.filter(bar__eg_id__in=id_list) How do I order the matching Foo objects according to the number of related Bar objects which have an eg_id value in the id_list?

    Read the article

  • ForeignKey django 1.1.1 model

    - by Spikie
    i have class staff_name(models.Model): firstname = models.CharField(max_length=150) surname = models.CharField(max_length=150) class inventory_transaction(models.Model): staffs = models.ForeignKey(staff_name) i want to get or create staff surname and first name through inventory_transaction i used these code below inventory_transaction.objects.get_or_create(staffs_surname_contains=sname,staffs_firstname_contains=fname) i got this error "staffs_surname_contains can not be defined" what have i done wrong ? thanks

    Read the article

  • how to limit the foreignkey dropdown with constraints?

    - by FurtiveFelon
    Hi all, I have a database which keeps track of interaction between two different teams (represented in the admin interface by two different groups). For some fields, i have a foreignkey to Users database, and i would like to limit the dropdown people to only the specific groups. If anyone have any suggestions, it would be much appreciated! Jason

    Read the article

  • Django: get count of ForeignKey item in template?

    - by AP257
    Straightforward question - apologies if it is a duplicate, but I can't find the answer if so. I have a User model and a Submission model, like this: class Submission(models.Model): uploaded_by = models.ForeignKey('User') class User(models.Model): name = models.CharField(max_length=250 ) How can I show the number of Submissions made by each user in the template? I've tried {{ user.submission.count }}, like this: for user in users: {{ user.name }} ({{ user.submission.count }} submissions) but no luck...

    Read the article

  • DataRelation Insert and ForeignKey

    - by Steve
    Guys, I have a winforms application with two DataGridViews displaying a master-detail relationship from my Person and Address tables. Person table has a PersonID field that is auto-incrementing primary key. Address has a PersonID field that is the FK. I fill my DataTables with DataAdapter and set Person.PersonID column's AutoIncrement=true and AutoIncrementStep=-1. I can insert records in the Person DataTable from the DataGridView. The PersonID column displays unique negative values for PersonID. I update the database by calling DataAdapter.Update(PersonTable) and the negative PersonIDs are converted to positive unique values automatically by SQL Server. Here's the rub. The Address DataGridView show the address table which has a DataRelation to Person by PersonID. Inserted Person records have the temporary negative PersonID. I can now insert records into Address via DataGridView and Address.PersonID is set to the negative value from the DataRelation mapping. I call Adapter.Update(AddressTable) and the negative PersonIDs go into the Address table breaking the relationship. How do you guys handle primary/foreign keys using DataTables and master-detail DataGridViews? Thanks! Steve EDIT: After more googling, I found that SqlDataAdapter.RowUpdated event gives me what I need. I create a new command to query the last id inserted by using @@IDENTITY. It works pretty well. The DataRelation updates the Address.PersonID field for me so it's required to Update the Person table first then update the Address table. All the new records insert properly with correct ids in place! Adapter = new SqlDataAdapter(cmd); Adapter.RowUpdated += (s, e) => { if (e.StatementType != StatementType.Insert) return; //set the id for the inserted record SqlCommand c = e.Command.Connection.CreateCommand(); c.CommandText = "select @@IDENTITY id"; e.Row[0] = Convert.ToInt32( c.ExecuteScalar() ); }; Adapter.Fill(this); SqlCommandBuilder sb = new SqlCommandBuilder(Adapter); sb.GetDeleteCommand(); sb.GetUpdateCommand(); sb.GetInsertCommand(); this.Columns[0].AutoIncrement = true; this.Columns[0].AutoIncrementSeed = -1; this.Columns[0].AutoIncrementStep = -1;

    Read the article

  • ASP.NET MVC 2: Linq to SQL entity w/ ForeignKey relationship and Default ModelBinder strangeness

    - by Simon
    Once again I'm having trouble with Linq to Sql and the MVC Model Binder. I have Linq to Sql generated classes, to illustrate them they look similar to this: public class Client { public int ClientID { get; set; } public string Name { get; set; } } public class Site { public int SiteID { get; set; } public string Name { get; set; } } public class User { public int UserID { get; set; } public string Name { get; set; } public int? ClientID { get; set; } public EntityRef<Client> Client { get; set; } public int? SiteID { get; set; } public EntityRef<Site> Site { get; set; } } The 'User' has a relationship with the 'Client' and 'Site . The User class has nullable ClientIDs and SiteIDs because the admin users are not bound to a Client or Site. Now I have a view where a user can edit a 'User' object, the view has fields for all the 'User' properties. When the form is submitted, the appropiate 'Save' action is called in my UserController: public ActionResult Save(User user, FormCollection form) { //form['SiteID'] == 1 //user.SiteID == 1 //form['ClientID'] == 1 //user.ClientID == null } The problem here is that the ClientID is never set, it is always null, even though the value is in the FormCollection. To figure out whats going wrong I set breakpoints for the ClientID and SiteID getters and setters in the Linq to Sql designer generated classes. I noticed the following: SiteID is being set, then ClientID is being set, but then the Client EntityRef property is being set with a null value which in turn is setting the ClientID to null too! I don't know why and what is trying to set the Client property, because the Site property setter is never beeing called, only the Client setter is being called. Manually setting the ClientID from the FormCollection like this: user.ClientID = int.Parse(form["ClientID"].ToString()); throws a 'ForeignKeyReferenceAlreadyHasValueException', because it was already set to null before. The only workaround I have found is to extend the generated partial User class with a custom method: Client = default(EntityRef<Client>) but this is not a satisfying solution. I don't think it should work like this? Please enlighten me someone. So far Linq to Sql is driving me crazy! Best regards

    Read the article

  • Django ForeignKey _set on an inherited model

    - by neolaser
    I have two models Category and Entry. There is another model ExtEntry that inherits from Entry class Category(models.Model): title = models.CharField('title', max_length=255) description = models.TextField('description', blank=True) ... class Entry(models.Model): title = models.CharField('title', max_length=255) categories = models.ManyToManyField(Category) ... class ExtEntry(Entry): groups= models.CharField('title', max_length=255) value= models.CharField('title', max_length=255) ... I am able to use the Category.entry_set but I want to be able to do Category.blogentry_set but it is not available. If this is not available,then I need another method to get all ExtEntryrelated to one particular Category Thanks

    Read the article

  • Django blog reply system

    - by dana
    hello, i'm trying to build a mini reply system, based on the user's posts on a mini blog. Every post has a link named reply. if one presses reply, the reply form appears, and one edits the reply, and submits the form.The problem is that i don't know how to take the id of the post i want to reply to. In the view, if i use as a parameter one number (as an id of the blog post),it inserts the reply to the database. But how can i do it by not hardcoding? The view is: def save_reply(request): if request.method == 'POST': form = ReplyForm(request.POST) if form.is_valid(): new_obj = form.save(commit=False) new_obj.creator = request.user new_post = New(1) #it works only hardcoded new_obj.reply_to = new_post new_obj.save() return HttpResponseRedirect('.') else: form = ReplyForm() return render_to_response('replies/replies.html', { 'form': form, }, context_instance=RequestContext(request)) i have in forms.py: class ReplyForm(ModelForm): class Meta: model = Reply fields = ['reply'] and in models: class Reply(models.Model): reply_to = models.ForeignKey(New) creator = models.ForeignKey(User) reply = models.CharField(max_length=140,blank=False) objects = NewManager() mentioning that New is the micro blog class thanks

    Read the article

  • django: How to make one form from multiple models containing foreignkeys

    - by Tim
    I am trying to make a form on one page that uses multiple models. The models reference each other. I am having trouble getting the form to validate because I cant figure out how to get the id of two of the models used in the form into the form to validate it. I used a hidden key in the template but I cant figure out how to make it work in the views My code is below: views: def the_view(request, a_id,): if request.method == 'POST': b_form= BForm(request.POST) c_form =CForm(request.POST) print "post" if b_form.is_valid() and c_form.is_valid(): print "valid" b_form.save() c_form.save() return HttpResponseRedirect(reverse('myproj.pro.views.this_page')) else: b_form= BForm() c_form = CForm() b_ide = B.objects.get(pk=request.b_id) id_of_a = A.objects.get(pk=a_id) return render_to_response('myproj/a/c.html', {'b_form':b_form, 'c_form':c_form, 'id_of_a':id_of_a, 'b_id':b_ide }) models class A(models.Model): name = models.CharField(max_length=256, null=True, blank=True) classe = models.CharField(max_length=256, null=True, blank=True) def __str__(self): return self.name class B(models.Model): aid = models.ForeignKey(A, null=True, blank=True) number = models.IntegerField(max_length=1000) other_number = models.IntegerField(max_length=1000) class C(models.Model): bid = models.ForeignKey(B, null=False, blank=False) field_name = models.CharField(max_length=15) field_value = models.CharField(max_length=256, null=True, blank=True) forms from mappamundi.mappa.models import A, B, C class BForm(forms.ModelForm): class Meta: model = B exclude = ('aid',) class CForm(forms.ModelForm): class Meta: model = C exclude = ('bid',) B has a foreign key reference to A, C has a foreign key reference to B. Since the models are related, I want to have the forms for them on one page, 1 submit button. Since I need to fill out fields for the forms for B and C & I dont want to select the id of B from a drop down list, I need to somehow get the id of the B form into the form so it will validate. I have a hidden field in the template, I just need to figure how to do it in the views

    Read the article

  • Django: UserProfile with Unique Foreign Key in Django Admin

    - by lazerscience
    Hi, I have extended Django's User Model using a custom user profile called UserExtension. It is related to User through a unique ForeignKey Relationship, which enables me to edit it in the admin in an inline form! I'm using a signal to create a new profile for every new user: def create_user_profile(sender, instance, created, **kwargs): if created: try: profile, created = UserExtension.objects.get_or_create(user=instance) except: pass post_save.connect(create_user_profile, sender=User) (as described here for example: http://stackoverflow.com/questions/44109/extending-the-user-model-with-custom-fields-in-django) The problem is, that, if I create a new user through the admin, I get an IntegritiyError on saving "column user_id is not unique". It doesnt seem that the signal is called twice, but i guess the admin is trying to save the profile AFTERWARDS? But I need the creation through signal if I create a new user in other parts of the system!

    Read the article

  • Django save, column specified twice

    - by realshadow
    Hey, I would like to save a modified model, but I get Programming error - that a field is specified twice. class ProductInfo(models.Model): product_info_id = models.AutoField(primary_key=True) language_id = models.IntegerField() product_id = models.IntegerField() description = models.TextField(blank=True) status = models.IntegerField() model = models.CharField(max_length=255, blank=True) label = models.ForeignKey(Category_info, verbose_name = 'Category_info', db_column = 'language_id', to_field = 'node_id', null = True) I get this error because the foreign key uses as db_column language_id. If I will delete it, my object will be saved properly. I dont quite understand whats going on and since I have defined almost all of my models this way, I fear its totally wrong or maybe I just missunderstood it... Any ideas? Regards

    Read the article

  • Easy way to observe user activity - how improve my database structure.

    - by Thomas
    Welcome, I need some advise to improve perfomence my web application. In the begin I had this structure of database: USER -id (Primary Key) -name -password -email .... PROFILE -user Primary Key, Foreign Key (USER) -birthday -region -photoFile ... PAGES -id (Primary Key) -user Foreign Key(USER) -page -date COMMENTS -id (Primary Key) -user Foreign Key(USER) -page Foreign Key(PAGE) -comment -date FAVOURITES_PAGES -id (Primary Key) -user Foreign Key(USER) -favourite_page Foreign Key(PAGE) -date but now one of the most important page of website is observatory, when everyone can observe activity others users. So I need select all pages, comments and favourites pages some users and display it in one list, sorted by date. For better perfomance (I think) I changed my structure to this: table USER and PROFILE without changes ACTIVITY (additional table- have common fields: user,date) -id (Primary Key) -user Foreign Key(USER) -date -page Foreign Key(PAGE) -comment Foreign Key(COMMENTS) -favourite_page Foreign Key(FAVOURITES_PAGES) PAGES -id (Primary Key) -page COMMENTS -id (Primary Key) -page Foreign Key(PAGE) -comment FAVOURITES_PAGES -id (Primary Key) -favourite_page Foreign Key(PAGE) So now it is very easy get sorted records from all tables. But I have no only foreign key to PAGES, COMMENTS and FAVOURITES_PAGES in ACTIVITY table - there is about ten Foreign Key fields and in one record only one have value, others have None: ACTIVITY id user date page comment ... 1 2 2010-02-23 None 1 2 1 2010-02-21 1 None .... It is corect solution. When I display about 40 records in one page (pagination) I must wait about one secound, but database is almost emty (a few users and about 100 records in others tables). It is depends on amount records per page - I have checked it, but why it takes too long time, becouse of relationships? The website is built in Python/Django. Any advices/opinion?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >