I have an ec2 instance running Ubuntu 14.04 and I want to host two sites from it. On my first site I have two settings file, production_settings.py and settings.py (for local development). I import the local settings into the production settings and override any settings with the production settings file.
Since my production settings file is not the default settings.py name, I have to create an environment variable
DJANGO_SETTINGS_MODULE='site1.production_settings'
However because of this whenever I try to start my second site it says
No module named site1.production_settings
I am assuming that this is due to me setting the environment variable. Another problem is that I won't be able to use different settings file for different sites.
How do I start use two different settings file for two different websites?
OK, so let me give you an overview first. I have this site and in it there is a form section. When you access that section you can view or start a new project. Each project has 3-5 different forms.
My problem is that I don't want viewers to have to go through all 3-5 pages to see the relevant information they need. Instead I want to give each project a main page where all the essential data entered into the forms is shown as non-editable data. I hope this makes sense.
So I need to find a way to access all that data from the different forms for each project and to feed that data into the new page I'll be calling "Main". Each project will have a separate main page for itself.
I'm pretty much clueless as to how I should do this, so any help at all would be appreciated.
Thanks
Hi
I want to install osqa on windows local system for this i have downloaded bitnami-djangostack-1.1.1-2-windows-installer.exe which has in built django,python,mysql & apache.
I have run a django example given on the django website. Its working fine.
But i am confused how to install osqa. I have downloaded the source code available on osqa site and readed the installation instruction(requires django 1.1.1).
But how to make it working?
Please help me on this
Thanks
I've seen a few examples defining choice fields like so:
COUNTRIES = (
('fr', _('France')),
('de', _('Germany')),
...
)
(source: http://code.djangoproject.com/ticket/5446
Also see: http://djangosnippets.org/snippets/494/)
What is the meaning of the leading underscores? And why is the second value in the tuple even parenthesized?
Hello, newbie here.
i have a local Postgre database which will be filled with data (daily) on my local development machine. What is a good solution to transfer/sync/mirror this data to a production postgre database.
For what it's worth I'm developing in Python using Dajngo.
Thanks!
I have code written both ways and I see flaws in both of them. Is there another way to write this or is one approach more "correct" than the other?
def functionOne(subscriber):
try:
results = MyModelObject.objects.filter(
project__id=1,
status=MyModelObject.STATUS.accepted,
subscriber=subscriber).values_list(
'project_id',
flat=True).order_by('-created_on')
except:
pass
def functionOne(subscriber):
try:
results = MyModelObject.objects.filter(
project__id=1,
status=MyModelObject.STATUS.accepted,
subscriber=subscriber)
results = results.values_list('project_id', flat=True)
results = results.order_by('-created_on')
except:
pass
I'm building a website that doesn't require a database because a REST API "is the database". (Except you don't want to be putting site-specific things in there, since the API is used by mostly mobile clients)
However there's a few things that normally would be put in a database, for example the "jobs" page. You have master list view, and the detail views for each job, and it should be easy to add new job entries. (not necessarily via a CMS, but that would be awesome)
e.g. example.com/careers/ and example.com/careers/77/
I could just hardcode this stuff in templates, but that's no DRY- you have to update the master template and the detail template every time.
What do you guys think? Maybe a YAML file? Or any better ideas?
Thx
my form is
class MapForm(forms.ModelForm):
class Meta:
model = Map
fields = ('mapName', 'kmlStr')
and the view is :
map_form = MapForm(request.POST or None)
if map_form.is_valid():
map = map_form.save(commit=False)
map.mapName=map_form.mapName#is thie code right ?
how to get the mapName 's value , us 'map_form.mapName' ?
thanks
Hi,
How can I fix number of concurrent sessions allowed at app level?
Basically I want a limit to how many concurrent requests to this url to keep the server from getting congested.
I guess some middleware hack?
Thanks.
Suppose this is my URL route:
(r'^test/?$','hello.life.views.test'),
How do I make it so that people can do .json, .xml, and it would pass a variable to my views.test, so that I know to make json or xml?
MYMESSAGE = "<div>Hello</div><p></p>Hello"
send_mail("testing",MYMESSAGE,"[email protected]",['[email protected]'],fail_silently=False)
However, this message doesn't get the HTML mime type when it is sent. In my outlook, I see the code...
For formatting a date using date filter you must use the following format :
{{ my_date|date:"Y-m-d" }}
If you use strftime from the standard datetime, you have to use the following :
my_date.strftime("%Y-%m-%d")
So my question is ... isn't it ugly (I guess it is because of the % that is used also for tags, and therefore is escaped or something) ?
But that's not the main question ... I would like to use the same DATE_FORMAT parametrized in settings.py all over the project, but it therefore seems that I cannot ! Is there a work around (for example a filter that removes the % after the date has been formatted like {{ my_date|date|dream_filter }}, because if I just use DATE_FORMAT = "%Y-%m-%d" I got something like %2001-%6-%12)?
I am trying to set up Google App Engine unit testing for my web application. I downloaded the file from here.
I followed the instructions in the readmen by copying the directory gaeunit into the directory with the rest of my apps and registering 'gaeunit' in settings.py. This didn't seem sufficient to actually get things going. I also stuck url('^test(.*)', include('gaeunit.urls')) into my urls.py file.
When I go to the url http://localhost:8000/test, I get the following error:
[Errno 2] No such file or directory: '../../gaeunit/test'
Any suggestions? I'm not sure what I've done wrong. Thanks!
I'd like everything to function correctly, except when it's mobile, the entire site will used a set of specific templates.
Also, I'd like to autodetect if it's mobile. If so, then use that set of templates throughout the entire site.
I have a handful of users on a server. After updating the site, they don't see the new pages. Is there a way to globally force their browsers and providers to display the new page? Maybe from settings.py? I see there are decorators that look like they do this on a function level.
I have a model called Page, which has a property called Content of type EditableContent. EditableContent have SidebarLeft and SidebarRight (type TemplateSection).
I want to edit the Page instance, in my Edit.aspx view. Because EditableContent is also attached to other models, I have a PartialView called ContentEditor.ascx that is strongly typed and takes an instance of EditableContent and renders it.
The rendering part all works fine, but when I post - everything inside my ContentEditor is not binded - which means that Page.Content is null.
On the PartialView, I use the strongly typed Html Helpers to do this:
<%= Html.HiddenFor(m => m.TemplateId) %>
And so on. But because the input elements on the form, rendered by ContentEditor.ascx, does not get the "Content" prefix to its id attribute - the values are not binded to Page.
So to overcome this, I've definitely done the wrong thing. Used loosely typed Html Helpers instead:
<%= Html.Hidden("Content.TemplateId", Model.TemplateId) %>
And when I'm dealing with a property that is a List of something it gets very ugly. I then have to render collection indexes manually... doh
What am I missing here? A BindPrefix in the controller action that the Form is being posted to?
Should I put both Page and EditableContent as parameters to the controller action:
public ActionResult Edit(Page page, EditableContent content) { ... }
Any help is much appreciated!