All Questions

Tagged with
Filter by
Sorted by
Tagged with
97 votes
6 answers
187k views

Check if an object exists

I need to check if Model.objects.filter(...) turned up anything, but do not need to insert anything. My code so far is: user_pass = log_in(request.POST) # form class if user_pass.is_valid(): ...
sinθ's user avatar
  • 11.3k
50 votes
6 answers
28k views

Create Ruby on Rails views (only) after controllers and models are already created

I've obtained a project that have controllers (minimal code only) and models, but the views are missing. Is there a way to generate the views only using scaffold or another tool?
Sean's user avatar
  • 2,038
44 votes
3 answers
50k views

Django Pass Multiple Models to one Template

I am building an address book that includes the relationships between entries, etc. I have separate models for Individuals, Companies, Venues, and Roles. On my index page I would like to list all of ...
Nahanaeli Schelling's user avatar
27 votes
4 answers
18k views

Backbone change model of View

I am fairly new to Backbone and have the following question: I have a collection of models. I have a collection view displaying tabs (with a view for each model in the collection). I have a view ...
Riebel's user avatar
  • 789
26 votes
4 answers
18k views

What are the Laravel naming conventions for controllers/models/views?

I remember hearing you should name your controllers, models and views in a special way. Either singular or plural. I don't remember which ones to name what though, and i can't find anything about it ...
qwerty's user avatar
  • 5,246
16 votes
3 answers
55k views

Using datetime to compare with dates in Django

I have a question in Django on how you can compare dates to solve some solutions. For example I have a datefield in my models.py Like below. class Invoice(models.Model): payment_date = models....
Shehzad009's user avatar
  • 1,587
13 votes
4 answers
25k views

MVC Error: The model item passed into the dictionary is null

I'm just trying to build a view but I'm getting the following error: System.InvalidOperationException: The model item passed into the dictionary is null, but this dictionary requires a non-...
109221793's user avatar
  • 16.6k
13 votes
1 answer
5k views

Good Practice: Organizing views.py in Django Apps

I am learning Django. My background is from PHP and Java with experience using Model View Controller frameworks. I have always had a seperate file for each of my views, models, and templates - but the ...
user avatar
13 votes
7 answers
7k views

Delphi: Good pattern/strategy for view <-> model synchronization

There's a lot of talk about model-view-controller, model-view-viewmodel, model-view-presenter and so on these days. What do you see as the best pattern for use with delphi and non-data aware ...
Vegar's user avatar
  • 12.9k
12 votes
0 answers
637 views

Model View Presenter nesting

I've run into a scenario which requires nesting of the MVP pattern. It is probably best to explain using a visual example: ------------------------------ | [View] | | | ...
Thick_propheT's user avatar
10 votes
6 answers
4k views

MVC: Where should I format data?

I get data from Model (an array with data) and I need to display with a specific format. I need to iterate over the array, format the data and then display it. Where should I format data to display? ...
jared's user avatar
  • 101
10 votes
1 answer
5k views

Communication between the View and Model in MVC

After reading from many different sources, I am very confused about how View and Model should communicate in the MVC pattern. To my understanding, the accepted answer of this post and this article ...
derrdji's user avatar
  • 13k
9 votes
1 answer
3k views

Why is this rails view spitting out a raw array at the end of an .each do loop? [duplicate]

I am stumped by this strange output in my Rails view. Here is my model: class Comment < ActiveRecord::Base belongs_to :post end Here is the relevant part of my view. I have isolated the ...
Michael's user avatar
  • 774
9 votes
2 answers
23k views

How do I get the first name and last name of a logged in user in Django?

I need to get the first name and last name of a user for a function in my views How do I do that? What is the syntax for it? I used request.user.email for the email, but I don't know see an option for ...
DeA's user avatar
  • 1,828
9 votes
4 answers
20k views

Extjs4 MVC, how get Model or View from a Controller class?

