django-socketio fails - even in example project - appreciate a clue
The error sound pretty simple. You user doesn't have the required permission to bind to port 834. You,ll either need to run it a sudden or change the port it runs on to a higher port. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1dc6fba7-986d-4f43-b4d1-77e316375348%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
very light weight django task queues
Django ztask is a pretty good solution for what you are describing https://github.com/dmgctrl/django-ztask -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0dff7d7c-f5dc-411a-9f14-0b8e1e5df11d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Django querysets and postgresql views
Yes you can. Just create the view however you like. Make a django model with the fields that map to the table the view returns and set the model to managed = false. You can only fetch data and do simple filtering obviously. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2b59ab10-3c98-495c-ae3c-00aad9a59f54%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Recursive Query
Although an old thread, I think it is still relevant. postgresql does support recursive queries http://www.postgresql.org/docs/8.4/static/queries-with.html And while not directly support by Django's ORM, could be done using the extra clause. Might be an interesting experiment to create a custom manager that could perform such queries. On Tuesday, March 18, 2008 7:52:21 AM UTC-5, Nacho wrote: > > I have a category table in my models such as > > class Category(models.Model): > parent = ForeignKey('self') > name = CharField(maxlength=30) > > I would like to, being in an item, be able to get all his lineage. > > Is there any way of doing this with django? > > Thank you, > > Regards -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Re: ZeroMQ / Mongrel2
You could use WSGID to link mongrel2 with your django app. Its pretty nice and easy to get running. On Tuesday, November 8, 2011 4:10:02 AM UTC-6, Tom Evans wrote: > > On Mon, Nov 7, 2011 at 11:58 PM, Markus Gattol> wrote: > > > > Maybe sombody has given http://code.google.com/p/django-dmq and > Mongrel2 a spin already and can report how it went? The reason I am > interested is because it would allow me to get rid of WSGI altogether and > have this stack (ZeroMQ being directly Mongrel2 for example): > > > > it would only allow you to get rid of WSGI if you no longer plan on > serving over HTTP. django-dmq is about serving 0MQ requests - there is > no magic translation from 0MQ <-> HTTP - and whilst Mongrel2 does > allow you to connect backends using 0MQ, they are not using the same > API, just the same transport. > > Cheers > > Tom > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/NM7cDspHyzoJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Build mobile apps for DJango sites — Would XML/JSON passing be the best approach?
I'll have ot agree with the Andre. I had a pretty large django project That I wanted to "Make Mobile". I used minidetector to determine mobile browsers http://code.google.com/p/minidetector/ tastypie to feed data sencha touch to build a UI based on the data from tasty pie. http://www.sencha.com/products/touch/ I had a fully functional mobile version of the site done over a weekend. Tastypie was a critical piece, and sencha touch is basically data ( json ) driven. Although cheap and dirty rather that set up different wsgi apps for mobile / desktop, If the user was a mobile user I basically reset the template_dir to point to a different directory for mobile. Sencha touch is a single page app, so I only have to make 1 new template. On Nov 21, 4:21 am, Alec Taylorwrote: > Good evening, > > I am strongly considering building my project using DJango. > > My project will provide a web-interface and a mobile app. > > I was thinking to build the mobile app from XML sheets, i.e.: > > > > > text here > text here > text here > text here > text here > > > Then I could easily parse the XML file using Qt and display it in a > neat way in the mobile app. > > I'm not sure if this is the best approach, so am open to recommendations. > > Thanks for all suggestions, > > Alec Taylor -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: rake routes
There is also a very useful project out there called django-command- extensions http://code.google.com/p/django-command-extensions/ you can install that. Along with a gaggle of things you will have a show_urls command python manage.py show_urls will print out all of the urls from all of the apps in your installed apps On Oct 19, 8:20 pm, Phlipwrote: > A web platform which I will refer to as "Rails" lets you print out all > the equivalents of the matchers and modules in the tree of urls.py > files using "rake routes". > > Does Django have such a command? Or how could one be written? > > -- > Phlip > http://bit.ly/ZeekLand -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Manually sorting items in a table - Doubly-Linked List vs sort_index
ah I see. But I'm a little confused. How are your users manipulating this list if not via a web page? are you saying you trying to create an API in your application for people to use on querysets and interact with the database table? The notion of lists & tables in the web space is a little ambiguous. On Oct 8, 7:05 am, Steven Sackswrote: > Sorry I accidentally repeated myself. > > List Delete closes gaps by setting item.prev = item.next and item.next > = item.prev. > > On Oct 8, 5:03 am, Steven Sacks wrote: > > > > > While I appreciate your response, your assumption is incorrect. > > However, I've found the solution and it's rather easy. > > > The List Delete function closes gaps by setting an item.prev = > > item.next and item.prev = item.next > > The List Insert function injects item(s) either at the end of the list > > (when the first item inserted's prev is the tail, and the tail's next > > is set to the first item inserted), or in the middle of the list > > (using similar logic). > > The List Move function simply calls List Delete to close the gaps, and > > List Insert with the new position. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Manually sorting items in a table - Doubly-Linked List vs sort_index
I'm assuming you are talking about the client facing site with html/ css/javascript. If that is the case, A DOM tree is already a doubly linked list. Elements are aware of their parent, their siblings and their children, who are again aware of their parents, children and siblings. All you should have to do is place the id as an attribute on the corresponding element and use the DOM api to do the rest. Most javascript libraries make doing that fairly easy to do now a days. no sense trying to re-invent the wheel on this one. you can use ajax to do an update after the user has made a change in the UI, or make the click a save button to commit changes. On Oct 6, 10:57 pm, Steven Sackswrote: > I've got items in a list that a user can arbitrarily move around in > whatever order they want. Additionally, they can add a group of items > to a list in a specific position within that list. > > Further, they can sort multiple items at once, meaning they can select > one to many, sequential or non-sequential, and move them as a group to > a new position in the list. > > The items will always be moved in order from top to bottom, so if you > select multiple items, whether they're sequential or non, they will be > flattened together into a group sequentially from the top to bottom. > > For example: > [1, 2, 3, 4, 5] > > If I select 1, 4, and 5 and move them to where id 1 in the list is, it > will look like this: > > [1, 4, 5, 2, 3] > > I need to refer to items not by their indices, but by their ids. So, > it's possible that a list might look like this (id-wise) > > [27, 31, 45, 7, 21] > > When I want to move items, I pass a before_id to determine which item > they should move before. If I pass 0 for before_id, they are moved to > the end of the list. > > I've got two possible choices here: > > 1) Doubly-linked list > > Each item in the list has a next_id and prev_id, which are foreign > keys to the Model that those objects are. When I move items in the > list, I calculate and modify the affected rows next/prev id fields. > > 2) sort_index > > A more brute force method is to have each item in the list have a > sort_index, and when I add/move items to the list, I determine where > they're supposed to go and calculate the sort_index for every row in > the table. This actually isn't as easy as it seems because you can't > Array.insert on a QuerySet. I'm leaning towards a doubly-linked list. > > Does anyone have any advice or other, more efficient ways of > accomplishing this? > > Thanks! -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Chat App?
The Flex Framework is open source. On Sep 16, 6:19 am, Sithembewena Lloyd Dubewrote: > Thanks Shamail! I should have mentioned that I actually need something > open-source :) > > On Thu, Sep 16, 2010 at 12:16 PM, Shamail Tayyab wrote: > > > > > > > On Thursday 16 September 2010 03:40 PM, Sithembewena Lloyd Dube wrote: > > >> Hi all, > > >> I will soon be working on a Django site that will incorporate a heavily > >> customised chat app. The client wants voip capability. > > >> I've had a look at the Twisted framework, but I need to know whether or > >> not there is anything else out there - perhaps tailored for use with > >> Django? > > >> -- > >> Regards, > >> Sithembewena Lloyd Dube > >>http://www.lloyddube.com > >> -- > >> You received this message because you are subscribed to the Google Groups > >> "Django users" group. > >> To post to this group, send email to django-us...@googlegroups.com. > >> To unsubscribe from this group, send email to > >> django-users+unsubscr...@googlegroups.com >> groups.com> > >> . > >> For more options, visit this group at > >>http://groups.google.com/group/django-users?hl=en. > > > If its VoIP, your best bet would be to use flash, accompanied along with a > > media server, your chat can also work. > > Reason: You need live streaming. > > Wowza media server/Adobe FMS is what you should consider once. > > > Regards > > > -- > > Shamail Tayyab > > Blog:http://shamail.in/blog > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > groups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > Regards, > Sithembewena Lloyd Dubehttp://www.lloyddube.com -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: how to get parent of related m2m model instance from within a template?
http://docs.djangoproject.com/en/dev/topics/db/queries/#related-objects On Jul 30, 12:29 pm, Jwrote: > I have a model, which has a related model, which then has a related > m2m field (See defs below). > > I want to add a method to the m2m model (ie: "Button") which, when > called in a template, will get me the original record that called the > relation. Is this possible? See method attempt below in the "Button" > model, called "get_duid". The point in this attempt is to be able to > return the original id within the template when iterating through the > buttons of a particular "DocumentUnit". > > class DocumentUnit(models.Model): > parent = models.ForeignKey('self', null=True, blank=True, > related_name='children') > unittype = models.ForeignKey(DocumentUnitType, > related_name='du') > content = models.TextField() > > class DocumentUnitType(models.Model): > name = models.CharField(max_length=40) > description = models.CharField(max_length=255, blank=True) > buttons = models.ManyToManyField('Button', null=True, > blank=True, related_name='button_du_types') > > class Button(models.Model): > btn_code = models.CharField(max_length=20) > title = models.CharField(max_length=50, blank=True) > href = models.CharField(max_length=150, blank=True) > viewname = models.CharField(max_length=50, blank=True) > css_class = models.CharField(max_length=70, blank=True) > text = models.CharField(max_length=50, blank=True) > prefix_id = models.CharField(max_length=20) > order = models.IntegerField(blank=True, null=True) > > def get_duid(self): > return self.button_du_types.pk > > Thanks for any help you can give me with this. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Sphinx Foreign key search
You probably want to use the indexer argument. It allows you to specify which indexes you want sphinx to search over. Of course you have to tell sphinx which indexes ( models ) you want it to search in. http://www.sphinxsearch.com/docs/current.html#ref-indexer On May 21, 8:47 am, urukaywrote: > Well, still trying to solve it...maybe i found the right way to do it, but > it's still in progress. If anything shows up, i'll keep you updated. > Hopefully this during few days i'll solve it. > > Radovan > > > > > > yafeng wu wrote: > > > Hi, > > > I got the same problem when building my website. Have you solved it? > > Please let me know. > > > Thanks, > > > On Apr 13, 4:04 am, urukay wrote: > >> Hi, > > >> I'm trying to create full text search on model, everything goes fine > >> when > >> searching TextFields but I have a problem with ForeignKey field. > > >> How can i do that? Can anyone point me to the right direction? > > >> Thanks > > >> Model example: > > >> class Model1(models.Model): > > >> text_field =models.TextField(max_length=250) > >> fek_field = models.ForeignKey('Model2') > > >> class Model2(models.Model): > >> text_field = models.TextField(max_length=250) > > >> -- > >> View this message in > >> context:http://old.nabble.com/Django-Sphinx-Foreign-key-search-tp28219147p282... > >> Sent from the django-users mailing list archive at Nabble.com. > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > View this message in > context:http://old.nabble.com/Django-Sphinx-Foreign-key-search-tp28228784p286... > Sent from the django-users mailing list archive at Nabble.com. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Decode a JSON object?
use the simplejson module from django.utils import simplejson I think your code is having problems becuase you are trying to deserialize something that isn't a json string, its an object. On May 3, 11:33 am, Thomas Allenwrote: > How can I parse a simple JSON object in Django? > > I would like to parse the response: {"totalspace": > 243862.672,"freespace":94053.564} > > django.core.serializers.deserialize('json', packet) seems to have > trouble parsing such a simple string. > > Thomas > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: site management - maintanance mode
http://code.google.com/p/django-maintenancemode/ On Mar 13, 6:21 am, "Henrik Genssen"wrote: > Hi, > > I have a site that runs on more many hosts. > now hast someone an idea, how to put the whole site (on all hosts) in > "maintanance mode" (keep normal users outside with a nice hint) - > without reloading all webservers and not changing the load-balancer / proxy > config - meaning: is there a django/python way for it? > > regards > > Hinnack -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to use pre-built HTML forms in Django
I would build a form using the forms library - subclass forms.Form and let django do the validation for you and return the errors. Once you have that bit in place, you can add your javascript enhancements and logic ontop of it. if need js funcionality for specific fields that Django doesn't supply, you create acustom field widget to do that part. This would be the easiest way. It looks like by all of your posts you are trying to build a django application with out any django! On Mar 9, 11:26 am, MMRUserwrote: > So as per your knowledge can u suggest a proper way of getting data > from a form but not as mentioned inhttp://www.djangobook.com/en/2.0/chapter07/ > that way is too rusty. > > Thanks. > > On Mar 9, 7:28 pm, rebus_ wrote: > > > On 9 March 2010 15:22, MMRUser wrote: > > > > The problem I's having is that my HTML form depends upon lot of > > > external resources like javascript validation libraries and lots of > > > css on fields (and some may differ from each other), and I think that > > > I don't need to use re-usable templates because I just want to design > > > a one simple form so there's only one HTML file.Do you think that is > > > it ok to just ignore the Django's template system and get along with > > > the normal way. > > > > On Mar 9, 2:32 pm, rebus_ wrote: > > >> On 9 March 2010 05:54, MMRUser wrote: > > > >> > Thanks another doubt,what about the css mappings class="field text > > >> > medium" do they also need to include in the class definition in > > >> > Django. > > > >> > On Mar 9, 9:21 am, rebus_ wrote: > > >> >> On 9 March 2010 05:04, MMRUser wrote: > > > >> >> > I have an pre-built HTML form (means I design the HTML form > > >> >> > separately) and I need to reuse it with Django form class > > >> >> > (django.forms), So how do I incorporate my HTML form with Django > > >> >> > form > > >> >> > class. for example > > > >> >> > HTML: > > > >> >> > > > >> >> > > > >> >> > Username > > >> >> > * > > >> >> > > > >> >> > > > >> >> > > > >> >> > > > >> >> > > > > >> >> > How do I map this HTML in to Django form definition, I know that it > > >> >> > can be done by modifying Django form fields according to this HTML. > > >> >> > But I guess it's a time consuming approach,so I would like to know > > >> >> > that is there any easy and time saving solutions for this issue. > > > >> >> > Thanks. > > > >> >> > -- > > >> >> > You received this message because you are subscribed to the Google > > >> >> > Groups "Django users" group. > > >> >> > To post to this group, send email to django-us...@googlegroups.com. > > >> >> > To unsubscribe from this group, send email to > > >> >> > django-users+unsubscr...@googlegroups.com. > > >> >> > For more options, visit this group > > >> >> > athttp://groups.google.com/group/django-users?hl=en. > > > >> >> Well usually you first create a form in django and use its instance to > > >> >> generate the HTML. > > > >> >> You can also write the HTML by yourself and all you need to be careful > > >> >> of is that name and id attributes of you inputs and input type are > > >> >> same as in the class you define. > > > >> >> Your HTML corresponds to: > > > >> >> class MyForm(forms.Form): > > >> >> Field11 = forms.CharField(label="Username", max_length=255) > > > >> >> I highly recommend to first setup a form class then write HTML and > > >> >> making form fields have more sensible names then Field11. > > > >> >> Also i suggest these links as further reading: > > > >> >>http://docs.djangoproject.com/en/dev/topics/forms/http://docs.djangop... > > > >> > -- > > >> > You received this message because you are subscribed to the Google > > >> > Groups "Django users" group. > > >> > To post to this group, send email to django-us...@googlegroups.com. > > >> > To unsubscribe from this group, send email to > > >> > django-users+unsubscr...@googlegroups.com. > > >> > For more options, visit this group > > >> > athttp://groups.google.com/group/django-users?hl=en. > > > >> No, CSS classes are not defined in form class (as far as i know). > > > >> I would suggest using reusable form templates [1] and putting the CSS > > >> classes on field wrappers for example. > > > >> This is what you are interested in: > > > >>http://docs.djangoproject.com/en/dev/topics/forms/#reusable-form-temp.. > > > >> Which ever approach you decide to use is valid, but writing a bunch of > > >> your own HTML for forms takes more time but is also more customisable, > > >> on the other hand using shortcut methods such as "as_p" [1] or > > >> "as_table" [2] is faster but you have less control over the outputted > > >> HTML. > > > >> [1]http://docs.djangoproject.com/en/dev/ref/forms/api/#as-p > > >> [2]http://docs.djangoproject.com/en/dev/ref/forms/api/#as-table > > > > -- > > > You received this message because
Re: Ajax request, json object, fields with instance of inherits class converted in regular string
you can also use simplejson and return data the way you want it. It isn't able to serialize date or time objects natively but this still covers 99% of the cases. from django.utils import simplejson from django.http import HttpResponse def view(request): return HttpResponse(simplejson.dumps([dict(monday=o.monday.name) for o in week.objects.all()]), mimetype="text/javascript") this method is a little more flexible and will be very useful if you have objects with more than one foreign key that you want to send back. On Feb 21, 11:28 am, Kev Dwyerwrote: > On Fri, 19 Feb 2010 07:00:36 -0800, manixor wrote: > > > > > > > The very big problem is, when I loop into object on template, in the > > monday field is not enymore the Day instance, but the string 1. How can > > I convert to an json object the week object, and to keep the instance of > > the inherits class, or how can I modify the ForeignField model, to point > > to another field, like name in my case and not to the pk, which is an > > integer in my case? > > Hello Maxinor, > > If I understand your problem correctly, I can think of two ways around this: > > (1) Use the development release (1.2, the natural keys > (http://docs.djangoproject.com/en/dev/topics/serialization/#natural-keys) > enhancement may do what you want. > (2) Set Day.name to have primary_key=True, that way the name will be > serialised instead of the automatically generated primary key. As > you have already set Day.name to be unique making it the primary key > shouldn't prove to be a problem. > > Cheers, > > Kev -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Object data change approvals.
You could use contrib.contenttypes framework to do this pretty easily provided the models you will be working with have a similar structure; they all have a field called 'content' for example that would be editable. You can have a model that is the intermediate which has a generic foreign key which points to the object which was edited. So when someone edits an item , the data in request.POST is used to make a new intermediate item rather than update the item that was actually edited. Then a moderator can decide to apply the update or not This would also create a history of edits on each object and make revision control and reverting rather easy. This means the intermediate model is really the 'Heavy Lifter' of the setup. On Feb 14, 10:36 pm, iliveinaparkwrote: > Thanks very much, Bruno, this is a pretty simple way of doing what I > want. > > Now I just have to figure out to apply it generically over multiple > levels of inheritance =/ > > Cheers mate. > > On Feb 12, 10:00 pm, bruno desthuilliers > > wrote: > > On Feb 12, 11:24 am, bruno desthuilliers > > wrote: > > > (snip) > > > oops, forgot to actually use the custom manager: > > > > class MyModelRevision(models.Model): > > > (snip) > > objects = MyModelRevisionManager() > > > > class Meta: > > > unique_together = (('MyModel', 'published'),) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Images, videos and thumbnails.
Well I can answer the last bit of your question at least. There are 2 basic field types Form Field & Model Field. Form fields are used in form classes where as Model Fields are used in Models. Model fields handle the normalization of python objects to data suitable for storage in your database and map to columns in a specific table. Form fields handle the normalization of user input to django/python objects. Form fields can be rendered out to HTML, where as Model fields can not. You can easily subclass/create new form fields with out too much of a hitch. Model fields on the other hand is pretty tricky business. On Feb 11, 11:17 am, Naspwrote: > Hey guys, I just did the big switch from PHP and I'm wondering if you > can help me solve this issue the django way. > > The big picture is, we've got news associated with images and videos. > Those "medias" can be ordered and must provide thumbnails for the > client side. > > So far i came up with inline ordering in the admin and thumbnail > generations via sorl. > I found out ffmpeg could easily extract thumbnails from videos so i > was about to try to build a wrapper around it to handle video files > the way sorl does with images via PIL. Do you know any other way to > generate video thumbnails? > > In order to structure the project i built a django app called "media" > and defined a VideoField(forms.FileField) class, this way we extract . > I'm planing to use an intermediate field called MediaField which will > handle the abstraction with a dictionary association based on the > model type attribute. > > class NewsMedia(models.Model): > """ > News Media > """ > MEDIA_CHOICES = ( > ('image', _('image')), > ('video', _('video')), > ) > news = models.ForeignKey(News) > type = models.CharField(max_length=1, > choices=MEDIA_CHOICES) > media = models.MediaField(medias={ > 'images': > models.ImageField(upload_to='uploads/images/'), > 'video' : > models.VideoField(upload_to='uploads/videos/'), > }, > type_field='type'); > order = models.IntegerField(null=True, blank=True) > > class Meta: > ordering = ('order',) > > Also i'm having problems trying to figure out whats the exact > difference between django.form.FileField and > django.db.models.FileField. > > I'd greatly appreciate If you have any idea how to implement those > features or know an already existing solution. > > thanks, > Simon -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Generic templates
I see what you are saying. your template would become somewhat complex and hard to maintain if you had a lot of permissions. However you can create whatever permissions you want in the meta class of your model and use those instead of the ACCESS_CHOICES and number checks class Meta: permissions=( ('system_acess','Has System Access'), ('staff_acess','Has Staff Access'), ) So a user can have both system and staff access or one or the other and you would only need to check once. if you are on a django version less than 1.2, there is a smart if tag on djangosnippets that is the basis of the new if tag in django 1.2. you can down load that and do {% if user.access <= 100 %} you have to be careful with booleans. The version I have doesn't treat zeros as false so you have rewrite some code to check for 1 or 0 {% if user.is_staff = 1 %} So you have options. You template tag would seem to be the most concise and DRYest route, at least in the template code On Feb 1, 12:12 am, Dylan Evans <dy...@contentfree.info> wrote: > On Sun, Jan 31, 2010 at 11:46 PM, esatterwh...@wi.rr.com < > > esatterwh...@wi.rr.com> wrote: > > if if you want to change the menu based on the user, you could > > probably just use the user permissions from the auth context processor > > > if the user has the permissions ( access ) to the option - show it > > > else - don't show it. > > > or if you want to use the model you have listed here, you could use > > the {% ifequal tag %} > > > {% ifequal myuser.access 1000 %} > > show some stuff... > > {% else %} > > show something else... > > {% endifequal %} > > The problem with that is if the user has permission 1000 for superuser and > there is a menu item for staff requiring a permission of 100 the if check > would fail. My programmers brain says, no problem just use a bit vector, but > django templates don't allow that either. In the development version it's > possible to do; > {% if myuser.access >= 100 %} > But i'm looking at deploying the site so i don't really want to use it. > > > > > I personally think using putting users in groups and assigning > > permissions then checking in the template for who has what would be > > the easiest solution. Django does most of the work for you > > That may be a better option, i'm still learning django and may have cheated > with access permissions. I'll look into it but i want to avoid a mess of if > checks. Since the menu is dynamically generated i can't assume a menu item > with any particular permission is going to arrive. > > The solution i did use seems to be working quite well. In the template the > "access" tag works like this. > > {% for item in menu.objects.all %} > {% access item %} > #Do stuff > {% endaccess %} > {% endfor %} > > The "access" tag checks for the existence of user in the context and > calculates the users access level, or failing that assumes an access of 1 > (Anonymous). Then it checks for an access property on item and renders the > block only if user.access >= item.access . You see why the formerly > mentioned if check is way simpler? > > > On Jan 30, 9:28 pm, Dylan Evans <dy...@contentfree.info> wrote: > > > No i have processors, i have all the data i need in the template, i just > > > don't know an elegant way to condition out menu items. > > > > This is how my model works > > > > ACCESS_CHOICES = ( > > > (1, "Public"), > > > (10, "Private"), > > > (100, "Staff"), > > > (1000, "System") > > > ) > > > > class Menu(models.Model): > > > name = models.CharField(max_length=16) > > > > class MenuItem(models.Model): > > > menu = models.ForeignKey(Menu) > > > access = models.IntegerField(choices=ACCESS_CHOICES) > > > > class MenuSubItem(models.Model): > > > item = models.ForeignKey(MenuItem) > > > access = models.ForeignKey(MenuSubItem) > > > > On Sun, Jan 31, 2010 at 5:31 AM, Shawn Milochik <sh...@milochik.com> > > wrote: > > > > I think you've missed context processors, which is easy to do. I'm > > assuming > > > > that your issue is that you want to have something passed in the > > context on > > > > every page load to do something like decide which menu items are > > available > > > > based upon whether the user is logged in, their privileges, or > > whatever. > > > > > Context processors allow you to define a dictionary that gets appended > > to > > &g
Re: Generic templates
if if you want to change the menu based on the user, you could probably just use the user permissions from the auth context processor if the user has the permissions ( access ) to the option - show it else - don't show it. or if you want to use the model you have listed here, you could use the {% ifequal tag %} {% ifequal myuser.access 1000 %} show some stuff... {% else %} show something else... {% endifequal %} I personally think using putting users in groups and assigning permissions then checking in the template for who has what would be the easiest solution. Django does most of the work for you On Jan 30, 9:28 pm, Dylan Evanswrote: > No i have processors, i have all the data i need in the template, i just > don't know an elegant way to condition out menu items. > > This is how my model works > > ACCESS_CHOICES = ( > (1, "Public"), > (10, "Private"), > (100, "Staff"), > (1000, "System") > ) > > class Menu(models.Model): > name = models.CharField(max_length=16) > > class MenuItem(models.Model): > menu = models.ForeignKey(Menu) > access = models.IntegerField(choices=ACCESS_CHOICES) > > class MenuSubItem(models.Model): > item = models.ForeignKey(MenuItem) > access = models.ForeignKey(MenuSubItem) > > > > > > On Sun, Jan 31, 2010 at 5:31 AM, Shawn Milochik wrote: > > I think you've missed context processors, which is easy to do. I'm assuming > > that your issue is that you want to have something passed in the context on > > every page load to do something like decide which menu items are available > > based upon whether the user is logged in, their privileges, or whatever. > > > Context processors allow you to define a dictionary that gets appended to > > the context of every response you send, so you can have that common stuff > > there. > > > 1. Write code to get the values appropriate for the current user or > > whatever. Put these in a Python file in your app. > > 2. Add that file to the TEMPLATE_CONTEXT_PROCESSORS in your settings.py. > > 3. Replace Context() with RequestContext() in your render_to_response > > calls. > > > If I've missed your actual point, please give more detail. I think this > > simplifies what you're trying to do. > > > Shawn > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com > groups.com> > > . > > For more options, visit this group at > >http://groups.google.com/group/django-users?hl=en. > > -- > "The UNIX system has a command, nice ... in order to be nice to the other > users. Nobody ever uses it." - Andrew S. Tanenbaum -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Problem with Django
these error messages seem to rather explanatory. you are trying to serialize data that the serializer you are using can not serialize. you will have to convert the data into a format that is serializeable before hand and then send it. On Jan 21, 3:16 am, Meenuwrote: > My form contains date of birth and total income field. I am getting > following errors: > > datetime.date is not json serializable > decimal is not json serializable. > > On Jan 21, 11:06 am, Prashanth wrote: > > > Hi, > > > On Thu, Jan 21, 2010 at 10:53 AM, Meenu wrote: > > > > I've noticed that my form submission seems to randomly fail on the > > > line var response_obj = eval('(' + o.responseText + ')'); in my > > > javascript. My form contains date and decimal fields. > > > Pretty hard to figure out just with the javascript line though eval > > looks fine, print the response that you are getting from django and > > try to debug or if you want people to point out do a pastebin of your > > view and response that you are doing in the javascript. > > > -- > > regards, > > Prashanth > > twitter: munichlinux > > blog: prashanthblog.appspot.com > > irc: munichlinux, JSLint, munichpython. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Convert Joomla Template to Django Template
You are in for a treat my friend. I will say that my short 4 or 5 encounters with Joomla were the reason took up django. I had never seen a line of python code in my life, but I was so thoroughly frustrated and irritated with Joomla that I took up a new language so I could use django. The good news is that I'm pretty positive you'll enjoy django once you get up and running. The bad news is, there is no easy way to convert them over. Django is just a framework where Joomla is an integrated application. Different languages with different design philosophies, built for very different purposes, You're trying to turn Coke, into Mountain Dew. They're both liquid... both come in a can... and they both have caffeine - And that as about as far as the similarities go. When it comes to more complex templates in joomla, the nastiness that I have encountered is there is PHP code everywhere. It is in the javascript files, the css files - it genereates css files that have php code in them. In many cases, Django's templates system won't allow you to do things like this, and that is by design. Django's templates are far more flexible for the end user comared to joomla, I can't say much for OchsCMS however. The standard practice for building templates with django is to start with a full HTML page that is visually the way you want it and work backwards cutting it up in to parts. Luckily, Joomla has basically 3 template variations - Home page, List Page, and a Detail Page. What I would recommend doing is direct your browser to a sample of each of the page types you want, do a 'view source', copy the code in to your editor and start working. On Jan 16, 1:48 pm, matt6486wrote: > Hi, > > I don't know anything about Django and honestly would rather stick > with my current CMS, Joomla, as my current site design works fine with > the Joomla template I have now. However, the journalism department > will probably end up moving to a CMS based on Django called OchsCMS > from their current CMS Joomla against my wishes. > > Since there is not much I can do about them changing the CMS, I really > want to convert my Joomla template to an exact copy template, but just > in Django form that will wor with OchsCMS. Again, I am neither > familiar with Django at all nor do I know how to code well. So I ask > you more professional-minded people out there: Is there an easy way > (or at least a not-so-difficult way) to convert my Joomla files I have > now in a .zip folder to a Django template? > > Any help would be greatly be appreciated. And a short step-by-step > explanation would be amazing! > Thank you, > > Matthew -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Text Search using Python
I've been working on 2 sites that use full text search on a wiki-like system where users use a WYSIWYG/html editor. This, obviously, doesn't apply to flatpages, but the poblem/solution might be of help. The problem is, if you try tindex/search html, you get a lot terrible results. For example, if you were searching for the word class, virtually ever document would come up as result because of the html class="" bit. The solution we are using was an off shoot of the wiki-app from pinax. We use google's diff_match_patch library alot.here is the basic rundown 1. Get HTML content from a from submitted by user. 2. use django's defaultfilter striptags to strip the html tags 3. used diff_match_patch to create a patch between the plain text and html 4. save the plain text as the content on the document model 5. save a text version of the patch on the document model 6. index the plain text when you search for strings, this will be what the search is performed on An instance method that accepts no parameters ( so it can be used in templates ) is used to recreate the HTML from the patch and plain text and that is displayed when a user wants to view the page. As of yet, we haven't seen an difference in performance when rendering pages. While, I'm not certain, I'm not so sure that flatpages would allow you to do this. And the solution is probably a bit more complicated than what one would want to do for just indexing static pages. I maybe wrong, but I don't think you will be index full HTML content and only search the plain text with out doing some kind of conversion of the HTML first. This does, however, depend on how you set up your templates for flatpages. I have had flat pages that extend a base template and just render out plain text into generic container. If you were to do that, then you could index the flatpage content as it would only be plain text. this could be done fairly easily with django's orm. end ramble. On Jan 14, 5:04 am, Amit Sethiwrote: > Hi , I have a project with a few static html pages , I wish to search these > static html using a django search app . Most of the tutorials I saw are > focused on searching django models but none I could see concentrates on > indexing static html pages . Can some one guide be to a library /tutorial > etc for searching and indexing static pages in a project . > > -- > A-M-I-T S|S -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: autocomplete widget
What I do for auto completers ( in general ) is point the widget at a URL that returns JSON objects and the parse the objects client side. For the user object your function might look like this: from django.utils import simplejson from django.contrib.auth.models import User from django.http import HttpResponse def ajax_get_users(request): users = User.objects.filter(username__istarstswith = request.POST ['q']) return HttpResponse(simplejson.dumps([dict(username=u.username, id=u.pk) for u in users]), mimetype='text/javascript')) should get something that looks like this [ {username:'username',id:4}, {username:'username2',id:5} ] [urls.py] url(r'^/member/search/$', 'path.to.views.ajax_get_users', name="myapp_ajax_user_search"), if you have your widget set up to include the needed javascript that should be it. Honestly, the JS parts is more difficult than the django part. Hope that makes sense On Jan 8, 1:46 pm, namelesswrote: > Hi at all, I am looking for a working simple example on autocomplete > widget for foreign key in Django. I have found many example but I > don't understand and doesn't work. > > This is my model: > > class profile(models.Model): > > user = models.ForeignKey(User, unique=True) > > class profileForm(ModelForm): > > user = forms.CharField(widget=AutoCompleteWidget()) > > class Meta: > model = profile > > I wish an AutoCompleteWidget working for this example. > > Could anyone help me pleaseee ? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: What apps do besides provide views?
@permalink maps a model to a view function through a specific url pattern giving you the ability to use get_absolute_url() just by passing parameters to the function. it will create the url for you. to the app question. An application or an organizational and way to focus your development. An app should have a goal, and a focus. You should be able to sum up what your application does in 1 simple sentence. If you can't you are probably describing something on the scope of a project. My app allows users to leave comments on any object from any view. That is what it does and that is ALL that it does. DONE. So organization and focus. For example todd, no, views do not need to live in a file called views.py. They can live anywhere. You would just need to remember where you are putting them all and tell your urls that is where the view function it should use is. But this would get very confusing to others trying to use your code. So it is a standard practice to use a file called views.py with an app that has a lot of views, I often times create a package called views and segment out the views into their own files that have a more specific focus http://www.youtube.com/watch?v=A-S0tqpPga4 The best advice I think anyone can give you comes down to 2 options. 1. don't bring your framework's 'programming baggage' with you. Django is not framework-X, it never will be, so trying to develop you programs as if it were, will get you frustrated fast. Baggage all leads to a dysfunctional relationship. in other words, trying to build a application like you do in RoR with django is going to situations / mailing list discussions like this one. 2. if you really like framework X...use framework X. On Dec 3, 2:30 pm, Todd Blanchardwrote: > Models? Where do I find an example? > > I've got Pro Django, Definitive Guide to Django, Python Essential Reference, > and I've read the online django tutorial and a bunch of random docs. I have > yet to see an instance of mapping a url to a model. > > Or, I don't know what you mean by model vs view (because when I say view - I > mean just a function that takes a request, returns a response, and lives in a > file called views.py). > > What am I missing? > > On Dec 3, 2009, at 11:58 AM, bruno desthuilliers wrote: > > > > > On 3 déc, 20:42, Todd Blanchard wrote: > >> On Dec 3, 2009, at 10:46 AM, Javier Guerra wrote: > > >>> remember that an app can do a lot more than provide views. > > >> Explain this one to me. AFAICS, its just http request/response all the > >> way down and this is basically done by getting a request to a view that > >> spits out a response. Side effects like updating the database sometimes > >> occur. > > > An app can expose views, indeed. It can also expose models - one of > > the most important parts of an application -, templatetags, filters, > > forms, fields, widgets etc. FWIW, the views are perhaps one of the > > less important thing an app has to offer - and obviously the most easy > > to factor out, cf genericviews. Models, OTHO, are really the core. If > > you end up writing most of your code in views, then you more than > > probably failed to identify what belongs to the model and what belongs > > to the views. The fact that "views" are a mandatory part of the > > request-response cycle doesn't mean they are the most important part > > of the app. > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Where to store repetitive form logic?
You can use a hidden input in the for as a way of holding the link or id/ct of an object so you can determine where to redirect to. If the action is repetitive and you have a pretty good idea of where you to redirect to, I would think that is a simple solution. This is what django's comment app does, allowing you to redirect users where you want after you submit a comment. Maybe peek in side of that to see how it was done? On Dec 4, 8:29 am, jwpeddlewrote: > I am currently trying to write a custom generic comment app and > growing increasingly frustrated with template tags. As far as I can > tell, template tags are the only mechanism provided that allow pieces > of logic to be shared across templates. Nonetheless, you cannot treat > them like a view, and cannot do things like redirect. Someone asking > about essentially the exact same thing two years ago > here:http://groups.google.ca/group/django-users/browse_thread/thread/a0603... > and Malcolm commented that this was unusual and that isn't what > template tags are for and the logic should go in a view. > > This isn't a satisfactory answer for me because the form logic in > question is identical regardless of the view/object. Why should anyone > be expected to duplicate form logic all over the project when it works > perfectly in a template tag without adding any repetitive code. The > only downside, as least in my case, is that I cannot redirect. > > Here's my basic tag:http://dpaste.com/128910/ > > I'd like to know why my thinking is flawed and where I can actually > put this logic without cluttering up every view that needs a comment > form. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: HELP PyAMF - Django + FLEX
http://pyamf.org/wiki/DjangoHowto On Nov 30, 10:55 am, Rafael Vieirawrote: > Good afternoon people, > > I am starting with pyAmf framework, and I have questions about how to > integrate models of Django with RemoteObjects of FLEX; -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Forms ForeignKeyField does not populate with initial value
in your IncidentForm definition set reporter to a ModelChoiceField (User.objects.all(), widget=forms.HiddenInput()) then it should work out ok. I usually hide fk fields to a user if i want the current request.user object, because I don't want to allow the possibility for it to be changed. On Nov 25, 10:32 pm, Todd Blanchardwrote: > I have a (simplified) model > > class Incident(models.Model): > title = models.CharField(max_length=128) > when_reported = models.DateTimeField(auto_now_add=True) > reporter = models.ForeignKey(User) > > Where User is from auth. When used with a ModelForm, this creates a popup > button with a list of users. I want it to default to the currently logged in > user so in my view I have: > > def new_incident(request): > form = IncidentForm(initial={ > 'reporter': request.user, > 'title': 'New Incident', > 'when_reported' : datetime.now(), > }) > > media = form.media > return render_to_response('incidents/new.html',{'form': form, 'media': > media},context_instance=RequestContext(request)) > > However the popup button's selection is never set to the current logged in > user. I have rendered the current logged in user's name elsewhere on the > page, it is set. But the popup selector isn't getting its selection set > right. Any tips? > > -Todd Blanchard -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Model inheritance - filtering base model only
a simple solution would be to put pass the contentype id and object id around in your url scheme domain.com/ct_id-object_id/ from there you can get the content type, which will be able to tell you the model, type, and give you the object. type = ContentType.objects.get(pk=ct_id) model = type.model_class() obj = model.objects.get(pk=obj_id) this would also cut down on the number of view functions you need to write. It's a mini generic view for you app, just figure out a naming convention for templates based on the model you have : template = template_name or "appfolder/%s_detail.html" % type.model you can have 1 url handle just about anything Done and Done On Nov 22, 6:32 pm, lfrodrigueswrote: > Hello, > > I have these models: > > class Player(models.Model): > . > > class PlayerM(Player): > ... > > If I do PlayerM.objects.all() e get all PlayerM objects and for > Player.objects.all() I get all Player and PlayerM as expected. > > How can get only the objects of type Player (only retrieve the objects > that were created with Player() constructor)? > > Regards, > > Luis -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.
Using Named Pairs
When using nested tuples for the choices option on a model you get the get_foo_display(). to get the readable version of the choice. However I want to get at the name of the groups. for example in the docs: MEDIA_CHOICES = ( ('Audio', ( ('vinyl', 'Vinyl'), ('cd', 'CD'), ) ), ('Video', ( ('vhs', 'VHS Tape'), ('dvd', 'DVD'), ) ), ('unknown', 'Unknown'), ) I more or less want to recreate this in a template. So there would be a spot that displays "Audio", then all of the objects that have either Vinyl or CD selected. I've seen the REGOUP template tag, but this doesn't quite do what i want. is their a simple way to get at the names of named groups? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.
Re: Django javascript includes
I would say template tags are the nice little framework for doing this. you could create a tags the looks in a certain path for files ending in '.js' based on the model or application and join it with settings.MEDIA_URL.. have it return a string of text or a list of strings that you can iterate over in the template. the you can have something like {% get_js_for_object myobject %} secondarly, some JavaScript frameworks have built in dependency loaders that will fetch scripts based on what is on the page of specified. mootools does. I think Dojo does. I'm sure others do. If you are more comfortable with javascript than python/django that might be something to look into. On Nov 17, 4:15 am, Thierrywrote: > Other frameworks (Symfony) offer simple hooks for managing js > includes. > In Django its simply a line of template code. > > This is annoying for managing JS dependencies. > > Did anyone write a nice little framework for managing js? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: How to lay out large, *modular* website in Django.
I think all you would need to do is organize the permissions and assign users to groups with the permissions need to access the various views / data. You could also easily make decorators for the view function. something like @employee_login_required that checks if the user is loged in and if the logged in user has the permissions to move on. If they don't you just redirect them somewhere else or don't display certain links in the template to get there ( both is probably the best option ). or check for is_staff in the User object. or put a check for is_employee I don't think you would need to make a different permissions system, you can create any number of permissions for any model and check for them in your views and in templates. I would think this is all you need to do. Make a permission can_view_stat_site, and check for it. @permission_required('yourapp.can_view_stat_site') def your_viewcode(self): ... You can import your model into another just like any other python module, But this would make your code less modular if that is what you are going for. I think the primary problem here is you are trying to build a site the same way you did with Zend, but in django (?) On Nov 17, 4:54 am, zimnyxwrote: > Guys, > > I'm trying to lay out Django code for large "website", which consists > of four subsytems: > - employees' website > - statistics website used also by employees > - public website (with users accounts) > - monitoring webservices > > This four components have different: > - auth types, > - different user types (employee account has really nothing to do with > customer account) > - different permission system > - different webpage layout, css, media > - different forms > > What is common between them: > - they use the same database > - most of models are shared between > - global configuration (database uri, debug level, i18n, session etc.) > > In (for example) Zend Framework it's very easy to lay out: > every subsystem is one ZF module and authentication is delegated to > appropriate plugin based on detected module. Every module has its own > controllers (Django views) + helpers, templates etc. Models connected > with specific module are stored within module directory, and "global" > models are available for all ZF modules. All rocks in a minute, code > has very readable structure. > > Can Django handle such modular code layout? > What's your advice? > > Cheers, > Piotrek -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.
Re: Questions about ContentType generic relations
You might want to do a search on django-tagging. this has been done and done well. On Nov 13, 6:04 pm, Continuationwrote: > How do I do queries when ContentType is involved? > > Using the example in the doc > (http://docs.djangoproject.com/en/dev/ref/contrib/contenttypes/#id1 > ) > > class TaggedItem(models.Model): > tag = models.SlugField() > content_type = models.ForeignKey(ContentType) > object_id = models.PositiveIntegerField() > content_object = generic.GenericForeignKey('content_type', > 'object_id') > > class Bookmark(models.Model): > url = models.URLField() > tags = generic.GenericRelation(TaggedItem) > > So say I attached a bunch of tags to a bunch of bookmarks. > > How do I get a list of all bookmarks that have the tag "django"? > > Also what kind of SQL statements are generated behind the scene to > enable this querying over generic relations? > > Say I have many different classes (e.g. Bookmark, ForumPost, > WikiEntry, QnA, Message, Photo, etc) that I want to attach tags to. > > If I want to find all the bookmarks, forum posts, wiki entries, Q, > messages, photos, etc that have the tag "django", can I do it in 1 > statement or would I have to do it separately for each class? > > Thanks -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=.
Re: render_to_response taking 50 seconds!
You might want to consider installing the debug toolbar ( http://github.com/robhudson/django-debug-toolbar ). it displays the amount of time taken for all of the rendering steps. It will defiantly help you narrow down the major culprits. On Nov 3, 5:12 am, Low Kian Seongwrote: > Pretty much confirmed it's the rendering or pulling of data from database: > > 1. I tried to render a html page instead of Excel. Same speed. So this > kicks out the theory of rending of excel is slowing the page down. > > 2. I tried shorting out all the data from the rendered page. Page came > up in less than 2 seconds. Put back all the data called from the db, > whomp! It goes back to 50 seconds. > > Now debugging the rendering of the template. Could an alternative > templating engine like jinja help this? > > On Tue, Nov 3, 2009 at 6:07 PM, bruno desthuilliers > > > > > > wrote: > > > On 3 nov, 09:09, Low Kian Seong wrote: > >> But I am confused here. How do iterate through the data another time? > >> Do I call the select_related in my views.py code like: > > >> manager_info = found_entries.select_related() > > >> then how do i iterate through manager_info in my template? > > > That's not how it works. The only thing you have to do is to > > call .select_related on your queryset - it will take care of > > generating a SQL request that follows the relationships. You have > > nothing else to do in your template. > > > ie, in your view: > > > objects = MyModel.filter(...).select_related() > > > And of course, *don't* use len(objects). > > >http://docs.djangoproject.com/en/dev/ref/models/querysets/#id1 > > -- > Low Kian Seong > blog:http://lowkster.blogspot.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Models for a hockey database
I have a pretty large site that tracks a football team and it's league ( http://www.muskegohitmen.com ). What I did was to have an abstract base statistics class that is attached to a player/user. then mad a class for every stat i wanted to track class Statistics(models.Model): #base class (abstract?) #for_player =models.ForeignKey(User, related_name = "%(class)s_related") for_player =models.ForeignKey(Member, related_name = "%(class)s_related") for_game = models.ForeignKey (Game,related_name = "%(class)s_related" ) date_stamp =models.PositiveIntegerField (editable=False) def save(self, force_insert=False, force_update=False): ds = self.for_game.date_scheduled self.date_stamp=ds.year super(Statistics, self).save(force_insert, force_update) class Meta: abstract = True @models.permalink def get_absolute_url(self): return '%d/%d"%d/statistics/' % (self.for_game.date_scheduled.year,self.for_game.date_scheduled.month,self.for_game.date_scheduled.day) get_absolute_url = permalink(get_absolute_url) #=== # OFFENSE # ALL % AND AVG ARE DONE AUTOMATICALLY - NO NEED TO INCLUDE THEM HERE #=== class PassingStatistics(Statistics): #passing passing_attempts = models.PositiveSmallIntegerField ('Attempts',default = 0) passing_completions = models.PositiveSmallIntegerField ('Completions',default = 0) passing_tot_yards = models.PositiveSmallIntegerField ('Total Yards',default = 0) passing_tds = models.PositiveSmallIntegerField ('Touchdowns', default = 0) passing_interceptions = models.PositiveSmallIntegerField ('Interceptions', default = 0) class Meta: verbose_name = 'Passing Statistics' verbose_name_plural = 'Passing Statistics' def passing_percentage(self): if self.passing_attempts == 0: return 0 else: return (( float(self.passing_completions) / float (self.passing_attempts) ) * 100) #==get_qb_rating = #if no statsDict is passed, we calculate QB rating for the current Game instance #Can easily re - use to calc for a span of games, career, season, etc #http://en.wikipedia.org/wiki/Passer_rating #= def get_qb_rating(self, statsDict=None): # store in variables to cut on memory / stack overflow & Processor cycles """ C = Passing Completions Y = Passing Yards Per Attempt T = Passing Touchdowns Per Attempt I + Interceptions Per Attempts Pass in a dictionary named statsDict if the Passing Statisitcs you wish to calculate statsDict["completions"] statsDict["attempts"] statsDict["yards"] statsDict["touchdowns"] statsDict["interceptions"] If no dictionary is passed, the function will calculate a QB rating for current game the stats associated with. C = ( (self.passing_completions / self.passing_attempts)*100 - 30) / 20 Y = ((self.passing_tot_yards / self.passing_attempts)-3) * (1/4) T = (self.passing_tds / self.passing_attempts) * 20 I = 2.375 - ( (self.passing_interceptions / self.passing_attempts) * 25 ) rating = (( max(min(C, 2.375),0 ) + max(min(Y,2.375),0) + max (min(T, 2.375),0) + max(min(I,2.375),0))/ 6) *100 """ if statsDict is not None: C = float(( (float(statsDict['completions']) / float (statsDict['attempts'])*100 - 30)) / 20 ) Y = ((statsDict['yards'] / statsDict['attempts']) - 3) /4 T = float((statsDict['touchdowns']) / float(statsDict ['attempts']) * 20) I = float(2.375 - ((float(statsDict['interceptions']) / float(statsDict['attempts'])) * 25 )) rating = (( max(min(C, 2.375),0 ) + max(min(Y,2.375),0) + max(min(T, 2.375),0) + max(min(I,2.375),0))/ 6) *100 return rating C = float(( (float(self.passing_completions) / float (self.passing_attempts)*100 - 30)) / 20 ) Y = ((self.passing_tot_yards / self.passing_attempts) - 3) /4 T = float((float(self.passing_tds) / float (self.passing_attempts)) * 20) I = float(2.375 - ((float(self.passing_interceptions) / float (self.passing_attempts)) * 25 )) rating = float((( max(min(C, 2.375),0 ) + max(min(Y,2.375),0) + max(min(T, 2.375),0) + max(min(I,2.375),0))/ 6) *100) return rating class RushingStatistics(Statistics): #rushing rushing_carries =
Re: What JavaScript framework do you use and why?
I use mootools a lot. When I was deciding which on to use, I first looked at How big is the library ( how long is it going to take me to learn ), how complex, does it do what I want/need. Does it fit the way I think, does it make sense with python/django. Mootools, to me was a pretty good fit. The descriptor of mootools was,'It's not about cows or milk! It stands for My Object Orientated Tools" The best thing about mootools is the Class implementation. It really turns a muddy scripting language into a more OO lang like python. You can create new classes & objects which can inherit from each other, etc. Going from python to mootools is easy as you don't have such a big shift in gears. There is also project that can convert your python code directly to mootools javascript. http://code.google.com/p/pygowave-server/wiki/PythonToJavaScriptTranslator Also, while a topic of much debate, one of mootools strengths and consequently it's weakness is that it extends some of the naitive objects in javascript. This makes coding faster and easier. However, the down side is that it doesn't really play well with some other javascript libraries. Personal experience has pointed out jquery and the 2.X versions of the YUI ( at least with out some patching ). But it has a host of built in methods for working with Javascripts native objects that just make life easier. I would really miss the Classes and ease/speed at which you can create applications. As of late Mootools has been under a pretty big surge in development. in the last 5-6 months it has gone from 1.2 to 1.2.4.1 and is on the verge of 2.0, so their has been a little frustration with backward compatibility and change in some syntax. But they have all previous versions on github making it pretty easy to stick with 1 version. Obviously a little biased, but that's my 2 cents. On Sep 28, 8:37 am, Joshua Russowrote: > MooTools does look interesting. What would you miss most about it, if you > had to develop without it? > > > > On Mon, Sep 28, 2009 at 11:07 AM, justind wrote: > > > Joshua, > > > Take a look at MooTools. It's a great library with a great API. It's > > been said that JQuery makes the DOM fun, but MooTools makes Javascript > > fun. > > > On Sep 28, 4:37 am, Joshua Russo wrote: > > > On Mon, Sep 28, 2009 at 4:00 AM, Jani Tiainen wrote: > > > > > Joshua Russo kirjoitti: > > > > > Great links guys, thanks. I'm still in the mindset of frameworks just > > > > > making JavaScript less painful too and I'm looking for ways to move > > > > > beyond that. I just started looking at Dojo before posting this and > > it > > > > > definitely looks like it has potential. > > > > > I'm pretty "heavy" user of Dojo. My project is completely built on top > > > > of Django/Dojo using JSON-RPC to do talk with Django part. > > > > > I'm pretty happy how it works, specially declarative way to make > > widgets > > > > is pretty cool comparing to other that usually require JS markup to > > > > achieve same thing. > > > > > Dojango is pretty nice. I just don't use (model)forms all. > > > > Do you use the Admin app at all? Or are your sites all just custom views? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: SQL query with complex WHERE clause
Probably want to look into using Q http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects On Aug 31, 7:18 pm, Gyanitwrote: > Hi All, > > I don't seem to find good source to help me write a complex where condition > in the django. > > The where condition is generic boolean clause built on top of literals. The > literal are just == or != check on a single field. > for example ((field1 == 2 and field2 != 5) or field3 == 6). > another example ((field1 > 1 or field1 < -3) and (field2 != "comment")) or > field3 == "django" > > I think it should be writable in the django queryset but I can't seem to > formulate it in generic format. > > Any pointers or guidance will be great. > > thanks > > -- > View this message in > context:http://www.nabble.com/SQL-query-with-complex-WHERE-clause-tp25232455p... > Sent from the django-users mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: interaction of django with paypal
You would probably want to create a unique key for each user and something to denote whether the key for the download had been used. the django-registration application does this pretty well, you might peek at that code. Or depending on the scope of the project, you could use the Satchmo app to handle your eCommerce On Aug 29, 11:39 am, orschirowrote: > Hello guys, > > I've set up a Single-Pay-Button via Paypal. After a customer had paid > successfully I configured Paypal to redirect the user to > download.domain.tld. There he has to fill in his personal data into a > html form and then receive some download data. > > Well and that is also the problem with my solution. Everyone who knows > the URL can download the data without to pay before. > > What I'm now looking for is a possibility to inquire whether the > customer has paid before he was visiting the download page. > > Some kind of If clause: > > def index(request): > if paypal true: > if request.method == 'POST': > formular = form(request.POST) > > else: > formular = form() > > return render_to_response('download/index.html', { > 'form': formular, > }) > else: > error message > > How could I do that? > > Thank you in advance. :) > > orschiro --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generating slugs
You might look in to the Autoslug field in django command extensions http://code.google.com/p/django-command-extensions/ the autoslug field is never displayed on a form, but you specify which fields from which to create the slug from. so you can do it how ever you want. I've found it very helpful. On Aug 27, 8:55 am, RubenKwrote: > I've setup my 'prepopulate_fields' so that it should automatically > enter a slug in the admin site, however when I click the 'add' link > it gives me the following error: > > "Key 'slug' not found in Form" > > I've triple checked all my models and database tables and everything > seems to be in order so I'm sort of stuck now! > These are my files: > > http://dpaste.com/hold/86096/- models.pyhttp://dpaste.com/hold/86098/- > admin.py > > Could anyone please assist me? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Javascript with built-in templates tags
On Aug 7, 9:31 pm, WilsonOfCanadawrote: > Hellos, > > I was wondering how to use {{ }} variables in javascript functions. > > ex. onchange = "changeArea({{ mooman |safe|escapejs}});" > > Thanks I had this problem too, it was pretty frustrating. I can to 2 different solutions. 1. new template in youapps directory calls whatever_js.html so you know that is actually javascript. * just write the ...Code {{ Here }} * and use the {% include whatever_js.html %} tag where needed. 2. Probably not always the best option, but is useful for testing. put the ... Code {{ Here }} in the template it self. This way django renders out all of the code before the JavaScript is interpreted and runs as expected. I'm pretty sure the Admin area does something pretty similar to the whatever_js.html templates idea. If all else fails you could copy and paste all of the js into your template the obtrusive way and see if it works properly, then work backward by pulling bits out. Maybe that helps? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: IDE for Django and Ext JS
You might look at Aptana Studio. It's another off shoot of eclipse, but built for web dev. Does all the nice code complete for HTML, Javascript and now even has a JSON editor. Also comes with support for Javascript libraries ( Ext Being one of them ), so it comes built with code completion and docs for the library in question special syntax. You just need drop in the Pydev plugin, which it will do for you at install, and pretty set. There is not a django specific plug in that I am aware of, but it just view the tags as text. However, you can hook the ide into a specific apache instance and DB on you system and preview of you django templates I suppose, this is my personal preference, but it makes sense in my small world ;) On Jul 28, 12:30 pm, Amir Habibiwrote: > Hi All, > > What development environment do you suggest for Django and Ext JS > based large projects? > Is Netbeans the best choice out there? > > Thanks > Amir --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Ajax and non-ajax forms.
most javascript frameworks have a way to stop to propagation of an event - say when you click a link. jQuery: Event.stopImmidiatePropigation() MooTools: Event.stop() Both of them i think( i know mootools does ) have a way of dealing with patterns of selectors. say all of the links have an ID that starts with ajaxform- So you can easily grab all of the links of this type and attach events to them. So, you could have the links on the page have a hard coded link or a link via the {% url %} tag link to the plain old vanilla form. In your javascript attach a click event to the links that does the ajax - say your script calls the view function and returns a block of HTML or some JSON data you can deal with. And you can do what you want with it. If the user's javascript is turned off - the AJAX never happens and the link to the plain vanilla form will work as normal. django requests have the is_ajax() method so you shouldn't need to write two separate view functions for this although you could. On May 6, 8:27 am, Chris Dewwrote: > I'd like to develop a Django application with the following > properties: > > A page (list of items) will have a link to a page with a form to add a > new item. > > If there is no javascript, the link will take the user to the new page > and let the user submit the form, then return them to the initial page > when the form successfully validates. > > If there is javascript, the link will open the form *within* the > current page (via ajax, perhaps as thickbox or greybox). Submission/ > validation errors of/on the form will take place entirely within the > current page. When the for is submitted and valid, the form's div > will disappear/close. > > At the moment, I think that I need to have ajax and non-ajax views for > *each form* within the application. > > I also need to code form template snippets (for ajax) for *each form* > which are included by the templates for the non-ajax pages. > > Has anyone developed a Django extension which makes this easier - some > form of 'unajax for non javascript-capable browsers'. > > I realise that I'll probably need to do this myself, by hand, but I > thought I'd ask the question, just in case. > > Thanks, > > Chris. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: YUI Image Uploader - OK on Firefox/Mac but not elsewhere
I found the TinyMCE & filebrowser insanely easy to impliment. I would say 9 out of the 10 issued I had was simply a matter of defining the right paths. I also found that creating a symlink for the admin media folder and calling it 'media/' solved most of the path name issues. that way you can leave most of the default paths in the settings.py file and it just works out of the box. On Feb 9, 4:39 pm, phoebebrightwrote: > Have been trying to get a RTE plugin working that will allow upload of > images. The YUI verion is almost there but will not play well with > browsers. > > The plugin from > herehttp://allmybrain.com/2008/11/06/example-yui-image-upload-with-yui-260/ > I modified to get Javascript to make an asynchronous call to this > function in the view: > > def uploadimage(request): > try: > upload_full_path = settings.CONTENT_IMAGES > > upload = request.FILES['image'] > dest = open(os.path.join(upload_full_path, upload.name), > 'wb+') > > for chunk in upload.chunks(): > dest.write(chunk) > > dest.close() > > result='{status:"UPLOADED",image_url:"%s%s"}' % > (settings.CONTENT_IMAGES_URL, upload.name) > > return_data = HttpResponse(result,mimetype='Content-Type: > text/ > html') > > except Exception, e: > return_data = HttpResponse("Error in uploading image") > > return_data.flush() > > return return_data > > The plugin was written for turbon gears/php and there is a tg example > here: > > http://allmybrain.com/2007/10/22/yui-image-uploader-example-with-turb... > > Firefox/Mac works perfectly. Safari downloads the image instead. No > version on PC appears to do anything, (but only have Mac for local > testing.) > Have tried every possible permutation of the content-type, Content- > Type and text/html definitely is the way to go. Various threads on > python refer to the need to open the file for reading as rb to make > sure windows knows it is binary, but not sure how to do that as the > response data is already in memory. > > In desperation I have also tried to implement image upload in TinyMCE > - can't get FileBrowser working on PC. and FCKeditor no modifiable > image upload that I could find. So I am back with YUI and hoping > someone can suggest something to try --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MultiValueDictKeyError when accessing POST items
I've run into a similar problem, but am trying to submit the form with a text link and java script. The submit element is on the page, but hidden. and I get the same error: HTML -- http://media.muskegohitmen.com images/ siteLogo_sm.png"/> Username: Password: LoginForgot Password ?! -- EXTERNAL JS FUNCTION --- // There is some mootools code in there, I thought that might be the problem, so I stuck the document line in there to see if that would fix it. function hitmenFormSubmit(form_id) { form = form_id.get('id'); this.alert("form submit " +" "+form); document.login_form.submit(); //$(form).submit(); } my views function is looking for request.POST['login'] == Login Any ideas? If i press input button, it works fine, if i press the javascript button I get the error On Dec 22 2008, 9:23 pm, Malcolm Tredinnickwrote: > On Mon, 2008-12-22 at 19:03 -0800, DragonSlayre wrote: > > I've created my own form: > > > > > Login: > > Username: > > > > Password: > > > > > > > > > I am mappying /accounts/login/ to a view of mine, which is then > > calling: > > > if request.method == 'POST': > > username = request.POST['login_username'] > > > I have no idea why I'm getting the error - "Key 'login_username' not > > found in ". > > > What am I doing wrong? > > login_username is the value of the id attribute on the label, not on the > form input element. Basically, your HTML isn't correct for the type of > form you're after. You need to identify the form input elements, rather > than the label elements. Compare the output from a Django form to what > you have an you should see the difference fairly quickly. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: MultiValueDictKeyError when accessing POST items
HTML http://media.muskegohitmen.com/images/ siteLogo_sm.png"/> Username: Password: LoginForgot Password ?! # JS - there is a little mootools in there, but though that might be the problem so I used the document. to see if that would do it function hitmenFormSubmit(form_id) { form = form_id.get('id'); this.alert("form submit " +" "+form); document.login_form.submit(); //$(form).submit(); } The HTML button is on the page for debugging. The HTML button works just fine. but the javascript button results in this error. Views function is looking for request.POST ['login'] == Login Why would a javascript submit not post the same data? On Dec 22 2008, 9:23 pm, Malcolm Tredinnickwrote: > On Mon, 2008-12-22 at 19:03 -0800, DragonSlayre wrote: > > I've created my own form: > > > > > Login: > > Username: > > > > Password: > > > > > > > > > I am mappying /accounts/login/ to a view of mine, which is then > > calling: > > > if request.method == 'POST': > > username = request.POST['login_username'] > > > I have no idea why I'm getting the error - "Key 'login_username' not > > found in ". > > > What am I doing wrong? > > login_username is the value of the id attribute on the label, not on the > form input element. Basically, your HTML isn't correct for the type of > form you're after. You need to identify the form input elements, rather > than the label elements. Compare the output from a Django form to what > you have an you should see the difference fairly quickly. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---