django

Django: Why does my CharField not get given the class vTextField?

I have a form like this: class DiaryEventForm(forms.Form): title = forms.CharField(max_length = 200) Which generates this HTML: <input id="id_title" type="text" name="title" maxlength="200" /> This shows up as really narrow in the admin (where I've got a custom view using this form). If I have a model defined like this: class ...

Model form is crashing on a foreign key in django

So I'm trying to create a new feed within the Admin page and its crashing with the error IntegrityError: lifestream_feed.lifestream_id may not be NULL, form['lifestream'] is set but form.instance.lifestream is not. form.fields even shows that lifestream is a django.forms.models.ModelChoiceField Here is the code: class FeedCreationFo...

passing object data through URL

I know that I can pass object values through a URL pattern and use them in view functions. For instance: (r'^edit/(?P<id>\w+)/', edit_entry), can be utilized like: def edit_entry(request, id): if request.method == 'POST': a=Entry.objects.get(pk=id) form = EntryForm(request.POST, instance=a) ...

How should I convert this long and complex PHP style URL query string to a Django url?

I'm converting a small PHP application to Django. One section has a long query string, indicating how a widget is to be displayed. There are a few required parameters and several optional ones. The current urls read like: app.php?id=102030&size=large&auto=0&bw=1&extra=1 The id and size are required, but auto, bw and extra are option...

django template call function

Using google appengine and django. Whenever I have a db.ReferenceProperty() inside a model like: class User( db.Model ) : name = db.StringProperty() avatar = db.ReferenceProperty( dbImage ) So when putting out a User's page, in the django template I CAN'T do <div> <span>{{ user.name }}</span> <span>{{ user.avatar.key...

Web App GPS Polling

So it looks like mobile phones these days are capable of providing gps data ;) I'm building a django app with a mobile edition that I want to be location aware. My question is, how does one access GPS data? Is there a standard, or do you have to custom code for android/iphone/other. Ideally, I'd imagine it being provided in the HTTP r...

How do I get PyFacebook working with the Google App Engine Patch?

I've tried to follow the advice of this question: http://stackoverflow.com/questions/984071/facebook-django-and-google-app-engine, however I've run into a number of problems. The first is that from facebook.djangofb import facebook doesn't work because when I try to use the decorator @facebook.require_login(), it complains that the face...

When editing an object in django the ImageField is not populated

I'm trying to edit an existing object through a form. Every thing is working fine except for the ImageField not being populated with the current value. Here's the model: class Post(models.Model): author = models.ForeignKey(User, editable=False) slug = models.SlugField(max_length = 110, editable=False) title = models.CharFi...

Implementing USZipCodeField and USStateField in django

I'm looking to implement a zipcode field in django using the form objects from localflavor, but not quite getting them to work. I want to have a zipcode field in a form (or ModelForm in my case), but the fields never validate as a zipcode when calling _get_errors() on the form object. The way I'm implementing it seems right to me but is...

Django not recognizing the MEDIA_URL path?

So I'm trying to get TinyMCE up and running on a simple view function, but the path to the tiny_mce.js file gets screwed up. The file is located at /Users/home/Django/tinyMCE/media/js/tiny_mce/tiny_mce.js. I believe that /media/js/tiny_mce/tiny_mce.js is correct, as the development server has no access to files above the root of the Djan...

Django One-To-Many Models

The following models describe a vulnerability and the URLs out on the internet that reference that vulnerability. Assume that each URL only ever talks about 1 vulnerability, and that many URLs will discuss that vulnerability. Is this the correct way to lay out the model? class Vuln(models.Model): pub_date = models.DateTimeField("Publi...

What is the best way to change the language files in Django

I want to change some of the strings in the language file for my language in Django. I can of course just change the .po file, but that seems unwise because if I update Django the file will be changed again. What is the best way to do this? I don't care if the solution is for the specific app I'm working on or for my entire Django inst...

translation in django fixtures

Here is example initial_data.json. I want let django store value from column 'name' into translation file. So later, when value is printed somewhere, it could use its translated value. Is there any way to do it? Thanks. [ {"pk": 1, "model": "category.category", "fields": {"name": "Report"}}, {"pk": 2, "model": "category.category", "fiel...

Django: information leakage problem when using @login_required and setting LOGIN_URL

Hi all, I found a form of information leakage when using the @login_required decorator and setting the LOGIN_URL variable. I have a site that requires a mandatory login for all content. The problem is that you get redirected to the login page with the next variable set when it's a existing page. So when not logged in and asking for: ...

Could not get cookie from another (parent) domain in Django

Hi All! I need to remove a cookie that was previously set for parent domain while browsing host at subdomain of the parent. I.e., a cookie "xyz" was set for example.com, and I am trying to remove it on subdomain.example.com, using Django backend. The request.COOKIES given to the view does not contain any cookies except those from subd...

Pythonize Me: how to manage caller context variables in Python? (Python/Django)

I'm trying to refactor a fairly hefty view function in Django. There are too many variables floating around and it's a huge function. Ideally, I want to modularize the view into logical functions. However, I have to pass the function context around to get easy access to the variables. For example, def complex_view(request, slug): ...

django, location based searches

Excuse my ignorance, I am not even sure of the correct term for this. What I want to do is search by city and state or zip code in my django application and also include results within certain distances of the location (25, 50, 75 miles). I am guessing you probably need to convert the city and state or zip code to lat and long and then...

django modelformset_factory - how to add a field in the view after commit=False + ignore empty forms

Hi, I create a FormSet with modelformset_factory. HourRecordFormSet = modelformset_factory(HourRecord, max_num=6, extra=3, form=HourRecordBatchForm) Then I want to set the project field of a certain HourRecord object to the actual project. This should be done in the view. I tried it like this. if hour_record_formset_january.is_val...

How can I encrypt my django code?

I have to upload my django project to a shared hosting provider. How can I encrypt my code? I want to hide my code on the server. Thanks :) ...

Implementing a bread crumb in Django

I'm writing an application in Django and I want every page to contain a bread crumb. The bread crumb needs to look like "Group A > Group A.1 > Group A.1.1". On each page the bread crumb will be different. Group is a model. The thing confusing me is getting the group object into the context. I am considering writing a context processo...