This question is related to this one
http://stackoverflow.com/questions/3340498/remove-all-the-elements-in-a-foreign-key-select-field
I had a foreign key field in my model which was getting pre-populated by its data and I wanted the select list to be empty. I did achieve that but the validation fails when I submit the form.
The error ...
I set up Mysql5, mysql5-server and py26-mysql using Macports. I then started the mysql server and was able to start the prompt with mysql5
In my settings.py i changed database_engine to "mysql" and put "dev.db" in database_name.
I left the username and password blank as the database doesnt exist yet.
When I ran python manage.py syncdb...
I'm new to Python & Django. I want to allow users to create new objects, and for each object to be related to the currently logged in user. So, I thought I'd use the generic create_object method - only I can't work out how best to do this so it's simple and secure.
Here's my model:
class Book(models.Model):
user = models.ForeignKey...
I am using Postgres as DBMS and Django.
My model that defines the table is:
class TtnetModem(models.Model):
ttnetModemSerino=models.CharField(_(u"Seri No"), max_length=20, default='', null=True, blank=True)
I change field definition...
ttnetModemSerino=models.CharField(_(u"Seri No"), max_length=20, unique= True)
on postgres, i ex...
In my admin.py i have:
class SayfaAdmin(admin.ModelAdmin):
def queryset(self, request):
qs = super(SayfaAdmin, self).queryset(request)
....
But, insteead of defining same queryset function, i wish to write a function which will be called within admin class and returns the result so, instead of writing something as ...
Hi guys, my problem is simple. Where the right place for a custom error_css_class value is when using ModelForm?
I tried this:
class ToolForm(ModelForm):
error_css_class = 'wrong_list'
class Meta:
model = Tool
widgets = {
'name' : TextInput(attrs={'class': 'small_input corners'}),
'description' : T...
How can auth can be configured or modified to disallow user sessions if the user's IP is not the same IP that he logged in with ?
I really try to protect my Django site from XSS as much as I can. But I never can be sure that I covered all the bases. If worst comes to worst and someone is able to put some XSS in my site, at least this cou...
I have a project w/ multiple apps. I am attempting to use the dumpdata command to create a fixture for each app. Calling dumpdata on a given app seems to work well.
This prints the data to the console:
python manage.py dumpdata myapp
However, when I attempt to create a json file containing the dumped data:
python manage.py dumpdat...
In a Django application I need to create an order number which looks like: yyyymmddnnnn in which yyyy=year, mm=month, dd=day and nnnn is a number between 1 and 9999.
I thought I could use a PostgreSQL sequence since the generated numbers are atomic, so I can be sure when the process gets a number that number is unique.
So I created a P...
Please advice whether is it correct method to change the urlconf and templatedir variables of a django settings file dynamically within a custom middleware function based on the site requested.
...
I'm using feincms in a django project and I want to use manage.py dumpdata but I get nothing:
python manage.py dumpdata feincms
[]
...
Dears
I have a django model as following
class Project(models.Model)
name=models.CharField(max_length=200)
class Application(models.Model)
proj=models.ForeignKey(Project, null=True, blank=True)
I need to modify the admin form of the project to be able to assign multiple applications to the project, so in the admin.py I ...
Hi,
I'm using app engine patch for an application on app engine. I have a model formset which works great for editing objects, but I can't use it for adding objects because I can't create an empty formset.
I want the user to be able to add multiple records at once, which I was I am using formsets.
In django, to create an empty formse...
I'm trying to think of a way to place Flash content into a blog post so that it appears inline between paragraphs. I'm writing a custom weblog application in Django (still learning) and I'll be using SWFObject for the embedding.
The blog is for me only so the back-end isn't too fancy. I'm simply using Django's built in admin interface....
I have a project coming up for client who is basically happy with how he manages his website. It's lots of HTML files (around 300 of them) that he insists on keeping flat HTML files so can easily edit and manage them using Dreamweaver. His site has a lot of traffic and so I'm looking into options of keeping things simple for him. He does...
Hello Experts. I have a prob. I'm trying to create a custom slugify functiom. I use django.autoslug. Due to autoslug documentation I was able to create a custom slugifier, but it needs to be improved and I do not know how do I realize that.
So I have a string (book title) i.e. .NET Framework 4.0 with C# & VB in VisualStudio 2010. I want...
Hi all, I have a question regarding the use of Python.
How do i run a command line command using Python? And after running the command,
how do i save the returned values?
For example:
user@home:~$: ls -l
drwxr-xr-x 3 root root 4096 ..[etc] home
-rw-r--r-- 1 user user 357 ..[etc] examples.doc
So what i intend to do, is to run the co...
Hi all,
I have a problem with the extra() method of queryset.
So, i retrieve my objects with :
invoices = Invoice.objects.select_related().filter(quantity__gt=0,begin__gte=values['start_day'],end__lte=values['end_day'])
So it works, I have my invoices.
After i use another time filter() :
invoices = invoices.filter(max__gte=duration...
Hello,
I'm trying to display the latest 5 posts using a generic view like this:
urlpatterns = patterns('',
(r'^$', 'django.views.generic.date_based.archive_index',
{
'queryset': Post.objects.all()[:5],
'date_field': 'created_on',
'template_name': 'index.html'}
})
However I am getting
AssertionError at...
Hello, I've searched similar topics but haven't found what I need..
I extended Users model with UserAttributes model, some additional fields added and etc.. now I'm trying to make ModelForm out this.. so I have a little problem in here..
I WANT TO list groups as a ChoiceField not a MultipleChoiceField.. It's a requirement by specifica...