Search Results

Search found 13838 results on 554 pages for 'disconnected model'.

Page 154/554 | < Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >

  • Sumproduct using Django's aggregation

    - by Matthew Rankin
    Question Is it possible using Django's aggregation capabilities to calculate a sumproduct? Background I am modeling an invoice, which can contain multiple items. The many-to-many relationship between the Invoice and Item models is handled through the InvoiceItem intermediary table. The total amount of the invoice—amount_invoiced—is calculated by summing the product of unit_price and quantity for each item on a given invoice. Below is the code that I'm currently using to accomplish this, but I was wondering if there is a better way to handle this using Django's aggregation capabilities. Current Code class Item(models.Model): item_num = models.SlugField(unique=True) description = models.CharField(blank=True, max_length=100) class InvoiceItem(models.Model): item = models.ForeignKey(Item) invoice = models.ForeignKey('Invoice') unit_price = models.DecimalField(max_digits=10, decimal_places=2) quantity = models.DecimalField(max_digits=10, decimal_places=4) class Invoice(models.Model): invoice_num = models.SlugField(max_length=25) invoice_items = models.ManyToManyField(Item,through='InvoiceItem') def _get_amount_invoiced(self): invoice_items = self.invoiceitem_set.all() amount_invoiced = 0 for invoice_item in invoice_items: amount_invoiced += (invoice_item.unit_price * invoice_item.quantity) return amount_invoiced amount_invoiced = property(_get_amount_invoiced)

    Read the article

  • Core Location in iPhone Simulator 3.2 (iPad)

    - by choise
    So, i'm trying to port my app to iPad. I'm using CoreLocation. Apple says the iPad does have Location: Wi-Fi Digital compass Assisted GPS (Wi-Fi + 3G model) Cellular (Wi-Fi + 3G model) so it should be possible to get the position of my ipad (at least with 3g model) about 3km radius would be enought. but it doesnt work in simulator (3.2 ipad) (running 3.1.3 in simulator simulates me cupertino). is there a way to get the position in simulator (3.2 ipad) ? i live in germany and here the ipad isnt released yet, so i cannot test it on my device. thanks!

    Read the article

  • Databinding a ListBox with SelectionMode = Multiple

    - by David Veeneman
    I have a WPF ListBox that I would like to Enable multiple selection in the ListBox, and Databind the ListBox to my view model. These two requirements appear to be incompatible. My view model has an ObservableCollection<T> property to bind to this ListBox; I set up a binding in XAML from the property to the ListBox.SelectedItems property. When I compiled, I got an error saying that the SelectedItems property was read only and could not be set from XAML. Am I binding to the wrong control property? Is there a way to bind a multiple-selection ListBox in XAML to a view model collection property? Thanks for your help.

    Read the article

  • GetAllUsers - MVC

    - by Jemes
    I’m using the Membership Provider and would like to display a list of all the users and their First Name, Last Name etc using the GetAllUsers function. I'm having trouble understanding how to implement this function in MVC. Has anyone implemented this in MVC or is there an easier way to list all the users in my application? Any help or advise would be really helpful. Controller public ActionResult GetUsers() { var users = Membership.GetAllUsers(); return View(users); } View Model public class GetUsers { [Required] [DisplayName("User name")] public string UserName { get; set; } [Required] [DisplayName("User name")] public string FirstName { get; set; } } View <%= Html.Encode(item.UserName) %> Error The model item passed into the dictionary is of type 'System.Web.Security.MembershipUserCollection', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[Account.Models.GetUsers]'.

    Read the article

  • Entity Framework 4 relationship management in POCO Templates - More lazy than FixupCollection?

    - by Joe Wood
    I've been taking a look at EF4 POCO templates in beta 2. The FixupCollection looks fine for maintaining the model correctness after updating the relationship collection property (i.e. product.Orders it would set the order.Product reference ). But what about support for handling the scenario when some of those Order objects are removed from the context? The use-case of maintaining cascading deletes in the in-memory model. The old Typed DataSet model used to do this by performing the query through the container to derive the relationship results. Like the DataSet, this would require a reference to the ObjectContext inside the entity class so that it could query the top-level Order collection. Better support for Separation of Concerns in the ObjectContext would be required. It looks like EF is not suited to this use-case that DataSets did out of the box.... am I right?

    Read the article

  • How to page while maintaining the querystring values in ASP.Net Mvc 2

    - by Picflight
    I am using the pager provided by Martijin Boland to implementing paging in my Asp.Net Mvc 2 application. My form uses the GET method to send all parameters to the querystring, it is a search form with several form elements. <% using (Html.BeginForm("SearchResults", "Search", FormMethod.Get)) {%> On the SearchResults View I am trying to implement paging: <div class="pager"> <%= Html.Pager(Model.PageSize, Model.PageNumber, Model.TotalItemCount, new { Request.QueryString })%> </div> The Html.Pager has some overloads which I am not too clear on how to use. The Request.QueryString makes the querystring look like this: http://localhost:1155/Search/SearchResults?QueryString=Distance%3D10%26txtZip%3D%26cb&page=2 Should it not be like this? http://localhost:1155/Search/SearchResults?Distance=20&txtZip=10021&page=2

    Read the article

  • How to detect non-graceful disconnect of Twisted on Linux?

    - by Victor Lin
    I wrote a server based on Twisted, and I encountered a problem, some of the clients are disconnected not gracefully. For example, the user pulls out the network cable. For a while, the client on Windows is disconnected (the connectionLost is called, and it is also written in Twisted). And on the Linux server side, my connectionLost of twisted is never triggered. Even it try to writes data to client, but the connection is lost. Why Twisted can't detect those non-graceful disconnection (even write data to client) on Linux? How to makes Twisted detect non-graceful disconnections? Because the feature Twisted can't detect non-graceful, I have lots of zombie user on my server. Thanks. Victor Lin.

    Read the article

  • Asking Box2d if a collision happened

    - by Rosarch
    I'm using Box2dx (ported to C#; optimized for XNA). It handles collision resolution, but how can I tell if two objects are currently colliding? This is the function I'm trying to write: public bool IsColliding(GameObjectController collider1, GameObjectController collider2) Where collider1.Model.Body is the Box2d Body, and collider1.Model.BodyDef is the Box2d BodyDef. (The same goes for collider2, of course.) UPDATE: Looks like contact listeners or this could be useful: AABB collisionBox; model.Body.GetFixtureList().GetAABB(out collisionBox); Why does GetFixtureList() return one fixture?

    Read the article

  • How can I use a custom ValidationAttribute to ensure two properties match?

    - by Brandon Linton
    We're using xVal and the standard DataAnnotationsValidationRunner described here to collect validation errors from our domain objects and view models in ASP.NET MVC. I'd like to have a way to have that validation runner identify when two properties don't match through the use of custom DataAnnotations. Right now I'm forced into doing it outside of the runner, this way: if (!(model.FieldOne == model.FieldTwo)) errors.Add(new ErrorInfo("FieldTwo", "FieldOne must match FieldTwo", model.FieldTwo)); My question is: can this be done using property-level validation attributes, or am I forced into using class-level attributes (in which case, I'd have to modify the runner...and my follow up question would be how best to retrieve them in that case). Thanks!

    Read the article

  • How to use Railroad to create a models diagram that show methods

    - by SeeBees
    Railroad is a great UML tool for Ruby on Rails. It can automatically generate class diagrams of models and controllers. For models, a railroad-generated class diagram shows attributes of each model and the associations between one model and another. A sample diagram can be found here. It is very useful for a developer to see attributes and associations of models. While attributes and associations reveal the inner states and relationships of models, methods specify their behaviours. They are all desirable in a class diagram. I would like railroad to generate a class diagram that also lists methods for models, which will help me to know what each model does. I know methods are displayed in a diagram that is generated for controllers, but I don't see such an option for a diagram of models. Does someone know how to do that with railroad? Or is that possible? Thanks!

    Read the article

  • Python decoding issue with hashlib.digest() method

    - by Sorw
    Hello StackOverflow community, Using Google App Engine, I wrote a keyToSha256() method within a model class (extending db.Model) : class Car(db.Model): def keyToSha256(self): keyhash = hashlib.sha256(str(self.key())).digest() return keyhash When displaying the output (ultimately within a Django template), I get garbled text, for example : ?????_??!`?I?!?;?QeqN??Al?'2 I was expecting something more in line with this : 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08 Am I missing something important ? Despite reading several guides on ASCII, Unicode, utf-8 and the like, I think I'm still far from mastering the secrets of string encoding/decoding. After browsing StackOverflow and searching for insights via Google, I figured out I should ask the question here. Any idea ? Thanks !

    Read the article

  • Pylons, SQlite and autoincrementing fields

    - by Maxfrank
    Hey! Just started working with Pylons in conjunction with SQLAlchemy, and my model looks something like this: from sqlalchemy import Column from sqlalchemy.types import Integer, String from helloworld.model.meta import Base class Person(Base): __tablename__ = "person" id = Column(Integer, primary_key=True) name = Column(String(100)) email = Column(String(100)) def __init__(self, name='', email=''): self.name = name self.email = email def __repr__(self): return "<Person('%s')" % self.name To avoid sqlite reusing id's that might have been deleted, I want to add AUTOINCREMENT to the column "id". I've looked through the documentation for sqlalchemy and saw that the sqlite_autoincrement can be issued. An example where this attribute is given can be found here. sqlite_autoincrement seems though to be issued when creating the table itself, and I just wondered how it can be supplied when using a declarative style of the model such as mine.

    Read the article

  • Timer or Thread?

    - by Pradeep Singh
    I have a method(say method1) that writes to database(sqlserver)and another method(say method2) that tries to access the same database after some time and updates the data row that was created by method1. The problem arises when method1 fails to access db due to the LAN being disconnected (this is not an exception this is a scenario that will definitely arise in my software, getting into details will make the question too complex) if method1 fails to access db method2 cannot work. What I want to do is to make method1 store values to local db instead of server if the LAN is disconnected and as soon as it enters value in local db the application should start trying to access the server after ever 10-15 seconds. What should I use timer or create a new thread?

    Read the article

  • Why i am not able to clear the date input field when i do not need? using jquery

    - by kumar
    I have this code in the view to display datepicker for input type.. $("input[id^='exc-flwup-']").datepicker({ duration: '', showTime: true, constrainInput: true, stepMinutes: 30, stepHours: 1, altTimeField: '', time24h: true, minDate: 0 }); This is my Input Filed in the Fieldset.. <label for="FollowupDate"> Follow-up: <span><input type="text" id="exc-flwup-<%=Model.ExceptionID %>" name="exc-flwup-<%=Model.ExceptionID %>" value="<%=Model.FollowupDate %>" /> </span> Problem Is when I click on the textbox on the UI I can select the date its working fine.. but when I am trying to clear the textbox its not going off its allways showing currect date and time.. Can anybody help me why its i am not able to make clear.. thanks

    Read the article

  • django-admin - how to modify ModelAdmin to create multiple objects at once?

    - by skrobul
    let's assume that I have very basic model class Message(models.Model): msg = models.CharField(max_length=30) this model is registered with admin module: class MessageAdmin(admin.ModelAdmin): pass admin.site.register(Message, MessageAdmin) Currently when I go into the admin interface, after clicking "Add message" I have only one form where I can enter the msg. I would like to have multiple forms (formset perhaps) on the "Add page" so I can create multiple messages at once. It's really annoying having to click "Save and add another" every single time. Ideally I would like to achieve something like InlineModelAdmin but it turns out that you can use it only for the models that are related to the object which is edited. What would you recommend to use to resolve this problem?

    Read the article

  • Unicode issue in Django

    - by Kave
    I seem to have a unicode problem with the deal_instance_name in the Deal model. It says: coercing to Unicode: need string or buffer, __proxy__ found The exception happens on this line: return smart_unicode(self.deal_type.deal_name) + _(u' - Set No.') + str(self.set) The line works if I remove smart_unicode(self.deal_type.deal_name) but why? Back then in Django 1.1 someone had the same problem on Stackoverflow I have tried both the unicode() as well as the new smart_unicode() without any joy. What could I be missing please? class Deal(models.Model): def __init__(self, *args, **kwargs): super(Deal, self).__init__(*args, **kwargs) self.deal_instance_name = self.__unicode__() deal_type = models.ForeignKey(DealType) deal_instance_name = models.CharField(_(u'Deal Name'), max_length=100) set = models.IntegerField(_(u'Set Number')) def __unicode__(self): return smart_unicode(self.deal_type.deal_name) + _(u' - Set No.') + str(self.set) class Meta: verbose_name = _(u'Deal') verbose_name_plural = _(u'Deals') Dealtype: class DealType(models.Model): deal_name = models.CharField(_(u'Deal Name'), max_length=40) deal_description = models.TextField(_(u'Deal Description'), blank=True) def __unicode__(self): return smart_unicode(self.deal_name) class Meta: verbose_name = _(u'Deal Type') verbose_name_plural = _(u'Deal Types')

    Read the article

  • How to reuse socket in .NET?

    - by Hermann
    I am trying to reconnect to a socket that I have disconnected from but it won't allow it for some reason even though I called the Disconnect method with the argument "reuseSocket" set to true. _socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); _socket.Connect(ipAddress, port); //...receive data _socket.Disconnect(true); //reuseSocket = true //...wait _socket.Connect(ipAddress, port); //throws an InvalidOperationException: Once the socket has been disconnected, you can only reconnect again asynchronously, and only to a different EndPoint. BeginConnect must be called on a thread that won't exit until the operation has been completed. What am I doing wrong?

    Read the article

  • XCOPY-deploying Microsoft Sync Framework in a no admin rights scenario (i.e. ClickOnce install)

    - by Mike Bouck
    I'm currently designing a smart client app (WPF) which needs to operate in an "occasionally disconnected" mode. For the offline scenario, I'm looking at using: Disconnected Service Agent Application Block (from the Smart Client Software Factory) Microsoft Sync Framework I should mention that I want my smart client app to be XCOPY-deployable, auto-updating, and installable without administrative privledges -- basically a ClickOnce-deployed app. From what I can tell this means the Microsoft Sync Framework is out because it has some COM in it's implementation that needs to get registered on the client which requires admin rights. Is it possible to XCOPY deploy and run MSF from a ClickOnce app? Any other ideas for data synchronization?

    Read the article

  • Django - Form validation error

    - by Igor G.
    Hello, I have a model like this: class Entity(models.Model): entity_name = models.CharField(max_length=100) entity_id = models.CharField(max_length=30, primary_key=True) entity_parent = models.CharField(max_length=100, null=True) photo_id = models.CharField(max_length=100, null=True) username = models.CharField(max_length=100, null=True) date_matched_on = models.CharField(max_length=100, null=True) status = models.CharField(max_length=30, default="Checked In") def __unicode__(self): return self.entity_name class Meta: app_label = 'match' ordering = ('entity_name','date_matched_on') verbose_name_plural='Entities' I also have a view like this: def photo_match(request): ''' performs an update in the db when a user chooses a photo ''' form = EntityForm(request.POST) form.save() And my EntityForm looks like this: class EntityForm(ModelForm): class Meta: model = Entity My template's form returns a POST back to the view with the following values: {u'username': [u'admin'], u'entity_parent': [u'PERSON'], u'entity_id': [u'152097'], u'photo_id': [u'2200734'], u'entity_name': [u'A.J. McLean'], u'status': [u'Checked Out'], u'date_matched_on': [u'5/20/2010 10:57 AM']} And form.save() throws this error: Exception in photo_match: The Entity could not be changed because the data didn't validate. I have been trying to figure out why this is happening, but cannot pinpoint the exact problem. I can change my Entities in the admin interface just fine. If anybody has a clue about this I would greatly appreciate it! Thanks, Igor

    Read the article

  • validates_associated in production

    - by Rien
    Hi all. Imagine a simple model. class Service belongs_to :user validates_associated :user accepts_nested_attributes_for :user end Nothing special right? The validations on the associated User model trigger correctly in development mode. But don't do anything in production. I've added a validates_on_presence :user just like the docs say. This triggers when there's no User associated with the Service, but fill in one thing on the User model and nothing happens! It's driving me up the walls. Am I overlooking something? More info about the MVC: I use formtastic for the forms. Thanks!

    Read the article

  • Kohana 2.3.4 ORM pivot table query

    - by anthony
    I'm trying to query a pivot table with Kohana's ORM and I'm wondering if there is a built in function I'm missing. Currently I only have 2 models setup for the tables "categories" and "products". There is a pivot table "categories_products", but I don't need a model for it when inserting data with this: $product = ORM::factory('product'); $product->add(ORM::factory('category', $addCat)); However, I can't figure out how to query it without creating a model for it. The "join_table" function only returns the name of the pivot table (which I thought selected the table at first). If you can save data to the pivot table without a model, it seems to me that you should be able to retrieve data in a similar way. Any ideas?

    Read the article

  • Fluentemail not working locally but working on server

    - by sreginogemoh
    My web app using Fluentemail to send emails. But there is strange thing happening, it is sending emails on server successfully, but locally I am getting such kind of errors: RazorEngine.Templating.TemplateCompilationException: Unable to compile template. Check the Errors list for details. at RazorEngine.Compilation.DirectCompilerServiceBase.CompileType(TypeContext context) at RazorEngine.Templating.TemplateService.CreateTemplate(String template, Type modelType) at RazorEngine.Templating.TemplateService.GetTemplate(String template, Type modelType, String name) at RazorEngine.Templating.TemplateService.Parse[T](String template, T model, String name) at RazorEngine.Razor.Parse[T](String template, T model, String name) at FluentEmail.Email.UsingTemplateFromFile[T](String filename, T model, Boolean isHtml) error CS2001: Source file 'C:\Windows\TEMP\5yn3eqdw.0.cs' could not be found} Is there any way I can fix that?

    Read the article

  • How to change id value when using Html.DropDownListFor helper in asp.net mvc 2.0?

    - by chobo2
    Hi I have a partial view that has something like this <%= Html.DropDownListFor(m => m.SelectedProductName, Model.ProductList, "Select a Product") %> Now you can create a new product and edit a existing product. Both editing and creating use the same form. The create is on the main page on load up. Edit popus up in a jquery u.i model dialog and renders a new partial view. So as far as the page is concerned is that I have 2 dropdown boxes with the same "id" which is bad since they should be unique. So how do I change the id? So when the edit loads it might have a id of "editSelectedProductName"? I tried to do this in the view model public string SelectedProductName{ get; set; } ViewModelConstructor() { SelectedProductName = "EditSelectedProductName"; } But it seems to not care and keeps using "SelectedProductName" as the product name. Thanks

    Read the article

  • Django aggregation query on related one-to-many objects

    - by parxier
    Here is my simplified model: class Item(models.Model): pass class TrackingPoint(models.Model): item = models.ForeignKey(Item) created = models.DateField() data = models.IntegerField() In many parts of my application I need to retrieve a set of Item's and annotate each item with data field from latest TrackingPoint from each item ordered by created field. For example, instance i1 of class Item has 3 TrackingPoint's: tp1 = TrackingPoint(item=i1, created=date(2010,5,15), data=23) tp2 = TrackingPoint(item=i1, created=date(2010,5,14), data=21) tp3 = TrackingPoint(item=i1, created=date(2010,5,12), data=120) I need a query to retrieve i1 instance annotated with tp1.data field value as tp1 is the latest tracking point ordered by created field. That query should also return Item's that don't have any TrackingPoint's at all. If possible I prefer not to use QuerySet's extra method to do this. That's what I tried so far... and failed :( Item.objects.annotate(max_created=Max('trackingpoint__created'), data=Avg('trackingpoint__data')).filter(trackingpoint__created=F('max_created')) Any ideas?

    Read the article

  • 3D Triangle - WPF

    - by user300423
    I am trying to apply an image brush to a Triangle in WPF without success. What am i doing wrong? This is my attempt: Dim ModelTri As New MeshGeometry3D ModelTri.Positions.Add(New Point3D(0, 0, 0)) ModelTri.Positions.Add(New Point3D(100, 0, 0)) ModelTri.Positions.Add(New Point3D(100, 100, 0)) Dim MeshTri As New MeshGeometry3D MeshTri.TriangleIndices.Add(0) MeshTri.TriangleIndices.Add(1) MeshTri.TriangleIndices.Add(2) 'Texture Dim TexturePoints As New PointCollection TexturePoints.Add(New Point(100, 0)) TexturePoints.Add(New Point(0, 100)) TexturePoints.Add(New Point(100, 100)) MeshTri.TextureCoordinates = TexturePoints 'Image Brush Dim imgBrush As New ImageBrush() imgBrush.ImageSource = New BitmapImage(New Uri("Mercury.jpg", UriKind.Relative)) imgBrush.Stretch = Stretch.Fill imgBrush.TileMode = TileMode.Tile imgBrush.SetValue(NameProperty, "imgBrush") Dim Mat As Material Dim DMaterial As New DiffuseMaterial DMaterial.Brush = imgBrush Dim Bind As New Binding("imgBrush") Bind.Source = imgBrush BindingOperations.SetBinding(DMaterial, BindingGroupProperty, Bind) 'This doesnt work Mat = DMaterial 'This works 'Mat = New DiffuseMaterial(New SolidColorBrush(Colors.Khaki)) Dim triangleModel As GeometryModel3D = New GeometryModel3D(ModelTri, Mat) Dim model As New ModelVisual3D() model.Content = triangleModel Viewport.Children.Add(model)

    Read the article

< Previous Page | 150 151 152 153 154 155 156 157 158 159 160 161  | Next Page >