Search Results

Search found 3558 results on 143 pages for 'django templatetags'.

Page 57/143 | < Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >

  • flash - django communication -- amf, xml, or json?

    - by shanyu
    We are considering to develop a Flash front-end to a web application written using Django. The Flash front-end will send a simple "id" to the server and in response receive a couple of objects. The application will be open only to authenticated users. To the extend of my current knowledge (which is basic for Flash) we can either use AMF or take an XML or JSON approach. AMF seems to have an upperhand as there are examples out on the internet showing it can cooperate easily with Django's authentication mechanism (most examples feature pyAMF). On the other hand, implementing a XML/JSON based solution may be easier and hassle free. Guidance will be much appreciated.

    Read the article

  • Custom login in Django

    - by alpgs
    Django newbie here. I wrote simplified login form which takes email and password. It works great if both email and password are supplied, but if either is missing i get KeyError exception. According to django documentation this should never happen: By default, each Field class assumes the value is required, so if you pass an empty value -- either None or the empty string ("") -- then clean() will raise a ValidationError exception I tried to write my own validators for fields (clean_email and clean_password), but it doesn't work (ie I get KeyError exception). What am I doing wrong? class LoginForm(forms.Form): email = forms.EmailField(label=_(u'Your email')) password = forms.CharField(widget=forms.PasswordInput, label=_(u'Password')) def clean_email(self): data = self.cleaned_data['email'] if not data: raise forms.ValidationError(_("Please enter email")) return data def clean_password(self): data = self.cleaned_data['password'] if not data: raise forms.ValidationError(_("Please enter your password")) return data def clean(self): try: username = User.objects.get(email__iexact=self.cleaned_data['email']).username except User.DoesNotExist: raise forms.ValidationError(_("No such email registered")) password = self.cleaned_data['password'] self.user = auth.authenticate(username=username, password=password) if self.user is None or not self.user.is_active: raise forms.ValidationError(_("Email or password is incorrect")) return self.cleaned_data

    Read the article

  • Union on ValuesQuerySet in django

    - by Wuxab
    I've been searching for a way to take the union of querysets in django. From what I read you can use query1 | query2 to take the union... This doesn't seem to work when using values() though. I'd skip using values until after taking the union but I need to use annotate to take the sum of a field and filter on it and since there's no way to do "group by" I have to use values(). The other suggestions I read were to use Q objects but I can't think of a way that would work. Do I pretty much need to just use straight SQL or is there a django way of doing this? What I want is: q1 = mymodel.objects.filter(date__lt = '2010-06-11').values('field1','field2').annotate(volsum=Sum('volume')).exclude(volsum=0) q2 = mymodel.objects.values('field1','field2').annotate(volsum=Sum('volume')).exclude(volsum=0) query = q1|q2 But this doesn't work and as far as I know I need the "values" part because there's no other way for Sum to know how to act since it's a 15 column table.

    Read the article

  • django: how to interconnect various logical pieces of a webpage

    - by facha
    Hi, everyone. I'm just starting with django, so sorry for a possibly stupid question. Imagine, I have a webpage with 3 logical pieces: content, dynamic menu, banners. It seems ok to me to have a template with something like: {% include "banners.html" %} {% include "menu.html" %} {% include "content.html" %} But then, how do I do it? Every piece has its separate logic in a separate view in its' separate app. How do I trigger execution of all three views and render all three templates? P.S. Is there a sourceforge-like site for django apps where I could take a look at how people are doing stuff in real projects?

    Read the article

  • Change text_factory in Django/sqlite

    - by Krumelur
    I have a django project that uses a sqlite database that can be written to by an external tool. The text is supposed to be UTF-8, but in some cases there will be errors in the encoding. The text is from an external source, so I cannot control the encoding. Yes, I know that I could write a "wrapping layer" between the external source and the database, but I prefer not having to do this, especially since the database already contains a lot of "bad" data. The solution in sqlite is to change the text_factory to something like: lambda x: unicode(x, "utf-8", "ignore") However, I don't know how to tell the Django model driver this.

    Read the article

  • MacBook for django development?

    - by Fernando
    Hi, I'm about to buy a new laptop (Asus G62) to replace my old ubuntu desktop. I will use it mostly for django development (and some legacy win32 stuff in a virtualbox). However, since I will need to do some iPhone development in the near future, I'm starting to think that it might be a wiser to buy a MacBook Pro, instead of the Asus and later a cheap (so to speak...) MacBook. How well suited is a MacBook Pro for Django development? I currently use WingIDE on Linux and love it, how does the Mac version compare to the linux one? Is the Ubuntu - Mac OS transition complicated? Will I be able to leverage my Linux knowledge? OTOH, I'm your average nerd, so I'm not sure if I'm cool enough for a Mac. Besides, having a double chin, a black turtle neck is completely out of question. Thanks in advance!

    Read the article

  • django-uni-form helpers and CSRF tags over POST

    - by linked
    Hi, I'm using django-uni-forms to display my fields, with a rather rudimentary example straight out of their book. When I render the form fields using <form>{%csrf_tag%} {%form|as_uni_form%}</form>, everything works as expected. However, django-uni-form Helpers allow you to generate the form tag (and other helper-related content) using the following syntax -- {% with form.helper as helper %}{% uni_form form helper%}{%endwith%} -- This creates the <form> tag for me, so there's nowhere to embed my own CSRF_token. When I try to use this syntax, the form renders perfectly, but without a CSRF token, and so submitting the form fails every time. Does anyone have experience with this? Is there an established way to add the token? I much prefer the second syntax, for re-use reasons. Thanks!

    Read the article

  • proper Django ORM syntax to make this code work in MySQL

    - by gtujan
    I have the following django code working on an sqlite database but for some unknown reason I get a syntax error if I change the backend to MySQL...does django's ORM treat filtering differently in MySQL? def wsjson(request,imei): wstations = WS.objects.annotate(latest_wslog_date=Max('wslog__date'),latest_wslog_time=Max('wslog__time')) logs = WSLog.objects.filter(date__in=[b.latest_wslog_date for b in wstations],time__in=[b.latest_wslog_time for b in wstations],imei__exact=imei) data = serializers.serialize('json',logs) return HttpResponse(data,'application/javascript') The code basically gets the latest logs from WSlog corresponding to each record in WS and serializes it to json. Models are defined as: class WS(models.Model): name = models.CharField(max_length=20) imei = models.CharField(max_length=15) description = models.TextField() def __unicode__(self): return self.name class WSLog(models.Model): imei = models.CharField(max_length=15) date = models.DateField() time = models.TimeField() data1 = models.DecimalField(max_digits=8,decimal_places=3) data2 = models.DecimalField(max_digits=8,decimal_places=3) WS = models.ForeignKey(WS) def __unicode__(self): return self.imei

    Read the article

  • How to isolate data per customer, Django powered website

    - by Sawwy
    I have recently started learning python and django and working on a project that includes building a website for collecting information from customers. I am currently trying to figure out best way to isolate the customer data (collected information is sensitive and should only be accessible by customer and the service provider). I found this post Postgresql - one database for everyone, or one-database per customer and my question is that can I automate the model inheritance with customer creation via admin? To be specific, when save() is called for adding customer via django admin, this should create the customer specific tables (create a new set of tables with 'company_name' -prefix). For more information of the environment, I have extended the basic user registration with custom UserProfile adding 'company' and 'role' fields for each user. Upon login, the 'company' of the user will be checked to filter out tables without the 'company_name' prefix. 'Role' will further filter the which company-specific tables and set rights (view, edit). will appreciate any suggestions if more elegant methods could be used to solve the data isolation problem than model inheritance.

    Read the article

  • Django Asynchronous Processing

    - by freyrs
    Hello all, I have a bunch of Django requests which executes some mathematical computations ( written in C and executed via a Cython module ) which may take an indeterminate amount ( on the order of 1 second ) of time to execute. Also the requests don't need to access the database. Right now everything is synchronous ( using Gunicorn with sync worker types ) but I'd like to make this asynchronous and nonblocking. I am very new to asynchronous Django, and so my question is what is the best stack for doing this. Is this sort of process something a task queue is well suited for? Would anyone recommend Tornado + Celery + RabbitMQ, or perhaps something else? Thanks in advance!

    Read the article

  • Django 404 pages not appearing?

    - by AP257
    I want to add a 404 page on my Django site. I've created a template, 404.html, and saved it in the root of my /templates directory. I've also made sure that the from django.conf.urls.defaults import * line is included at the top of urls.py. I've set DEBUG to False. (I've been following these instructions.) However, if I try to go to a page that I know doesn't exist - whether a made-up URL or a view specifically designed to do get_object_or_404 - the 404 page doesn't appear: I just get Chrome's standard 'Oops! This link appears to be broken' page. Oddly, I also have a 500.html template in the same place and that is appearing just fine if I generate a 500 error. What might the problem be?

    Read the article

  • django + xmppy: send a message to two recipients

    - by Agrajag
    I'm trying to use xmpppy for sending jabber-messages from a django-website. This works entirely fine. However, the message only gets sent to the -first- of the recipients in the list. This happens when I run the following function from django, and also if I run it from an interactive python-shell. The weird part though, is that if I extract the -body- of the function and run that interactively, then all the recipients (there's just 2 at the moment) get the message. Also, I do know that the inner for-loop gets run the correct count times (2), because the print-statement does run twice, and return two different message-ids. The function looks like this: def hello_jabber(request, text): jid=xmpp.protocol.JID(settings.JABBER_ID) cl=xmpp.Client(jid.getDomain(),debug=[]) con=cl.connect() auth=cl.auth(jid.getNode(),settings.JABBER_PW,resource=jid.getResource()) for friend in settings.JABBER_FRIENDS: id=cl.send(xmpp.protocol.Message(friend,friend + ' is awesome:' + text)) print 'sent message with id ' + str(id) cl.disconnect() return render_to_response('jabber/sent.htm', locals())

    Read the article

  • Django models & Python class attributes

    - by Geo
    The tutorial on the django website shows this code for the models: from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() Now, each of those attribute, is a class attribute, right? So, the same attribute should be shared by all instances of the class. A bit later, they present this code: class Poll(models.Model): # ... def __unicode__(self): return self.question class Choice(models.Model): # ... def __unicode__(self): return self.choice How did they turn from class attributes into instance attributes? Did I get class attributes wrong?

    Read the article

  • Cannot save model due to bad transaction? Django

    - by Kenneth Love
    Trying to save a model in Django admin and I keep getting the error: Transaction managed block ended with pending COMMIT/ROLLBACK I tried restarting both the Django (1.2) and PostgreSQL (8.4) processes but nothing changed. I added "autocommit": True to my database settings but that didn't change anything either. Everything that Google has turned up has either not been answered or the answer involved not having records in the users table, which I definitely have. The model does not have a custom save method and there are no pre/post save signals tied to it. Any ideas or anything else I can provide to make answering this easier?

    Read the article

  • Django: text fixture fails to load

    - by Esteban Feldman
    Hi all, Did a dumpdata of my project, then in my new test I added it to fixtures. from django.test import TestCase class TestGoal(TestCase): fixtures = ['test_data.json'] def test_goal(self): """ Tests that 1 + 1 always equals 2. """ self.failUnlessEqual(1 + 1, 2) When running the test I get: Problem installing fixture 'XXX/fixtures/test_data.json': DoesNotExist: XXX matching query does not exist. But manually doing loaddata works fine does not when the db is empty. I do a dropdb, createdb a simple syncdb the try loaddata and it fails, same error. Any clue? Python version 2.6.5, Django 1.1.1

    Read the article

  • Your Django Development process/steps (Step by Step)

    - by AJ
    I want to know step by step process of how folks develop on Django here. I have seen that whenever I try to create a website in Django, I always get confused amongst: DB Schema/models.py UI/Template Structure Login module urls.py views.py How do you approach this? I may have missed something. You do not need to elaborate everything, just stepwise what you do. If you do two things at the same time (or side-by-side), that would also be helpful to mention. Thanks a lot.

    Read the article

  • Django: switch language of message sent from admin panel

    - by yoshi
    I have a model, Order, that has an action in the admin panel that lets an admin send information about the order to certain persons listed that order. Each person has language set and that is the language the message is supposed to be sent in. A short version of what I'm using: from django.utils.translation import ugettext as _ from django.core.mail import EmailMessage lang = method_that_gets_customer_language() body = _("Dear mister X, here is the information you requested\n") body += some_order_information subject = _("Order information") email = EmailMessage(subject, body, '[email protected]', ['[email protected]']) email.send() The customer information about the language he uses is available in lang. The default language is en-us, the translations are in french (fr) and german (de). Is there a way to use the translation for the language specified in lang for body and subject then switch back to en-us? For example: lang is 'de'. The subject and body should get the strings specified in the 'de' translation files.

    Read the article

  • Filter across three tables using Django

    - by Vanessa MacDougal
    I have 3 django models, where the first has a foreign key to the second, and the second has a foreign key to the third. Like this: class Book(models.Model): year_published = models.IntField() author = models.ForeignKey(Author) class Author(models.Model): author_id = models.AutoField(primary_key=True) name = models.CharField(max_length=50) agent = models.ForeignKey(LitAgent) class LitAgent(models.Model): agent_id = models.AutoField(primary_key=True) name = models.CharField(max_length=50) I want to ask for all the literary agents whose authors had books published in 2006, for example. How can I do this in Django? I have looked at the documentation about filters and QuerySets, and don't see an obvious way. Thanks.

    Read the article

  • Creating a custom widget using django for use on external sites

    - by ajt
    I have a new site that I am putting together and part of it has statistics for the site's users. I would like to create a widget that others can use on another website by invoking javascript that reads data from my server and shows that statistics for a given user, but I am having a hard time finding specific tutorials that covers this in django. I have seen the link at Alex Maradon's site [0], but it looks to me like that is passing html back to the widget and I am having a hard time figuring out how to do this using something like xml. Are there any django apps for doing this or does anyone know of good how-tos? [0] http://alexmarandon.com/articles/web_widget_jquery/

    Read the article

  • Custom Django tag & jQuery

    - by pocoa
    I'm new to Django. Today I created some Django custom tags which is not that hard. But now I wonder what is the best way to include some jQuery or some Javascript code packed into my custom tag definition. What is the regular way to include a custom library into my code? For example: {% faceboxify item %} So assume that it'll create a specific HTML output for Facebox plugin. I just want to learn some elegant way to import this plugin into my code. I want the above definition to be enough for all functionality. Is there any way to do it? I couldn't find any example. Maybe I'm missing something.. Thank you.

    Read the article

  • Single database with multiple instances of Django

    - by jwesonga
    I have a Django project where the company will have a main site like www.ourcompany.org and a bunch of sub-domains like project.ourcompany.org. Content appearing in the sub-domains like case studies should also appear in the main site. I've decided to use multiple instances of Django BUT one database for each sub-domain so that I can have some flexibility and take advantage of the Sites framework. What I'm not sure of is how to access the models across the multiple instances. If I have a model: class CaseStudy(models.Model): title=models.CharField(max_length=100) site=models.ManyToMany(Site) Do I need to create this model in every instance so that I can have access to the object?

    Read the article

  • Model Django Poll

    - by MacPython
    I followed the django tutorial here: http://docs.djangoproject.com/en/dev/intro/tutorial01/ and now I am at creating a poll. The code below works fine until I want to create choices, where for some reason I always get this error message: line 22, in unicode return self.question AttributeError: 'Choice' object has no attribute 'question' Unfortunatley, I dont understand where I made an error. Any help would be greatly appreciated. Thanks for the time! CODE: import datetime from django.db import models class Poll(models.Model): question = models.CharField(max_length=200) pub_date = models.DateTimeField('date published') def __unicode__(self): return self.question def was_published_today(self): return self.pub_date.date() == datetime.date.today() class Choice(models.Model): poll = models.ForeignKey(Poll) choice = models.CharField(max_length=200) votes = models.IntegerField() def __unicode__(self): return self.question

    Read the article

  • Django equivalent to paster for backend processes

    - by intractelicious
    I use pylons in my job, but I'm new to django. I'm making an rss filtering application, and so I'd like to have two backend processes that run on a schedule: one to crawl rss feeds for each user, and another to determine relevance of individual posts relative to users' past preferences. In pylons, I'd just write paster commands to update the db with that data. Is there an equivalent in django? EG is there a way to run the equivalent of python manage.py shell in a non-interactive mode?

    Read the article

< Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >