Let's say I'm using the default auth.models.User plus my custom Profile and Address models which look like this:
class Profile(models.Model):
user = models.OneToOneField(User)
primary_phone = models.CharField(max_length=20)
address = models.ForeignKey(Address)
class Address(models.Model):
country = CountryField(default=...
What's the name of the widget that we use to assign user permission in admin page (under the "add users" option)?
How can I use it for other things?
...
My primary navigation consists of news categories, which belong to the Category model. I hardcoded the nav in templates/base.html but want to make it dynamic...
Is it a bad idea to embed model code in my template? If so how should I pull them? Should I make the nav file separate? And not only will I just rely on the categories, but I al...
Basically, I misread this but would still really appreciate some assurance. I recently came across the django tutorial (http://djangotutorial.com) and have fell in love with the framework. I have a website that is simply ran on wordpress and a simple plugin at the moment at http://runningshoesreview.org.
I've been wanting to do many th...
Short version: How do you deploy your Django servers? What application server, front-end (if any, and by front-end I mean reverse proxy), and OS do you run it on? Any input would be greatly appreciated, I'm quite a novice when it comes to Python and even more as a server administrator.
Long version:
I'm migrating between server hosts, s...
Hi all,
Would it be possible/best practice to use 1 FormWizard for manipulating multiple models?
I've experimented with the FormWizard and have defined all the forms. The page 'flow' itself works like a charm. However with all the checks that need to be done and Models that are manipulated it feels like I'm sticking code in the form's...
Hi All,
So im wanting to extend the django auth.User model to add extra fields. Ive read a few articles here and there, and am almost there.
Im just trying to make the signup form at the moment. So a new user can sign up. I can get the new User created but when I come to save the UserProfile object to the database it fails citing
Cann...
Hello,
I have a Promotion model that contains a promotion codes and a foreignkey to a purchase model Class.
Here is the model:
class Promotion(models.Model):
purchase = models.ForeignKey('Purchase')
promotion_code = models.CharField(max_length=20)
def promotion_code_generate(self): #returns a string based promotion code with 7 leng...
Hello,
I want to set the "default" value as a randomly generated String for the promotion_code part of my Promotion model, for that the code_generate function is used.
The issue with the code below that it seems like default=code_generate() generates this random string once every server start thus assigning the same value. I can see th...
Someone has probably already developed a technique for relieving the tedium for the following idiomatic unit test:
GET a url with form data already populated
POST a revised form with one or more fields edited
Check response (profit!)
Step 2 is the most tedious, cycling through the form fields. Are there any time-saving hacks for tes...
I'm using django-tinymce in my Django website. Through the admin interface one can edit a SimplePage object which has a tinymce.models.HTMLField. The website visitor will then see the html rendered in the content area of the page.
Problem is, the website itself has a dark background, and the TinyMCE textarea has a white one. By default ...
I have a simple form
class MyForm(forms.Form):
...
fieldname = forms.CharField(help_text="Some help text")
I can then display this form with django's handy {{ form.as_ul }} if I like, now I need to stylise the help_text and I have no idea how. Django doesn't appear to wrap that string in anything that will let my CSS get to i...
I have Users which can be either TypeS, TypeC, or TypeA. I have models for each of these types to store additional information. Now, in the Users table, should I have
3 nullable foreign-key fields to designate which type they are
2 fields, 1 with the name of the type and 1 with the foreign key
1 field designating the type with the for...
My applet runs file when I call it from a static applet.html file, like this:
<applet archive="applet.jar" code="com.xxx.yyy.PApplet"
width="100" height="20"></applet>
But how do I put the same line in a django template? And where should I put the .jar and .java files? I also noticed that it appends .class to the PApplet while lo...
I want my app to throw an MemoryError when its usage goes over 1GB. I'm running in WSGI daemon mode.
I see 3 places the memory limit could be:
apache.conf
wsgi somewhere
django configuration
but I can't find the right config options. In PHP you can do this with :
php_value memory_limit 1GB
in your apache.conf
...
I am storing my templates in the database and I don't have any path to provide for the template.render method.
Is there any exposed method which accepts the template as a string?
Is there any workaround?
...
I am quite new to Django, so it may be a stupid question, but, nevertheless:
I need Django admin part to edit contents on the site, and also I want to have authentification, that will allow registred users to leave comments.
I have the following idea of implementation it: have 2 different tables(admins and other registred users) and us...
Revised question:
In my dbms, I'm storing the literal <<<firefox-image>>>, I confirmed in Navicat and Mysql CLI that its <<<firefox-image>>>. When I use the Python shell and try to grab the same article entry, the outer <>'s get converted to < and <, respectively.
Snippet of me testing:
>>> entry = Entry.objects.filter( pub_dat...
TinyMCE is working just fine, all except for the popup windows. They come up blank, and after a little bit of Google searching, apparently it has something to do with cross domain errors with Firefox and Django. I tried using document.domain, but I have a feeling that it doesn't work when you're using the Django development server (http:...
Can't seem to get sorl.thumnail to create thumbnails. It just creates empty files.
Say, tried uploading 3.gif, the original file gets uploaded fine, thumbnail does not created, it creates a file with 0 bytes:
-rwxrwxrwx 1 www-data www-data 14128 2010-02-13 06:57 3.gif
-rwxrwxrwx 1 www-data www-data 0 2010-02-13 06:57 3_gif_200x200...