Search Results

Search found 13838 results on 554 pages for 'disconnected model'.

Page 46/554 | < Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >

  • HDMI with Intel Mobile 4 Graphics Controller

    - by roel
    When connecting my TV over HDMI, it shows up in display settings and xrandr: Aspire1825PTZ:~$ lspci | grep VGA 00:02.0 VGA compatible controller: Intel Corporation Mobile 4 Series Chipset Integrated Graphics Controller (rev 07) Aspire1825PTZ:~$ xrandr Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192 LVDS1 connected 1366x768+0+0 (normal left inverted right x axis y axis) 256mm x 144mm 1366x768 60.0*+ 1360x768 59.8 60.0 1024x768 60.0 800x600 60.3 56.2 640x480 59.9 VGA1 disconnected (normal left inverted right x axis y axis) HDMI1 connected (normal left inverted right x axis y axis) 720x576 50.0 720x480 59.9 DP1 disconnected (normal left inverted right x axis y axis) HDMI2 disconnected (normal left inverted right x axis y axis) DP2 disconnected (normal left inverted right x axis y axis) DP3 disconnected (normal left inverted right x axis y axis) TV1 disconnected (normal left inverted right x axis y axis) However, the resolution is way too low and the screen remains black. Everything works fine in Windows, but I'd rather not reboot just to watch a film... Could anyone help me please?

    Read the article

  • How to get distinct values from the List&lt;T&gt; with LINQ

    - by Vincent Maverick Durano
    Recently I was working with data from a generic List<T> and one of my objectives is to get the distinct values that is found in the List. Consider that we have this simple class that holds the following properties: public class Product { public string Make { get; set; } public string Model { get; set; } }   Now in the page code behind we will create a list of product by doing the following: private List<Product> GetProducts() { List<Product> products = new List<Product>(); Product p = new Product(); p.Make = "Samsung"; p.Model = "Galaxy S 1"; products.Add(p); p = new Product(); p.Make = "Samsung"; p.Model = "Galaxy S 2"; products.Add(p); p = new Product(); p.Make = "Samsung"; p.Model = "Galaxy Note"; products.Add(p); p = new Product(); p.Make = "Apple"; p.Model = "iPhone 4"; products.Add(p); p = new Product(); p.Make = "Apple"; p.Model = "iPhone 4s"; products.Add(p); p = new Product(); p.Make = "HTC"; p.Model = "Sensation"; products.Add(p); p = new Product(); p.Make = "HTC"; p.Model = "Desire"; products.Add(p); p = new Product(); p.Make = "Nokia"; p.Model = "Some Model"; products.Add(p); p = new Product(); p.Make = "Nokia"; p.Model = "Some Model"; products.Add(p); p = new Product(); p.Make = "Sony Ericsson"; p.Model = "800i"; products.Add(p); p = new Product(); p.Make = "Sony Ericsson"; p.Model = "800i"; products.Add(p); return products; }   And then let’s bind the products to the GridView. protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Gridview1.DataSource = GetProducts(); Gridview1.DataBind(); } }   Running the code will display something like this in the page: Now what I want is to get the distinct row values from the list. So what I did is to use the LINQ Distinct operator and unfortunately it doesn't work. In order for it work is you must use the overload method of the Distinct operator for you to get the desired results. So I’ve added this IEqualityComparer<T> class to compare values: class ProductComparer : IEqualityComparer<Product> { public bool Equals(Product x, Product y) { if (Object.ReferenceEquals(x, y)) return true; if (Object.ReferenceEquals(x, null) || Object.ReferenceEquals(y, null)) return false; return x.Make == y.Make && x.Model == y.Model; } public int GetHashCode(Product product) { if (Object.ReferenceEquals(product, null)) return 0; int hashProductName = product.Make == null ? 0 : product.Make.GetHashCode(); int hashProductCode = product.Model.GetHashCode(); return hashProductName ^ hashProductCode; } }   After that you can then bind the GridView like this: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Gridview1.DataSource = GetProducts().Distinct(new ProductComparer()); Gridview1.DataBind(); } }   Running the page will give you the desired output below: As you notice, it now eliminates the duplicate rows in the GridView. Now what if we only want to get the distinct values for a certain field. For example I want to get the distinct “Make” values such as Samsung, Apple, HTC, Nokia and Sony Ericsson and populate them to a DropDownList control for filtering purposes. I was hoping the the Distinct operator has an overload that can compare values based on the property value like (GetProducts().Distinct(o => o.PropertyToCompare). But unfortunately it doesn’t provide that overload so what I did as a workaround is to use the GroupBy,Select and First LINQ query operators to achieve what I want. Here’s the code to get the distinct values of a certain field. protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DropDownList1.DataSource = GetProducts().GroupBy(o => o.Make).Select(o => o.First()); DropDownList1.DataTextField = "Make"; DropDownList1.DataValueField = "Model"; DropDownList1.DataBind(); } } Running the code will display the following output below:   That’s it! I hope someone find this post useful!

    Read the article

  • Java EE???????????!? ?Oracle ADF???????!!|WebLogic Channel|??????

    - by ???02
    WebLogic Server???Java EE??????????????????????Oracle Application Development Framework(ADF)????????????Oracle ADF????????????????????????????????????????GUI?????????????????Web???????????????????????????????????????/??????????????????????Fusion Application???????/?????????Oracle ADF?????????Java EE????????????????????????????? Fusion Middleware?????????????????????????Oracle ADF???????????????(???)??????????????????? ???Web??????????????????????????????1???MVC???????????????????????·????????Model?????????????????????View?????Model?View??????Controller????3???????????????????????????????????????Model?View?Controller?????????????????????????????????????????????????????????????????????????????????????????????? ????MVC???????????????????????????Controller?Model?????????EJB????????Web???????Model????????????????????????????View?Model??????Model????????????????????????????????????????????????2004???????????Oracle ADF???????????????????????????Java EE???????????????·??·???????????Oracle Technology Network:?Oracle Applicastion Development Framework????Java EE????????????????? Oracle ADF??????????????????????????????????????????????????IDE?JDeveloper??????????????????????????????WYSIWYG????????????????????????????????????????????????????????????SQL??????????·????·??????????????????????????Oracle Technology Network:?Oracle JDeveloper ????????Oracle JDeveloper 11g ????????  ???Oracle ADF??????????????????????/????????????Web UI??????????????????????????????????Oracle Enterprise Manager?Oracle Enterprise Performance Management?Oracle Business Intelligence??????????????????????????????????·?????????Fusion Application????????????????Oracle ADF??????????????????????/???????????????????????????????????150?????GUI?????????·??????????? Oracle ADF???????????????ADF Faces???ADF Task Flow???ADF Model?????????????View?Controller?Model?????????????????????????????????????ADF Security??????????????????????????????????ADF Business Components???????????? ??Oracle ADF???????Web??????????????????????????????????????????????????????Oracle ADF???ADF Faces???JSF?????150?????GUI???????????????&????????????????Ajax?????????????????????? ???????????????????????????????????????????????????GUI??????????????????????????????????????????????GUI????????????·???????????????????????????????Web??????????????? Oracle ADF???Web?????????????????????????????Excel?????????????????????????????????????Desktop Integration???????????????????????????????????????Excel?????????????????????????? ????????????????????·????????????????????????ADF Mobile???????????????????????????Web???????????????????????????????·???????????????·??????????????????????????????????ADF Mobile??????·????????????????????????·?????????????????ADF????????????????? ?ADF Business Components???ADF Task Flow???????????????ADF Business Components?J2EE????·???????????????·?????????????????????????·????·??????????????????????????????????????·??????Java???????????????????????JDBC?????????????????????????? ???ADF Task Flow?JSF?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????URL???????????????????????????????????????????? ??????Java EE??????????????????Oracle ADF???????????????????????.NET Framework?????????????????????·?????Oracle ADF????????????????????????????????????????????????????Oracle ADF??????????????????????????????????????Java EE 6?HTML5???????? Oracle ADF????????Java EE?????Java EE6??????????Web???????????????????HTML5??????????????????????????????·??????????????????????????????????????????????? ???????????????????????????1????????????????????·??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????? ???????Oracle ADF?????????????????????????????????????????????????????????????????????????????????Oracle ADF????????????·???????????????????????????????????Oracle ADF???Java EE?????????????????????????????????:?Oracle JDeveloper?Oracle ADF 11g?Release 2(11.1.2.x):????

    Read the article

  • Django automatically compress Model Field on save() and decompress when field is accessed

    - by Brian M. Hunt
    Given a Django model likeso: from django.db import models class MyModel(models.Model): textfield = models.TextField() How can one automatically compress textfield (e.g. with zlib) on save() and decompress it when the property textfield is accessed (i.e. not on load), with a workflow like this: m = MyModel() textfield = "Hello, world, how are you?" m.save() # compress textfield on save m.textfield # no decompression id = m.id() m = MyModel.get(pk=id) # textfield still compressed m.textfield # textfield decompressed I'd be inclined to think that you would overload MyModel.save, but I don't know the pattern for in-place modification of the element when saving. I also don't know the best way in Django to decompress when the field when it's accessed (overload __getattr__?). Or would a better way to do this be to have a custom field type? I'm certain I've seen an example of almost exactly this, but alas I've not been able to find it recently. Thank you for reading – and for any input you may be able to provide.

    Read the article

  • QT4 - MDI model or Dock Windows?

    - by umanga
    Greetings, In the QT application we develop we need to display several 'Viewer windows'(to display data in XY plane ,YX plane,XZ plane and in 3D). We were hoping to use MDI application model ,but later client asked for a requirement to drag and view 'Viewer windows' in multiple desktops.(using multiple monitors). This can not be done using MDI window model ,because we cannot move MDI window outside the Main Application Window. Only possible way is to use Dock windows because they can be undocked from Main Application Window and move into other desktops, but Dock windows primary used for tool-palettes or utility windows. (http://doc.qt.nokia.com/4.6/qdockwidget.html#details) Is it a good practice to use Dock window for our requirement? thanks in advance.

    Read the article

  • Designing a data model in VS2010 and generating ORM code, application

    - by Kay Zed
    Simply put: I have a database design in my head and I now want to use Visual Studio 2010 to create a WPF application. Key is to use the VS2010 tools to take much as possible manual work out of my hands. -The database engine is SQLite -ORM probably through DBLINQ -Use of LINQ -The application can create new, empty database instances -Easily maintainable (changes in data model possible) Q- How do I start designing the database model (visually) in Visual Studio 2010? Should this be an xsd? Do I do this in a separate project? Q- Next, how can I make the most use of VS2010 code generation tools to generate a business layer? Q- I suppose the business layer will be added as a Data Source (in another project?) and from there it's a rather generic data binding solution? I tried finding clear examples of this but it's a jungle out there, the hunt for a solution is NOT converging to one clear method.... :_(

    Read the article

  • Model Not Valid Even With No [Required] Attribute

    - by griegs
    I have a model which is validating as False even though I have no validation rules attached to it what so ever. So this is my model; public class QuickQuote { public Enumerations.AUSTRALIA_STATES state { get; set; } public Enumerations.FAMILY_TYPE familyType { get; set; } public Enumerations.CoverLevel hospitalCover { get; set; } public Enumerations.CoverLevel extrasCover { get; set; } public Enumerations.YesNo pregnancy { get; set; } } And in my controller I have; [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(IndexFormViewModel fvm) { if (!ModelState.IsValid) return View(fvm); The problem is that unless I put a value into each field it's validating as false even though it shouldn't care. Can anyone see what the problem is here?

    Read the article

  • Programmatically specifying Django model attributes

    - by mojbro
    Hi! I would like to add attributes to a Django models programmatically, at run time. For instance, lets say I have a Car model class and want to add one price attribute (database column) per currency, given a list of currencies. What is the best way to do this? I had an approach that I thought would work, but it didn't exactly. This is how I tried doing it, using the car example above: from django.db import models class Car(models.Model): name = models.CharField(max_length=50) currencies = ['EUR', 'USD'] for currency in currencies: Car.add_to_class('price_%s' % currency.lower(), models.IntegerField()) This does seem to work pretty well at first sight: $ ./manage.py syncdb Creating table shop_car $ ./manage.py dbshell shop=# \d shop_car Table "public.shop_car" Column | Type | Modifiers -----------+-----------------------+------------------------------------------------------- id | integer | not null default nextval('shop_car_id_seq'::regclass) name | character varying(50) | not null price_eur | integer | not null price_usd | integer | not null Indexes: "shop_car_pkey" PRIMARY KEY, btree (id) But when I try to create a new Car, it doesn't really work anymore: >>> from shop.models import Car >>> mycar = Car(name='VW Jetta', price_eur=100, price_usd=130) >>> mycar <Car: Car object> >>> mycar.save() Traceback (most recent call last): File "<console>", line 1, in <module> File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/base.py", line 410, in save self.save_base(force_insert=force_insert, force_update=force_update) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/base.py", line 495, in save_base result = manager._insert(values, return_id=update_pk) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/manager.py", line 177, in _insert return insert_query(self.model, values, **kwargs) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/query.py", line 1087, in insert_query return query.execute_sql(return_id) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/sql/subqueries.py", line 320, in execute_sql cursor = super(InsertQuery, self).execute_sql(None) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/models/sql/query.py", line 2369, in execute_sql cursor.execute(sql, params) File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/util.py", line 19, in execute return self.cursor.execute(sql, params) ProgrammingError: column "price_eur" specified more than once LINE 1: ...NTO "shop_car" ("name", "price_eur", "price_usd", "price_eur... ^

    Read the article

  • Extending Code Igniter Model functions to external PHP Scripts

    - by Fábio Antunes
    Hello everybody. I'm doing a small web app, which uses CKeditor for user input, and CKfinder for file management (images/flash). Those who know CKFinder, also know that the config file for CKFinder as a function named CheckAuthentication() that returns false or true, giving or not permissions to use CKFinder. This is were a Custom PHP Code checks if the user as authorization to access CKFinder or not. Well for my app I'm using Code Igniter, and of course I've created a model were i handle everything about User Permissions, Loggin, Session Cookies, etc. And i also have a function witch its propose is just to check if the user is Logged in. So I would like to know if someone knows a way that i can call the function isLoggedIn() inside the model security from inside the function CheckAuthentication() in CKFinder config file. Thanks in advance.

    Read the article

  • Asp.Net MVC does automatic model validation for DateTime but no others

    - by MattSlay
    I'm using MVC 2 with some Models from a LinqToSql project that I built. I see that when I post back to a Controller Action after editing a form that has a DateTime field from the Model, the MVC Html.ValidationMessageFor() helper will nicely display an error beside the Date text box. This seems to happen automatically when the you test ModelState.IsValid() in the Controller Action, as if the MVC model binding automatically knows that the DateTime field cannot be empty. My question is... I have some other string fields in these LinqToSql generated classes that are Not-Nullable (marked as Not Nullable in Sql Server which passes thourgh to the LinqToSql generated classes), so why doesn't Mr. MVC pick up on those as well and display a "Required" message in the ValidationMessageFor() placeholders I have added for those fields? Sure, I have successfully added the MetadataType(typeof) buddy classes to cover these Non-nullable string fields, but it sure does seem redundant to add all this metadata in buddy classes when the LinqToSql generated classes already contain enough info that MVC could sniff out. It MVC validation works with DateTime automatically, why not these Not-nullable fields too?

    Read the article

  • Bind list from FormView to model in ASP.net webforms

    - by Monty
    For a large fillin form I use the asp.net FormView for the magic databinding to my model. In this model I've a property called Rides (shown below), which exposes a list, which I obviously not want to be replaced entirely. So I made it readonly. However, this way I can't use the databinding features anymore. Is there a common solution for this problem? public IList<Ride> Rides { get { if (this._rides == null) { this._rides = new List<Ride>(); } return this._rides; } }

    Read the article

  • Eclipselink read complex object model in an ordered way

    - by Raven
    Hi, I need to read a complex model in an ordered way with eclipselink. The order is mandantory because it is a huge database and I want to have an output of a small portion of the database in a jface tableview. Trying to reorder it in the loading/quering thread takes too long and ordering it in the LabelProvider blocks the UI thread too much time, so I thought if Eclipselink could be used that way, that the database will order it, it might give me the performance I need. Unfortunately the object model can not be changed :-( The model is something like: @SuppressWarnings("serial") @Entity public class Thing implements Serializable { @Id @GeneratedValue(strategy = GenerationType.TABLE) private int id; private String name; @OneToMany(cascade=CascadeType.ALL) @PrivateOwned private List<Property> properties = new ArrayList<Property>(); ... // getter and setter following here } public class Property implements Serializable { @Id @GeneratedValue(strategy = GenerationType.TABLE) private int id; @OneToOne private Item item; private String value; ... // getter and setter following here } public class Item implements Serializable { @Id @GeneratedValue(strategy = GenerationType.TABLE) private int id; private String name; .... // getter and setter following here } // Code end In the table view the y-axis is more or less created with the query Query q = em.createQuery("SELECT m FROM Thing m ORDER BY m.name ASC"); using the "name" attribute from the Thing objects as label. In the table view the x-axis is more or less created with the query Query q = em.createQuery("SELECT m FROM Item m ORDER BY m.name ASC"); using the "name" attribute from the Item objects as label. Each cell has the value Things.getProperties().get[x].getValue() Unfortunately the list "properties" is not ordered, so the combination of cell value and x-axis column number (x) is not necessarily correct. Therefore I need to order the list "properties" in the same way as I ordered the labeling of the x-axis. And exactly this is the thing I dont know how it is done. So querying for the Thing objects should return the list "properties" "ORDER BY name ASC" but of the "Item"s objects. My ideas are something like having a query with two JOINs. Joing Things with Property and with Item but somehow I was unable to get it to work yet. Thank you for your help and your ideas to solve this riddle.

    Read the article

  • Fetched Property in XCode Data Model Editor for minimum value

    - by wal
    How do I add a Fetched Property in XCode's Data Model Editor for minimum value of one attribute?? My model: Item (name, note, storedItem) StoredItem (price, item) Item 1 ---> N StoredITem (1->N Relationship) I want that Item has a fetched property named minPrice and its value is the minimum value setted for price in the storedItems. Example: Item1 (banana, storedItem1 ... storedItem4, 10) StoredItem1 (10,item1) StoredItem2 (15,item1) StoredItem3 (30,item1) StoredItem4 (54,item1) What do I put in Destination?? StoredItem? And what do I put in Expression??

    Read the article

  • How to Load a VRML model on PaperVision3d?

    - by DomingoSL
    Hello, im very new at papervision3d, i know in order to display a .DAE model i use this import flash.events.Event; import org.papervision3d.objects.parsers.DAE; [SWF(width=640, height=480, backgroundColor=0x808080, frameRate=30)] public class Earth extends PV3DARApp { private var _earth:DAE; public function Earth() { addEventListener(Event.INIT, _onInit); init('Data/camera_para.dat', 'Data/flarlogo.pat'); } private function _onInit(e:Event):void { _earth = new DAE(); _earth.load('model/amorfo.dae'); But how can i do in order to use VRML models (.WRL). Thanks.

    Read the article

  • Entity Framework Model with inheritance and RIA Services

    - by TimothyP
    Hi, We have an entity framework model with has some inheritance in it. The following example is not the actuall model, but just to make my point... Let's say Base class: Person Child classes: Employee, Customer The database has been generated, the DomainService has been created and we can get to the data: lstCustomers.ItemsSource = context.Persons; EntityQuery<Person> query = context.GetPeopleQuery().Take(4); context.Load(query); But how can I modify the query to only return Customers ?

    Read the article

  • SubWebFolder and mutliple bin folders with Website model?

    - by OutOFTouch
    Hi, I am looking for some advice on how what is the best approach to subweb folders and having mutliple bin folders in the WebSite Project model. For adding new pages at a later stage without recompiling the core files of a website and without building a full fledged Plug-in framework api. I am aware of being able to drop in the compiled dlls into the main bin folder and to just copy over the new page files to a sub folder but I am looking for a more organized file/folder approach. Here is the how it was done with WAP: Moving the Code-Behind Assemblies/DLLs to a different folder than /BIN with ASP.NET 1.1 Multiple /bin folders in ASP.NET I should also mention that I see that I can still do it the old way with the website project model by making the adjustment to the config section mentioned here but I was wondering if that has any side affects. AssemblyBinding in Web Config and XMLNS

    Read the article

  • How do I render 3d model into directshow virtual camera output

    - by Mr Bell
    I want to provide a virtual webcam via DirectShow that will use the video feed from an existing camera running some tracking software against it to find the users face and then overlay a 3d model oriented just that it appears to move the users face. I am using a third party api to do the face tracking and thats working great. I get position and rotation data from that api. My question is whats the best way to render the 3d model and get into the video feed and out to direct show? I am using c++ on windows xp.

    Read the article

  • Ruby on Rails: Model.all.each vs find_by_sql("SELECT * FROM model").each ?

    - by B_
    I'm fairly new to RoR. In my controller, I'm iterating over every tuple in the database. For every table, for every column I used to call SomeOtherModel.find_by_sql("SELECT column FROM model").each {|x| #etc } which worked fine enough. When I later changed this to Model.all(:select => "column").each {|x| #etc } the loop starts out at roughly the same speed but quickly slows down to something like 100 times slower than the the find_by_sql command. These calls should be identical so I really don't know what's happening. I know these calls are not the most efficient but this is just an intermediate step and I will optimize it more once this works correctly. Thanks!

    Read the article

  • Help a Python newbie with a Django model inheritance problem

    - by Joshmaker
    I'm working on my first real Django project after years of PHP programming, and I am running into a problem with my models. First, I noticed that I was copying and pasting code between the models, and being a diligent OO programmer I decided to make a parent class that the other models could inherit from: class Common(model.Model): self.name = models.CharField(max_length=255) date_created = models.DateTimeField(auto_now_add=True) date_modified = models.DateTimeField(auto_now=True) def __unicode__(self): return self.name class Meta: abstract=True So far so good. Now all my other models extend "Common" and have names and dates like I want. However, I have a class for "Categories" were the name has to be unique. I assume there should be a relatively simple way for me to access the name attribute from Common and make it unique. However, the different methods I have tried to use have all failed. For example: class Category(Common): def __init__(self, *args, **kwargs): self.name.unique=True Spits up the error "Caught an exception while rendering: 'Category' object has no attribute 'name' Can someone point me in the right direction?

    Read the article

  • asp.net mvc - bootstrapping object via model binder

    - by csetzkorn
    Hi, I have a domain object Thing which can contain several Categories. So I have implemented my HTML helper to create a checkbox group of all possible Categories. I have no problem receiving: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Thing Thing, List<string> Categories) However I am wondering whether I could use a custom Model binder to use just this: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Create(Thing Thing) So basically I am looking for a way to use the model binder to bootstrap the object tree/graph. Any pointers appreciated. Thanks. Christian

    Read the article

  • 3D Character/Model Creator

    - by Click Ok
    I'm in a project to create a 3d game using XNA/C#, and the game will use a lot of 3d characters. Looking at the current 3d games, in some they create near to hundreds of characters, what lead me to think that there are some good 3d character/model creator. To narrow the sample, the game will have characters like the game "Grand Chase". There are some good (and easy) character model creator for to use in XNA development? Free is better, of course, but I will get payed versions too. EDIT: Another question is about the movements of the characters. The movements like walk, jump, sit, etc are "created" by the "character creator tool" or by the game?

    Read the article

  • Modify on-the-fly verbose_name in a model field on django admin

    - by PerroVerd
    Hi I have this sample model working with the admin class Author(models.Model): name = models.CharField(_('Text in here'), max_length=100) with verbose_name set as ugettext_lazy 'Text in here', but sometimes, depending on the site_id i want to present a diferent verbose name, so I modified the init in this way def __init__(self, *args, **kwargs): super(Author, self).__init__(*args, **kwargs) #some logic in here self._meta.get_field('name').verbose_name = _('Other text') It works, displaying the 'Other text' instead the 'Text in here'... except for the very first time the author/add view is used. ¿Is it the right way to do it? ¿How can i fix the first time problem? Thanks in advance

    Read the article

  • How to setup default attributes in a ruby model

    - by webdestroya
    I have a model User and when I create one, I want to pragmatically setup some API keys and what not, specifically: @user.apikey = Digest::MD5.hexdigest(BCrypt::Password.create("jibberish").to_s) I want to be able to run User.create!(:email=>"[email protected]") and have it create a user with a randomly generated API key, and secret. I currently am doing this in the controller, but when I tried to add a default user to the seeds.rb file, I am getting an SQL error (saying my apikey is null). I tried overriding the save definition, but that seemed to cause problems when I updated the model, because it would override the values. I tried overriding the initialize definition, but that is returning a nil:NilClass and breaking things. Is there a better way to do this?

    Read the article

  • form_tag for search model

    - by kip
    I have a search controller which is to be used to search over a separate model called house. The house model has a restful setup. I want the results listed on the index action of the search controller. The form_tag url is giving me some problems. What is the correct path for this? Below is the search form (search/form): <% form_tag index_search do -%> <p> <%= collection_select(:house, :category_id, Category.all, :id, :name) %> </p> <p> <strong>price</strong><br /> <%= text_field_tag :min_price, params[:min_price], :size => 3 %> <%= text_field_tag :max_price, params[:max_price], :size => 4 %>

    Read the article

  • Zend Framework: Flash Messenger, add a message from the model

    - by Dan
    Any idea on how best to add a message to flash messenger from the model? As FlashMessenger is an action helper, this seems not to be possible, so the obvious solution is to create an internal message object in the model, and return that to the controller from where you can use addMessage(). But if you want to return something else as well, this falls down. Another idea is an additional session namespace for these internal messages, which is then merged in with the Flash Messenger namespace messages at output time? Anyone have any thoughts or experience on this? Cheers.

    Read the article

< Previous Page | 42 43 44 45 46 47 48 49 50 51 52 53  | Next Page >