Search Results

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

Page 137/143 | < Previous Page | 133 134 135 136 137 138 139 140 141 142 143  | Next Page >

  • QuestionOrAnswer model?

    - by Mark
    My site has Listings. Users can ask Questions about listings, and the author of the listing can respond with an Answer. However, the Answer might need clarification, so I've made them recursive (you can "answer" an answer). So how do I set up the database? The way I have it now looks like this (in Django-style models): class QuestionOrAnswer(Model): user = ForeignKey(User, related_name='questions') listing = ForeignKey(Listing, related_name='questions') parent = models.ForeignKey('self', null=True, blank=True, related_name='children') message = TextField() But what bugs me is that listing is now an attribute of the answers as well (it doesn't need to be). What happens if the database gets mangled and an answer belongs to a different listing than its parent question? That just doesn't make any sense. We can separate it with polymorphism: QuestionOrAnswer user message created updated Question(QuestionOrAnswer) shipment Answer(QuestionOrAnswer) parent = ForeignKey(QuestionOrAnswer) And that ought to work, but now ever question and answer is split into 2 tables. Is it worth this overhead for clearly defined models?

    Read the article

  • correct approach to store in database

    - by John
    I'm developing an online website (using Django and Mysql). I have a Tests table and User table. I have 50 tests within the table and each user completes them at their own pace. How do I store the status of the tests in my DB? One idea that came to my mind is to create an additional column in User table. That column containing testid's separated by comma or any other delimiter. userid | username | testscompleted 1 john 1, 5, 34 2 tom 1, 10, 23, 25 Another idea was to create a seperate table to store userid and testid. So, I'll have only 2 columns but thousands of rows (no of tests * no of users) and they will always continue to increase. userid | testid 1 1 1 5 2 1 1 34 2 10

    Read the article

  • Calculating spam probability

    - by Hobhouse
    I am building a website in python/django and want to predict wether a user submission is valid or wether it is spam. Users have an accept rate on their submissions, like this website has. Users can moderate other users' submissions; and these moderations are later metamoderated by an admin. Given this: user A with an submission accept rate of 60% submits something. user B moderates A's post as a valid submission. However, his moderations are often wrong, and his moderations' accept rate is a mere 30%. user C moderates A's post as spam. User C is usually right. His moderations' accept rate is 80%. How can I predict the chance of A's post being spam?

    Read the article

  • Stack recommendations for small/medium-sized web application in Python

    - by reto
    I'm looking for some recommendations for a python web application. We have some memory restrictions and we try to keep it small and lean. We thought about using WSGI (and a python webserver) and build the rest ourself. We already have a template engine we'd like to use, but we are open for some suggestions regarding the whole request handling (the controller). The application has to run in a single process and the requests have to be processed with multiple threads. We've looked at django, but we are a not sure if it fits into our memory budget. Your feedback is very welcome! Cheers, Reto

    Read the article

  • Is str.replace(..).replace(..) ad nauseam a standard idiom in Python?

    - by meeselet
    For instance, say I wanted a function to escape a string for use in HTML (as in Django's escape filter): def escape(string): """ Returns the given string with ampersands, quotes and angle brackets encoded. """ return string.replace('&', '&amp;').replace('<', '&lt;').replace('>', '&gt;').replace("'", '&#39;').replace('"', '&quot;') This works, but it gets ugly quickly and appears to have poor algorithmic performance (in this example, the string is repeatedly traversed 5 times). What would be better is something like this: def escape(string): """ Returns the given string with ampersands, quotes and angle brackets encoded. """ # Note that ampersands must be escaped first; the rest can be escaped in # any order. return replace_multi(string.replace('&', '&amp;'), {'<': '&lt;', '>': '&gt;', "'": '&#39;', '"': '&quot;'}) Does such a function exist, or is the standard Python idiom to use what I wrote before?

    Read the article

  • JQuery Autocomplete CSS not working?

    - by gath
    I am trying to implement JQuery Autocomplete pluggi using Django. I've been able to wire the thing together and I can actually see the result back in the HTML template. My problem is that the JQuery Autocomplete CSS doesn't seem to work. The results I get are not well formatted/styled, and they have no background and you cannot even select them. What is it that am missing? I have these three files in my media folder same folder: autocomplete.js dimensions.js autocomplete.css In my html template I have the following function: $(function(){ setAutoComplete("tags", "tagResults", "/taglookup/?query="); }); My textfield looks like this; <input type="text" name="tags" value=""> Where do I put the tagResults in my HTML template document? Every time I try to introduce a DIV with id="tagResults", JQuery throws an error. Any ideas?

    Read the article

  • Creating a new project from a project skeleton using git

    - by asciitaxi
    In order to get a new django project up and running faster, I'd like to maintain a separate "project skeleton" on which I base all my new projects. It would be great if, as I improved the skeleton, I could bring those improvements into my active projects. How can I accomplish this with git? So, maybe in my remote git repository machine I would have 1 repo for each project and one for the skeleton? proj-A-repo proj-B-repo skeleton-repo If I want to create a new proj-C locally based on the skeleton, then push my local changes up to the remote server in a new repo called proj-C-repo, how might I do this? I've read through quite a bit of git documentation, but I'm confused about how to go about this. Do I need to clone the skeleton, or create an empty repo and then track a remote branch, or something else?

    Read the article

  • PUT parameters not working in python / google app engine

    - by magegu
    hi, i'm working on a simple RESTful webservice with python with the webapp framework on the google app engine. Basically i'm sending all request via AJAX/jquery - for POST it works like a charm, but when I'm sending data with PUT, the parameters are empty / not processed. this is my PUT: $.ajax({ type: "PUT", url: "/boxes", data: { name: this.name, archived: this.archived }, success: function(msg){ } }); firebug saids i'm putting: Parameter application/x-www-form-urlencoded archived false name 123112323asdasd but using this python code: from google.appengine.ext import webapp from google.appengine.ext.webapp import util, template from google.appengine.ext import db from google.appengine.api.datastore_types import * from django.utils import simplejson as json import cgi import datetime class BoxHandler(webapp.RequestHandler): def post(self): #working print "test" self.response.out.write(self.request.get("name")) def put(self): print "test" #not working self.response.out.write(self.request.get("name")) will just return test Status: 200 OK Content-Type: text/html; charset=utf-8 Cache-Control: no-cache Expires: Fri, 01 Jan 1990 00:00:00 GMT Content-Length: 0 so .. hm, is there anything i'm missing here? cheers, Martin

    Read the article

  • If I already know Perl Is Python worth learning?

    - by Garett
    I'm all for learning and continual improving one’s self, and I believe you should have as many tools as possible in your toolbox. However, I was wondering if it was worth it learning Python, since I already know a couple of dynamic interpreted languages, including Perl. My background is mostly C/C++/Java/C#, but I’ve programmed in Perl quite a bit over the years. I recently read Dive Into Python, as well as the tutorial for the Django framework for a new project where Python was suggested. However, I kept finding myself thinking that I can still accomplish much of the same stuff with Perl, so I’m not sure when I would choose a Python approach over one that I’m already familiar with. This is by no means meant to start any kind of language war, and I do recognize that language choice is quite subjective. I just wondering when one would make such a choice.

    Read the article

  • PHP vs JSP Which is should I use/learn for my project?

    - by Jon
    I'm planning on making a fitness planning web application for my senior project at school. However, I don't know anything about either technology and my only experience with web development previously was with python and django. I was wondering what people might recommend to learn, what is most useful to learn for the job market, and what would be best for this project. If it matters, the programming languages I know are, C, C++, Java, and Python. My goal of the project is to learn technologies that will make me a more marketable person. Thanks

    Read the article

  • GVim highlighting with matchadd eventually slows down?

    - by Kyle MacFarlane
    I have the following in ~/.vim/ftplugin/python.vim to highlight long lines, accidental tabs and extra whitespace in Python files: hi CustomPythonErrors ctermbg=red ctermfg=white guibg=#592929 au BufWinEnter *.py call matchadd('CustomPythonErrors', '\%>80v.\+', -1) au BufWinEnter *.py call matchadd('CustomPythonErrors', '/^\t\+/', -1) au BufWinEnter *.py call matchadd('CustomPythonErrors', '\s\+$', -1) au BufWinLeave *.py call clearmatches() The BufWinLeave is so that the matches are cleared when I switch to another file in case that file isn't a .py file. It's an essential feature for me when working with something like Django. It all works fine for random amounts of time; from ten minutes to hours (my guess is it depends on how many files I open/close). But eventually when any line over 80 characters is displayed GVim slows to a halt and requires a restart. Does anyone have any ideas why this would eventually slow down?

    Read the article

  • While making an RSS reader which saves articles, how can I prevent duplicates?

    - by Koning Baard
    Lets say I have a RSS feed which lists the 3 newest questions on SO. At 1 o'clock, the feed looks like this: While making an RSS reader which saves articles, how can I prevent duplicates? Convert char array to UNICODE in MFC C++ How to deploy a Java Swing application with an embedded JavaDB database? At 2 o'clock, this feed looks like: django url from another template than the one associated with the view-function While making an RSS reader which saves articles, how can I prevent duplicates? Convert char array to UNICODE in MFC C++ (duplicate articles are bold) I want to download the RSS feed every 5 minutes, parse it and save the articles that aren't already saved, but I do not want duplicates (items that remain in the new, updated feed like the examples above). What can I use to determine if an article is already saved? Thanks

    Read the article

  • In MVC framworks (such as Ruby on Rails), does usually Model spell as singular and controller and vi

    - by Jian Lin
    I usually see Ruby on Rails books using script/generate model Story name:string link:string which is a singular Story, while when it is controller script/generate controller Stories index then the Story now is Stories, which is plural. Is this a standard on Ruby on Rails? Is it true in other MVC frameworks too, like CakePHP, Symfony, Django, or TurboGears? I see that in the book Rails Space, the controller is also called User, which is the same as the model name, and it is the only exception I see. Update: also, when scaffold is done on Ruby on Rails, then automatically, the model is singular and the controller and view are both plural.

    Read the article

  • Twitter API + OAuth - 401 error developing locally using reverse SSH tunnel

    - by oliland
    I'm developing a django application which lets users connect their Twitter account. As I'm developing locally, I have set up a reverse SSH tunnel so that the Twitter API has a valid callback url (myserver.net): ssh -nNTR :6969:localhost:8000 myserver.net On successful authentication, Twitter passes back its OAuth access tokens to myserver.net, which in turn attempts to access Twitter's API, which returns a 401 error. I assume that because the callback is different to the address which is accessing the API (myserver.net / localhost), Twitter denies me access. I have tried this: export http_proxy="http://myserver.net:3128" Where myserver.net:3128 is running a Squid Proxy server to tunnel Twitter's API requests from my development machine so they appear to be coming from myserver, but receive the same 401 error. When I deploy to a server with a proper hostname / static IP address it works fine. What else do I need to do?

    Read the article

  • iPad as programming platform--What future do touch screens have with programming?

    - by user94154
    I read this question a few weeks ago. I thought about it when I first saw the iPad. Do you think it would be possible to set up a development environment on the iPad? I think it would be awesome if there was an InstantRails App, a Django App, maybe even 280 North's Atlas could run on it :). Would you develop using an on-screen keyboard and a 10 inch screen? Steve Jobs seems to think touch-screens are the future of web browsing. What Future does touch have with programming?

    Read the article

  • How should I declare default values for instance variables in Python?

    - by int3
    Should I give my class members default values like this: class Foo: num = 1 or like this? class Foo: def __init__(self): self.num = 1 In this question I discovered that in both cases, bar = Foo() bar.num += 1 is a well-defined operation. I understand that the first method will give me a class variable while the second one will not. However, if I do not require a class variable, but only need to set a default value for my instance variables, are both methods equally good? Or one of them more 'pythonic' than the other? One thing I've noticed is that in the Django tutorial, they use the second method to declare Models. Personally I think the second method is more elegant, but I'd like to know what the 'standard' way is.

    Read the article

  • How, in general, can web framework support REST style?

    - by juro
    I would like to know, what are the ways a web framework may be suitable for designing a RESTful app, in general. One goal is for example to provide http request routing, so they are automatically sent to appropriate controllers. From architectural point of view, web framework based on MVC pattern are more suitable for REST. What other features of web frameworks are helpful by building apps satisfying the REST constraints? Is there any reason why you consider certain languages(python/java) or web frameworks(django/turbogears/jersey/restlets/...) as the most applicable ones?

    Read the article

  • is unicode( codecs.BOM_UTF8, "utf8" ) necessary in Python 2.7/3?

    - by Brian M. Hunt
    In a code review I came across the following code that contains the following: # Python bug that renders the unicode identifier (0xEF 0xBB 0xBF) # as a character. # If untreated, it can prevent the page from validating or rendering # properly. bom = unicode( codecs.BOM_UTF8, "utf8" ) r = r.replace(bom, '') This is in a function that passes a string to Response object (Django or Flask). Is this still a bug that needs this fix in Python 2.7 or 3? Something tells me it isn't, but I thought I'd ask because I don't know this problem very well. Thanks for reading.

    Read the article

  • code deployment options

    - by bobinabottle
    We've been looking at automating our server and code deployments. We've already decided on puppet for our server configurations, but are looking for a more "push" style tool to use for code deployments. I'm currently looking at either using capistrano or fabric, but I'm not sure what would be the most mature to use? We deploy a number of different services, none of which are currenlty written in rails or django, so we don't mind about language. What would be the best one to build custom deployment scripts? Or have I missed another tool out there? We are also considering git pushing with hooks for deployment, but feel it will be limited/hacky in what we want to achieve with it. Any thoughts or experience would be great to hear. Cheers

    Read the article

  • What will be the setup process for website development?

    - by Vijay Shanker
    Hi, I want to create a simple site for my personal usage. And this only in python based technologies. So I want to get a expert oponian on this topic. What should i used as platform? I did a search for available options and found Django, grok, web2py and many more of these. Which one a novice use should use? If I choose to use only the basic python scripts then what option i have to work on? http://wiki.python.org/moin/WebBrowserProgramming. This link on python site confused me more, instead of solving my curiosity about the topic. Please give some pointer to accurate and easy to understand reading materials. I have got a idea of developing java based web applications using either spring-webmvc and struts. Can I relate Java process to python process for web development?

    Read the article

  • Fastest way to store/retrieve a dictionary - SQL, text file...?

    - by AP257
    Hi all, This is a really really super dumb question, so I apologise, but I'd be grateful for some advice. I've got a text file of words and word frequencies. It's very large - theoretically we're talking millions of rows. I just want to retrieve values from the file, and do it as quickly and efficiently as possible (for a web app, in Django). My question is: what is the best way to store and retrieve the values? Should import them into SQL? Or keep the file and use grep? Or put them into a JSON dictionary...? Or some other way? Sorry for the dumb question, would be very grateful for advice!

    Read the article

  • For anyone with free time: Trying to learn how to replace PHP with Python, failing terribly.

    - by MALON
    I want give web development using Python a shot, but I'm failing hard. I don't even know if I CAN run Python. The webpage for my web host says it supports all kinds of stuff, including Python. I've never touched anything CGI related and this does not appear to be a noob friendly area. Below is all the information I could think of that might be useful: Shared host: Yes Webhost: dibbsonhosting.com Server OS: linux Python installed: Yes (or so says the webhost) mod_python installed: Don't Know WSGI installed: Don't Know Access to http.conf: No Terminal access: No Cpanel: Yes FTP: Yes Django: downloaded latest stable release, not uploaded anywhere, not sure where to put it. DB: MySQL 5.x I really want to use Python for web development! Thanks!

    Read the article

  • Optimization Techniques in Python

    - by fear-matrix
    Recently i have developed a billing application for my company with Python/Django. For few months everything was fine but now i am observing that the performance is dropping because of more and more users using that applications. Now the problem is that the application is now very critical for the finance team. Now the finance team are after my life for sorting out the performance issue. I have no other option but to find a way to increase the performance of the billing application. So do you guys know any performance optimization techniques in python that will really help me with the scalability issue

    Read the article

  • Get Python 2.7's 'json' to not throw an exception when it encounters random byte strings

    - by Chris Dutrow
    Trying to encode a a dict object into json using Python 2.7's json (ie: import json). The object has some byte strings in it that are "pickled" data using cPickle, so for json's purposes, they are basically random byte strings. I was using django.utils's simplejson and this worked fine. But I recently switched to Python 2.7 on google app engine and they don't seem to have simplejson available anymore. Now that I am using json, it throws an exception when it encounters bytes that aren't part of UTF-8. The error that I'm getting is: UnicodeDecodeError: 'utf8' codec can't decode byte 0x80 in position 0: invalid start byte It would be nice if it printed out a string of the character codes like the debugging might do, ie: \u0002]q\u0000U\u001201. But I really don't much care how it handles this data just as long as it doesn't throw an exception and continues serializing the information that it does recognize. How can I make this happen? Thanks!

    Read the article

  • Updating a modul leve shared dictionary

    - by Vishal
    Hi, A module level dictionary 'd' and is accessed by different threads/requests in a django web application. I need to update 'd' every minute with a new data and the process takes about 5 seconds. What could be best solution where I want the users to get either the old value or the new value of d and nothing in between. I can think of a solution where a temp dictionary is constructed with a new data and assigned to 'd' but not sure how this works! Appreciate your ideas. Thanks

    Read the article

< Previous Page | 133 134 135 136 137 138 139 140 141 142 143  | Next Page >