django

How do I include the Django settings file?

I have a .py file in a directory , which is inside the Django project folder. I have email settings in my settings.py, but this .py file does not import that file. How can I specify to Django that settings.py should be used , so that I can use EmailMessage class with the settings that are in my settings.py? ...

django-admin.py startproject mysite not working well on windows 7

Hi I'm learning django and I did successfully start a site on Window XP by following the tutorial. However, on Window 7 when I issued: django-admin.py startproject mysite python.exe was started and a window appeared to ask me to choose either python.exe or other program to open a file.... did I do anthing wrong or there are more tric...

how to create english language dictionary application with python (django)?

Hi All, I would like to create an online dictionary application by using python (or with django). It will be similar to http://dictionary.reference.com/. PS: the dictionary is not stored in a database. it's stored in a text file or gunzip file. Free english dictionary files can be downloaded from this URL: dicts.info/dictionaries.php...

spam and dirty words comment post filtering/prevention/blocking in python (django)

Hi All, My basic question is how to prevent spam and dirty words in a comment post system under python (django). I have a collection of phrases (approximately 3000 phrases) to be blocked. What I want to do is like this: If I found a comment which has a dirty-word when user clicks the post button, then the web should popup a warnin...

how can I put a process in background using django ?

I tried os.system, os.spwanl, etc.. but it doesn't work well I need to execute some background process from django application. ...

Modify on-the-fly verbose_name in a model field on django admin

Hi I have this sample model working with the admin class Author(models.Model): name = models.CharField(_('Text in here'), max_length=100) with verbose_name set as ugettext_lazy 'Text in here', but sometimes, depending on the site_id i want to present a diferent verbose name, so I modified the init in this way def __init__(self, ...

django insert data from 2 tables using a single ModelForm

Hi there, I want to get data from 2 tables into a form using ModelForm, like this: fist model: class Cv(models.Model): created_by = models.ForeignKey(User, blank=True) first_name = models.CharField(('first name'), max_length=30, blank=True) last_name = models.CharField(('last name'), max_length=30, blank=True) url = mo...

How to save links in TextFields

I have a simple Blog model with a TextField. What is the best way to save links in the TextField ? 1) Saving link in the database in this form: http://www.example.com and then using some filter in the template to trasform it in form: <a rel="nofollow" href="http://www.example.com&gt;http://www.example.com&lt;/a&gt; 2) Saving link in...

Is it possible to use template tags in ValidationError's strings?

I need to throw ValidationError containing anchor. if not profile.activated(): raise ValidationError('Your profile is not activated. <a href="{% url resend_activation_key %}">Resend activation key</a>.') What I need to modify to make this work? ...

Use Apache authentication in Django without popup

I am using Apache to authenticate users for Django, but I would like to do so without the popup form that Apache uses in its basic configuration. How do I embed the login form within a page while still using Apache for authentication? That is, I'd like a page that says "Please login" and provides a form asking for username and passwo...

Which StackOverflow-style MarkDown (WMD) javascript editor should I use?

Background I'm working on an application which requires user-entered content, and I've decided to use a StackOverflow-style MarkDown editor. After researching this topic for the last few days, I realize there are numerous forks of the base WMD editor, some with a few basic enhancements and some with serious differences from the StackOve...

Django and conditional aggregates

I have two models, authors and articles: class Author(models.Model): name = models.CharField('name', max_length=100) class Article(models.Model) title = models.CharField('title', max_length=100) pubdate = models.DateTimeField('publication date') authors = models.ManyToManyField(Author) Now I want to select all authors...

What is a good sample solrconfig.xml for django-haystack?

I am building out a solr instance for django, but the example provided from solr is super verbose, with many things that are not relevant to haystack. A sample with spelling suggestions, morelikethis, and faceting, without the extra stuff that haystack doesn't use would go a long way to helping me understand what is needed and what isn't...

Django - Form validation error

Hello, I have a model like this: class Entity(models.Model): entity_name = models.CharField(max_length=100) entity_id = models.CharField(max_length=30, primary_key=True) entity_parent = models.CharField(max_length=100, null=True) photo_id = models.CharField(max_length=100, null=True) username = models.CharField(m...

How to return number of rows in the template

In my view I return all posts of one blog: posts = Post.objects.filter(blog=blog) and pass it to context. But.. How can I get the number of posts in the template ? This is my template: <h1>Number of posts: {{ ??? }} </h1> {% for post in posts %} {{ post.title }} {{ post.body }} {% endfor %} ...

Django: returning a selection of fields from a model based on their values?

I am working with some data over which I have little control. I'd like to return ONLY the fields of my model that aren't certain 'uninteresting' values (e.g. '0', 'X' or '-'), and access them individually in the template. My model is like this: class Manors(models.Model): structidx = models.IntegerField(primary_key=True, verbose_n...

How to make Dajax callback into scoped object

I cant seem to find a way to make django-dajaxice have its callback inside same scoped object from which made the initial call. MyViewport = Ext.extend(MyViewportUi, { initComponent: function() { MyViewport.superclass.initComponent.call(this); }, LoadRecordsCallback: function(data){ if(data!='DAJAXICE_EXCEPT...

In Django, how to define a "location path" in order to display it to the users?

I want to put a "location path" in my pages showing where the user is. Supposing that the user is watching one product, it could be Index > Products > ProductName where each word is also a link to other pages. I was thinking on passing to the template a variable with the path like [(_('Index'), 'index_url_name'), (_('Products'), 'produc...

How should I go about learning Python?

I am currently learning PHP and want to learn about OOP. I know Python is a well-organized and is all OOP, so would learning Python be a wise choose to learn OOP? The thing is I am more towards web development then just general programming, and I know Python is just a general purpose language, but there is Django. So how should I g...

Problems with i18n using django translation on App-Engine with Korean and Hindi

I've got a setup based on the post here, and it works perfectly. Adding more languages to the mix, it recognises them fine, except for Korean (ko) and Hindi (hi). Chinese/Japanese/Hebrew are all fine, so nothing to do with encodings/charsets I don't think. Taking a look into the django code inside the app-engine SDK, I notice that all t...