Re: point url with folder to s3
On Mon, Nov 14, 2011 at 8:47 AM, ydjango wrote: > I have all my static being served from https://www.example.com/media/ > > in my code I have all images pointing to /media all over the code. > for example: > > Is there a way I can point it to use S3 and cloudfront to serve the > static files. > > My understanding is that I cannot use CNAME. If I was using > media.example.com instead of www.example.com/media, I could have used > CNAME. > > Any other solution? (without requiring me to change all the instances > of /media in all my code) > > I use nginx and apache and django 1.1.x. (I will be upgrading Django > soon if ORM performance does not become an issue.) > If updating the code is out of the question, then why not put a redirect into the apache or nginx conf, something along the lines of (untested, for nginx. Look up modrewrite to do this in your apache conf): server { listen 80; server_name www.example.com; rewrite /media/(.*) http://domain.of.external.media.com/path/to/media/$1 permanent; # the rest of your nginx conf here } And then take your time to replace references to /media in your code, because you really should anyway. You should probably be using a variable in your code for media location in the future, so you only have to change /media once. Isn't there a variable in the settings explicitly for the url of static media? ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Custom User Model, Django Admin, and the password field
Hi, I've created a custom user model in my application by subclassing django.contrib.auth.models.User. This user model is working, but there are a couple of problems I have with it. 1) The change password link in the admin site doesn't work? 2) The default password box on the add/edit page for a user is a little unfriendly. Ideally, what I'd like is the two password fields from the change password form on the add/edit user form in the admin, which will automatically turn convert the entered password into a valid encrypted password in Django. This would make the admin system MUCH friendlier and much more suited to my needs, as a fair number of user accounts will be created and maintained manually in this app, and the person responsible for doing so will likely be scared off at the sight of that admin field, or just type a clear text password and wonder why it doesn't work. Is this possible / How do I do this? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: can any on help me how to create a sample model project.
On Wed, Dec 16, 2009 at 5:53 AM, chiranjeevi muttoju wrote: > hi as i said that i had installed the mysql in other machine. when i > installing the python-mysql connector using the command > python setup.py build > At a wild guess, not knowing what you've got installed already, sounds like you don't have the mysql client libraries installed. In ubuntu that would be sudo apt-get install libmysqlclient15-dev Not sure on the name of the corresponding red hat package. ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: FK to an Abstract class? Alternative?
On Wed, Dec 16, 2009 at 5:21 AM, Victor Hooi wrote: > class ExaminationRecord(models.Model): > assessment = models.OneToOneField(AssessmentTask) I don't particularly understand the point of this class? ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Initial snag with the "Django Book"
On Thu, Dec 17, 2009 at 12:26 PM, nodxof wrote: > I've just started learning django using "The Definitive Guide to > django" second edition. > > Going by the initial example in Chapter 3 I get this. > > Page not found (404) > Request Method: GET > Request URL: http://127.0.0.1:8000/ > Using the URLconf defined in mysite.urls, Django tried these URL > patterns, in this order: > ^hello/$ > The current URL, , didn't match any of these. At a guess based on the line "The current URL, ,", did you try to browse to http://127.0.0.1:8000/hello/ or http://127.0.0.1:8000/ ? (hint: http://127.0.0.1:8000/hello/ should work.) ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Custom Django-Admin commands
Hi all, I've written a custom command to use with manage.py, and from the root of the project directory, it works great. But the problem is, this command is almost never going to be called from within the project directory. (hoping the spacing doesn't get too mangled when I send this) /home/ user/ <- ""/home/user/proj/manage.py custom" command doesn't exist. proj/ <- "/home/user/proj/manage.py custom" works manage.py app/ management/ commands/ custom.py Is there something I'm missing? ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Custom Django-Admin commands
On Tue, Dec 22, 2009 at 12:16 PM, Doug Blank wrote: > > You probably just need to set your PYTHONPATH: > > cd /home/user > PYTHONPATH=proj python proj/manage.py custom > That was my initial thought too, however setting the PYTHONPATH does not affect the behaviour in this instance. ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Custom Django-Admin commands
On Tue, Dec 22, 2009 at 3:51 PM, Alex_Gaynor wrote: > > Do you have __init__.py files in each of those directories? Of course - Else it woud not work from the project's root directory either. ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Custom Django-Admin commands
I'm at a loss as to understand why, but I've worked out what I need to add to pythonpath. PYTHONPATH=/home/user i.e. The pythonpath needs to include NOT the project's root, but the directory one level ABOVE that for custom commands to work properly... Thanks for the help guys. ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Custom Django-Admin commands
On Tue, Dec 22, 2009 at 3:24 PM, Bill Freeman wrote: > If you are calling this from, for example, crontab note that each line > in crontab is executed in its own subshell, so you have the choice of > setting PYTHONPATH, or (my personal favorite because it works with so > many kinds of scripts) you can cd to the project directory and execute > the script as ./manage.py custom, by separating the cd and ./manage.py > with a semicolon. Too, if you are doing this from a bash (or sh or, > probably, csh) script, commands run inside parentheses run in a sub > shell, so you can do the cd, semi, manage trick, and when the subshell > exits, the rest of your script is still running in its original > directory. Finally, if this is a command line utility that you want > to run from wherever and just have on the path, create a sh (or bash) > script that cd's and runs it instead, and put that on the path. This > last works on windows too, using bat files (or whatever the cmd.exe > equivalent is). > Thanks Bill, I'd considered that route, but ultimately, I had a puzzle that needed solving. =) ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Django Tutorial 1.1: Viewing SQLite3 tables
On Fri, Jan 8, 2010 at 10:50 AM, wormser17 wrote: > mlooby$ sqlite3 > SQLite version 3.6.12 > Enter ".help" for instructions > Enter SQL statements terminated with a ";" > sqlite> .schema > sqlite> .schema; > unknown command or invalid arguments: "schema;". Enter ".help" for > help > sqlite> .schema project.db > sqlite> .schema project > sqlite> .schema project; > sqlite> Try this: $ sqlite3 /path/to/db ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: why does if statement fail with
On Fri, Jan 8, 2010 at 1:25 PM, Biju Varghese wrote: > if statement in template language checks only whether the variable is > empty or not... > comparison can be done with other variants of if such as ifequals > ifnotequal etc... > OP is using django 1.2. http://docs.djangoproject.com/en/dev/releases/1.2-alpha-1/#smart-if-tag ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Re: Namespace Security
I had a similar requirement for a current project. Users in the admin needed to be able to see ONLY the objects that they had created. My solution was: 1) http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser 2) Add foreign key to model to track which user created the object. 3) Use the ThreadLocals trick with a custom save() to set the user (Objects created via command line get assigned the first superuser in the DB) 4) A smart manager that is now aware of the current logged in user thanks to the ThreadLocals middleware and can use that to limit requests. (displaying all if superuser, or if run using python manage.py shell) I'm sure this approach could be expanded to use namespaces/groups instead of user on the model's foreign key. To my mind at least, it's a little easier to follow what's going on than overriding various methods in admin.py ~Justin -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.