The CUED People database

The cuedmembers application contains models and logic to maintain a shadow copy of a list of CUED members. It augments the builtin django.contrib.auth.User model with information about a member of CUED. This includes:

  • The full list of “first names”;
  • Their research group and division (if any); and
  • Whether they are a current member of CUED.


class cuedmembers.models.Member(*args, **kwargs)[source]

An extension of the standard Django User to indicate that a particular user is a member of the Department.

There is a one-to-one mapping of Users to Members however not every User is necessarily a Member.


While there is nothing stopping you adding a foreign-key to a Member in models, its better to add a foreign-key to a User. That way you app’s models are decoupled from relying on the CUED membership database and may be of wider user.

The “Surname” and “Preferred name” fields from the Department are mapped through to the associated User’s last_name and first_name. The “First names” provided by the Department are stored in this model.

An “active” member is currently present at CUED.

Information in this model is expected to be provided by the Department. See for some discussion of what the fields mean.

Note that is_active is the primary means by which one should judge if a Member is currently a member of the Department.

This model does not include role/course, host/supervisor, room number or phone number. The “arrived” flag is folded into the is_active field.


The django.contrib.auth.models.User associated with this Member.


A string containing the first names for the member supplied by the Department. Although it is tempting to use a space as a separator for these, that way danger lies!


The ResearchGroup which this member is a part of.


Members are not usually deleted from the database. Instead they become “active” or “inactive”. This is to allow for the same person to be considered as the same person if they leave CUED and then subsequently return.


This member’s CRSid. The CRSid is the username of the associated user.

This property merely returns the username of the associated User.

class cuedmembers.models.MemberManager[source]

A specialised Manager for Member instances.


A query-set of active users.


A query-set of inactive users.

update_or_create_by_crsid(crsid, defaults=None)[source]

Retrieve or create a new member from a crsid. If a corresponding user does not exist, it is created. The newly created user has set_unusable_password() called on it and is added to the database.

The first_name, last_name and email entries in defaults are set on the corresponding user and any other values are set on the member.

See the update_or_create() documentation for discussion of the defaults parameter.


CUED members who are active are a member of a group. Membership of this group is automatic for those members who have is_active set to True when imported from CSV via csv.read_members_from_csv().


The group membership is not automatically updated when save() is called on the models.Member model. This is because only advanced users who know what they’re doing should be fiddling with the database model directly!

By default this group is called “CUED Members” but the name may be overridden by setting the CUED_MEMBERS_GROUP setting.

Departmental structure

The Department is structure into Divisions which comprise separate Research Groups. The cuedmembers app ships with a fixture which is automatically loaded into the database at migrate-time which contains the current Divisions and Research Groups.

class cuedmembers.models.Division(*args, **kwargs)[source]

A division within CUED. The primary key for a division is actually its letter, A-F.


The Divisional ID letter, A-F.


A human-readable name for the Division.

class cuedmembers.models.ResearchGroup(*args, **kwargs)[source]

A research group in CUED.


The Division which this research group is a part of.


A human-readable name for the Research Group.


String giving the name of the group created or returned by get_member_group().

Management commands

Synchronising membership data via CSV files

The importcuedmembers management command is used to synchronise the membership database with an authoritative source.

The Department provide CSV dumps of CUED membership. See for more details. This command allows the ingestion of a CSV file in the format outlined at that page into the database.

Members listed in the CSV file are created if they don’t exist. Their personal details, such as first name, surname, etc. are updated from the CSV. A previously active member who does not appear in the CSV file is marked inactive. Similarly, a previously inactive member who appears in the CSV file is marked active.

By default, an email address of <crsid> is used for each member. This can be configured through the --email-domain argument.

This command can take either a path to a CSV file on the local system or a http or https URL to a CSV file located on a remote server.