MVC 5 Multiple Models in a Single View

I would say this is good example of using ViewModel here. I would suggest something like – Create ViewModel with the composition of the two classes public class AddWeightModel { [Required] [DataType(DataType.Text)] [Display(Name = “Stone”)] public Nullable<short> Stone { get; set; } [Required] [DataType(DataType.Text)] [Display(Name = “Pound”)] public Nullable<short> Pound { get; set; } } … Read more

models.py getting huge, what is the best way to break it up?

It’s natural for model classes to contain methods to operate on the model. If I have a Book model, with a method book.get_noun_count(), that’s where it belongs–I don’t want to have to write “get_noun_count(book)“, unless the method actually intrinsically belongs with some other package. (It might–for example, if I have a package for accessing Amazon’s … Read more

Django model instances primary keys do not reset to 1 after all instances are deleted

I wouldn’t call it an issue. This is default behaviour for many database systems. Basically, the auto-increment counter for a table is persistent, and deleting entries does not affect the counter. The actual value of the primary key does not affect performance or anything, it only has aesthetic value (if you ever reach the 2 … Read more

Rails 4: organize rails models in sub path without namespacing models?

By default, Rails doesn’t add subfolders of the models directory to the autoload path. Which is why it can only find namespaced models — the namespace illuminates the subdirectory to look in. To add all subfolders of app/models to the autoload path, add the following to config/application.rb: config.autoload_paths += Dir[Rails.root.join(“app”, “models”, “{*/}”)] Or, if you … Read more

Should I avoid multi-table (concrete) inheritance in Django by any means?

First of all, inheritance has not a natural translation to relational database architecture (ok, I know, Oracle Type Objects and some other RDBMS support inheritance but django don’t take advantage of this functionality) At this point, notice than django generates new tables to subclasses and write lots of left joins to retrieve data from this … Read more