Search Results

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

Page 91/309 | < Previous Page | 87 88 89 90 91 92 93 94 95 96 97 98  | Next Page >

  • django template find value within list

    - by dotty
    Hay, how do i find a value with in python list in django's template system? example list = [1,2,3,4,5,6,7] x = 1 if x is in list: return u'found!' else: return u'not found' endif: Something along those lines. any help would be great

    Read the article

  • Django site runs into "504 timeout error"

    - by jack
    I have a Django based site on Nginx+FastCGI which keeps running into "504 timeout error" after about 30 minutes since FastCGI process restarted. I did a "ps -aux" check and a lot of FastCGI processes are with D status. How can I figure out which part of the site make FastCGI processes not responsing?

    Read the article

  • Django: GROUP BY two values

    - by AP257
    I would basically like to do the same as this question, but grouping by combinations of two values, rather than just one: SELECT player_type, team, COUNT(*) FROM players GROUP BY player_type, team; Does anyone know whether, and how, this is possible in Django? I'm using 1.2.

    Read the article

  • How to access image folder in django

    - by anc1revv
    I just started django and i want to access images uploaded by a user. here is my model: class Food(models.Model): name = models.CharField(max_length=100) price = models.DecimalField(max_digits=4, decimal_places=2) quantity = models.IntegerField(blank=True, null=True) description = models.CharField(max_length=200) location = models.CharField(max_length=100) time = models.DateTimeField() photo_thumbnail = models.ImageField(upload_to="images") photo_fullsize = models.ImageField(upload_to="images") i stored the image in the "images" folder below the html is this: img src="{{steak.photo_thumbnail}}" and steak.photo_thumbnail = images/steak_and_egg_thumbnail_1.png here is the error i get: [06/Jul/2012 19:08:24] "GET /menu/ HTTP/1.1" 200 99 [06/Jul/2012 19:08:24] "GET /menu/images/steak_and_egg_thumbnail_1.png HTTP/1.1" 404 2127

    Read the article

  • Pagination of Date-Based Generic Views in Django

    - by Apreche
    I have a pretty simple question. I want to make some date-based generic views on a Django site, but I also want to paginate them. According to the documentation the object_list view has page and paginate_by arguments, but the archive_month view does not. What's the "right" way to do it?

    Read the article

  • Django: saving pickled object

    - by pistacchio
    Hi, i have a large dictionary I'd like to save. I have pickled it using cPickle.dumps and saved the result into a TextField. When trying to retrieve it (cPicle.loads) i get the following error: loads() argument 1 must be string, not unicode Does anybody have any experience in serializing python objects and storing them in a DB using Django? Thanks in advance.

    Read the article

  • Creating temporary user accounts - Django

    - by RadiantHex
    Hi folks, I need to setup temporary User models for each visitors, where the visitors are obviously tied by session data. I might not be aware of it, but does Django support attaching data to Anonymous users? The only way, I am currently aware of, is to use the session dictionary part of the request object. Help would be very much appreciated!

    Read the article

  • How to span multile tables in Django

    - by ipartola
    The Django documentation gives en example like so: b = Blog.objects.get(id=1) b.entry_set.all() Which from what I understand results in 2 queries. What if I wanted to get the blog, the blog entries and all the comments associated with that entry in a number of queries that does not depend on the number of entries? Or do I have to drop down to SQL to do that?

    Read the article

  • Django for web2py developers

    - by carrier
    Now that I've gotten relatively familiar with web2py, I'd like to give Django a go. What are the main differences? What would be the most efficient way to get started taking into account web2py knowledge? (It must help to have some python application framework knowledge,no?) EDIT Also, if you've used both, can you offer an opinion on which you prefer and why?

    Read the article

  • Run a shell command from Django

    - by Badifunky
    Hello, I'm developing a web page in Django (using apache server) that needs to call a shell command to enable/dissable some daemons. I'm try to do it with os.system(service httpd restart 1>$HOME/out 2>$HOME/error) and this command doesn't return anything. Any idea how can i fix this?

    Read the article

  • onmouseover problems with JavaScript (rendered using django and django-imagekit)

    - by Michael Moreno
    I'm using Imagekit. View.py includes: def pics(request): p = Photo.objects.all() return render_to_response('Shots.html', {'p': p}) The following simple code in the template will generate associated images: {% for p in p %} <img src = "{{ p.display.url }}"> <img src = "{{ p.thumbnail_image.url }}"> {% endfor %} I'm attempting to generate a series of thumbnails {{ p.thumbnail_image.url }} which, when mouseover'd, will generate the slightly larger version of the image, {{ p.display.url }} via Javascript. The following code in the template attempts to do so: <html> <head> <HEAD> <script language="Javascript"> { image1 = new Image image2 = new Image image1.src = {{ p.thumbnail_image.url }} image2.src = {{ p.display.url }} </script> </head> <body> {% for p in p %} <a href="" onMouseOver="document.rollover.src= image2.src onMouseOut="document.rollover.src= image1.src"> <img src="{{ p.thumbnail_image.url }}" border=0 name="rollover"></a> {% endfor %} </body> </html> This will display the series of thumbnails, but the larger image will not display when mouseover'd. I believe it has to do with how I'm specifying the variable {{ p.display.url }}.

    Read the article

  • asp .net MVC 2.0 Validation

    - by ANDyW
    Hi I’m trying to do some validation in asp .net MVC 2.0 for my application. I want to have some nice client side validation. Validation should be done most time on model side with DataAnnotations with custom attributes( like CompareTo, StringLenght, MinPasswordLenght (from Membership.MinimumumpassworkdLenght value). For that purpose I tried to use xval with jquery.validation. Some specific thing is that most of forms will be working with ajax and most problems are when I want to validate form with ajax. Here is link for sample project http://www.sendspace.com/file/m9gl54 . I got two forms as controls ValidFormControl1.ascx, ValidFormControl2.ascx <% using (Ajax.BeginForm("CreateValidForm", "Test", new AjaxOptions { HttpMethod = "Post" })) {%> <div id="validationSummary1"> <%= Html.ValidationSummary(true)%> </div> <fieldset> <legend>Fields</legend> <div class="editor-label"> <%= Html.LabelFor(model => model.Name)%> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Name)%> <%= Html.ValidationMessageFor(model => model.Name)%> </div> <div class="editor-label"> <%= Html.LabelFor(model => model.Email)%> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Email)%> <%= Html.ValidationMessageFor(model => model.Email)%> </div> <div class="editor-label"> <%= Html.LabelFor(model => model.Password)%> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.Password)%> <%= Html.ValidationMessageFor(model => model.Password)%> </div> <div class="editor-label"> <%= Html.LabelFor(model => model.ConfirmPassword)%> </div> <div class="editor-field"> <%= Html.TextBoxFor(model => model.ConfirmPassword)%> <%= Html.ValidationMessageFor(model => model.ConfirmPassword)%> </div> <p> <input type="submit" value="Create" /> </p> </fieldset> <% } %> <%= Html.ClientSideValidation<ValidModel>() .UseValidationSummary("validationSummary1", "Please fix the following problems:") %> Both look same the difference is only validation summaryID (validationSummary1, validationSummary2). Both controls are rendered on one page : Form2 <%Html.RenderPartial("~/Views/Test/ValidFormControl2.ascx", null); %> Form1 <%Html.RenderPartial("~/Views/Test/ValidFormControl.ascx", null); %> Validation property First problem, when we have two controls with same type to validate it don’t work becosue html elements are rendered by field name ( so we have two element with same name “Password” ). Only first form will be validated by client side. The worst thing is that even if we have different types and their fields name is same validation won’t work too ( this thing is what I need to repair it will be stupid to name some unique properites for validation ). Is there any solution for this ? Custom attributes validation Next thing custom attributes validation ( All those error are when I use Ajax for on normal form validation is working without problem. ): CompareTo - Simple compare to that is done in mvc template for account model ( class attribute saying with two property will be compared ) , and it wasn’t show on page. To do it I created own CachingRulesProvider with compareRule and my Attribute. Maybe there is more easy way to do it? StringLenght with minimum and maximum value, I won’t describe how I done it but is there any easy whey to do it? Validation summary When I have two two control on page all summary validation information goes to first control validation summary element, even xval generated script say that elementID are different for summary. Any one know how to repair it? Validation Information Is there any option to turn on messages on place where is Html.ValidationMessageFor(model = model.ConfirmPassword). Becsoue for me it isn’t show up. I would like to have summary and near field information too not only red border. Any one know how to do it? Ajax submit Anyone know how to do easy without massive code in javascript to do submit via javascript. This will be used to change input submit to href element (a). Both look same the difference is only validation summaryID

    Read the article

  • Dynamic model choice field in django formset using multiple select elements

    - by Aryeh Leib Taurog
    I posted this question on the django-users list, but haven't had a reply there yet. I have models that look something like this: class ProductGroup(models.Model): name = models.CharField(max_length=10, primary_key=True) def __unicode__(self): return self.name class ProductRun(models.Model): date = models.DateField(primary_key=True) def __unicode__(self): return self.date.isoformat() class CatalogItem(models.Model): cid = models.CharField(max_length=25, primary_key=True) group = models.ForeignKey(ProductGroup) run = models.ForeignKey(ProductRun) pnumber = models.IntegerField() def __unicode__(self): return self.cid class Meta: unique_together = ('group', 'run', 'pnumber') class Transaction(models.Model): timestamp = models.DateTimeField() user = models.ForeignKey(User) item = models.ForeignKey(CatalogItem) quantity = models.IntegerField() price = models.FloatField() Let's say there are about 10 ProductGroups and 10-20 relevant ProductRuns at any given time. Each group has 20-200 distinct product numbers (pnumber), so there are at least a few thousand CatalogItems. I am working on formsets for the Transaction model. Instead of a single select menu with the several thousand CatalogItems for the ForeignKey field, I want to substitute three drop-down menus, for group, run, and pnumber, which uniquely identify the CatalogItem. I'd also like to limit the choices in the second two drop-downs to those runs and pnumbers which are available for the currently selected product group (I can update them via AJAX if the user changes the product group, but it's important that the initial page load as described without relying on AJAX). What's the best way to do this? As a point of departure, here's what I've tried/considered so far: My first approach was to exclude the item foreign key field from the form, add the substitute dropdowns by overriding the add_fields method of the formset, and then extract the data and populate the fields manually on the model instances before saving them. It's straightforward and pretty simple, but it's not very reusable and I don't think it is the right way to do this. My second approach was to create a new field which inherits both MultiValueField and ModelChoiceField, and a corresponding MultiWidget subclass. This seems like the right approach. As Malcolm Tredinnick put it in a django-users discussion, "the 'smarts' of a field lie in the Field class." The problem I'm having is when/where to fetch the lists of choices from the db. The code I have now does it in the Field's __init__, but that means I have to know which ProductGroup I'm dealing with before I can even define the Form class, since I have to instantiate the Field when I define the form. So I have a factory function which I call at the last minute from my view--after I know what CatalogItems I have and which product group they're in--to create form/formset classes and instantiate them. It works, but I wonder if there's a better way. After all, the field should be able to determine the correct choices much later on, once it knows its current value. Another problem is that my implementation limits the entire formset to transactions relating to (CatalogItems from) a single ProductGroup. A third possibility I'm entertaining is to put it all in the Widget class. Once I have the related model instance, or the cid, or whatever the widget is given, I can get the ProductGroup and construct the drop-downs. This would solve the issues with my second approach, but doesn't seem like the right approach.

    Read the article

  • IntegrityError: foreign key violation upon delete

    - by Lukasz Korzybski
    I have Order and Shipment model. Shipment has a foreign key to Order. class Order(...): ... class Shipment() order = m.ForeignKey('Order') ... Now in one of my views I want do delete order object along with all related objects. So I invoke order.delete(). I have Django 1.0.4, PostgreSQL 8.4 and I use transaction middleware, so whole request is enclosed in single transaction. The problem is that upon order.delete() I get: ... File "/usr/local/lib/python2.6/dist-packages/django/db/backends/__init__.py", line 28, in _commit return self.connection.commit() IntegrityError: update or delete on table "main_order" violates foreign key constraint "main_shipment_order_id_fkey" on table "main_shipment" DETAIL: Key (id)=(45) is still referenced from table "main_shipment". I checked in connection.queries that proper queries are executed in proper order. First shipment is deleted, after that django executes delete on order row: {'time': '0.000', 'sql': 'DELETE FROM "main_shipment" WHERE "id" IN (17)'}, {'time': '0.000', 'sql': 'DELETE FROM "main_order" WHERE "id" IN (45)'} Foreign key have ON DELETE NO ACTION (default) and is initially deferred. I don't know why I get foreign key constraint violation. I also tried to register pre_delete signal and manually delete shipment objects before delete on order is called, but it resulted in the same error. I can change ON DELETE behaviour for this key in Postgres but it would be just a hack, I wonder if anyone has a better idea what's going on here. There is also a small detail, my Order model inherits from Cart model, so it actually doesn't have id field but cart_ptr_id and after DELETE on order is executed there is also DELETE on cart, but it seems unrelated? to the shipment-order problem so I simplified it in the example.

    Read the article

  • Autodiscovery for inclusion tags

    - by Ludwik Trammer
    The title may be a little confusing, but I don't know how else to call it. I would like to create a Django project with a large set of applications you could arbitrary turn on or off using INSTALLED_APPS option in settings.py (you would obviously also need to edit urls.py and run syncdb). After being turned on an app should be able to automatically: Register it's content in site-wide search. Luckily django-haystack has this built-in, so it's not a problem. Register cron jobs. django-cron does exactly that. Not a problem. Register a widget that should be displayed on the homepage. The homepage should include a list of boxes with widgets form different applications. I thought about inclusion tags, because you can put them anywhere on a page and they control both content and presentation. The problem is I don't know how to automatically get a list of inclusion tags provided by my applications, and display them one by one on a homepage. I need a way to register them somehow, and then display all registered tags.

    Read the article

  • Render multiple Form instances

    - by vorpyg
    I have a simple application where users are supposed to bet on outcome of a match. A match consists of two teams, a result and a stake. Matches with teams are created in the Django admin, and participants are to fill in result and stake. The form must be generated dynamically, based on the matches in the database. My idea is to have one (Django) Form instance for each match and pass these instances to the template. It works fine when I do it from django shell, but the instances aren't rendered when I load my view. The form looks like this: class SuggestionForm(forms.Form): def __init__(self, *args, **kwargs): try: match = kwargs.pop('match') except KeyError: pass super(SuggestionForm, self).__init__(*args, **kwargs) label = match self.fields['result'] = forms.ChoiceField(label=label, required=True, choices=CHOICES, widget=forms.RadioSelect()) self.fields['stake'] = forms.IntegerField(label='', required=True, max_value=50, min_value=10, initial=10) My (preliminary) view looks like this: def suggestion_form(request): matches = Match.objects.all() form_collection = {} for match in matches: f = SuggestionForm(request.POST or None, match=match) form_collection['match_%s' % match.id] = f return render_to_response('app/suggestion_form.html', { 'forms': form_collection, }, context_instance = RequestContext(request) ) My initial thought was that I could pass the form_collection to the template and the loop throught the collection like this, but id does not work: {% for form in forms %} {% for field in form %} {{ field }} {% endfor %} {% endfor %} (The output is actually the dict keys with added spaces in between each letter - I've no idea why…) It works if I only pass one Form instance to the template and only runs the inner loop. Suggestions are greatly appreciated.

    Read the article

  • Automatically use inclusion tags (?) in a template, depending on installed apps

    - by Ludwik Trammer
    The title may be a little confusing, but I don't know how else to call it. I would like to create a Django project with a large set of applications you could arbitrary turn on or off using INSTALLED_APPS option in settings.py (you would obviously also need to edit urls.py and run syncdb). After being turned on an app should be able to automatically: Register it's content in site-wide search. Luckily django-haystack has this built-in, so it's not a problem. Register cron jobs. django-cron does exactly that. Not a problem. Register a widget that should be displayed on the homepage. The homepage should include a list of boxes with widgets form different applications. I thought about inclusion tags, because you can put them anywhere on a page and they control both content and presentation. The problem is I don't know how to automatically get a list of inclusion tags provided by my applications, and display them one by one on a homepage. I need a way to register them somehow, and then display all registered tags.

    Read the article

< Previous Page | 87 88 89 90 91 92 93 94 95 96 97 98  | Next Page >