models

how to properly define a ManyToMany field in the models.py file

╄→гoц情女王★ 提交于 2019-12-24 13:25:52
问题 In my Django app I have the following models.py: from django.db import models import datetime class Job(models.Model): name = models.CharField(max_length = 250, null = False) user = models.CharField(max_length = 30, null = False) command = models.CharField(max_length = 1000, null = False) whenToRun = models.DateTimeField('Run Date', null = False) output = models.CharField(max_length = 100000, null = True) class Host(models.Model): jobs = models.ManyToManyField(Job, blank = True) name = models

button_to not passing correct id from params hash

我的梦境 提交于 2019-12-24 07:16:11
问题 The button_to is not passing the correct id to the line_item. In the log below you see the bike_id change from the correct '86' to the incorrect '1' (which coincidentally is my user_id). Any help would be appreciated. Below is the error from my development.log, then the code from my view and controllers. Thanks. development.log Started POST "/line_items?bike_id=86" for 127.0.0.1 at 2011-08-01 18:09:52 -0400 DEPRECATION WARNING: Setting filter_parameter_logging in ActionController is

laravel 4 trait autoloading in models

半腔热情 提交于 2019-12-24 07:07:08
问题 OK, I am struggling for over 2 hours now... It must be one of the "oh god, it was that obvious" times where you are so tired and you cannot see the solution... I want to extend the eloquentmodel to include a trait. so my class looks like <?php class Note extends Eloquent{ use \Admin\GreatTrait; ... } and I created the app/Traits/Admin directory structure and there I created the file named GreatTrait.php with the following contents: <?php namespace Admin; trait GreatTrait{ ... } and of cource

XML Serialization is not including milliseconds in datetime field from Rails model

妖精的绣舞 提交于 2019-12-24 05:58:47
问题 By default, the datetime field from the database is being converted and stripping off the milliseconds: some_datetime => "2009-11-11T02:19:36Z" attribute_before_type_cast('some_datetime') => "2009-11-11 02:19:36.145" If I try to overrride the accessor for this attribute like; def some_datetime attribute_before_type_cast('some_datetime') end when I try "to_xml" for that model, I get the following error: NoMethodError (undefined method `xmlschema' for "2009-11-11 02:19:36.145":String): I have

magento visitor logs

江枫思渺然 提交于 2019-12-24 01:28:10
问题 Is there a way to access the user logs in Magento? I know the database has a table called log_visitor that can see logs visitors, and log_visitor_info logs more info about the visitors (IP, user agent). How do I get to that data? When I write $visitors = Mage::getModel('log/visitor')->getCollection() foreach ($visitors as $visitor) { print_r($visitor->getData()); } I get an error PHP Fatal error: Uncaught exception 'Exception' with message 'Recoverable Error: Method Varien_Db_Select::_

(Ruby,Rails) CRUD nested models more than 4 levels deep on a single page…?

爱⌒轻易说出口 提交于 2019-12-24 01:19:02
问题 As much amazing info as is out there, it often seems to fall just short of my demented requirements. That said, I'm looking for a mechanism by which to handle multiple nested models on a single page. Now, I've seen all the videos and posts (not really, but humor me) on nesting two models (Railscasts, etc.). However, I need to deal with models nested 4 deep, all the while using Javascript to keep the page clean. Basically I have Site -> Buildings -> Controllers -> Measurements and would like

Multi-page Multi-Model Form in Rails

一个人想着一个人 提交于 2019-12-24 00:48:48
问题 I'm trying to create a multi-page form that uses multiple models. I have an applicant and this applicant has more than one address (one to many relationship). I would like the first page to contain information about the applicant, and then the page after that to have the form for the address(es) This is what I have at the moment: applicant.rb has_many :addresses, :dependent => :destroy accepts_nested_attributes_for :addresses address.rb belongs_to :applicant applicants_controller.rb: def new

Where should a certain function go- model or controller? CakePHP

雨燕双飞 提交于 2019-12-23 22:40:32
问题 Trips hasMany Legs hasMany Segments In my flight search app, I've got a function that returns unique Leg.destination(s). This function is for a trip controller method. Do I put the function in the trip model or leg model? If in the leg model I call it with $this->Trip->Leg->findUniqueDests.....? I'm asking because I want to stick to CakePHP convention. Thanks! //code that finds ALL destinations for each Leg $destinations=$this->Trip->Leg->find('all', array('limit'=>100,'fields'=>'Leg

Laravel 4.2 created_at column gives “The format separator does not match” error

一个人想着一个人 提交于 2019-12-23 21:33:23
问题 I am trying to access the created_at column in one of my models and I get the following error: The format separator does not match. The format separator does not match. The format separator does not match. The error actually repeats 3 times. This is how I try to access the column: $model->created_at I do not have $timestamps set to false in my model and I can access the other columns just fine. What is the problem? 回答1: Did you override the getDateFormat() in your model? I ran into this

Search collection and retrieve model backbonejs

随声附和 提交于 2019-12-23 19:09:18
问题 I am trying to search a collection for a model attribute and then grab and return the entire model ? var myModel = Backbone.Model.extend({ defaults: { a: '', b: '', c: '', d: '', e: '' } }); My collection has around 100 of myModels. I am trying to search through the collection by a , find it and then return the entire myModel of a so I can access the other attributes ? 回答1: If I understand your question correctly, you want to use the where method on Backbone collections, here in the docs: