django

django - the best way to combine pagination with filtering and request.POST - like stackoverflow - ajax?

Hi, I want to combine pagination with filtering. Since I have a lot of filters I do not want to send them per GET request, since the URLs get really ugly. Since django pagination uses GET request to pass the page parameters, I do not know how I can combine these two approaches. Any idea? Great add-on would be: How can I combine this...

Django custom managers - how do I return only objects created by the logged-in user?

I want to overwrite the custom objects model manager to only return objects a specific user created. Admin users should still return all objects using the objects model manager. Now I have found an approach that could work. They propose to create your own middleware looking like this: #### myproject/middleware/threadlocals.py try: ...

Click overlay for html page with click stats

How would you setup click overlay for html page that has click stats with number of clicks stored. Is there a jquery example for something like this. The ideal click overlay will have have a little box on top on each link with how many times it was clicked. ...

Django - testing of different visual blocks

I have some the page elements split into separate visual blocks. I am currently integrating the front end htmls from the designer, so it is important for me to test how they appear in the browser individually (each block). What is the simplest way I can implement this using django-testing? I know I can create a view with all the block...

Piston customize response representation

I am using piston and I would like to spit out a custom format for my response. My model is something like this: class Car(db.Model): name = models.CharField(max_length=256) color = models.CharField(max_length=256) Now when I issue a GET request to something like /api/cars/1/ I want to get a response like this: {'name' : 'BMW'...

'WSGIRequest' object has no attribute 'facebook'

Hi. Im trying to implement django-socialregistration, with all dependences included, I just followed those instructions. im having this error after authenticating with facebook: 'WSGIRequest' object has no attribute 'facebook' C:\Python25\lib\site-packages\socialregistration\views.py in facebook_login 108. if not request.facebook.ch...

How to implement Django model audit trail? How do you access logged in user in models save() method?

I want to keep track of the user who creates and then updates all of a given model's records. I have the "user" information in the logged in user's UserProfile (all users must be logged in to update these records). ...

How to use C# client to consume Django/Python web service (all methods are returning null)?

I have a C# command-line client that I'm testing the consumption of SOAP/WSDL via Django/Python/soaplib created WSDL. I've managed to successfully connect to the web service by adding a service reference. I then call one of service's methods, and the service processes the data I send, but it returns null instead of the integer I'm expect...

Django undirected graph

I want to build an undirected graph in Django. I have built an edge model with two foreign keys (first,second) to the node class, but there is a conflict with the related_name. I can use first_set and second_set, but since the graph is undirected, it doesn't matter if it is being liked to or from. What is the recommended way to deal w...

Regex for search queries.

Hi, I have page designed in Django that has its own search engine. What I need help with is construction of regex that will filter only valid queries, which are consisting only of polish alphabet letters(both upper- and lowercase) and symbols * and ? , can anyone be of assistance? EDIT: I tried something like that: query_re = re.compil...

Python + Facebook, getting info about a group easily

I have a need to display some basic info about a facebook group on a website i am building. All i am really looking to show is the total number of members, and maybe a list of the few most recent people who joined. I would like to not have to login to FB to accomplish this, is there an API for groups that allows anonymous access? or do...

How do I change the label of choices in CheckBoxSelectMultiple

I am using the CheckBoxSelectMultiple widget in my form Actually I have overridden this widget to display the choice as required. I wanted to change the displayed label of the choices. What would I have to change in the render method of the CheckBoxSelectMultiple for this. Thanks ...

The queryset's `count` is wrong after `extra`

When I use extra in a certain way on a Django queryset (call it qs), the result of qs.count() is different than len(qs.all()). To reproduce: Make an empty Django project and app, then add a trivial model: class Baz(models.Model): pass Now make a few objects: >>> Baz(id=1).save() >>> Baz(id=2).save() >>> Baz(id=3).save() >>> Baz...

Cannot decode/encode in UTF-8.

I have a text-box which allows users to enter a word. The user enters: über In the backend, I get the word like this: def form_process(request): word = request.GET.get('the_word') word = word.encode('utf-8') #word = word.decode('utf-8') print word For some reason, I cannot decode or encode this!! It gives me the err...

For Django's CSRF failure middleware, how can you get the CSRF errors to report what URL is failing?

For Django's CSRF failure middleware, how can you get the CSRF errors to report what URL is failing? ...

How can I find out who is responsible for Django's CSRF middleware?

How can I find out who is responsible for Django's CSRF middleware so I could ask them questions? I'm having so many CSRF failures for months on my Django site and it is costing me hours and hours of problems every few weeks. I want to contact the developers who worked on it to ask them one or two root questions about the problems I'm ...

Registration form with profile's field

Hi at all, I have a simply question. This is my profile: class Profile(models.Model): user = models.ForeignKey(User, unique=True) born = models.DateTimeField('born to') photo = models.ImageField(upload_to='profile_photo') I want to create a REGISTRATION FORM with this fields ( from User and Profile models ): username, first_name...

What does "mro()" do in Python?

in django.utils.funcitonal.py: for t in type(res).mro():#<-----this if t in self.__dispatch: return self.__dispatch[t][funcname](res, *args, **kw) i don't understand mro i search by google,and saw much english Article,but i still can't anderstand it, who can give me a simple example ,thanks...

What's the suggested way of importing modules within a django project

This has always bothered me, and I've never really come up with my own preferred way of doing this. When importing something from one of your own applications in a django project, do you import with: from myproject.mymodule.model import SomeModel from myproject.anotherone.model import AnotherModel or, do you do: from mymodule.model ...

Empty Request.FILES with Django Upload forms

Trying to use a very simple form to upload a file into a new class instance. I am expecting to have both files in request.FILES but it's empty. I am on the bundled dev server. been stuck here and went through all related questions ... wayfinder_map.media_file = request.FILES['media_file'] generates MultiValueDictKeyError: "Key 'medi...