models

x86 and Memory Addressing

I've been reading up on memory models in an assembly book I picked up and I have a question or two. Let's say that the address bus has 32 lines, the data bus has 32 lines and the CPU is 32-bit (for simplicity). Now if the CPU makes a read request and sends the 32bit address, but only needs 8 bits, all 32 bits come back anyway? Also, t...

Python/Django application with dynamic model name (application reuse)

Hi, excuse me in advance if this is not the right title for the problem but here it is: You have application that works with pre defined model. What happens if you want to use this application one more time in your project but pointing to different model (same structure but differen name). For example - you have a "News" application ...

How do I filter the models I see in the Add View dialog window with ASP.NET MVC?

Is there a way to restrict what I see when I select the View Data Class drop down, to just the models in my Application? It seems that if I have any references in my app, that drop down gets really noisy. ...

Multiple custom model binders for one model in ASP.NET MVC

This is a general model binding question that applies to MVC 1 & 2. I'm wondering if MVC2 would be better for this, but here's my question: I have a fairly complex model: public interface IEvent public int Id public string Title public List<EventContact> Contacts public List<EventDatesLocations> DatesLocations public class Ev...

Mapping legacy database columns in a rails project

We are creating a rails application for an already existing database. We need to map some database tables together. Suppose we have three tables: event, event_groups and event_to_groups. There are some events, there are some groups, and each event can be assigned to one or more groups. How do I model this relation in rails? eg: Ex...

How to convert this query to a "django model query" ?

Hello ! What i want is simple : models : class userLastTrophy(models.Model): user = models.ForeignKey(userInfo) platinum = models.IntegerField() gold = models.IntegerField() silver = models.IntegerField() bronze = models.IntegerField() level = models.IntegerField() rank = models.IntegerField() pe...

Trouble with Rails has_many relationships

I'm writing an app where a user can both create their own pages for people to post on, and follow posts on pages that users have created. Here is what my model relationships look like at the moment... class User < ActiveRecord::Base has_many :pages has_many :posts has_many :followings has_many :pages, :through => :followings, :source ...

Best way to re-use the same django models and admin for multiple apps

Given a reference app ( called guide), how can I create additional apps that will reuse the same model/admin/views than guide - the motivation behind is to be able to individually control each subapp. guide guideApp1 exact same models/admin/views than guide guideApp2 exact same models/admin/views than guide in the Admin site, I...

Custom Views in MVS with input names not-matching to Model property names.

We are using MVC in our application; the Views we are using get created by other team. The problem is that they use their own names for input HTML controls which are different from the input text-box names in the Model. I have a strong feeling that this issue had already been addressed somewhere but cannot find any references. Could anyb...

Django: one form for two models (solved)

UPDATE The issue is solved, all the code you can see works. Hello! I have a ForeignKey relationship between TextPage and Paragraph and my goal is to make front-end TextPage creating/editing form as if it was in ModelAdmin with 'inlines': several fields for the TextPage and then a couple of Paragraph instances stacked inline. The proble...

django how get session in models

django how get session in models or how get session out views ...

How can I support conditional validation of model properties

I currently have a form that I am building that needs to support two different versions. Each version might use a different subset of form fields. I have to do this to support two different clients, but I don't want to have entirely different controller actions for both. So, I am trying to come up with a way to use a strongly typed mo...

Django multiple many to many fields?

Hello everybody I am building a news app for my website. I want to use a sort of tag system. Each news article can have different and multiple tags. All tags are saved in a tag model, and i want to connect the tags to the newsarticle. Now is this possible with: tags = models.ForeignKey( TagsModel ) for one tag, but how i can do this wit...

Hierarchical models of software quality

Can anyone help me listing the Hierarchical models of software quality? Please can anyone say me Is it just McCall and Bohem model or many other hierarchical models exists? ...

Rails: show some examples of code from controllers, models and views

Hy, my controller example: class FriendsController < ApplicationController before_filter :authorize, :except => [:friends] ############## ############## ## REQUESTS ## ############## ############## ################## # GET MY FRIENDS # ################## # Get my friends. def friends @frie...

Problem with migrating a model in ruby

I run script/generate model query edit query.rb in models.. class Query < ActiveRecord::Base #I even tried Migrations instead of Base def sef.up create table :queries do|t| t.string :name end end def self.down drop_table :queries end end ,run rake db:migrate. and what I see in db is this: mysql> desc quer...

Saving model object in django throws no error but attribute value doesn't change

Hi. I get a model object, change an attribute, save it and it still has the old attribute: >>> g = SiteProfile.objects.get(pk=3) >>> g.renew_date datetime.date(2010, 4, 11) >>> g.renew_date = date.today()+timedelta(days=365) >>> g.renew_date datetime.date(2011, 4, 11) >>> g.save() >>> g.renew_date datetime.datetime(2010, 4, 11, 16, 57,...

is a ModelChoiceField always required?

I have a model class Article(models.Model): . . language = models.ForeignKey(Language, help_text="Select the article's language") parent_article = models.ForeignKey('self', null=True, blank=True) If an article is an original article then 'parent_article=None'. If an article is a translation then 'parent_article' <> Non...

Serialize model into Query string

Hi. Would it be possible to serialize a model object into a query string? I've no idea if this is even possible, but if not, what is the best way to do this? <% Html.RenderAction("Grid", "Grid", new { gridModel= ViewData["model"]}); %> The Model is containing ca 20 properties, and creating the querystring with them in individually wo...

Model associations

I have two models Library and Book. In my Library model, I have an array - book_ids. The primary key of Book model is ID. How do I create a has_many :books relation in my library model? This is a legacy database we are using with rails. Thanks. ...