django

Django url debugger

I'm developing a django application and over time, the URLs have grown. I have a lot of them with me now and due to some change I made, one view started to malfunction. When I try to GET http://example.com/foo/edit_profile, it's supposed to execute a view certain view function X but it's executing Y instead. Somewhere the url routing is ...

How to render django-cms plugin in every page?

Hello! I have a latest news plugin for django-cms. I want to show 5 latest news in footer. Footer placed in every page of site. How i can render this plugin in every page? ...

A-z Index Django

Im looking for advice on desinging a web page with an A - Z index. Kind of like : http://www.bls.gov/bls/topicsaz.htm I have a long list of objects, with a title, that I want do display alphabetically, easy! But I want to put in the A-Z with anchors, do I do this in the template, I would have to loop through all the objects in the t...

Django: Use of DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT in settings.py?

I would like to globally (through my entire site, admin and front-end) adjust the way dates and time are displayed to my likings, but I cannot figure out what is going on with the DATE_FORMAT, DATETIME_FORMAT and TIME_FORMAT variables in settings.py. In this question it says that the settings are ignored. The question is over a year old...

Django QuerySet .defer() problem - bug or feature?

An example is better than a thousand words: In [3]: User.objects.filter(id=19)[0] == User.objects.filter(id=19)[0] Out[3]: True In [4]: User.objects.filter(id=19)[0] == User.objects.filter(id=19).defer('email')[0] Out[4]: False Does it work like this on purpose ? Subquestion: is there any simple way to get a regular mode...

django logging: log is not created

Hello, I'm running my app on the GAE development server, with app-engine-patch to run Django. One of my views is bugged , so I want to log everything that happens. I added in myapp.views: import logging LOG_FILENAME = '/mylog.txt' logging.basicConfig(filename=LOG_FILENAME,level=logging.DEBUG) and my function is: def function(string...

Decode values of a tuple in django template

if(len(f1) > 0): for qs in profile_map: up = Profile.objects.get(pk=qs.emp.id) t_name = up.first_name + up.last_name t_arr.append((q.profile.id,emp_name)) response_dictionary.update({'tarr':t_arr}) render_to_response('project/profile_table.html',context_instance=RequestContext(request,{'response_dict...

Django: Sending Signals - Not understanding the documentation

I have 2 listeners defined: def update_dashbaord_modified_date(sender, **kwargs): """Listen for changes to Goal, Action, etc. since we want to update the date modified on Dashbaord when a change occurs.""" ... do something ... post_save.connect(update_dashbaord_modified_date) # Register to listen for post_save signals post_...

How to test context and session in Django after redirect?

I have a view that looks like this: def login(request): ... # some variables has been set here ... if request.POST.get('remember_me', None): request.session.set_expiry(1209600) # 2 weeks return HttpResponseRedirect(reverse('dashboard')) Now If I assert for the variables using context, I get the error: "Attr...

Python/Django AttributeError "Object 'players' has no attribute 'fields'

I am setting up the admin page so that I might be able to use it to add data, players in this case. When you go and attempt to register the Players class in admin.py you get the error described in the question title (object 'players' has no attribute 'fields'). Looking through views.py that I pasted a snippet out of below I don't see wha...

How to change multiple select field to multiple input fields for a many-to-many case?

When I display the ToolBoxEditForm it uses a multiple select field. But what I want is a form that lets the user edit each tool he has in the toolbox as a text field. I cant figure out how to do this with the many-to-many field. class Tool(models.Model): tool_name = models.CharField(unique=True, max_length=200) ...... class ToolBox...

How do clone a Mercurial repository into a directory that already exists?

Hello. I have a client's Django project that I'm developing locally, using Mercurial for version control. I push my local repository to my personal remote server (where I keep all my projects) and then when I come to deploy it (on whichever web server) I clone that respository there from my personal server. This works fine on most serv...

Django Customizing Form Rendering

When rendering a django form using the as_p method, you traditionally get something like: <p>Subject: <input type="text" name="subject" maxlength="100" /></p> if you had defined the following field: subject = forms.CharField(max_length=100) Is there some additional property available to fields, that customizes how they are rendered...

Django: Exposing model method to admin.

Example model: class Contestant(models.Model): first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) email = models.EmailField() ... def send_registration_email(self): ... I'd like to be able to expose this method to the admin so that managers can login and manually cal...

CSS Templating system for Django / Python?

I'm wondering if there is anything like Django's HTML templating system, for for CSS.. my searches on this aren't turning up anything of use. I am aware of things like SASS and CleverCSS but, as far as I can tell, these still don't solve my issue as I want to dynamically generate a CSS file based on certain conditions, so that a differen...

Django model field with default value set violates not null constraint when saved.

My field: signup_date = models.DateTimeField(blank=True,default=datetime.now) My error when saving: IntegrityError: null value in column "signup_date" violates not-null constraint I'm trying to make a simple unit test where I create a bound instance of a ModelForm from a dict and save it. Thanks. Traceback (most recent call last)...

How do I post to a Django 1.2 form using urllib?

Going off of this other SO question, I tried to use urlencode and urlopen to POST data to a form. However, Django 1.2 gives me a CSRF verification failed error when I use it. Is there a workaround? Thanks. ...

How do I redirect in Django with context?

I have a view that validates and saves a form. After the form is saved, I'd like redirect back to a list_object view with a success message "form for customer xyz was successfully updated..." HttpResponseRedirect doesn't seem like it would work, because it only has an argument for the url, no way to pass dictionary with it. I've tri...

Django - redirect to login page if UserProfile matching query does not exist error

I have extended the user model using the UserProfile method. However I occasionally get the Django error message UserProfile matching query does not exist when running the query request.user.get_profile() I think this is happening when I have become logged out of the system so my user becomes an AnonymousUser. Is there any way I can aut...

django-photologue upload_to

Hi all. I have been playing around with django-photologue for a while, and find this a great alternative to all other image handlings apps out there. One thing though, I also use django-cumulus to push my uploads to my CDN instead of running it on my local machine / server. When I used imagekit, I could always pass a upload_to='whatev...