Search Results

Search found 8839 results on 354 pages for 'optional parameters'.

Page 12/354 | < Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >

  • Django Formset validation with an optional ForeignKey field

    - by Camilo Díaz
    Having a ModelFormSet built with modelformset_factory and using a model with an optional ForeignKey, how can I make empty (null) associations to validate on that form? Here is a sample code: ### model class Prueba(models.Model): cliente = models.ForeignKey(Cliente, null = True) valor = models.CharField(max_length = 20) ### view def test(request): PruebaFormSet = modelformset_factory(model = Prueba, extra = 1) if request.method == 'GET': formset = PruebaFormSet() return render_to_response('tpls/test.html', {'formset' : formset}, context_instance = RequestContext(request)) else: formset = PruebaFormSet(request.POST) # dumb tests, just to know if validating if formset.is_valid(): return HttpResponse('0') else: return HttpResponse('1') In my template, i'm just calling the {{ form.cliente }} method which renders the combo field, however, I want to be able to choose an empty (labeled "------") value, as the FK is optional... but when the form gets submitted it doesn't validate. Is this normal behaviour? How can i make this field to skip required validation?

    Read the article

  • Javascript: Pass array as optional method args

    - by Dave Paroulek
    console.log takes a string and replaces tokens with values, for example: console.log("My name is %s, and I like %", 'Dave', 'Javascript') would print: My name is Dave, and I like Javascript I'd like to wrap this inside a method like so: function log(msg, values) { if(config.log == true){ console.log(msg, values); } } The 'values' arg might be a single value or several optional args. How can I accomplish this? If I call it like so: log("My name is %s, and I like %s", "Dave", "Javascript"); I get this (it doesn't recognize "Javascript" as a 3rd argument): My name is Dave, and I like %s If I call this: log("My name is %s, and I like %s", ["Dave", "Javascript"]); then it treats the second arg as an array (it doesn't expand to multiple args). What trick am I missing to get it to expand the optional args?

    Read the article

  • .Net SvcUtil: attributes must be optional

    - by Michel van Engelen
    Hi, I'm trying to generate C# code classes with SvcUtil.exe instead of Xsd.exe. The latter is giving me some problems. Command line: SvcUtil.exe myschema.xsd /dconly /ser:XmlSerializer Several SvcUtil problems are described and solved here: http://blog.shutupandcode.net/?p=761 One problem I can't solve is this one: Error: Type 'DatafieldDescription' in namespace '' cannot be imported. Attributes must be optional and from namespace 'http://schemas.microsoft.com/2003/10/Seri alization/'. Either change the schema so that the types can map to data contract types or use ImportXmlType or use a different serializer. ' I changed <xs:attribute name="Order" use="required"> to <xs:attribute name="Order" use="optional"> and <xs:attribute name="Order"> But the error remains. Is it possible to use attributes, or do I have to delete them all (in that case, this excercition is over)?

    Read the article

  • How can I make the C# compiler infer these type parameters automatically?

    - by John Feminella
    I have some code that looks like the following. First I have some domain classes and some special comparators for them. public class Fruit { public int Calories { get; set; } public string Name { get; set; } } public class FruitEqualityComparer : IEqualityComparer<Fruit> { // ... } public class BasketEqualityComparer : IEqualityComparer<IEnumerable<Fruit>> { // ... } Next, I have a helper class called ConstraintChecker. It has a simple BaseEquals method that makes sure some simple base cases are considered: public static class ConstraintChecker { public static bool BaseEquals(T lhs, T rhs) { bool sameObject = l == r; bool leftNull = l == null; bool rightNull = r == null; return sameObject && !leftNull && !rightNull; } There's also a SemanticEquals method which is just a BaseEquals check and a comparator function that you specify. public static bool SemanticEquals<T>(T lhs, T rhs, Func<T, T, bool> f) { return BaseEquals(lhs, rhs) && f(lhs, rhs); } And finally there's a SemanticSequenceEquals method which accepts two IEnumerable<T> instances to compare, and an IEqualityComparer instance that will get called on each pair of elements in the list via Enumerable.SequenceEquals. public static bool SemanticSequenceEquals<T, U, V>(U lhs, U rhs, V comparator) where U : IEnumerable<T> where V : IEqualityComparer<T> { return SemanticEquals(lhs, rhs, (l, r) => lhs.SequenceEqual(rhs, comparator)); } } // end of ConstraintChecker The point of SemanticSequenceEquals is that you don't have to define two comparators whenever you want to compare both IEnumerable<T> and T instances; now you can just specify an IEqualityComparer<T> and it will also handle lists when you invoke SemanticSequenceEquals. So I could get rid of the BasketEqualityComparer class, which would be nice. But there's a problem. The C# compiler can't figure out the types involved when you invoke SemanticSequenceEquals: return ConstraintChecker.SemanticSequenceEquals(lhs, rhs, new FruitEqualityComparer()); If I specify them explicitly, it works: return ConstraintChecker.SemanticSequenceEquals< Fruit, IEnumerable<Fruit>, IEqualityComparer<Fruit> > (lhs, rhs, new FruitEqualityComparer()); What can I change here so that I don't have to write the type parameters explicitly?

    Read the article

  • How do i configure optional flags in MVC 1.0 routes

    - by Thomas Jespersen
    I want to configure a route with optional flags. E.g. I want to be able to call the products page and send optional filters (flags) for offers and in stock options. If the flags are NOT specified then all products should be returned. http://localhost/products http://localhost/products/onlyOnOffer http://localhost/products/onlyInStock http://localhost/products/onlyInStock/onlyOnOffer [AcceptVerbs(HttpVerbs.Get)] public ActionResult GetProducts(bool onlyInStock, bool onlyOnOffer) { //... } How would I configure the route? Is it even possible in MVC 1.0? What about MVC 2.0.

    Read the article

  • velocity: join optional fields with a separator/prefix

    - by SlowStrider
    What would be the most concise/readable way in a velocity template to join multiple fields with a separator while leaving out empty or null Strings without adding excess separators? As an example we have a tooltip or appointments that goes like: Appointment ($number) [with $employee] [-] [$remarks] [-] [$roomToVisit] Where I used brackets to indicate optional data. When filled in it would normally show as Appointment (3) with John - ballroom - serve Java coffee When $remarks is empty but $roomToVisit is not, this becomes: Appointment (3) with John - ballroom When $remarks is "serve Java coffee" but $roomToVisit is empty we get: Appointment (3) with John - serve Java coffee When both are empty: Appointment (3) with John Bonus: also make the field prefix optional. When only $employee is empty we should get: Appointment (2) serve Java coffee - ballroom Ideally I would like the velocity template to look very similar to the first code box. If this is not possible, how would you achieve this with a minimum of distracting code tags? Similar ideas (first is much more verbose): Join with intelligent separators velocity: do something except in last loop iteration

    Read the article

  • Problem with optional arguments in C #defines

    - by imikedaman
    Hi, I'm having a problem with optional arguments in #define statements in C, or more specifically with gcc 4.2: bool func1(bool tmp) { return false; } void func2(bool tmp, bool tmp2) {} #define CALL(func, tmp, ...) func(tmp, ##__VA_ARGS__) int main() { // this compiles CALL(func2, CALL(func1, false), false); // this fails with: Implicit declaration of function 'CALL' CALL(func2, false, CALL(func1, false)); } That's obviously a contrived example, but does show the problem. Does anyone know how I can get the optional arguments to "resolve" correctly? Additional information: If I remove the ## before _VA_ARGS_, and do something like this: bool func2(bool tmp, bool tmp2) { return false; } #define CALL(func, tmp, ...) func(tmp, __VA_ARGS__) int main() { CALL(func2, false, CALL(func2, false, false)); } That compiles, but it no longer works with zero arguments since it would resolve to func(tmp, )

    Read the article

  • Doing Time Limited Flight Recordings Using Start Up Parameters

    - by Marcus Hirt
    Just like with the old JRockit Runtime Analyzer, it is possible to start up recordings using command line parameters to JRockit. The parameter is called -XX:StartFlightRecording in R28. Below is an example that starts a flight recording half a minute after the JVM has been started. The recording will last for a minute. The name when viewing the ongoing recordings will be MyRecording, and the resulting file will be written to C:\tmp\myrecording.jfr. The recording will use the settings in jre\lib\jfr\profile.jfs. -XX:StartFlightRecording=delay=30s,duration=60s,name=MyRecording,filename=C:\tmp\myrecording.jfr,settings=profile For more information, see the JRockit R28 command line parameter documentation.

    Read the article

  • Can't reboot netbook with any of the reboot parameters

    - by Delan Azabani
    I have a Sony VPCW218AG netbook that I've dual-booted with Ubuntu 10.10. Unlike the preinstalled Windows 7, Ubuntu will not reboot on this computer. Rebooting from Gnome, using the reboot command and SysRq+REISUB all don't work; they end hanging with a blank screen. I have read that Atom netbooks don't have a keyboard controller and therefore the default reboot method, kbd, won't work. I have actually tried all ten reboot= parameters listed here; none of them work. I have also tried disabling ACPI with noacpi acpi=off for each one; that didn't help either. Are there any other things I can try to fix the rebooting problem?

    Read the article

  • Webmaster Tools - URL Parameters Settings Do Not Work

    - by David
    Google Webmaster Tools shows problems with duplicate title tags under Optimization - HTML Improvements, for example: ???????? Mitsubishi Electric Mr. Slim PC Series PC-3KAKLT (220V) 30000 BTU > /????-????/mitsubishi-mr-slim-pc3kaklt-30000-btu.html > /????-????/mitsubishi-mr-slim-pc3kaklt-30000-btu.html?category_id=96 These two pages have exactly the same content, a rel-canonical tag is set, and they are (no longer) linked to internally. Additionally, we used the Configuration - URL Parameters setting, to set this parameter to No: Doesn't affect page content about one month ago. However, Google is still showing these HTML improvements (and rankings dropped dramatically). What else can we do here? Best, David

    Read the article

  • Google indexing page with parameters but page is Disallowed in robots.txt

    - by Jakobud
    I have the following in robots.txt: User-agent: * Disallow: /refer.php User-agent: NinjaBot Allow: / Sitemap: http://www.mysite.com/sitemap.xml The refer.php file does various things depending on what GET parameters are passed to it. When I do a Google search, I see tons of results for pages like this: http://www.mysite.com/refer.php?o=23945 http://www.mysite.com/refer.php?o=39858 http://www.mysite.com/refer.php?o=9683 http://www.mysite.com/refer.php?o=10569 http://www.mysite.com/refer.php?o=58304 http://www.mysite.com/refer.php?o=69604 Is the reason that Google is indexing these because I don't have an asterisk * after refer.php in the robots.txt ? Should changing it to Disallow: /refer.php* fix the problem?

    Read the article

  • Where do I add boot parameters to use ks.cfg

    - by user10822
    Hi, I created a kickstart file ks.cfg and then I have put that in the bootable disk*(Ubuntu 10.04)* and then added the following line to the isolinux.cfg linux ks=ks.cfg and have not removed any other lines from the isoconfig.cfg file and then while installing the installation is not automated, again it is asking for language and all. If i removed include menu.cfg or any other line from isolinux.cfg i am getting a boot error. What should i do now to automate the installation.Where should i add the boot parameters so that installation will start from the ks.cfg . Thanks and Regards Ravi Kumar

    Read the article

  • creating object parameters in {}?

    - by RealityDysfunction
    I am trying to decode a piece of code from a book: List<Person> people = new List<Person>() { new Person {FirstName="Homer",LastName="Simpson",Age=47}, new Person {FirstName="Marge",LastName="Simpson",Age=45} }; Person is just a simple class they made, with a bunch of fields: Name, Last Name, etc... What I don't understand is, don't we send parameters to a constructor of Person in non-curly brackets? I tried replicating this code, but it doesn't seem to fly, any takers? Thanks for input.

    Read the article

  • SQL Server 2008: Table Valued Parameters

    In SQL Server 2005 and earlier, it is not possible to pass a table variable as a parameter to a stored procedure. When multiple rows of data to SQL Server need to send multiple rows of data to SQL Server, developers either had to send one row at a time or come up with other workarounds to meet requirements. While a VB.Net developer recently informed me that there is a SQLBulkCopy object available in .Net to send multiple rows of data to SQL Server at once, the data still can not be passed to a stored proc.Possibly the most anticipated T-SQL feature of SQL Server 2008 is the new Table-Valued Parameters. This is the ability to easily pass a table to a stored procedure from T-SQL code or from an application as a parameter.

    Read the article

  • Where should the database and mail parameters be stored in a Symfony2 app?

    - by Songo
    In the default folder structure for a Symfony2 project the database and mail server credentials are stored in parameters.yml file inside ProjectRoot/app/config/parameters.yml with these default values: parameters: database_driver: pdo_mysql database_host: 127.0.0.1 database_port: null database_name: symfony database_user: root database_password: null mailer_transport: smtp mailer_host: 127.0.0.1 mailer_user: null mailer_password: null locale: en secret: ThisTokenIsNotSoSecretChangeIt During development we change these parameters to the development database and mail servers. This file is checked into the source code repository. The problem is when we want to deploy to the production server. We are thinking about automating the deployment process by checking out the project from git and deploy it to the production server. The thing is that our project manager has to manually update these parameters after each update. The production database and mail servers parameters are confidential and only our project manager knows them. I need a way to automate this step and suggestion on where to store the production parameters until they are applied?

    Read the article

  • Permissions depending on parameters passed to application

    - by Engineiro
    I have a java app that writes to a very important table I have. This is sudo protected, but this app takes a parameters for where the output should go. The default is the REAL DEAL but the "output" parameter takes priority over the default, so if a user provides a path that they have write permission for, say: /home/username/mystuff then I would like for users to be allowed to write to these directories. The app is launched in a shell script, so I am wondering if I can check that the string does not equal /path/to/real/deal and not empty (since /path/to/real/deal is the default) and allow users to write to places they have permissions for. My impression of linux permissions is that it is tied to the application itself and cannot be conditionally approved, but I wonder if there is some bash fu or alternative method I can perform to get me my desired result. Using Ubuntu 10.04.4 LTS

    Read the article

  • How to name a method that both performs a task and returns a boolean as a status?

    - by Limbo Exile
    If there is a method bool DoStuff() { try { // doing stuff... return true; } catch (Exception ex) { return false; } } should it rather be called IsStuffDone()? Both names could be misinterpreted by the user: If the name is DoStuff() why does it return a boolean? If the name is IsStuffDone() it is not clear whether the method performs a task or only checks its result. Is there a convention for this case? Or an alternative approach, as this one is considered flawed? For example in languages that have output parameters, like C#, a boolean status variable could be passed to the method as one and the method's return type would be void.

    Read the article

  • Factory for arrays of objects in python

    - by Vorac
    Ok, the title might be a little misleading. I have a Window class that draws widgets inside itself in the constructor. The widgets are all of the same type. So I pass a list of dictionaries, which contain the parameters for each widget. This works quite nicely, but I am worried that the interface to callers is obfuscated. That is, in order to use Window, one has to study the class, construct a correct list of dictionaries, and then call the constructor with only one parameter - widgets_params. Is this good or bad design? What alternatives does the python syntax provide?

    Read the article

  • Crystal report subreport parameter autobinding logic feeds duplicate parameters to different subrepo

    - by quillbreaker
    I have a report, and I place the same subreport within the footer twice. The report has three parameters and the subreport has four parameters. When I try to run the report through the report designer, it prompts me for seven parameters instead of the eleven I was hoping for. It prompts for one set of parameters for the subreport (with a default prompt of @parameter(subreport.rpt)/@parameter(subreport.rpt - 01), and passes the same set of parameters to both subreports. This isn't what I want the report to do. Furthermore, if I look at 'show report parameters', it does show eleven parameters, with the same value for both subreport parameter sets. So it knows that it's two different subreports, but it does not want to let me enter it that way. Is there some way I can make crystal designer realize that it should take different values for each subreport? The only solution I've found is to add 8 more parameters, one for each subreport / subreport parameter combination, and bind them individually. It works, but it feels like a workaround. Does anyone have a better solution?

    Read the article

  • OpenVPN make redirect-gateway optional

    - by Tuinslak
    Hi there, I'm currently running an OpenVPN server for multiple clients. All traffic is directed through the VPN (it's set up as gateway; push "redirect-gateway def1"). So far, all is working fine. However, I'd like to connect a couple of servers to this virtual private network, without these servers using the OVPN daemon as gateway. These servers have to be accessible from both their WAN as well as their LAN IP address. Certain services will be accessible only from the LAN side. Is there any way, for a client, to ignore the push redirect-gateway option? Kind regards, Tuinslak

    Read the article

  • How to ignore query parameters in web cache?

    - by eduardocereto
    Google Analytics use some query parameters to identify campaigns and to do cookie control. This is all handled by javascript code. Take a look at the following example: http://www.example.com/?utm_source=newsletter&utm_medium=email&utm_ter m=October%2B2008&utm_campaign=promotion This will set cookies via JavaScript with the right campaign origin. This query parameters can have multiple and sometimes random values. Since they are used as cache hash keys the cache performance is heavily degraded in some scenarios. I suppose there's a not so hard configuration on cache servers to just ignore all query parameters or specific query parameters. Am I right? Does anyone know how hard is it in popular web cache solutions, to create ? I'm not interested in a specific web cache solution. It would be great to hear about the one you use.

    Read the article

  • How to ignore query parameters in web cache?

    - by eduardocereto
    Google Analytics use some query parameters to identify campaigns and to do cookie control. This is all handled by javascript code. Take a look at the following example: http://www.example.com/?utm_source=newsletter&utm_medium=email&utm_ter m=October%2B2008&utm_campaign=promotion This will set cookies via JavaScript with the right campaign origin. This query parameters can have multiple and sometimes random values. Since they are used as cache hash keys the cache performance is heavily degraded in some scenarios. I suppose there's a not so hard configuration on cache servers to just ignore all query parameters or specific query parameters. Am I right? Does anyone know how hard is it in popular web cache solutions, to create ? I'm not interested in a specific web cache solution. It would be great to hear about the one you use.

    Read the article

< Previous Page | 8 9 10 11 12 13 14 15 16 17 18 19  | Next Page >