django

Flickr albums in django admin

I want to do the following: Having a model (p.e. a model which handles data about photographic reports) create a section which has a preview of an specific flickr album. The URL will be provided by an URLField (until the first save the preview will not be available). After the first save, it'll show previews of all the images inside th...

how to add readonly_field in django admin site?

Hi all, I have the following problem: I have two models: Article and Comment, in Comments, i have parent = models.ForeignKey(Article). I have it set up so that Comments is inline to ArticleAdmin(admin.ModelAdmin), and CommentInline(admin.StackedInline). Also, all fields in CommentInline i've put into readonly_fields. What I would like ...

Cookieless Django for government site

As I'm writing a django site from government bodies I'm not going to be able to use cookies. I found this snippet http://djangosnippets.org/snippets/1540/ but it's currently not allowing users to login. Before I start debugging I wondered if anyone else has solved this problem with this snippet or in any other way? UPDATE The ONLY an...

Django snippet with logic

Hi, is there a way to create a Django snippet that has logic? I think about something like contact template tag: {% contact_form %} with template: <form action="send_contact_form" method="POST">...</form> with logic: def send_contact_form(): ... I want to be able to use it anywhere in my projects. It should work only by sp...

Cannot Extend Django 1.2.1 Admin Template

I am attempting to override/extend the header for the Django admin in version 1.2.1. However when I try to extend the admin template and simply change what I need documented here: http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-vs-replacing-an-admin-template), I run into a recursion problem. I have an index.html file...

How to set title and class in the HTML for the options of a ModelChoiceField?

I have a model class MyModel(models.Model): name = models.CharField(max_length=80, unique=True) parent = models.ForeignKey('self', null=True, blank=True) I want to render a ModelChoiceField for that model that looks like: <select name="mymodel" id="id_mymodel"> <option value="1" title="Value 1" class="">Value 1</option> ...

django-admin - how to modify ModelAdmin to create multiple objects at once?

let's assume that I have very basic model class Message(models.Model): msg = models.CharField(max_length=30) this model is registered with admin module: class MessageAdmin(admin.ModelAdmin): pass admin.site.register(Message, MessageAdmin) Currently when I go into the admin interface, after clicking "Add message" I have on...

Is PHP enough to be a great developer or do you have to learn Rails/Python?

My question really is can you do EVERYTHING in PHP that you can do in (Ruby)Rails/Django(python)? By me just concentrating on PHP (Framworks too) will i be losing out in someway? I prefer PHP but everyone tells me Rails is better? Any advice? Thank you in advance ;-) ...

Django, CSRF protection and js generated form

I have to create a form dynamically via javascript (yeah, that sounds ugly, but read this for the reason) and wants to make its submission CSRF proof. Usually, I use the @csrf_protect decorator in my views, and the {% csrf_token %} tag in my templates, as recommanded in the doc. But what should I do with a client-side generated form ? If...

Django: Page doesn't load images

I am working on a Django project for a company. This project worked very well before today. Today I found a page can not show images (and their corrsponding links). I checked source code of THAT PAGE, I found there are images and links, I just can not find them on the page. I checked the auth of the server and I am sure I can write th...

django auth : strange error with authenticate()

I am using authenticate() to authenticating users manually. Using admin interface I can see that there is no 'last_login' attribute for Users Debug traceback is : Environment: Request Method: GET Request URL: https://localhost/login/ Django Version: 1.1.1 Python Version: 2.6.5 Installed Applications: ['django.contrib.auth', 'django.c...

Is there a Python library that eases the creation of CLI utilities like Django management commands?

I want to create a set of command-line utilities in python that would be used like so: python utility.py command1 -option arg Very similar to django management commands. Is there any library that eases the creation of such commands? ...

How to implement Django-Comment Reply ?

How to provide reply option to the user so that they can comment for an existing comment ? ...

django left join with null

The model: class Product(models.Model): name = models.CharField(max_length = 128) def __unicode__(self): return self.name class Receipt(models.Model): name = models.CharField(max_length=128) components = models.ManyToManyField(Product, through='ReceiptComponent') class Admin: pass def __unicode__(self): return ...

Strange bug in Django admin list-editing mode

We have Django as DB editor for our customers. We have 2 installations on different servers - one talking to dev DB and used for testing new features (we do some customizations to admin), another used on production. It's convenient for customer to use list editing mode for batch updating one field for one model. The set of list-editable...

How do I specify an order of values in drop-down list in a Django ModelForm?

Ok, here is the question. class UserForm(forms.ModelForm): class Meta: model = User fields = ('team', 'related_projects') In models.py class User is defined as follows: class User (models.Model): team = models.ForeignKey(Team, verbose_name = _('team')) related_projects = models.ManyToManyField(Projec...

Django: Filtering datetime field by *only* the year value?

Hi folks, I'm trying to spit out a django page which lists all entries by the year they were created. So, for example: 2010: Note 4 Note 5 Note 6 2009: Note 1 Note 2 Note 3 It's proving more difficult than I would have expected. The model from which the data comes is below: class Note(models.Model): business = models.Forei...

Avoid 404 page override

I 'm using django-lfs with default django-app.Its appear django-lfs override 404 default template. How to avoid this process ...

How to receive ajax request using django?

I have the following JQuery Ajax request on my template that i want pass to my django view, function loginUser(){ $.ajax({ type:"POST", url :"/login-user/", data:"title=ajax call", datatype:"json", error:function(data){alert('Error:'+data);} success:function(dat...

cleaned_data() doesn't have some of the entered data

I have a simple form for a user to enter in Name (CharField), Age(IntegerField), and Sex(ChoiceField). However the data that is taken from the Sex choice field is not showing up in my cleaned_data(). Using a debugger, I can clearly see that the data is being received in the correct format but as soon as I do form.cleaned_data() all sign ...