I have a 3 - 4000 nodes in a drupal 6 installation on mysql and want to access these data through my django application. I have used manage.py inspectdb to get a skeleton of a model structure. I guess that there are good/historical reasons for drupal's database schemes, but find that there are some hard to understand structure and that t...
I may be loading data the wrong way.
excerpt of data.json:
{
"pk": "1",
"model": "myapp.Course",
"fields":
{
"name": "Introduction to Web Design",
"requiredFor": [9],
"offeringSchool": 1,
"pre_reqs": [],
"offeredIn": [1, 5, 9]
}
},
I run python manage.py loaddata -v2 data:
...
I have found plenty of great PHP frameworks, but so many of them seem to use rails-like URL routing. Anyone know of a PHP framework which emulates the django model?
...
Given these two models:
class Profile(models.Model):
user = models.ForeignKey(User, unique=True, verbose_name=_('user'))
about = models.TextField(_('about'), blank=True)
zip = models.CharField(max_length=10, verbose_name='zip code', blank=True)
website = models.URLField(_('website'), blank=True, verify_exists=False)
cla...
Hey,
Imagine you have this model:
class Category(models.Model):
node_id = models.IntegerField(primary_key = True)
type_id = models.IntegerField(max_length = 20)
parent_id = models.IntegerField(max_length = 20)
sort_order = models.IntegerField(max_length = 20)
name = models.CharField(max_length = 45)
...
Hi folks,
I'm having a little problem here!
I have discovered the following as being the globally accepted method for customizing Django admin field.
from django import forms
from django.utils.safestring import mark_safe
class AdminImageWidget(forms.FileInput):
"""
A ImageField Widget for admin that shows a thumbnail.
"...
I have a main class with a category property and several subclasses. I'd like to set the default category for each subclass. For example:
class BaseAd(models.Model):
CATEGORY_CHOICES = ((1, 'Zeta'), (2, 'Sigma'), (3, 'Omega'),)
category = models.IntegerField(choices=CATEGORY_CHOICES)
...
class SigmaAd(BaseAd):
additiona...
I have inserted this in settings.py:
AUTHENTICATION_BACKENDS = (
'blog.auth.backends.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
blog is an application ( correctly installed ), auth is a folder in blog application, backends.py is the file that contain this method:
from django.contrib.auth.backends import ModelBacke...
Hi!
I need to implement a "Remember me" button in a login form that uses the django-registration app. Any ane can help me showing me the way for do this?
Thanks
...
Is it possible to have multiple models included in a single ModelForm in django? I am trying to create a profile edit form. So I need to include some fields from the User model and the UserProfile model. Currently I am using 2 forms like this
class UserEditForm(ModelForm):
class Meta:
model = User
fields = ("firs...
When making a django request through json as,
var info=id + "##" +name+"##"
$.post("/supervise/activity/" + info ,[] ,
function Handler(data,arr)
{
}
In urls.py
(r'^activity/(?P<info>\d+)/$, 'activity'),
In views,
def activity(request,info):
print info
The request does not go through.info is a string.How can th...
Hi,
I got very simple hierarchical structure: every object can have 0 or 1 parent. There's no limit on how many children each object can have.
So in my application I got such a model:
class O(Model):
name = CharField(max_length = 20)
parent = ForeignKey('O', related_name = 'children')
Now I would like to be able to fetch all obj...
Hello. I have such db model:
from datetime import datetime
class TermPayment(models.Model):
dev_session = models.ForeignKey(DeviceSession, related_name='payments')
user_session = models.ForeignKey(UserSession, related_name='payment')
date = models.DateTimeField(default=datetime.now(),blank=True)
sum = models.FloatFi...
In my views i have the date in the following format s_date=20090106 and e_date=20100106
The model is defined as
class Activity(models.Model):
timestamp = models.DateTimeField(auto_now_add=True)
how to query for the timestamp filed with the above info.
Activity.objects.filter(timestamp>=s_date and timestamp<=e_date...
Well, when I'm trying to use 'inclusion' in Django, I met some confused problems that I can't solve it by myself.
There is the structures for my project.
MyProject---
App1---
__init__.py
models.py
test.py
urls.py
views.py
...
I have a middleware that does some processing. On certain conditions it raises an exception and the user sees my 500.html template - correctly responding to 500 http status.
Now, on some exceptions I would like to render different template than default 500.html. Is it possible/how to achieve that?
...
Django (1.2 beta) will reset the database(s) between every test that runs, meaning each test runs on an empty DB. However, the database(s) are not flushed. One of the effects of flushing the database is the auto_increment counters are reset.
Consider a test which pulls data out of the database by primary key:
class ChangeLogTest(django...
Hi guys,
I am a newbee to django and jython. I need to create and save image thumbnails in database. I am using django running on jython and mysql database. I was exploring python imaging library, but the i found out that i wont work with jython.
How do i create image thumbnails using jython and then save them in mysql db?? Any kind of ...
I'm trying to sync my db from a view, something like this:
from django import http
from django.core import management
def syncdb(request):
management.call_command('syncdb')
return http.HttpResponse('Database synced.')
The issue is, it will block the dev server by asking for user input from the terminal. How can I pass it the ...
I'm trying to use ModelAdmin.filter_horizontal and ModelAdmin.filter_vertical for ManyToMany field instead of select multiple box but all I get is:
My model:
class Title(models.Model):
#...
production_companies = models.ManyToManyField(Company, verbose_name="компании-производители")
#...
My admin:
class TitleAdmin(ad...