Search Results

Search found 7702 results on 309 pages for 'django validation'.

Page 43/309 | < Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >

  • How make this special many2many fields validation using Django ORM?

    - by e-satis
    I have the folowing model: class Step(models.Model): order = models.IntegerField() latitude = models.FloatField() longitude = models.FloatField() date = DateField(blank=True, null=True) class Journey(models.Model): boat = models.ForeignKey(Boat) route = models.ManyToManyField(Step) departure = models.ForeignKey(Step, related_name="departure_of", null=True) arrival = models.ForeignKey(Step, related_name="arrival_of", null=True) I would like to implement the following check: # If a there is less than one step, raises ValidationError. routes = tuple(self.route.order_by("date")) if len(routes) <= 1: raise ValidationError("There must be at least two setps in the route") # save the first and the last step as departure and arrival self.departure = routes[0] self.arrival = routes[-1] # departure and arrival must at least have a date if not (self.departure.date or self.arrival.date): raise ValidationError("There must be an departure and an arrival date. " "Please set the date field for the first and last Step of the Journey") # departure must occurs before arrival if not (self.departure.date > self.arrival.date): raise ValidationError("Departure must take place the same day or any date before arrival. " "Please set accordingly the date field for the first and last Step of the Journey") I tried to do that by overloading save(). Unfortunately, Journey.route is empty in save(). What's more, Journey.id doesn't exists yet. I didn't try django.db.models.signals.post_save but suppose it will fail because Journey.route is empty as well (when does this get filled anyway?). I see a solution in django.db.models.signals.m2m_changed but there are a lot of steps (thousands), and I want to avoid to perform an operation for every single of them.

    Read the article

  • Java PlayFramework & Python Django GAE

    - by Maik Klein
    I already know Java, C# and C++. Now I want to start with web development and I saw that some really big sites are built with Python/C++. I like the coding style of Python, it looks really clean, but some other things like no errors before runtime is really strange. However, I don't know what I should learn now. I started with Python but then I saw that Google App Engine also supports Java and the PlayFramework looks amazing too. Now I am really confused. Should I go with Python or Java? I found the IDE for Python "PyCharm" really amazing for web development. Does Java have something similar, eclipse maybe? I know that this question isn't constructive, but it will help me with my decision. What are pro and cons of both languages?

    Read the article

  • Django vs Ruby on Rails [closed]

    - by Michal Gumny
    I know that this is not place for languages war, but my question is quite specific. I'm iOS developer and I have friend who is Android developer, we have idea to make some commercial project together, but we will need quite advaned back-end. We want to learn one of this two frameworks and their languages from scratch, so my question is what language is faster to learn, and write app, which is better for small start up

    Read the article

  • Django - how should I implement generic apps that have dependencies on other generic apps?

    - by MikeRand
    Hi all, I'm using Marty Alchin's Django app that creates historical records (add, change, delete) based on models found in other Django apps (found in chapter 11 of Pro Django). Question: how do I implement this historical_records app into my other generic Django apps while still maintaining loose coupling? For example, I have a generic app (forecast) that manages a Forecast (of any other model). For one project, I'd like to use historical_records so that I can track changes to a Forecast instance. But I don't want to require all future projects that might want to use forecast to also use historical_records. Any guidance would be greatly appreciated. Thanks, Mike

    Read the article

  • Next steps for Asp.Net C# developer (RoR vs Python Django vs PhP Drupal)

    - by ProfessorB
    A majority of my web development experience has been on the .Net stack (mainly Asp.net C#). I am looking to learn something new in my spare time, for the use of personal projects and possibly for use professionally (as an ISV). I know some Python, done some scripting with it in the past, nothing on the web though. Php has been around for a long time and RoR has gained a lot of popularity. Are there any developers from the .NET world that have migrated over to one or more of the other platforms? If so, which do you prefer and why? Which would you suggest and why?

    Read the article

  • What sorts of tools make a Django Developer valuable? [closed]

    - by MrOodles
    I am a Django Consultant and I want to increase the value that I provide to clients. My first question was an epic failure according to the FAQ. So I'll try again before I delete it. What types of tools should a Django developer have in his tool belt to increase the value to the client? Would a collection of project templates be useful? Are there open-source project templates available that can be forked and altered? Is there a proper way to configure templates to include dependencies for certain types of projects? What about deployment scripts using tools like Puppet or Chef? Does it make a lot of sense to fork Django apps on GitHub and make contributions to open source projects there? Would clients percieve extra value in programmers that are contributing to open source projects? Are there industry best practices for implementing continuous integration in a Django project? I want the answer to be open ended, as I'm at the beginning of my research. I am curious to know what sorts of tools other Django consultants use on a daily and per-project basis, and how they use them.

    Read the article

  • Custom Validation - Dependent Drop Down Lists

    - by Holysmoke
    Hi, I've two columns in a sheet that are interdependent and I want to use validation, drop-down lists, on both as follows: Column A (TYPE) | Column B (Sub-TYPE) ------------------------------------------| TypeA, TypeB | If TypeA SubTypeA1, | ... TypeN | SubTypeA2 ... SubTypeAN | ------------------------------------------| Creating the column A drop down is trivial. How do I create the Column B drop down, that in turn depends on what was chosen in Column A? TIA

    Read the article

  • Show models.ManyToManyField as inline, with the same form as models.ForeignKey inline

    - by Kristian
    I have a model similar to the following (simplified): models.py class Sample(models.Model): name=models.CharField(max_length=200) class Action(models.Model): samples=models.ManyToManyField(Sample) title=models.CharField(max_length=200) description=models.TextField() Now, if Action.samples would have been a ForeignKey instead of a ManyToManyField, when I display Action as a TabularInline in Sample in the Django Admin, I would get a number of rows, each containing a nice form to edit or add another Action. However; when I display the above as an inline using the following: class ActionInline(admin.TabularInline): model=Action.samples.through I get a select box listing all available actions, and not a nifty form to create a new Action. My question is really: How do I display the ManyToMany relation as an inline with a form to input information as described? In principle it should be possible since, from the Sample's point of view, the situation is identical in both cases; Each Sample has a list of Actions regardless if the relation is a ForeignKey or a ManyToManyRelation. Also; Through the Sample admin page, I never want to choose from existing Actions, only create new or edit old ones.

    Read the article

  • CharField values disappearing after save (readonly field)

    - by jamida
    I'm implementing simple "grade book" application where the teacher would be able to update the grades w/o being allowed to change the students' names (at least not on the update grade page). To do this I'm using one of the read-only tricks, the simplest one. The problem is that after the SUBMIT the view is re-displayed with 'blank' values for the students. I'd like the students' names to re-appear. Below is the simplest example that exhibits this problem. (This is poor DB design, I know, I've extracted just the relevant parts of the code to showcase the problem. In the real example, student is in its own table but the problem still exists there.) models.py class Grade1(models.Model): student = models.CharField(max_length=50, unique=True) finalGrade = models.CharField(max_length=3) class Grade1OForm(ModelForm): student = forms.CharField(max_length=50, required=False) def __init__(self, *args, **kwargs): super(Grade1OForm,self).__init__(*args, **kwargs) instance = getattr(self, 'instance', None) if instance and instance.id: self.fields['student'].widget.attrs['readonly'] = True self.fields['student'].widget.attrs['disabled'] = 'disabled' def clean_student(self): instance = getattr(self,'instance',None) if instance: return instance.student else: return self.cleaned_data.get('student',None) class Meta: model=Grade1 views.py from django.forms.models import modelformset_factory def modifyAllGrades1(request): gradeFormSetFactory = modelformset_factory(Grade1, form=Grade1OForm, extra=0) studentQueryset = Grade1.objects.all() if request.method=='POST': myGradeFormSet = gradeFormSetFactory(request.POST, queryset=studentQueryset) if myGradeFormSet.is_valid(): myGradeFormSet.save() info = "successfully modified" else: myGradeFormSet = gradeFormSetFactory(queryset=studentQueryset) return render_to_response('grades/modifyAllGrades.html',locals()) template <p>{{ info }}</p> <form method="POST" action=""> <table> {{ myGradeFormSet.management_form }} {% for myform in myGradeFormSet.forms %} {# myform.as_table #} <tr> {% for field in myform %} <td> {{ field }} {{ field.errors }} </td> {% endfor %} </tr> {% endfor %} </table> <input type="submit" value="Submit"> </form>

    Read the article

  • Why is this UL and inline JS giving errors during HTML validation?

    - by thor
    I've just run the homepage of a site I'm working on through the w3c HTML validator and it's come back with 3 errors and 2 warnings. I've taken a look at them but can't see why they would be causing a problem. I've pasted them in below (I've removed URL's/strings etc as the site isn't quite ready to be made public yet). This is being validated against XHTML Transitional by the way. The UL comes back with the following error: end tag for "ul" which is not finished <ul id='tabs'></ul> <ul id='tabs'> <li> <a href="/en/folder/folder/search?categories[]=cat1" class="tab1" title="tab_title"> <img alt="img_alt" src="img_src" /> <span> tab1_text </span> </a> </li> <li> <a href="/en/folder/folder/search?categories[]=cat2" class="tab2" title="tab_title"> <img alt="img_alt" src="img_src" /> <span> tab2_text </span> </a> </li> <li> <a href="/en/folder/folder/search?categories[]=cat3" class="tab3" title="tab_title"> <img alt="img_alt" src="img_src" /> <span> tab3_text </span> </a> </li> <li> <a href="/en/folder/folder/search?categories[]=cat4" class="tab4" title="tab_title"> <img alt="img_alt" src="img_src" /> <span> tab4_text </span> </a> </li> <li> <a href="/en/folder/folder/search?categories[]=cat5" class="tab5" title="tab_title"> <img alt="img_alt" src="img_src" /> <span> tab5_text </span> </a> </li> <li> <a href="/en/folder/folder/search?categories[]=cat6" class="tab6" title="tab_title"> <img alt="img_alt" src="img_src" /> <span> tab6_text </span> </a> </li> <li> <a href="/en/folder/folder/search?categories[]=cat7" class="tab7" title="tab_title"> <img alt="img_alt" src="img_src" /> <span> tab7_text </span> </a> </li> <li> <a href="/en/folder/folder/search?categories[]=cat8" class="tab8" title="tab_title"> <img alt="img_alt" src="img_src" /> <span> tab8_text </span> </a> </li> </ul> For the inline javascript, I'm getting 2 errors and 2 warnings all for the same thing - I have a simple if statement with && and the validator appears to be seeing this as HTML rather than javascript: character "&amp;" is the first character of a delimiter but occurred as data and xmlParseEntityRef: no name <script type='text/javascript'> if (weather_data != null && weather_data['data'] != null){ display_weather(); } </script> The javascript is placed just before the body close tag at the end of the document. If you need to see the full source then let me know and I can send it over.

    Read the article

  • How do I make a Data Validation drop-down exclude blanks?

    - by Iszi
    Related: How can I use non-adjacent cells on another sheet for a Data Validation drop-down, and only show non-blank values? For now, I've worked around the above problem by re-arranging my sheet so all the Data Validation Source cells are in one range. I'm leaving the above question open though, because I think it still poses an interesting problem. However, the issue now is that the Data Validation drop-down isn't working in the way I expected it to (and how I believe others are telling me it should). Even though I've got everything into one named range, Excel still shows blanks in a drop-down that references that range. Setup: Sheet 1 A1= (blank) B1= Header A2= 1 B2= Value1 A3= 2 B3= Value2 A4= 3 B4= Value3 A5= 4 B5= (empty) A6= 5 B6= (empty) A7= 6 B7= (empty) Sheet1!B2:B7 is named Validation Sheet2!A1 is set to use Data Validation with a Source =Validation, and in-cell drop-down. The drop-down in Sheet2!A1 shows: Value1 Value2 Value3 . . . (Dots represent blank lines) How can I get rid of these blank lines in the in-cell drop-down, while still including Sheet1!B5:B7 in the Data Validation Source? Note: I nuked the sheet, and tried it again without column A from Sheet1 (putting values from column B in the above example into column A), and it worked fine. Adding Column A back though, brought the blanks back into the Data Validation drop-down. What do I need to do to keep column A as I want it and keep the in-cell drop-down clean?

    Read the article

  • working on lists in python

    - by owca
    I'm trying to make a small modification to django lfs project, that will allow me to deactivate products with no stocks. Unfortunatelly I'm just beginning to learn python, so I have big trouble with its syntax. That's what I'm trying to do. I'm using method 'has_variants' which returns true if product has any. Then I'm building a list from variants for this product. Next for every product in this list (I've called it 'set') I check it's stock and set bool variable 'inactive' to true if product has no stocks and to false if there are any. Finally if 'inactive' is false I'm setting self.active to 0. Code fails in line with: set[] = s How to correct it ? def deactivate(self): """If there are no stocks, deactivate the product. Used in last step of checkout. """ if self.has_variants(): for s in self.variants.filter(active=True): set[] = s for var in set: if var.get_stock_amount() == 0: inactive = True else: inactive = False else: if self.get_stock_amount() == 0: inactive = True if inactive: self.active = False return 0 error log : Traceback (most recent call last): File "manage.py", line 11, in <module> execute_manager(settings) File "/home/purplecow/rails/purpledev/site-packages/django/core/management/__i nit__.py", line 362, in execute_manager utility.execute() File "/home/purplecow/rails/purpledev/site-packages/django/core/management/__i nit__.py", line 303, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/purplecow/rails/purpledev/site-packages/django/core/management/bas e.py", line 195, in run_from_argv self.execute(*args, **options.__dict__) File "/home/purplecow/rails/purpledev/site-packages/django/core/management/bas e.py", line 213, in execute translation.activate('en-us') File "/home/purplecow/rails/purpledev/site-packages/django/utils/translation/_ _init__.py", line 73, in activate return real_activate(language) File "/home/purplecow/rails/purpledev/site-packages/django/utils/translation/_ _init__.py", line 43, in delayed_loader return g['real_%s' % caller](*args, **kwargs) File "/home/purplecow/rails/purpledev/site-packages/django/utils/translation/t rans_real.py", line 205, in activate _active[currentThread()] = translation(language) File "/home/purplecow/rails/purpledev/site-packages/django/utils/translation/t rans_real.py", line 194, in translation default_translation = _fetch(settings.LANGUAGE_CODE) File "/home/purplecow/rails/purpledev/site-packages/django/utils/translation/t rans_real.py", line 180, in _fetch app = import_module(appname) File "/home/purplecow/rails/purpledev/site-packages/django/utils/importlib.py" , line 35, in import_module __import__(name) File "/home/purplecow/rails/purpledev/lfs/caching/__init__.py", line 1, in <mo dule> from listeners import * File "/home/purplecow/rails/purpledev/lfs/caching/listeners.py", line 10, in < module> from lfs.cart.models import Cart File "/home/purplecow/rails/purpledev/lfs/cart/models.py", line 8, in <module> from lfs.catalog.models import Product File "/home/purplecow/rails/purpledev/lfs/catalog/__init__.py", line 1, in <mo dule> from listeners import * File "/home/purplecow/rails/purpledev/lfs/catalog/listeners.py", line 5, in <m odule> from lfs.catalog.models import PropertyGroup File "/home/purplecow/rails/purpledev/lfs/catalog/models.py", line 589 set[] = s ^ SyntaxError: invalid syntax

    Read the article

  • ASP.NET Ajax.BeginForm Posts Even If Validation Fails

    - by Acoustic
    I'm just overlooking something simple... but my form, which is an Ajax form, always submits even if the validation fails. I'm not using jQuery validation, just the standard .NET MVC validation. Each of the field failing get show the validation message and highlight the field, but the form just submits anyway. Is there an OnBegin script I can call to prevent the form from submitting if there are errors? Thanks for the help! Ajax.BeginForm("EditUserProfile", new AjaxOptions { HttpMethod = "Post", OnComplete = ToggleViews", UpdateTargetId ="userProfileContainer" })

    Read the article

  • Spring MVC jQuery remote validation

    - by raulsan
    Hi, I am using Spring MVC on the server side, but in one of the pages I decided to create an AJAX validation with jQuery rather than the default Spring validation. Everything works great, except when I have to do a remote validation to check if a "title" already exists. For the javascript I have the following: var validator = $("form").validate({ rules: { title: { minlength: 6, required: true, remote: { url: location.href.substring(0,location.href.lastIndexOf('/'))+"/checkLocalArticleTitle.do", type: "GET" } }, html: { minlength: 50, required: true } }, messages: { title: { required: "A title is required.", remote: "This title already exists." } } }); Then, I use Spring-Json to make this validation and give a response: @RequestMapping("/checkLocalArticleTitle.do") public ModelAndView checkLocalArticleTitle(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { Map model = new HashMap(); String result = "FALSE"; try{ String title = request.getParameter("title"); if(!EJBRequester.articleExists(title)){ result = "TRUE"; } }catch(Exception e){ System.err.println("Exception: " + e.getMessage()); } model.put("result",result); return new ModelAndView("jsonView", model); } However, this does not work and the field "title" is never validated. I think the reason for this is that I am returning an answer in the manner: {result:"TRUE"} when in fact, the answer should be: {"TRUE"} I don't know how to return a single response like this one using a ModelAndView answer. Another thing that is not working is the customized message for the "remote" validation: messages: { title: { required: "A title is required.", remote: "This title already exists." } }, The required message works, but not the remote message. I looked around, but I didn't see many people using Spring and jQuery at the same time. I would appreciate some help here.

    Read the article

  • Validation plugin hijacks click function?

    - by timkl
    Absolute newbie question, any help is highly appreciated :) I am using curvycorners (http://www.curvycorners.net/) in combination with the jQuery validation plugin (http://bassistance.de/jquery-plugins/jquery-plugin-validation/), and I'm having problems getting the div to redraw the rounded corners when I do like this: $("input[type='submit']").click(function(e) { curvyCorners.redraw(); }); When I click the submit-button the first time the form validates, the validation error-message pops up and expands the div, causing the layout to go ugly. However when I click on it the second time the rounded corners redraw nicely. Could it be that my validation plugin hijacks my initial click? How do I go about this? Any hint is very much appreciated.

    Read the article

  • adding jquery validation after form created

    - by CoffeeCode
    im using a jquery validation plugin first i add the validation to the form: $('#EmployeeForm').validate({ rules: { "Employee.FirstName": "required", "Employee.PatronymicName": "required", "Employee.LastName": "required", "Employee.BirthDay": { required: true, date: true } }, messages: { "Employee.FirstName": { required: "*" }, "Employee.PatronymicName": { required: "*" }, "Employee.LastName": { required: "*" }, "Employee.BirthDay": { required: "*", date: "00.00.00 format" } } }); and then latter a need to add validation rules to other form elements: $('#Address_A.Phone1, #Address_A.Phone2, #Address_B.Phone1, #Address_B.Phone2').rules("add", { digits: true, messages: { digits: "?????? ?????" } }); but i get an error: 'form' is null or not an object i check, the form and all the elements in it are created before i add validation to it. cant figer out whats wrong.

    Read the article

  • Kohana 3: Example of model with validation

    - by Svish
    I find examples and tutorials about models and about validation. And I places that say the validation (or most of it at least) should be in the model, which I agree with. But I can't any examples or tutorials that show how that should be done. Could anyone help me with a simple example on how that could be done? Where would you have the rules in the model? Where would the validation happen? How would the controller know if the validation passed or fail? How would the controller get error messages and things like that? Hope someone can help, cause feel a bit lost here :p

    Read the article

  • How to prevent HTTP 304 in Django test server

    - by Augusto Men
    I have a couple of projects in Django and alternate between one and another every now and then. All of them have a /media/ path, which is served by django.views.static.serve, and they all have a /media/css/base.css file. The problem is, whenever I run one project, the requests to base.css return an HTTP 304 (not modified), probably because the timestamp hasn't changed. But when I run the other project, the same 304 is returned, making the browser use the file cached by the previous project (and therefore, using the wrong stylesheet). Just for the record, here are the middleware classes: MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.transaction.TransactionMiddleware', ) I always use the default address http://localhost:8000. Is there another solution (other than using different ports - 8001, 8002, etc.)?

    Read the article

  • jQuery / Spry Validation / Problem

    - by samuel baldus
    Hi Chaps, I have a PHP form with one input and a button. A jQuery script ('loading' animated gif) is triggered on the click of the submit button. I also have a Spry Validation field linked to the input. At the moment, if the validation is triggered, the animated gif continues and won't stop. The furthest I've managed to get with it, is to click the validation message to stop the animation, but what I'm really after is to stop the animation when the validation is visible/triggered, but I can't find a suitable Event. $(function() { $("#button_download") .click(function() { }) .throbber(); $("#sprytextfield1") .click(function(sprytextfield1) { $.throbberHide(); }) }); If someone can point me in the right direction, that would be sweet.

    Read the article

  • Django 1.2 object level permissions - third party solutions?

    - by mawimawi
    Since Django 1.2 final is almost out, I am curious if there are already projects that use the new object level permissions / row level permissions system. [django-authority][1] which is a possible solution for Django up to 1.1 has not been updated for a while, and does not (yet) use the new permissions system. It seems to me that Django-Authority is in a comatose state. Does someone know about upcoming or maybe even finished solutions? I'd appreciate any good links to active projects with at least some downloadable content very much. [1]: http://packages.python.org/django-authority/ django-authority

    Read the article

  • django urls.py regex isn't working

    - by Phil
    This is for Django 1.2.5 and Python 2.7 on Wamp Server running apache version 2.2.17. My problem is that the my URLConf in urls.py isn't redirecting, it's just throwing a 404 error. urls.py: from django.conf.urls.defaults import * # Uncomment the next two lines to enable the admin: #from django.contrib import admin #admin.autodiscover() urlpatterns = patterns('', (r'^app/$', include('app.views.index')), # Uncomment the admin/doc line below to enable admin documentation: #(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: #(r'^admin/', include(admin.site.urls)), ) views.py from django.http import HttpResponse def index(request): return HttpResponse("Hello World") I'm getting the following error: ImportError at /app/ No module named index I'm stumped as I'm only learning Django, can anybody see something wrong with my code? Here's my PythonPath: ['C:\Windows\system32\python27.zip', 'C:\Python27\Lib', 'C:\Python27\DLLs', 'C:\Python27\Lib\lib-tk', 'C:\wamp\bin\apache\Apache2.2.17', 'C:\wamp\bin\apache\apache2.2.17\bin', 'C:\Python27', 'C:\Python27\lib\site-packages', 'c:\wamp\www\seetwo']

    Read the article

  • jQuery Validation plugin with JQGrid?

    - by Herb Caudill
    Has anyone successfully used the jQuery Validation plugin with JQGrid? I realize that JQGrid has its own validation scheme, but it's limited and a little clumsy; and I'd prefer to reuse the validation UI, language, and rules that I'm using with the rest of my forms.

    Read the article

  • ASP.NET MVC 2.0 Client-Side Validation HOWTO

    - by AlexWalker
    Where can I find some good information on the new client-side validation functionality included in ASP.NET MVC v2? I'd like to find information about using the client-side validation JavaScript without using DataAnnotations, and I'd like to find out how custom validations are handled. For example, if I want to validate two fields together, how would I utilize the provided JavaScript? Or if I wanted to write validation code on the server-side that queried a database, how could I use the provided JavaScript to implement a similar validation? I don't see any books on MVC2 yet, and the blog entries I've found are not detailed enough.

    Read the article

  • Does Java Spring 3.0 MVC support annotation/attribute based client side validation like Asp.net MVC

    - by Athens
    In Asp.Net MVC 2.0, at least in the beta, you could decoration your model classes with data annotation attributes and enable client side validation that leverages that criteria defined in your model data annotation attibutes. Is there anything similar for Java Spring MVC 3.0? Is it possible to inject a component into the response pipeline that can inspect the model's annotated properties and render client side validation logic to complement the server side validation logic that is invoked prior to the controller handling the request?

    Read the article

< Previous Page | 39 40 41 42 43 44 45 46 47 48 49 50  | Next Page >