Search Results

Search found 15231 results on 610 pages for 'presentation model'.

Page 62/610 | < Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >

  • List of Django model instance foreign keys losing consistency during state changes.

    - by Joshua
    I have model, Match, with two foreign keys: class Match(model.Model): winner = models.ForeignKey(Player) loser = models.ForeignKey(Player) When I loop over Match I find that each model instance uses a unique object for the foreign key. This ends up biting me because it introduces inconsistency, here is an example: >>> def print_elo(match_list): ... for match in match_list: ... print match.winner.id, match.winner.elo ... print match.loser.id, match.loser.elo ... >>> print_elo(teacher_match_list) 4 1192.0000000000 2 1192.0000000000 5 1208.0000000000 2 1192.0000000000 5 1208.0000000000 4 1192.0000000000 >>> teacher_match_list[0].winner.elo = 3000 >>> print_elo(teacher_match_list) 4 3000 # Object 4 2 1192.0000000000 5 1208.0000000000 2 1192.0000000000 5 1208.0000000000 4 1192.0000000000 # Object 4 >>> I solved this problem like so: def unify_refrences(match_list): """Makes each unique refrence to a model instance non-unique. In cases where multiple model instances are being used django creates a new object for each model instance, even if it that means creating the same instance twice. If one of these objects has its state changed any other object refrencing the same model instance will not be updated. This method ensure that state changes are seen. It makes sure that variables which hold objects pointing to the same model all hold the same object. Visually this means that a list of [var1, var2] whose internals look like so: var1 --> object1 --> model1 var2 --> object2 --> model1 Will result in the internals being changed so that: var1 --> object1 --> model1 var2 ------^ """ match_dict = {} for match in match_list: try: match.winner = match_dict[match.winner.id] except KeyError: match_dict[match.winner.id] = match.winner try: match.loser = match_dict[match.loser.id] except KeyError: match_dict[match.loser.id] = match.loser My question: Is there a way to solve the problem more elegantly through the use of QuerySets without needing to call save at any point? If not, I'd like to make the solution more generic: how can you get a list of the foreign keys on a model instance or do you have a better generic solution to my problem? Please correct me if you think I don't understand why this is happening.

    Read the article

  • How to model a social news feed on Google App Engine

    - by PEZ
    We want to implement a "News feed" where a user can see messages broadcasted by her friends, sorted with newest message first. But the feed should reflect changes in her friends list. (If she adds new friends, messages from those should be included in the feed, and if she removes friends their messages should not be included.) If we use the pubsub-test example and attach a recipient list to each message this means a lot of manipulation of the message recipients lists when users connect and disconnect friends. We first modeled publish-subscribe "fan out" using conventional RDBMS thinking. It seemed to work at first, but then, since the IN operator works the way it does, we quickly realized we couldn't continue on that path. We found Brett Slatkin's presentation from last years Google I/O and we have now watched it a few times but it isn't clear to us how to do it with "dynamic" recipient lists. What we need are some hints on how to "think" when modeling this.

    Read the article

  • XML file as model for django project

    - by Ankur Chauhan
    Hi, I have a XML file that is managed by other programs, I am writing a web service such that users are able to query this file. In essence i am using a xml based database instead of using sql as the model database in Django. how do i do this? all the tutorials that i find use a sql database in the backend. is there a way to use the xml file as a database.

    Read the article

  • How to get the model of iPhone from code. (e.g. MC143C)

    - by zakirulq
    Hi, I need to get the iPhone model number from code. I can see the model number from my iPhone which is "MC143C", but when I am retrieving this by using code it is returning "iPhone". This is the code I am using to get the model number. NSLog(@"model: %@", [[UIDevice currentDevice] model]); Can anyone please help me to have the information i want to get from my device. Thanks, !ZAQ

    Read the article

  • Nested Model Form p1 Railscasts example

    - by arzon
    Has anyone managed to make the example at http://railscasts.com/episodes/196-nested-model-form-part-1 work? When I followed through the sample, it never saves any question nor the answer to the database but it manages to create a new survey entry. I am using: Rails 2.3.5 ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32] nifty-generators (0.4.0)

    Read the article

  • Best solution for managing navigation (and marking currently active item) in CakePHP

    - by Nathan
    So I have been looking around for a couple hours for a solid solution to handling site navigation in CakePHP. Over the course of a dozen projects, I have rigged together something that works for each one, but what I'm looking for is ideally a CakePHP plugin that handles the following: Navigation Model Component for handing off to the view Element View Helper for displaying the navigation (with control over sublevels displayed and automatically determining the "active" item based on URL and/or controller/model/slug Admin pages for managing a tree of navigation Any suggestions for an all-in-one solution or even the individual components would be very appreciated! Or even suggestions on how you have handled it in the past

    Read the article

  • In Rails, how can a record belong_to a single user, but also have multiple "secondary" users?

    - by Kuro
    In my app, I have a User model and a Project model. A user has_many assignments and each project belongs_to a user. But along with each project having an owner, the user who created it, I would like the owner be able to share it with others (so that the project gets shown on the other users' account along with their own). I imagine having to use has_many :through, and setting up a projects_users table with a user_id and a project_id. And I guess this would be the end result? Project.first.user # The creator of the project => #<User id: 1, name: 'andrew', etc...> Project.first.users # The users that the creator chose to share it with => [#<User id: 2 ...>, #<User id: 3 ...>] How would I go about doing this? Thanks!

    Read the article

  • How to configure the 5554:WVGA800H model in android

    - by siva
    HI Can any one help me out in Configuring the 5554:WVGA800H model in android,as per this link http://developer.android.com/guide/developing/tools/emulator.html#emulatornetworking they have given the screen for the TABLET ,can any one guide me in this? Thanks & Regards P.Sivasankar

    Read the article

  • Cover flow model in iphone

    - by abdulsamad
    I am making the cover flow model on the iPhone using the tutorial found here: http://www.chaosinmotion.com/flowcover.m I want to move the cover flow animation up in the screen at height of about 150, but when I change the starting y point of the rectangle, then my image is cut off from the top. How can I prevent this?

    Read the article

  • Core Data => Adding a related object always nil

    - by mongeta
    Hello, I have two tables related: DataEntered and Model DataEntered -currentModel Model One DataEntered can have only ONE Model, but a Model can stay into many DataEntered. The relationship is from DataEntered to Model (No To Many-relathionship) and no inverse relation. XCode generates the setters for DataEnteredModel: @property (nonatomic, retain) NSSet * current_model; - (void)addCurrent_modelObject:(CarModel *)value; - (void)addCurrent_model:(NSSet *)value; I have a Table and when I select a model, I want to store it to DataEntered: Model *model = [fetchedResultsController objectAtIndexPath:indexPath]; NSLog(@"Model %@",model.name); // ==> gives me the correct model name [dataEntered addCurrent_modelObject:model]; // ==> always nil [dataEntered setCurrent_model:[fetchedResultsController objectAtIndexPath:indexPath]]; // the same, always nil what I'm doing wrong ????? thanks, r.

    Read the article

  • Zend Framework Modules can't find/load Models..

    - by user284503
    For some frustrating reason, I configured some Modules, which seemed to work fine, However I cannot load a Modules Models. If I move the Models to the Default they load, but I just can't get the Framework to find them locally.. Example: My Modules Directory is: application\modules\books\models\books.php (books is my Model) class Application_Module_Books_Model_Books extends Zend_Db_Table_Abstract {} I also tried.. Books_Model_Books, Model_Books, books, Modules_.. you name it I tried it :) My controller is in the Books Module, and is an Index Controller, and it can never find the Local Model. I'm using Application.ini and it is configured this way: resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers" resources.frontController.params.displayExceptions = 1 resources.frontController.moduleDirectory = APPLICATION_PATH "/modules" I have a BootStrap in the Modules Directory: class Admin_Bootstrap extends Zend_Application_Module_Bootstrap { } I'm on Zend Framework 1.10, and ideas.. ?

    Read the article

  • Django model fields getter / setter

    - by pistacchio
    Hi, is there something like getters and setters for django model's fields? For example, I have a text field in which i need to make a string replace before it get saved (in the admin panel, for both insert and update operations) and make another, different replace each time it is read. Those string replace are dynamic and need to be done at the moment of saving and reading. As I'm using python 2.5, I cannot use python 2.6 getters / setters. Any help?

    Read the article

  • populate textarea from model arraylist

    - by user281180
    I have an arraylist namelist in my model and in my view I need to fill the textarea with the values in the arraylist {%> <%=Html.TextArea("Namelist",Html.Encode(namelist))%> <%} But i`m having the following in my textarea being dislpayed: System.Collections.ArrayList... How to solve this?

    Read the article

  • JAVA - Strange problem (probably thread problem) with JTable & Model

    - by Stefanos Kargas
    I am using 2 Tables (JTable) with their DefaultTableModels. The first table is already populated. The second table is populated for each row of the first table (using an SQL Query). My purpose is to export every line of the first table with it's respective lines of the second in an Excel File. I am doing it with a for (for each line of 1st table), in which I write a line of the 1st table in the Excel File, then I populate the 2nd table (for this line of 1st Table), I get every line from the Table (from it's Model actually) and put it in the Excel File under the current line of 1st table. This means that if I have n lines in first table I will clear and populate again the second table n times. All this code is called in a seperate thread. THE PROBLEM IS: Everything works perfectly fine ecxept that I am getting some exceptions. The strange thing is that I'm not getting anything false in my result. The Excel file is perfect. Some of the lines of the exceptions are: Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 = 0 at java.util.Vector.elementAt(Vector.java:427) at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:632) at javax.swing.JComponent.paint(JComponent.java:1017) at javax.swing.RepaintManager.paint(RepaintManager.java:1220) at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:803) I am assuming that the problem lies in the fact that the second table needs some more time to be populated before I try to get any data from it. That's why I see RepaintManager and paintDirtyRegions in my exceptions. Another thing I did is that I ran my program in debug mode and I put a breakpoint after each population of the 2nd table. Then I pressed F5 to continue for each population of 2nd table and no exception appeared. The program came to it's end without any exceptions. This is another important fact that tells me that maybe in this case I gave the table enough time to be populated. Of course you will ask me: If your program works fine, why do you care about the exceptions? I care for avoiding any future problems and I care to have a better understanding of Java and Java GUI and threads. Why do you depend on a GUI component (and it's model) to get your information and why don't you recreate the resultset that populates your tables using an SQL Query and get your info from the resultset? That would be the best and the right way. The fact is that I have the tables code ready and it was easier for me to just get the info from them. But the right way would be to get everything direct from database. Anyway what I did brought out my question, and answering it would help me understand more things about java. So I posted it.

    Read the article

  • OCL constraints intended prevent node creation in an GMF generated editor only makes it invisible

    - by TheMorph
    Hello, I am working on editors created with GMF and struggling with OCL right now. Is there a possibilty to prevent a node to be created if an OCL statement in the mapping evaluates to false? If tried adding an OCL statement to a node and all it does is making the node not visible in the editor, but it is created. There is also an OCL statement in the ecore file, but this way it is only evaluated when there should be something done with the created model. I does not prevent a user to construct an invalid model but this is what I intend to prevent. Thanks in advance, Morph

    Read the article

  • How do I initialize attributes when I instantiate objects in Rails?

    - by nfm
    Clients have many Invoices. Invoices have a number attribute that I want to initialize by incrementing the client's previous invoice number. For example: @client = Client.find(1) @client.last_invoice_number > 14 @invoice = @client.invoices.build @invoice.number > 15 I want to get this functionality into my Invoice model, but I'm not sure how to. Here's what I'm imagining the code to be like: class Invoice < ActiveRecord::Base ... def initialize(attributes = {}) client = Client.find(attributes[:client_id]) attributes[:number] = client.last_invoice_number + 1 client.update_attributes(:last_invoice_number => client.last_invoice_number + 1) end end However, attributes[:client_id] isn't set when I call @client.invoices.build. How and when is the invoice's client_id initialized, and when can I use it to initialize the invoice's number? Can I get this logic into the model, or will I have to put it in the controller?

    Read the article

  • 3d model viewer in Flash or Java

    - by Magnetic_dud
    I want to show a box in 3d on my website, and I was thinking to do it in Flash. How I can show a 3d model? I need something very simple, it's a textured cube, no interaction required, just let the user pan and zoom. There is a 3ds viewer in flash or something like that? Java is also ok (but flash is preferred)

    Read the article

  • How to use OCL constraints to prevent node creation in an GMF generated editor

    - by TheMorph
    Hello, I am working on editors created with GMF and struggling with OCL right now. Is there a possibilty to prevent a node to be created if an OCL statement in the mapping evaluates to false? If tried adding an OCL statement to a node and all it does is making the node not visible in the editor, but it is created. There is also an OCL statement in the ecore file, but this way it is only evaluated when there should be something done with the created model. I does not prevent a user to construct an invalid model but this is what I intend to prevent. Thanks in advance, Morph

    Read the article

< Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >