Search Results

Search found 25123 results on 1005 pages for 'domain model'.

Page 136/1005 | < Previous Page | 132 133 134 135 136 137 138 139 140 141 142 143  | Next Page >

  • Get a queryset of objects through an intermediary model

    - by skyl
    I want get all of the Geom objects that are related to a certain content_object (see the function I'm trying to build at the bottom, get_geoms_for_obj() class Geom(models.Model): ... class GeomRelation(models.Model): ''' For tagging many objects to a Geom object and vice-versa''' geom = models.ForeignKey(Geom) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey() def get_geoms_for_object(obj): ''' takes an object and gets the geoms that are related ''' ct = ContentType.objects.get_for_model(obj) id = obj.id grs = GeomRelation.objects.filter( content_type=ct, object_id=id ) # how with django orm magic can I build the queryset instead of list # like below to get all of the Geom objects for a given content_object geoms = [] for gr in grs: geoms.append(gr.geom) return set(geoms) # A set makes it so that I have no redundant entries but I want the # queryset ordering too .. need to make it a queryset for so many reasons...

    Read the article

  • Convert executed SQL result to a list of Model object

    - by huynq9
    I'm wondering that is it possible to convert the executed query result to a list of models. I'm using Ruby with ActiveRecord and need to execute custom SQL query to join two or many tables. The code looks like below: connection = ActiveRecord::Base.connection sql = "select T1.f1, T2.f2 from T1 left join T2 on T1.id = T2.id" @result = connection.execute(sql) In Ruby code, I defined a models to manage the executed SQL result: class Model property :f1, :f2 end Is there any way to convert @result to list of Model object? so I can deal with each item in the list as following @result.each do |item| puts item.f1 puts item.f2 end

    Read the article

  • asp.net mvc default model binding problem

    - by csetzkorn
    I have some problems with ASP.NET MVC’s default model binder. The View contains HTML like this: <input name="SubDTO[0].Id" value="1" type="checkbox"> <input name="SubDTO[1].Id" value="2" type="checkbox"> This is my simplified ‘model’: public class SubDTO { public virtual string Id { get; set; } } public class DTO { public List<SubDTO> SubDTOs { get; set; } public DTO() { SubDTOs = new List< SubDTO>(); } } All this works fine if the user selects at least the first checkbox (SubDTO[0].Id). The controller ‘receives’ a nicely initialised/bound DTO. However, if the first check box is not selected but only, for example, SubDTO[1].Id the object SubDTOs is null. Can someone please explain this ‘strange’ behaviour and how to overcome it? Thanks. Best wishes, Christian

    Read the article

  • Model Django Poll

    - by MacPython
    I followed the django tutorial here: http://docs.djangoproject.com/en/dev/intro/tutorial01/ and now I am at creating a poll. The code below works fine until I want to create choices, where for some reason I always get this error message: line 22, in unicode return self.question AttributeError: 'Choice' object has no attribute 'question' Unfortunatley, I dont understand where I made an error. Any help would be greatly appreciated. Thanks for the time! CODE: import datetime from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question def was_published_today(self): return self.pub_date.date() == datetime.date.today() class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def __unicode__(self): return self.question

    Read the article

  • Model state inferno - how can Model.A be two different things at the same time?

    - by Martin
    I have this <%=Model.StartDate%> <%=Html.Hidden("StartDate", Model.StartDate)%> it outputs: 2010-05-11 11:00:00 +01:00 <input type="hidden" value="2010-03-17 11:00:00 +01:00" name="StartDate" id="StartDate"> What the... It's a paging mechanism so the hidden value was valid on the first page and I've been able to move forward to the next page. But since the values won't update properly it ends there. What do I need to do? Using firefox.

    Read the article

  • [Linux] domain socket "sendto" encounter "errno 111, connection refused"

    - by z.cHris
    I am using domain socket to get values from another process, like A to get a value from B, It works well for months. But recently, A is failed during "sendto" message to B with "errno 111, connection refused" occasionally. I checked the B domain socket bind file, it is exists. I also do some tests in another machine, also works well. So, does anyone encounter this problem before? Can anyone have some clues what might be probably wrong in this scenario? Thanks very much.

    Read the article

  • ASP.NET MVC: View does not get rendered with updated model value

    - by Newton
    I'm experiencing the a challenge in populating the child records. My previous code was like - <%= Html.TextBox("DyeOrder.Summary[" + i + "].Ratio", Model.DyeOrder.Summary[i].Ratio.ToString("#0.00"), ratioProperties) %> This code does not render the updated values after post back. To resolve this issue my work around was like - <%= "<input id='DyeOrder_Summary_" + i + "__Ratio' name='DyeOrder.Summary[" + i + "].Ratio' value='" + Model.DyeOrder.Summary[i].Ratio.ToString("#0.00") + "' " + ratioCss + " type='text' />"%> This is very clumsy to me. Is there any better ideas...

    Read the article

  • How to handle this type of model validation in Ruby on Rails

    - by randombits
    I have a controller/model hypothetically named Pets. Pets has the following declarations: :belongs_to owner :has_many dogs :has_many cats Not the best example, but again, it demonstrates what I'm trying to solve. Now when a request comes in as an HTTP POST to http://127.0.0.1/pets, I want to create an instance of Pets. The restriction here is, if the user doesn't submit at least one dog or one cat, it should fail validation. It can have both, but it can't be missing both. How does one handle this in Ruby on Rails? Dogs don't care if cats exists and the inverse is also true. Can anyone show some example code of what the Pets model would look like to ensure that one or the other exists, or fail otherwise? errors.add also takes an attribute, in this case, there is no particular attribute that's failing. It's almost a 'virtual' combination that's missing.

    Read the article

  • Model Binding with Parent/Child Relationship

    - by user296297
    I'm sure this has been answered before, but I've spent the last three hours looking for an acceptable solution and have been unable to find anything, so I apologize for what I'm sure is a repeat. I have two domain objects, Player and Position. Player's have a Position. My domain objects are POCOs tied to my database with NHibernate. I have an Add action that takes a Player, so I'm using the built in model binding. On my view I have a drop down list that lets a user select the Position for the Player. The value of the drop down list is the Id of the position. Everything gets populated correctly except that my Position object fails validation (ModelState.IsValid) because at the point of model binding it only has an Id and none of it's other required attributes. What is the preferred solution for solving this with ASP.NET MVC 2? Solutions I've tried... Fetch the Position from the database based on the Id before ModelState.IsValid is called in the Add action of my controller. I can't get the model to run the validation again, so ModelState.IsValid always returns false. Create a custom ModelBinder that inherits from the default binder and fetch the Position from the database after the base binder is called. The ModelBinder seems to be doing the validation so if I use anything from the default binder I'm hosed. Which means I have to completely roll my own binder and grab every value from the form...this seems really wrong and inefficient for such a common use-case. Solutions I think might work, I just can't figure out how to do... Turn off the validation for the Position class when used in Player. Write a custom ModelBinder leverages the default binder for most of the property binding, but lets me get the Position from the database BEFORE the default binder runs validation. So, how do the rest of you solve this? Thanks, Dan P.S. In my opinion having a PositionId on Player just for this case is not a good solution. There has to be solvable in a more elegant fashion.

    Read the article

  • CakePHP: Using two tables for a single model

    - by mwaterous
    I'm just picking up development in CakePHP right now so forgive me if this seems obvious; it did to me when I first read about has, belongsTo, hasMany, etc. The problem is I would like to associate two tables with a single model, and was wondering if there was a way to configure this so that when CakePHP did it's queries it automatically performed a join on the two tables. I don't want to create a separate model for the second table as it is merely a meta information table - the master table will contain the primary information required, the meta table will be populated with secondary information that is not required and therefore may or may not be set for every row of the master table.

    Read the article

  • model (3ds) stats & snapshot in linux

    - by acidzombie24
    I want to write an app that takes in a model filename via cmd line, create a list of stats (poly count, scaling, as much as possible or maybe the stats that i would like) and to load the model with its textures (with anything else) and draw it from multiple position to save the images as pngs. How would i do this? are there utils i can use to extract data from models? how about drawing the models? my server does not have a desktop or video card, would no video HW be a problem?

    Read the article

  • How do I add to a model when on the Show of another model?

    - by Angela
    I on the Show of "Contacts" and want, from that page, to submit a Comment that is related to the Contact. The way I understand to do it would be: <%= start_form_tag :action => "add_comment", :id => @contact %> <% text_area "comment, "body", "rows" = > 5 %> <br> <%= submit_tag %> <%= end_form_tag %> I would create a method in the Contacts controller: def add_comment Contact.find(params[:id]).comments.create(params[:comment]) end However, I feel there's a better way, but don't know what that is? I learned this on a pretty outdated book. Basically, I want to add a new object belonging to a Model while on the Show of a different Model. Would formtastic help me, and if so, how?

    Read the article

  • How Do I Import a 3D Object into Adobe Flex?

    - by Kim
    Hi everyone, I wanted to know if anyone here knows how to import a 3D Object (i.e. Maya 3D Model) into Adobe Flex Application? I needed to create a simple Flex application which will allow me to rotate the 3D Object by dragging but I cannot seem to start doing it because I'm having a hard time trying to figure out how I can import my 3D model into Flex. This is exactly what I wanted to do: 3D Object in Flex I hope someone can help me. Thanks a lot :)

    Read the article

  • Setting Up TFS Server outside of a domain

    - by Ben
    Hi Im trying to set up TFS 2010 on a machine that is connected to a network, but not on the domain. I am trying to connect this to a SQL Server that is also connected to the network and also not on the domain. When I run through the TFS configuration Wizard and try to connect to the SQL Server, it fails with a message "A connection can not be made...." which looks like it cant see the Server. However when i connect through SQL Management Studio it works when i use SQL Authentication (not Windows Auth). I beleive its failing because TFS needs to connect using Windows Authetication (please correct me if im wrong). I can not add the Windows Authentication for my TFS machine onto the SQL machine becuase they are on different domains (again, pleas correct me if I'm wrong). Does anyone have any suggestions? Thanks.

    Read the article

  • Trim email list into domain list

    - by hanjaya
    The function below is part of a script to trim email list from a file into domain list and removes duplicates. /* define a function that can accept a list of email addresses */ function getUniqueDomains($list) { // iterate over list, split addresses and add domain part to another array $domains = array(); foreach ($list as $l) { $arr = explode("@", $l); $domains[] = trim($arr[1]); } // remove duplicates and return return array_unique($domains); } What does $domains[] = trim($arr[1]); mean? Specifically the $arr[1]. What does [1] mean in this context? How come variable $arr becomes an array variable?

    Read the article

  • default model field attribute in Django

    - by Rosarch
    I have a Django model: @staticmethod def getdefault(): print "getdefault called" return cPickle.dumps(set()) _applies_to = models.TextField(db_index=True, default=getdefault) For some reason, getdefault() is never called, even as I construct instances of this model and save them to the database. This seems to contradict the Django documentation: Field.default The default value for the field. This can be a value or a callable object. If callable it will be called every time a new object is created. Am I doing something wrong? Update: Originally, I had this, but then I switched to the above version to debug: _applies_to = models.TextField(db_index=True, default=cPickle.dumps(set())) I'm not sure why that wouldn't work.

    Read the article

  • Rails - Paperclip, getting width and height of image in model

    - by Corey Tenold
    Trying to get the width and height of the uploaded image while still in the model on the initial save. Any way to do this? Here's the snippet of code I've been testing with from my model. Of course it fails on "instance.photo_width". has_attached_file :photo, :styles => { :original => "634x471>", :thumb => Proc.new { |instance| ratio = instance.photo_width/instance.photo_height min_width = 142 min_height = 119 if ratio > 1 final_height = min_height final_width = final_height * ratio else final_width = min_width final_height = final_width * ratio end "#{final_width}x#{final_height}" } }, :storage => :s3, :s3_credentials => "#{RAILS_ROOT}/config/s3.yml", :path => ":attachment/:id/:style.:extension", :bucket => 'foo_bucket' So I'm basically trying to do this to get a custom thumbnail width and height based on the initial image dimensions. Any ideas?

    Read the article

  • In Grails, How can I create a domain model to link two of another model?

    - by gerges
    Hey all, I'm currently trying to create a Friendship domain object to link two User objects (with a bit of additional data: createDate, confirmedStatus). My domain model looks as follows class Friendship { User userOne User userTwo Boolean confirmed Date createDate Date lastModifiedDate static belongsTo = [userOne:User , userTwo:User] static constraints = { userOne() userTwo() confirmed() createDate() lastModifiedDate() } } I've also added the following entries to the user class static hasMany = [ friendships:Friendship ] static mappedBy = [ friendships:'userOne' , friendships:'userTwo' ] When I do this, the result is a new friendship created (and viewable through the controller) with both users listed in their respective places. When I view the details of userOne, I see the friedship listed. When I view the details of userTwo, no friendship is listed. This is not the behavior I expected. What am I doing incorrectly? Why can't I see the friendship listed under both users?

    Read the article

  • Determining Cross Domain Active Directory Group Membership

    - by thecaptain0220
    I am currently working on a project where I need to query Active Directory to determine group membership of a user. I initially was locating the user and retrieving the memberOf attribute. The problem with this is that there is a domain and a child domain. The groups are universal groups so they can be used in both domains and they don't show up in the memberOf attribute. Unfortunately there doesn't seem to be much info around for Active Directory access with C++. Is there anyway to determine group membership in this case in C++?

    Read the article

  • Mercurial Branching Model for task features

    - by Stan
    My development env: Windows 7, TortoiseHg, ASP.NET 4.0/MVC3 Test branch: code on test server Prod branch: code on production server This is my current branching model. The reason to branch out every task (feature) is because some features go to live slower. So in above graph, task 1 finished earlier (changeset #5), and merge into test branch for testing. However, due to bug or modification of original request, changesets #10, #12 have been made. While task 2 has finished testing #8 and pushed to live #9 already. My problem is every time when modifying task branch (like #10, #12), I have to do another merge to test branch (#11, #13), this makes the graph very messy. Is there any way to solve this issue? Or any better branching model?

    Read the article

  • How do you set a cookie to be accessible across the entire domain in Javascript

    - by Tzarkov
    I suppose there should be a way to set a cookie to be accessible from the entire domain nevermind from which directory you are setting the cookie. Say in mypage.com/blue/index.php y set the cookie "colour=blue;" this way: document.cookie = "colour" + "=" + "blue" + "; expires=" + expireDate.toGMTString() + "; path=/"; Using this code, the cookie retrieval function in mypage.com/home.php can't access the content of the cookie. If it was just from first level directories that the cookie needs to be set, we would be ok by doing path=../ instead of path=/ But how do you go about writing generic code that sets a cookie that is accessible from any page in that domain not minding how deep in the file structure is the page the cookie is being set from?

    Read the article

  • How do I keep subdomain.domain.com links from mapping to subdomain.domain.com/subdomain?

    - by Alan Jackson
    I have a virtual directory created and a sub domain that points to that virtual directory. My links always route to subdomain.domain.com/subdomain/controller/action when they can leave off the subdomain link. Is there an easy way to stop that? Also, it's the same problem when I mapped anotherdomain.com to my virtual directory. It ends up linking to anotherdomain.com/virtualdir/controller/action. It just looks unprofessional to me to have all my links be myapp.com/myapp/action/controller.

    Read the article

< Previous Page | 132 133 134 135 136 137 138 139 140 141 142 143  | Next Page >