Symfony 1.4 don't load sfFormExtraPlugin on production server |
What is the actual issue ? symfony Modules or JS files not loaded ?
Maybe you forgot to publish the plugin assets ?
Have you tried
php symfony plugin:publish-assets
|
Django Path Issues - failing to import module on admin screen load |
Assuming the .bash_profile you posted is from your home directory, and
you're running apache in the usual way, i.e. as a daemon process started by
user root and forking children as user www-data or apache or somesuch, then
the PYTHONPATH won't apply to the apache process, so you'll have to
configure it separately.
If you're using mod_wsgi, then you can add the following apache directive
to your webserver config...
WSGIPythonPath
$HOME/virtual/lib/python2.7/site-packages:$HOME/website/project
...ensuring you substitute $HOME for the full, absolute pathname to your
home directory, since it won't be the same for the apache user.
Update
According to the guide, you should have created a file
~/public_html/dispatch.fcgi, containing something like...
#!/usr/local/bin/python2.6
import sy
|
my django admin page don't have the css when viewed over the apache server |
Tell Django where to find the static files (if you have not already).
First, make sure you have STATIC_ROOT and STATIC_URL set correctly in
`settings.py', and then on your live server simply run the following
command.
python manage.py collectstatic
This will collect all static files necessary for the admin to render
correctly.
When running the development server (runserver) static files are
automatically found using STATICFILES_FINDERS, but in production this is
not the case, in-fact STATICFILES_FINDERS does somethine else in
production, it finds and collects the files after `running python manage.py
collectstatic ' they are then served in your case by Apache.
|
Dynamically load stylesheets |
You can add/remove/edit link tags in your head area with java script to
add/remove stylesheet files.
Code example:
Add a stylesheet to the head:
var newstyle = document.createElement("link"); // Create a new link Tag
// Set some attributes:
newstyle.setAttribute("rel", "stylesheet");
newstyle.setAttribute("type", "text/css");
newstyle.setAttribute("href", "filename.css"); // Your .css File
document.getElementsByTagName("head")[0].appendChild(newstyle);
To remove or edit a stylesheet you can give every stylesheet an id
attribute and access it with this:
document.getElementById('styleid')
Or you can loop through all link tags in the head area and find the correct
one but I suggest the solution with the ID ;)
Now you can change the href attribute:
document.getElementById('styleid').
|
How to find which admin logged in django admin site? |
Using formfield for choice field One can do this
def formfield_for_choice_field(self, db_field, request, **kwargs):
if db_field.name == "user_type":
kwargs['choices'] = (
(1, 'ADMIN'),
(0, 'USER'),
)
if request.user.is_superuser:
kwargs['choices'] += ((2, 'SUPER ADMIN'),)
return super(UserProfileAdmin,
self).formfield_for_choice_field(db_field, request, **kwargs)
|
Rails Active Admin Coffescript not compiling in production |
Running bundle exec rake assets:precompile should place your assets in
public/assets/ directory.
Change config.serve_static_assets to true in your
config/environments/production.rb:
config.serve_static_assets = true
Then restart your rails server.
Update:
Change config.assets.compile to true in config/environments/production.rb
to let Sprockets handle the assets in pipeline. See "Live Compilation".
|
How can I order the native django users in the django admin page based on creation time? |
Shouldn't it just be:
ordering = ['-date_joined']
You can order by any field the model gives you.
Since you didn't specify the UserModel you are using, I guess you are
talking about the BaseUser?
If so, you can order by:
first_name
last_name
id
email
date_joined
username
[is_staff] # bool
[is_active] # bool
|
Intelligently enabling django.jQery everywhere in Django admin site |
You can redefine admin base template to look like this:
... some lines before...
<script type="text/javascript">window.__admin_media_prefix__ = "{%
filter escapejs %}{% static "admin/" %}{% endfilter %}";</script>
{% block extrahead %}{% endblock %}
<INCLUDE YOUR JQUERY HERE>
{% block blockbots %}<meta name="robots" content="NONE,NOARCHIVE"
/>{% endblock %}
... all other lines ...
In this case, you include the jquery you want and, as it is included always
after the default admin scripts, admin site is going to be using the jquery
you included...
Hope it helps!
|
Django - admin.py for multiple apps in a single django project |
@i.h4d35 I think DivinusVox is right. Try to add your new app in
INSTALLED_APPS in the settings.py and it should be solved. Please check
admin info from Django official website.
|
Django : Storing user steps with django admin form |
Django form wizard is what you want.
You can use SessionWizardView for more easily display the wizard when user
comes back again.
|
django make available few of the django admin forms to the users at a different url |
When you create a User, you can give different access to any part of your
app in the user permission tab. This mechanism should do what you want.
If you want to go further and play with the display of your app while
keeping something similar to the django admin, you can use the templates of
django admin in a view in order to give access to only a part of your model
and add more design and custom functions.
In this case, I'll suggest you to make a copy of the templates located in
djangocontribadmin emplatesadmin and then you can modifiy them as you want.
|
django admin django.contrib.staticfiles |
The Django Book is a little out of date (although an update is in the works
I believe):
This book was originally published by Apress in 2009, and covered Django
1.0. Since then, it’s languished. We’re working on getting the book
updated to cover Django 1.4, 1.5, and beyond
Static files are all the CSS/JS & images that your site (and the django
admin) uses. They need to be collected and placed somewhere that your
server (or development server) can serve them. This is the job of
django.contib.staticfiles.
You can read more about this in the 'Managing Static Files' documentation
Websites generally need to serve additional files such as images,
JavaScript, or CSS. In Django, we refer to these files as “static
files”. Django provides django.contrib.staticfiles to help yo
|
ApiController accept the json in POST on the localhost testing server, but not on the production server. Why? |
Try changing the code to this instead to see why you are getting a bad
request,
return Request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
You should always include ModelState in your response if you are returning
a 400 due to invalid ModelState. That way the clients would have
information on what is wrong with their request.
Also, if possible, just for debugging, enable IncludeExceptionDetails
always by doing this on your configuration. That way you can get more
details in your 400 error response.
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
Remember that you should IncludeExceptionDetails always only for debugging
on production servers. Otherwise, you would be leaking security sensitive
information to everyone who can access your service which is b
|
Different formatting of HAML to HTML on rails production server compared to development server |
This is normal behaviour take a look at the FAQ:
http://haml.info/docs/yardoc/file.FAQ.html#q-indentation-in-production
|
PDOStatement->execute 14 times slower on production server than on development server |
I finally figured it out today! The problem was that the temporary tables
were not created in memory on the production server. I don't know why since
the config files clearly states it should but I solved the problem by
adding ENGINE = MEMORY to all CREATE TEMPORARY TABLE calls.
E.g.:
CREATE TEMPORARY TABLE group_members (id INT PRIMARY KEY) ENGINE = MEMORY
|
How to use the same settings.py for staging and production. Django |
I recommend using environment variables instead of if/elif chains and/or
includes. The main reasons are:
config varies substantially across deploys, code does not - hence you
should aim to strict separation of config from code.
environment specific information pertains to the environment - env vars are
easy to change between deploys without changing any code.
avoids checking sensitive information like passwords into source control by
accident.
For example:
DATABASES = {
'default': {
'ENGINE': os.environ.get('DB_NAME', 'django.db.backends.sqlite3'),
'NAME': os.environ.get('DB_NAME', 'some_default'),
'USER': os.environ.get('DB_USER', ''),
'PASSWORD': os.environ.get('DB_PASS', ''),
'HOST': os.environ.get('DB_HOST', ''),
'PORT': '',
|
Django logging not working in production |
I managed to solve the problem by putting this line of code to apache
configuration file:
WSGIApplicationGroup %{GLOBAL}
Explanation could be found here:
https://code.google.com/p/modwsgi/wiki/ApplicationIssues#Python_Simplified_GIL_State_API
|
Cant get Custom widget to work by replacing django's default date time widget in django admin |
For a jQuery widget you'll need to include the jQuery.js (or whatever name
you have) core library file in your html header. The
TypeError: $ is undefined ...
makes it seem as if you might have forgotten to do that.
The TimeZoneDate widget is claiming the widget is called
id="date_time_tz"
but the js is attempting to work with something called
$('#date-time-tz')
I'd suggest changing one or the other so that they match! Maybe in the
widget;
id="date-time-tz"
|
Passenger can't load Sinatra app in production? |
There may be multiple reasons why this happens.
"Debugging application startup problems" from the Phusion Passenger wiki
explains how you can debug startup timeout problems.
|
Django Slow on Production, fast in test |
It should be slow only for the first time on production server but for the
following access to the pages the behavior should be different if django
memcached for example.
install django-memcached on production server
settings.py:
CACHE_BACKEND ="memcached://127.0.0.1:11211/" # change the IP to the
server IP
CACHE_TIMEOUT =60*60 #to keep items in the cache it's up to you
# if you wish to cache some data which are permanently in high demand
views.py :
from django.core.cache import cache
from project.settings import CACHE_TIMEOUT
# example of how to use the cache in the methods
def method(request):
model_cache_key = request.path
c = cache.get(model_cache_key)
if not c:
c=get_object_or_404(model,id=self.id)
cache.set(model_cache_key,c,CACHE_TIMEOUT)
#END OF USE C
|
Page Load only partially fires in production |
Sounds like an older DLL version is in production. Make sure to compile
completely (full build).
Hit Ctrl + Shift + B from Visual Studio, and upload again. While doing so,
pay attention if the bin folder's files are the same size.
|
Why won't js assets combine / load with PyroCMS in production? |
You have to do has follow to render the JS assets :
{{ asset:js file="theme::custom.js" group="default" }}
{{ asset:js file="theme::app.js" group="default" }}
{{ asset:render group="default" }}
{{ asset:render group="modules" }}
I think asset:render_js don't actually works
|
Is Django and Active Python 2.x for production environments on Windows 2008 R2 with IIS 7.5? |
I used http://django-windows-tools.readthedocs.org/en/latest/ to
successfully accomplish this.
Note that Running Python & Django on IIS is a reasonably similar
question here on stackoverflow.
|
Django compressor fails to compress coffeeScript files in production |
It was a not so easy to find coffeeScript problem. In my machine I was
using coffeescript v1.4.X and heroku was using v1.6.3. I had a for own in
array that v.1.4 allowed(it shouldn't) but v1.6.3 didn't(actually it didn't
show the right error but a different one which is a bug shown here).
Anyway I solved the problem fixing the coffee file but I still think its a
compressor error not to fail in production ignoring errors without giving
any clue of what happened.
|
How to fix Django admin look? |
Admin's static files are missing. When you run Django with DEBUG = True it
will serve static files automatically. In production you should make your
webserver serve them (since they are static and serving them dynamically
with Django is a waste of resources).
I'd suggest checking this HOWTO. Long story short:
Set STATIC_URL to whatever you like (default /static/ is fine).
Set STATIC_ROOT to a directory, files from which will be served by your
webserver at STATIC_URL. (That is, when browser requests
yourdomain.com/static/foo the webserver should go to STATIC_ROOT and take
foo from there)
Execute ./manage.py collectstatic each time your static files are changed.
It will collect all the files from your installed apps (INSTALLED_APPS) and
copy them to STATIC_ROOT.
In case of Django admin,
|
Django Admin foreign key |
You can define a function in the model inside class Package. Since you need
to know the status you can find status of the recent follow ups using
def get_status_name(self):
a = self.followup_set.latest('follow_up_date')
return a.status.status_name
|
App read only in Django admin when it should not |
For anyone having the same issue. It appears that the lack of a separate
admin.py file causes this issue. An admin.py file isn't mandatory according
to the documentation but it somehow causes this problem.
|
Django admin login for particular url |
Redirect to the admin login form if user is not superuser:
def add_movie(request, *args, **kwargs):
if not (request.user.is_authenticated() and request.user.is_superuser):
return
HttpResponseRedirect(settings.LOGIN_URL+'?next=/admin/movies/add/')
do_your_stuff(...)
If it is an API, you may want to raise PermissionDenied instead.
|
Cannot login to Django admin |
I suggest you to clear your localhost cookies and try with another browser.
I've issues with chrome v28 that I don't have in firefox v22.
Let me know if it helps.
Regards.
-- EDIT --
Try to put this line in your settings.py. It solved for me.
SESSION_COOKIE_DOMAIN = None
|
Django Admin Inlines |
I have no idea why you do this but you can check it this way:
from your_app.models import SomeModel
class MyParentModelAdmin(admin.ModelAdmin):
def save_formset(self, request, form, formset, change):
if formset.model == SomeModel:
pass
|
Django Admin Using Button |
It looks like you simply want to provide a link in your admin change list
to go to a view that will carry out an action on the row - you don't need a
form to do this as you are simply doing a GET anyway with a link:
def method2(self):
return '<a href="path/to/action/%s?param1=%s" target="_blank">Do
Something</a>' % (self.id, label)
The reason you are having problems is that you can't nest a form within a
form (the entire change list in the django admin is already a form)
|
Django admin filter |
Can you post some of your code? I'm not entirely sure I understood the
relationship between the instances to your email - is it an email field? a
ForeighKey to a different model? how is there more than one if it's not a
ManyToMany or similar relationship? And how is the filtering done in the
admin?
EDIT
Ok now I understand the problem. What you want is not possible. See for the
django admin site the fact that they are the same email doesn't matter
because it's still a different object. There's no way around that without
either specifying that field to be unique or messing with the admin site
code.
A better solution would be to configure the email as searchable in the
admin model and then when you search for email example@example.com it would
bring all matches back.
Another good solutio
|
Django ManyToMany in admin |
Short answer: don't use the admin site.
long answer:
The admin site is great. It's powerful and neat and easy to configure in a
few minutes. But that's about it. And that's fine, because it's not meant
to be used for highly costumized projects. Yes, there are some built in
ways to create costum forms for the admin site to use instead of the
default, or show it in different ways, but it's still not that flexible
The way I see it, you have two options:
Copy the admin site files to your project, learn how it works and costumize
it to your needs
Don't use the admin site, build your own views.
Now you might seem to like the first idea, but in my experience the second
one is always easier. As tempting as it is to use the admin site, it's not
that complicated to built something like that y
|
Copy data from local production SQL Server database to remote read only SQL Server database |
I think the logshipping solution fits your needs. After a one-time setup
proces, the logs would be continually shipped from the local db to the
remote db. Keeping the remote perfectly in sync with the local one,
providing you with the readonly copy.
Logshipping is available in all editions, besides Express.
There would be no need for a continuous restore process.
You can find more information here.
|
serving static files with nginx on diffent machine and gunicorn on a diffrent one for a django production |
Please can any one advice me the right way to do this in a production
environment.
Use a network attached storage (NAS) device that is mounted on both
machines. This is how you would do it the right way in production.
You could do all sorts of other workarounds - like rsync, nfs, etc. however
the most reliable way to have this working is with a proper NAS.
|
Change field name in django admin |
Look at Field.label.
See this: https://docs.djangoproject.com/en/dev/ref/forms/fields/#label
Basically, it's
class MyForm(forms.Form):
name = forms.CharField(label='My Name')
But that requires extending the admin, which may be more than you want to
do.
|
Heroku Django-Admin 500 Error? |
You can add free getsentry addon and receive exception traceback remaining
in DEBUG=False in production.
You can also setup plain email notification on errors as admin email.
Without any information about error details it will be hard to give you
advice.
|
How to add readonly inline on django admin |
After a while of trying to find the name I figured out thanks to this
answer, so I checked the names at self.opts.local_fields and found the name
of the middle table and added it to a readonly field:
class SummaryInline(admin.TabularInline):
model = ParserError.summaries.through
readonly_fields = ('myclasssummary',)
pretty simple but took me a while so I figured out it was a good idea to
add it here.
|
Django Filtering Admin Dropdowns |
You need to provide a custom form to the admin, telling it to only show a
certain queryset for the Model B field:
from django import forms
from django.contrib import admin
from myapp.models import Person
class ModelAForm(forms.ModelForm):
model_b = ModelChoiceField(
queryset=ModelB.objects.exclude(model_a__isnull=False))
class Meta:
model = ModelA
class ModelAAdmin(admin.ModelAdmin):
form = ModelAForm
|
Unicode error in django admin |
Change your code like this :
class Owner(models.Model):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=50)
def __unicode__(self):
return self.name
See this link : django unicode error on admin page
|