django

Convert URL to screenshot (script).

There is the URL of page on the Internet. I need to get a screenshot of this page (no matter in which browser). I need a script (PHP, Python (even Django framework)) that receives the URL (string) and output screenshot-file at the exit (file gif, png, jpg). UPD: I need dynamically create a page where opposite to URL will be placed sc...

Django or Drupal for 10gb entries

What would be better option, drupal or django if there was data of 10gb of entries to be imported from MSSQL darabase One of requirements is to have editors access so they can update content at anytime. ...

How can i remove special characters in a Posted data

I need to remove special characters from the posted data. It may be possible by using Regular Expressions or may be other. How to strip the special characters. Plz help ...

How to strip " (quotes) from post data

I have a textbox. When the user enters the " symbol. I had to strip that symbol before storing into the database. Please help. Any help will be appreciated Django Code: postDict = request.POST.copy() profile = quser.get_profile() profile.i_like= postDict['value'] profile=profile.save() ...

DROP CASCADE in Sql Server

I'm running a South migration in a Django project that uses Sql Server and pyodbc. This is backwards migration so the South is trying to delete a few of my tables. The South executes the following method in order to drop the tables: def delete_table(self, table_name, cascade=True): """ Deletes the table 'table_name'. """ ...

Which is the easiest way to remove Django User model's 30 character limit?

I've inherited a Django application which uses a custom form-less auth backend. It works around the 30 character limit in django.contrib.auth.models.User by a SQL hack ALTER TABLE auth_user MODIFY COLUMN username varchar(90);, which is of course only valid for the database, but not for forms. Since I'm trying to remove all the hacks from...

Django: preventing QuerySet deletions on a model?

I have a model whose delete() method I have overridden. Because this is not called on a bulk QuerySet delete, I would like to disable QuerySet deletion or somehow assert against it happening. Is there any way to do that? ...

How to mock chained function calls in python?

I'm using the mock library written by Michael Foord to help with my testing on a django application. I'd like to test that I'm setting up my query properly, but I don't think I need to actually hit the database, so I'm trying to mock out the query. I can mock out the first part of the query just fine, but I am not getting the results I...

REST vs SOAP - Is SOAP really more secure than REST?

Hi folks, I am not an expert in SOAP, but from my knowledge SOAP is just an HTTP request formatted in XML in order to supply structured data. I need to implement a simple API with a list of parameters. I proposed using a simple REST interface, but I have been told that SOAP is more secure. Any ideas on this topic? ...

order objects by most unique views (stored in another table with ip) in django

Related models: models.py class Entry(models.Model): ... class EntryView(models.Model): entry = models.ForeignKey(Entry) dt_clicked = models.DateTimeField(auto_now_add=True) ip = models.CharField(max_length=15, db_index=True, blank=True) host = models.CharField(max_length=64, db_index=True, blank=True) referer ...

Quick counting with linked Django Models

I've got a stack of Models something like this (I'm typing it out in relative shorthand): class User: pass class ItemList: pass # A User can have more than one ItemList # An ItemList can have more than one User # Classic M2M class ItemListOwnership: user = fk(User) itemlist = fk(ItemList) # An ItemList has multipl...

Django - Access parent window in ModelAdmin

Hello, I have a class called News which have a choices field called category. Each category is also representing by classes with the News class as foreignKey field. So in admin, when I create a new category instance, I have to create a News, which is represented with a popup. The main page which represents the category class is the p...

How to create a unique slug in Django

I am trying to create a unique slug in Django so that I can access a post via a url like this: http://www.mysite.com/buy-a-new-bike_Boston-MA-02111_2 The relevant models: class ZipCode(models.Model): zipcode = models.CharField(max_length=5) city = models.CharField(max_length=64) statecode = models.CharField(max_length=32) ...

Annotating django QuerySet with values from related table

I have a model Page with 2 related models PageScoreHistory and PageImageHistory, where both history models have page field as a ForeignKey to Page and have a date field. The problem I am having, is that when I get a list of PageImageHistory QuerySet, I want to be able to retrieve the score the page had at the time the image was taken. Fo...

Django cannot make m2m_changed change the same m2m field

My models looks something like this: class Store: category = ManyToManyField(Category) class Category: parent = ForeignKey(Category) This is what I want to do: def update_storem2m_handler(instance, action, reverse=False, pk_set=[], **kwargs): for c in instance.category.all(): instance.category.add(c.parent) m2m_ch...

Testing for extra_context in django

Hi, I'm trying to test if the extra_context provided by the user was correctly processed in the view. Here is my test approach: # tests.py (of course it's a part of TestCase class) def test_should_use_definied_extra_context(self): response = self.client.get(reverse('contact_question_create'), { 'extra_context': {'foo': 'ba...

Proper way to test Django signals

I'm trying to test sent signal and it's providing_args. Signal triggered inside contact_question_create view just after form submission. My TestCase is something like: def test_form_should_post_proper_data_via_signal(self): form_data = {'name': 'Jan Nowak'} signals.question_posted.send(sender='test', form_data=form_...

Django - populate a MultipleChoiceField via request.user.somechoice_set.all()

Is there a more efficient, or cleaner way to do the following? class SpamForm(ModelForm): some_choices = fields.MultipleChoiceField() def __init__(self, *args, **kwargs): super(SpamForm, self).__init__(*args, **kwargs) self.fields['some_choices'].choices = [[choice.pk, choice.description] for choice in self.inst...

How do I reference a django variable in javascript?

Hello, I am working on a project that requires me to use a value contained in a variable from my view.py template. I need to use that variable in my javascript. Does anyone know a proper way to pass a variable from django to JS? Here is my function in views.py @login_required @never_cache_headers def user_feed(request, user=None, ext...

Multiple individual users on one database

I have a .sql database with which i interact using Django . The database in the beginning is filled with public data that can be accessed from anynone. Multiple individual users can add rows into a table(private data). How can a user see only the changes he made in the database(private data)? ...