I have a report model looking a bit like this:
class Report(models.Model):
date = models.DateField()
quantity = models.IntegerField()
product_name = models.TextField()
I know I can get the last entry for the last year for one product this way:
Report.objects.filter(date__year=2009, product_name="corn").order_by("-date")[0...
I have a datastore model representing items in an ecommerce site:
class Item(db.Model):
CSIN = db.IntegerProperty()
name = db.StringProperty()
price = db.IntegerProperty()
quantity = db.IntegerProperty()
Is there some way to enforce integrity constraints? For instance, I would like to make sure that quantity is never s...
Hey,
I am trying to access an instance variable which is set in the controller in the model. The controller is the products controller and the model is the products model. The instance variable is a instance of another model called account.
The instance variable is @current_account
When I run the code nothing happens, I do not get an ...
I am writing an objective-c model to hold all of the data parsed from an XML connection. I am using an NSURLConnection to download the data asynchronously and it is then passed to the parser. I have done this before, but not with such a large xml file. I would like to garner some opinions on the best way to store the data. Here are s...
In my experience I have only had 2 patterns work for large-scale desktop application development when trying to keep the model and UI in sync.
1-An eventbus approach via a shared eventbus command objects are fired (ie:UserDemographicsUpdatedEvent) and have various parts of the UI update if they are bound to the same user object updated ...
I realize something like this has been asked, but this may be a little different
Below is my Event object:
Event : IEvent
public int Id
public string Title
public List<EventContact> Contacts
And EventContact:
EventContact
public int Id
public string Name
public string Email
So, an Event has a list of EventContact objec...
Hello all. I have been struggling with this question for awhile now, and I haven't reached a conclusion. I'm not typically a UI programmer, so forgive the noobishness.
I'm writing a typical application with a UI layer (WPF) and a business layer. I want to post status messages to the UI from the business layer (perhaps deep within the...
I'm creating a tableless Rails model, and am a bit stuck on how I should use it.
Basically I'm trying to create a little application using Feedzirra that scans a RSS feed every X seconds, and then sends me an email with only the updates.
I'm actually trying to use it as an activerecord model, and although I can get it to work, it doesn...
Scenario: large project with many third party apps. Want to add tagging to those apps without having to modify the apps' source.
My first thought was to first specify a list of models in settings.py (like ['appname.modelname',], and call django-tagging's register function on each of them. The register function adds a TagField and a cus...
I'm having trouble setting up a report model to create reports with report builder. I guess I'm doing something wrong when configuring the report model, but it might also due to change of primary entity in report builder.
I have 3 tables: Client, Address and Product. The Client has PK ClientNumber. The Address and Product both have a FK...
Hay I've got a question about relationships.
I want to Users to have Friendships. So a User can be a friend with another User. I'm assuming i'll need to use the ManyToManyField, through a Friendship table. But i cannot get it to work. Any ideas?
Here are my models.
class User(models.Model):
username = models.CharField(max_length=9...
Is this the proper way to detect which device a user is running?
NSString *currentModel = [[UIDevice currentDevice] model];
if ([currentModel isEqualToString:@"iPhone"]) {
// The user is running on iPhone so allow Call, Camera, etc.
} else {
// The user is running on a different device (iPod / iPad / iPhone Simulator) disallow C...
UPDATE: I ended up creating a new forms.Form instead of using a ModelForm
hi,
in a ModelForm I replaced a field by excluding it and adding a new one
with the same name, as shown below in AddRestaurantForm. When saving
the form with the code shown below, I get an error in form.save_m2m()
("Truncated incorrect DOUBLE value"), which seems...
I have an entry.rb model and I'm trying to make a semi-complicated validation. I want it to require one or more of the following fields: phone, phone2, mobile, fax, email or website. How would you write the intended code? Would something like this work?
validates_presence_of :phone and or :phone2 and or :mobile and or :fax and or :email...
Is Model only Entity Data Model class of my database? Model as simple place where i have my data? Or I can input in Model something more?
...
I have a Rails application that lists information about local services. My objectives for this model are as follows: 1. Require the name and tag_list fields. 2. Require one or more of the tollfreephone, phone, phone2, mobile, fax, email or website fields. 3. If the paddress field has a value, then encode it with the Geokit plugin. Here i...
Are there any approaches to set in model field label? I dont want use 'label' property in form helper.
...
I'm not sure how to model sub-methods in UML sequence diagram. When in the execution of one method another method is called (from the same class). I tried to give an example below:
How would you guys model this in UML (in a sequence diagram)?
..
car1.drive();
..
...
in Car class:
..
drive(){
this.startEngine();
}
startEngine(){
...
I find examples and tutorials about models and about validation. And I places that say the validation (or most of it at least) should be in the model, which I agree with. But I can't any examples or tutorials that show how that should be done.
Could anyone help me with a simple example on how that could be done? Where would you have th...
Hello!
What I want is to create a Model that connects with another using a has_many association in a dynamic way, without the foreign key like this:
has_many :faixas_aliquotas, :class_name => 'Fiscal::FaixaAliquota',
:conditions => ["regra_fiscal = ?", ( lambda { return self.regra_fiscal } ) ]
But I get the error:
: SE...