I'm implementing a search system onto my django project, using django haystack. The problem is that some fields in my models have some french accents, and I would like to find the entries which contents the query with and without accents.
I think the best Idea is to create a SearchIndex with both the fields with the accents, and the sam...
Hi All,
Just curious how people are deploying their Django projects in combination with virtualenv
More specifically, how do you keep your production virtualenv's synched correctly with your development machine?
I use git for scm but I don't have my virtualenv inside the git repo - should I, or is it best to use the pip freeze and t...
Why is Django executing statements such as this:
SELECT (1) AS [a] FROM [my_table]
WHERE ([my_table].[id] = ?
AND NOT ([my_table].[id] = ? )) (1, 1)
This happens when calling is_valid() on a formset created the following way:
MyFormSet = modelformset_factory(Table, fields=['my_field'], extra=0)
my_form_set = MyFormSet(request.POST...
I have the following django model:
RESOURCE_DIR = os.path.join(settings.MEDIA_ROOT, 'resources')
class Resource(models.Model):
title = models.CharField(max_length=255)
file_name = models.FilePathField(path=RESOURCE_DIR, recursive=True)
and I want to give the URL to the file in a template so that the user can view it or downlo...
I allow users to submit a query at mysite.com/go/QUERY\
If the query contains "/" Apache chokes.
From urls.py:
(r'^go/(?P<querytext>.*)$', 'mysite.engine.views.go'),
Try:
http://mysite.com/go/http%3A%2F%2F
Result:
Not Found
The requested URL /go/http:// was not found on this server.
Apache/2.2.12 (Ubuntu) Server at ...
BUT, ...
Say I do something like this in a python shell for my Django app:
>>>from myapp.models import User
>>>user = User.objects.get(pk=5)
>>>groups = user.groups.all()
What I'd like to do is stash these 3 commands somehow without leaving the shell. The goal being I can quickly restore a similar environment if I restart the shell session lat...
I have a Django app. When logged in as an admin user, I want to be able to pass a secret parameter in the URL and have the whole site behave as if I were another user.
Let's say I have the URL /my-profile/ which shows the currently logged in user's profile. I want to be able to do something like /my-profile/?__user_id=123 and have the u...
How can this be that this error was raised? I entered this:
def json(self):
return json.dumps(
{
'items': self.items
}
)
and got that error (because self.items was an empty queryset (Django)
but then,
def json(self):
return json.dumps(
{
'items': [] # Pass in empty list to...
Greetings,
Assume I have such model:
class Foo(models.Model):
type = models.ForeignKey(Type)
start_time = models.DateTimeField()
end_time models.DateTimeField()
For each Foo object that is having the same type, I need this time interval (end_time - start_time) to be unique so that creation of a second Foo with a clashing ...
My Django app, deployed in mod_wsgi under Apache using Django's standard WSGIHandler, authenticates users via form login on the Django side. So to Apache, the user is anonymous. This makes the Apache access log less useful.
Is there a way to pass the username back through the WSGI wrapper to Apache after handling the request, so that it...
I'm finding myself always passing a 'user' variable to every call to render_to_response
A lot of my renders looks like this
return render_to_response('some/template', {'my':context,'user':user})
Is there a way to automatically send this 'user' variable without manually adding it to the context each time a method is called?
...
Hay guys, I've wrote a simple upload method for my pictures
class Picture(models.Model):
path = models.CharField(max_length=200)
filename = models.CharField(max_length=200)
car = models.ForeignKey('Car')
thumb_path = models.CharField(max_length=200)
created_on = models.DateField(auto_now_add=True)
updated_on = mo...
I'm creating a new model called Tickets which I want to ensure always has a valid userID assigned to it.
I'm using AUTH_PROFILE_MODULE to setup the profile which also gives the error NameError: name 'User' is not defined when I try to run syndb.
How do I setup a foreign key to make sure this always is the case?
## tickets/models.py
c...
Just installed fabric, trying to use to same fabfile that works on a different server, getting this error here:
Traceback (most recent call last):
File "/var/lib/python-support/python2.6/fabric.py", line 1211, in main
load(fabfile, fail='warn')
File "/var/lib/python-support/python2.6/fabric.py", line 467, in load
execfile(fi...
Is there any (X)HTML to BBCode coverter python module out there?
I'd like to migrate my website forum from markdown to BBCode but I didn't found out any simple way. One option is to convert the markdown text to (X)HTML using the built in django markup module and then convert it again to BBCode. Well, I realized that find a (X)HTML to BB...
Because of the way Eventlet, which Spawning depends on, installs itself, it can't be installed into a virtualenv. The following error (wrapped for readability) illustrates:
Running eventlet-0.9.4/setup.py -q bdist_egg --dist-dir \
/tmp/easy_install-m_s75o/eventlet-0.9.4/egg-dist-tmp-fAZK_u
error: SandboxViolation: chmod('/home/myuser/...
Hello,
Is there a way in Django to group some fields from a ModelForm? For example, if there's a model with fields like: age, gender, dob, q1, q2, q3 and a form is created based in such Model, can I group the fields like: info_fields = (age, gender, dob) and response_fields = (q1, q2, q3). This would be helpful to display all fields in ...
Hay guys, I'm using an ImageField to upload files, however when i add upload_to to the ImageField it doesnt append the directory to the MEDIA_ROOT
MEDIA_ROOT = '/Users/username/Django/site/assests/'
picture = models.ImageField(upload_to='uploads')
i get an error saying
No such file or directory: u'/Users/username/Django/site/assest...
for
django.contrib.auth.User and django.contrib.auth.Group
i am doing like this
for g in request.user.groups:
l.append(g.name)
Got an error
TypeError at /
'ManyRelatedManager' object is not iterable
Request Method: GET
Request URL: http://localhost:8000/
Exception Type: TypeError
Exception Value:
'ManyRelatedManager'...
I have inserted a definition for a view in $template_dir/sql/$someTableName.sql file. (create or replace view) so every time I run syncdb, the db views are created.
Can I create in models.py a python class which accesses that view?
Is it better practice to just use python's raw sql functionality instead?
---EDIT---
Another problem I ...