This may sound like a stupid question, since the very purpose of virtualenv is to this exactly: Installing some specific version of a package (in this case Django) inside the virtual environment. But it's exactly what I want to do, and I can't figure it out.
I'm on Windows XP, and I created the virtual environment successfully, and I'm ...
Background:
When I run the django-admin.py loaddata example.json I get this error. "ImportError: Settings cannot be imported, because environment variable DJANGO_SETTINGS_MODULE is undefined." I understand the problem. It needs the DJANGO_SETTINGS_MODULE to be able to access the database to do this import. I've had this problem before a...
I have a models.py class as below
class Educational_Qualification(models.Model):
user = models.ForeignKey(User)
exam = models.CharField(max_length=40)
pass_month = models.CharField(max_length=40)
I have a views.py as below
def create_qualification(request):
QFormSet = modelformset_factory(Educational_Qualification, extra=3,...
Hello
I;m having a problem in calling a function that returns a result, from another function
To make it clear, my functiona are:
def calculate_questions_vote(request):
useranswer = Answer.objects.filter (answer_by = request.user)
positive_votes = VoteUpAnswer.objects.filter(answer = useranswer)
negative_votes = VoteDownAns...
Been banging my head on this for a while and I've read a bunch of articles and the issue isn't any clearer. I have a bunch of strings stored in my database, imagine the following:
x = '\xd0\xa4'
y = '\x92'
At the Python shell I get the following:
print x
Ф
print y
?
Which is exactly what I want to see. However then there is the fol...
i;m trying to iterate through some values, and calculate a rank. i have a calculate_rank function where i calculate a sum of values. The problem is at the second function. I want that a user's rank to be the sum of all the user that in a follow relation with him.
I am doing an iteration in the second function here where i try to add the...
Ok! I have this model:
class my(models.Model):
name = models.TextField()
description = models.TextField()
created = models.DateTimeField()
def __unicode__(self):
return self.name
I'm gettin data to this model from mssql database and saving it. Something like this.
mysql_name='somedata' #this data come...
I have a common data {the logged-in user's message number) to display on every page. I can simply pass to template as
dict={'messagenumber':5}
return render_to_response('template.html',dict,context_instance=RequestContext(request))
But it looks tedious if i have this dict data pass to very page. Is there an easier way to pass common d...
Since Django 1.2.1 'prepopulated_fields' won't prepopulate in the admin.
prepopulated_fields = {'slug': ('title',)} doesn't seem to work since uploading to a Django 1.2.1 server after developing on a 1.1.1.
What changed?
I read http://code.djangoproject.com/wiki/NewformsAdminBranch#Changedprepopulate_fromtobedefinedintheAdminclassnot...
I'm finding conflicting information on whether to use OneToOneField(User) or ForeignKey(User, unique=True) when creating a UserProfile model by extending the Django User model.
Is it better to use this?:
class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
or this?:
class UserProfile(models.Model):
us...
I have a fairly basic dialog maker for jquery that works in 2 out of 3 places. In the 3rd instance where I try to use it, the fields in the form are disabled once the dialog is displayed.
The general concept behind the code is that the form is on a different page of the website, and for convenience, when javascript is enabled, you can ...
What is the difference between
mymodel=model.objects.get(name='pol')
and
mymodel=model.objects.filter(name='pol')
...
This is what I am currently using for registration:
def register(request):
if request.method == 'POST':
form = UserCreationForm(request.POST)
if form.is_valid():
new_user = form.save()
messages.info(request, "Thanks for registering. Please login to continue.")
return HttpResponseRe...
I have a model that contains a foreign key value, then in the form generated from this model as a ModelChoiceField. I want to auto select the user's (update_author).
I've tried the below code, using the initial property.
The view creates a formset with the the dates initialized to now() for the empty form. But, I want also the update_au...
I have downloaded django and have followed the instructions to deploy my first website:
In the docs, it says:
"Now that the server's running, visit http://127.0.0.1:8000/ with your Web browser. You'll see a "Welcome to Django" page, in pleasant, light-blue pastel. It worked!"
The problem is that I am not running the website locally, i...
Could someone show me how i could write a login decorator like @redirect_to_home for my views so that it modifies the request.PATH variable to a new a value like / whenever it is applied to a view.
I've seen people do quite complex stuff with decorators: I'm yet to figure them out thoroughly.
Thanks
...
I've got a model like this:
class MyModel(models.Model):
name = models.CharField(max_length=255)
code = models.FileField()
When a new MyModel is submitted, I want to allow for the code field to be left empty, in which case I need Django to create an empty file (with arbitrary name).
Question is: what is the right way to do it...
I need to add event calendar functionality to my application, and I'm wondering what do you think is the best way to do it ? Are there any interesting projects providing the needed functionality ? A snippet : http://djangosnippets.org/snippets/129/ ? Write it on my own ?
...
I using Django and a generic view "django.views.generic.create_update.create_object"
I have a model form wich i pass to the generic view:
url(r'^add$', create_object, {'template_name':'tpl.html','form_class':MyModelForm,'post_save_redirect':'/'},name = 'add'),
I need to get current user in my ModelForm.save method..
But i can't find w...
I'm spitting out my categories tree like so:
<div id="categories-tree">
{% load mptt_tags %}
{% full_tree_for_model bugs.Category as cats cumalative count bugs.Bug.categories %}
{% for node, structure in cats|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
<a href="/categories/{{node.slug}}">{{ node }...