django

Django application for media content

Hello, I'm looking for a Django application which stores and outputs articles (like on the internet media sites), probably containing pictures. I need paged output because the articles are going to be large, and I also need some kind of content navigation for the same reason. Can you advise me of some? Any applications, even those that...

Django: sqlite for dev, mysql for prod?

Quick question: is it a good idea to use sqlite while developing a Django project, and use MySQL on the production server? ...

Django form validation: making "required" conditional?

I'm new to Django (and Python), and am trying to figure out how to conditionalize certain aspects of form validation. In this case, there's a HTML interface to the application where the user can choose a date and a time from widgets. The clean method on the form object takes the values of the time and date fields and turns them back into...

Modifiying a Django view for a certain project

So I simply want to use the delete() from the django.contrib.comments.views.moderation module, but only allowing the users with permission to delete their comments. In order to do this, all I have to do is uncomment #@permission_required("comments.delete_comment"), but I want to be able to do this without modifying the django framework. ...

Django, validating Form

Hello, I want my forms to be dynamic, some parameters sucj as max_length for IntegerField varies from model to model. By using the information from here, I have written this form: def my_form(inputname, inputlastname, inputamount): class MyForm(forms.Form): name = forms.CharField(max_length=50,required=True,initial=inputname) last...

What is the best way to store multiple date strings in Django?

I'm building a Django app that needs to store multiple selected dates for an event. The first thing that came to mind was build the event model: class Event(models.Model): title = models.CharField(max_length=200) creator = models.ForeignKey(User) modified = models.DateTimeField(auto_now=True, auto_now_add=False) ...

In django what is a SKU ?

When I read django code I often see in models what is called "sku", and "slug". E.g: name = models.CharField(_("Full Name"), max_length=255, blank=False, help_text=_("This is what the product will be called in the default site language. To add non-default translations, use the Product Translation section below.")) slug = models.Sl...

Is it possible to decorate include(...) in djano's urls with login_required?

I have a few restricted areas on the site, for which I would like to specify login_required decorator. However I would like to do that once per inclusion in main urls.py, not per individual url in included urls.py So instead of: /private/urls.py: (r'^profile/$', login_required(profile)), I'd do something along the lines: /urls.py ...

Django - Overriding the Model.create() method?

The Django docs only list examples for overriding save() and delete(). However, I'd like to define some extra processing for my models only when they are created. For anyone familiar with Rails, it would be the equivalent to creating a :before_create filter. Is this possible? ...

Detecting changed form values -- Firefox replaces with user-input values, breaking dirtiness detection.

Hi, I'm implementing form dirtiness detection for a web-app. The 'dirtiness' that I'm interested in is the server's value versus what's displayed on the form. The server is running Django, most of our scripting is in jQuery. We serve the form fields with the correct default values corresponding to the value on the server, e.g. <input ...

Django: custom 404 handler that returns 404 status code

The project I'm working on has some data that needs to get passed to every view, so we have a wrapper around render_to_response called master_rtr. Ok. Now, I need our 404 pages to run through this as well. Per the instructions, I created a custom 404 handler (cleverly called custom_404) that calls master_rtr. Everything looks good, b...

Django, how to access request object in settings.py

Is it somehow possible to access the request object inside settings.py? Maybe by creating a temporary settings object, modifying it and then telling the rest of the "chain" to use that instead of the normal settings.py? I need it to decide which DB-connection to use. As an extra question. If I were to have something like 5000 database ...

Django: check for generic type in template?

I'm using generic types in my Profile model: user_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() details = generic.GenericForeignKey('user_type', 'object_id') But now I want to check if a user is a certain type from within my template. I can get the user type with {{ user.get_profile.user_type }} but t...

Django logout infinite loop?

Why is this running into an infinite loop, and 'TESTING' never gets printed? It seems like the logout function is causing the page to redirect to itself, but the documentation suggests that you can put your own redirect after calling that function. def logout(request): logout(request) print 'TESTING' messages.success(request...

django sites default

Hello! Many 'reusable apps' require django-sites. There is annoying field "publish on" in admin interface, which I can't exclude because it has no default parameter (so the entry will be published nowhere. I tried). The model is described in the 'reusable app' so I don't want to change it. How can I get rid of this annoying field? ...

Modifying the `clear` attribute of an image with TinyMCE

I'm using TinyMCE with the tinymce-django app in my Django website. I am using it in the admin interface to edit HTML fields. (Something like a flatpage.) When adding images with TinyMCE, how can I change their clear style attribute? ...

Google app engine database values not incrementing

Here is some code that is not working how it is supposed to work. Every time the database is queried, I get either a 0 or 1 value for the options, and the values in database do not increment, even though as as you can see, in line 86 and 89, the values are being incremented. Any idea what's going wrong here? I am using Django on Google A...

django error:Invalid block tag: 'endblock'

why?? thanks ...

When I use httplib for my OAUTH in Python, I always get "CannotSendRequest" and then "

Traceback: File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/home/ea/ea/hell/life/views.py" in linkedin_auth 274. token = oauth_linkedin.get_unauthorised_request_token() File "/home/ea/ea/hell/life/o...

Django Regex 'Break Out'?

How do you 'break out' of a regex in Django? Therefore if one of your URL tokens (after and before a slash /token/) needs 3 digits, a COLON, 3 letters, a 'T' and then 2 digits, a DASH and then 3 digits - how would you do this? Example: Accept: 678:bhgT23-789 Reject: 345:fdsM43-432 I've started off with a r'^(?P<somevar>\w{2})/', but...