Ext.define('DigitalPaper.controller.Documents', { extend: 'Ext.app.Controller', views: ['Documents'], stores: ['Documents'], models: ['Documents'], init: function() { console.log('[OK] ...
Pierluigi B Web Developer's user avatar
9 votes
3 answers
4k views

About view models and interfaces

I'm developing a WPF Prism application, and everything is working fine. My view models all have interfaces, which are injected by MEF. However, I don't really understand the benefit of interfaces for ...
L-Four's user avatar
  • 13.4k
8 votes
1 answer
4k views

MvcMailer: Taking user input in view through model and then inserting it into mail

I don't know if I am explaining this correctly, or if the solution is rather simple, so here goes: I am using MvcMailer, but before that I set up a wizard input form which I call Quote.cshtml. Behind ...
REMESQ's user avatar
  • 1,200
8 votes
1 answer
11k views

How to save other data after form_valid action in django UpdateView?

I have successfully changed a particular field net in my object based on the quantity qty field with the following code. class OrderDetailsProductEdit(UpdateView): model = OrdersPlaced fields ...
MiniGunnR's user avatar
  • 5,720
8 votes
4 answers
8k views

MVC3 pass @model to partial view

I have two partial views which are exactly the same, but for the @model. @model Project.Models.X @model Project.Models.Y How could I pass this model type to the view so that I can use the same view ...
TheGwa's user avatar
  • 1,919
8 votes
3 answers
2k views

ASP.NET MVC ViewModelBuilder Suggestions

For anything but trivial view models, I use a view model builder that handles the responsibility of generating the view model object. Right now, I use constructor injection of the builders into my ...
Marco's user avatar
  • 2,463
7 votes
1 answer
7k views

DJANGO: how to limit inlineformset queryset

An EU can use this form to select the roles (Project Manager, Developer etc) they play for any given project. I want to limit the project field options to only those in the employees department. Right ...
thedeepfield's user avatar
  • 6,178
7 votes
2 answers
2k views

Storing persistent information about items in view

I've my own view based directly on QAbstractItemView. Generally speaking I need to store some information about particular model's item. So in my view I have a map from QModelIndex to struct ...
Michał Walenciak's user avatar
7 votes
1 answer
7k views

MVC - do I need to use Controller in the View?

As I know in the standard implementation of the MVC we pass Controller and Model to the View But Im a little bit disagree with this idea. I dont want my view to know about both controller and model (...
pleerock's user avatar
  • 18.6k
7 votes
10 answers
853 views

Do you buy the reuse story for the presentation layer in MVP and its variations? [closed]

Besides the unit testing benefits, what I heard regarding MVP pattern was that the reusability of the presentation layer. So, you would design one presentation layer and use it for WinForms (rich) ...
Jiho Han's user avatar
  • 1,620
7 votes
1 answer
21k views

building a 3d model viewer android? [duplicate]

I'm trying to build a model viewer in opengl, but got stumped... I basically just want to build my own app that can load a custom model in .off or .obj format and display it on my tablet.
user avatar
6 votes
3 answers
2k views

ASP.NET MVC model validation breaks MVC rule?

using ASP.NET MVC, I have a Model, to which I'm attaching attributes so that I can get use the MVC Model bound validation, but to doesn't this break the rule of MVC, where you are putting items that ...
Tomasz Iniewicz's user avatar
6 votes
2 answers
7k views

Do you initialize your Backbone views from within a model or elsewhere?

Do you initialize your Backbone views from within a model or elsewhere? I'm trying to figure out what the best way to organize model/views. Does it make sense to have your models initialize the ...
boom's user avatar
  • 11.2k
6 votes
3 answers
14k views

"Unknown column 'user_id' error in django view

I'm having an error where I am not sure what caused it. Here is the error: Exception Type: OperationalError Exception Value: (1054, "Unknown column 'user_id' in 'field list'") Does anyone ...
rksprst's user avatar
  • 6,571
6 votes
1 answer
11k views

Access modelData within delegate in QML

Is there a way to access modelData from View delegate (Repeater in particular). I tried to use a separate property and tried to access it via model.modelData but neither of this worked. Please see ...
senx's user avatar
  • 640
6 votes
3 answers
5k views

What is the advantage of Model-View-Controller (MVC) over Model-View?

Could anyone give an example of why it would be advantageous to use MVC instead of a simpler Model and a View only. Note: whether it's called MVC or MVP (Model-View-Presenter), I'm talking about the ...
Saleh Al-Abbas's user avatar
6 votes
1 answer
3k views

Django - One view, multiple URLs?

I am fairly new to both Python and Django and would like to follow best practices where possible. I would like to tidy up the following code to make it easier to work with. I am trying to set up a ...
Dan's user avatar
  • 6,363
6 votes
1 answer
5k views

How does the model update the view in MVC pattern?

I have a confusion about the structure of MVC pattern. In some places while searching on google I found that the model updates all those views which are subscribed to that model. How the model ...
Wearybands's user avatar
  • 2,455
6 votes
1 answer
2k views

Oracle materialized view with Entity Framework model

Is it possible to query Oracle materialized view with Entity Framework model using linq?
eozcan's user avatar
  • 115
5 votes
3 answers
28k views

YII : How to Change datetime format displayed on the View

A newbie question in Yii: I have a model of a table in Yii that contain a datetime field. I'm using CActiveForm to display this field: <div class="row"> <?php echo $form->labelEx($...
Calua's user avatar
  • 495
5 votes
1 answer
2k views

Ruby on Rails: Get next item in model

Say I have simply ran rails g scaffold book name:string about:text On the 'show' view, how would I implement a button to go to the next item in the model. I can't simply do @next = @book.id + 1 ...
Keenan Thompson's user avatar
5 votes
3 answers
2k views

Laravel - Lot of Accessors (Mutators) for rendering Views with Blade

I have a Laravel 7 project with the need of a lot of data transformation from the model to the views before being displayed. I thought about using Laravel Accessors and use them directly in my blade....
Alice's user avatar
  • 116
5 votes
2 answers
8k views

Object is not iterable: Filtering QuerySet to display latest instance

I am trying to create a filter in a QuerySet using Django that returns the most recent instance that was submitted by the current logged in user. I so far have the following in my view.py file: def ...
user2798841's user avatar
5 votes
1 answer
3k views

Qt models behind proxies and fetchMore()/canFetchMore()

I am interested to know how would views behave in cases when the main data model with incremental data fetching is behind a proxy or chain of proxies. How proxy which does item rearrangements like ...
yshurik's user avatar
  • 772
5 votes
2 answers
17k views

Django Adding Values to ForeignKey

I'm trying to set up a way for users to "watch" certain items (i.e. add items to a list containing other items by other users): class WatchList(models.Model): user = models.ForeignKey(User) ...
Nick B's user avatar
  • 9,269
5 votes
1 answer
4k views

Ember not updating the view on model change

This fiddle has the starter kit recreated, with and extra button that alters the model. http://jsfiddle.net/UjacC/1/ However, when clicking change, the array changes, but the view is not being ...
Ska's user avatar
  • 6,828
5 votes
1 answer
2k views

Get array from model to view

In my model I have one int object and a boolean array: public class mymodel { public int Round { get; set; } public Boolean[] lstLabs { get; set; } } In my view I write this : <script type="...
ParPar's user avatar
  • 7,495
5 votes
1 answer
6k views

In QT, chaining models does not work as expected

Alright, I have a really basic QStandardItemModel, filled with some numbers. I managed to display it in a QTableView, it's ok. I created a new model ( subclass either of QAbstractItemModel or ...
user avatar
5 votes
1 answer
6k views

Updating Model from form in Backbone

I am creating a simple application using Backbone and Laravel to manage bookings, and I'm working on a simple form to update user data for the currently signed in user. I was wondering, is there a ...
user avatar
5 votes
3 answers
3k views

Using MVC, how should one handle communication between Views? Between Models?

Question number three in my quest to properly understand MVC before I implement it: I have two cases in mind: The primary application window needs to launch the preferences window. (One View ...
bouvard's user avatar
  • 3,870
5 votes
1 answer
3k views

When should I use user.get_profile in django?

I saw another answer here and other places on the web that recommend using user.get_profile when extending the built-in django user. I didn't do that in the below example. The functionality seems ...
sharataka's user avatar
  • 5,064
4 votes
3 answers
315 views

Is it bad to use a model directly from a view in codeigniter?

I know normally the data is passed thru to the view with the controller. however, currently in my view I load my model ($this->load->model('Db_model');) so i can use it in a loop to retrieve a users ...
jason's user avatar
  • 41
4 votes
2 answers
5k views

Yii2: call custom method in class User from view

I would like to extend my own user model, with a function called getFirstname. The function should return a custom field in the database. But when I extend the user model. It says "Calling unknown ...
Anders Andersen's user avatar
4 votes
1 answer
6k views

How to synchronize Model and View Model bidirectional in MVVM?

It's a simple question and I searched the Internet for hours without success... I have a model and a view model with one property. To make this property viewable in the view, I use a view-model-...
Stephan Engelhardt's user avatar
4 votes
1 answer
4k views

MVC 3, View Model for user registration process. Password validation not working properly

I am trying to create a user registration page using MVC 3, so that I can better understand the process of how it works, what's going on behind the scenes etc. I am running into some issues when ...
sec_goat's user avatar
  • 1,272
4 votes
2 answers
1k views

In MVC frameworks (such as Ruby on Rails), does usually Model spell as singular and controller and view spell as plural?

I usually see Ruby on Rails books using script/generate model Story name:string link:string which is a singular Story, while when it is controller script/generate controller Stories index then the ...
nonopolarity's user avatar

1
2 3 4 5
17